On off scripts: Difference between revisions

From Spring
Jump to navigationJump to search
on/off code exemple
 
m removed cob synthax
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
---know and change the on off button state---
---'''know and change the on off button state'''---


(from player or from script action)
defined in UnitDef by the tags:
<code>
ActivateWhenBuilt=false,
OnOffable=true,
</code>
 
switched by player or by script action




Line 30: Line 36:
local isactive
local isactive


isactive=GetUnitValue(1)
isactive==Spring.GetUnitIsActive(unitID)


</code>
</code>
Line 47: Line 53:
end
end
</code>
</code>
**note : the lua equivalent is maybe not possible
*[[SpringRtsTutorialAnimDef]] return to the list of animDef exemples
[[Category:Emmanuel]]

Latest revision as of 16:41, 18 March 2013

---know and change the on off button state---

defined in UnitDef by the tags: ActivateWhenBuilt=false, OnOffable=true,

switched by player or by script action


  • detect the switching of on/off button

local starton startoff


function script.Activate ( )

starton=1

end


function script.Deactivate ( )

startoff=1

end


  • know the state of on/off

local isactive

isactive==Spring.GetUnitIsActive(unitID)


  • change the on/off state(1=on,0=off)

local something

if something==true

then SetUnitValue (20,1)

else SetUnitValue (20,0)

end

    • note : the lua equivalent is maybe not possible