Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

On off scripts

From Fightorder
Revision as of 08:41, 18 March 2013 by interemmanuel>Emmanuel (removed cob synthax)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

---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