Loading...
  OR  Zero-K Name:    Password:   

Post edit history

Need some LUA Widget scripting help

To display differences between versions, select one or more edits in the list using checkboxes and click "diff selected"
Post edit history
Date Editor Before After
1/22/2019 2:30:46 PMPLrankZenfur before revert after revert
1/22/2019 2:30:18 PMPLrankZenfur before revert after revert
Before After
1 Here's working code snippet: 1 Here's working code snippet:
2 \n 2 \n
3 [quote] 3 [quote]
4 local function TurnOn(newtonid) 4 local function TurnOn(newtonid)
5 local states = Spring.GetUnitStates(newtonid) 5 local states = Spring.GetUnitStates(newtonid)
6 if states["active"] == false then 6 if states["active"] == false then
7 Spring.GiveOrderToUnit(newtonid,35666,{1},0) 7 Spring.GiveOrderToUnit(newtonid,35666,{1},0)
8 end 8 end
9 end 9 end
10 \n 10 \n
11 local function TurnOff(newtonid) 11 local function TurnOff(newtonid)
12 local states = Spring.GetUnitStates(newtonid) 12 local states = Spring.GetUnitStates(newtonid)
13 if states["active"] == true then 13 if states["active"] == true then
14 Spring.Echo("Set state to active") 14 Spring.Echo("Set state to active")
15 --Spring.GiveOrderToUnit(newtonid,CMD.ONOFF,{0},0) -- does not work 15 --Spring.GiveOrderToUnit(newtonid,CMD.ONOFF,{0},0) -- does not work
16 Spring.GiveOrderToUnit(newtonid,35666,{0},0) 16 Spring.GiveOrderToUnit(newtonid,35666,{0},0)
17 end 17 end
18 end 18 end
19 [/quote] 19 [/quote]
20 \n
21 Indents were optimised out by forum.