Factory scripts: Difference between revisions

From Spring
Jump to navigationJump to search
exemple of factory
 
m added related unitdef tag (need linkage)
Line 1: Line 1:
<big>FACTORY SCRIPT</big>
<big>FACTORY SCRIPT</big>
Factory are totally diferent synthax from mobile builder due to engine design:
:<sub>Factory are totally diferent synthax from mobile builder due to engine design:</sub>


==Basic code==
<code>
<code>
local pad = piece "pad" --piece where the unit build is landed  
:local pad = piece "pad" --piece where the unit build is landed  
:local nano = piece "nano" --piece where the nano particule come from
local nano = piece "nano" --piece where the nano particule come from
:function script.QueryBuildInfo ( ) return pad end
:function script.QueryNanoPiece ( ) return nano end
function script.QueryBuildInfo ( ) return pad end
:function script.Activate()
:StartThread( product )
:end


function script.QueryNanoPiece ( ) return nano end
:function product()
:Signal(1)
:SetSignalMask(1)
:SetUnitValue ( 19,1)--ask evacuate area
:SetUnitValue ( 18,1)--switch the UnitDef Yardmap to open
:SetUnitValue ( 5,1)--start nano
:return 1
:end


function script.Activate()
:function script.Deactivate()  
StartThread( product )
:StartThread( endproduct )
end
:end
 
:function endproduct()
:Signal(1)
:SetSignalMask(1)
:SetUnitValue ( 5,0)--end nano
:SetUnitValue ( 18,0)--switch the UnitDef Yardmap to close
:SetUnitValue ( 19,0)--stop to ask evacuate area
:return 0
:end
 
</code>
note: if the pad piece is more high than ground then the unit will fall when completed
 
 
===advanced script===
*can have arms with multiple nao emiter moving pad and checking the unit completion


function product()
Signal(1)
SetSignalMask(1)
SetUnitValue ( 19,1)--ask evacuate area
SetUnitValue ( 18,1)--switch the UnitDef Yardmap to open
SetUnitValue ( 5,1)--start nano
return 1
end


function script.Deactivate()
StartThread( endproduct )
end


function endproduct()
Signal(1)
SetSignalMask(1)
SetUnitValue ( 5,0)--end nano
SetUnitValue ( 18,0)--switch the UnitDef Yardmap to close
SetUnitValue ( 19,0)--stop to ask evacuate area
return 0
end


</code>
--UnitDef tag involvd in the factory :--
note: if the pad piece is more high than ground then the unit will fall when completed
:Builder = 1,--the unit build some static or mobile units
:WorkerTime = 999,--amount per second can be spent in build of metal & energy max
:CanBeAssisted=1,
:buildoptions = {product1,product2}

Revision as of 15:38, 13 November 2012

FACTORY SCRIPT

Factory are totally diferent synthax from mobile builder due to engine design:

Basic code

local pad = piece "pad" --piece where the unit build is landed
local nano = piece "nano" --piece where the nano particule come from
function script.QueryBuildInfo ( ) return pad end
function script.QueryNanoPiece ( ) return nano end
function script.Activate()
StartThread( product )
end
function product()
Signal(1)
SetSignalMask(1)
SetUnitValue ( 19,1)--ask evacuate area
SetUnitValue ( 18,1)--switch the UnitDef Yardmap to open
SetUnitValue ( 5,1)--start nano
return 1
end
function script.Deactivate()
StartThread( endproduct )
end
function endproduct()
Signal(1)
SetSignalMask(1)
SetUnitValue ( 5,0)--end nano
SetUnitValue ( 18,0)--switch the UnitDef Yardmap to close
SetUnitValue ( 19,0)--stop to ask evacuate area
return 0
end

note: if the pad piece is more high than ground then the unit will fall when completed


advanced script

  • can have arms with multiple nao emiter moving pad and checking the unit completion



--UnitDef tag involvd in the factory :--

Builder = 1,--the unit build some static or mobile units
WorkerTime = 999,--amount per second can be spent in build of metal & energy max
CanBeAssisted=1,
buildoptions = {product1,product2}