I'm trying to set a condition on my recurring time event (interval of 30 seconds... but the interval is unimportant)
The following code example was in the documentation as an example condition:
Code: Select all
ScriptTest='--comment\r\nif unit ~= nil then\r\n return true\r\n else\r\n return false\r\n end'I wrote what I thought was a reasonable condition, returning true and false, like the example, but all I get if condition fails, even when I manually verify that the condition should be true... it fails.
Here is my code:
Code: Select all
local cScript = ""
cScript = cScript.."local unit = ScenEdit_GetUnit({side= '"..side_name.."', name = '"..unit_name.."'})'".."\r\n"
cScript = cScript.."if(unit ~= nil) then return (unit.speed == 0) end\r\n"
cScript = cScript.."return false"
--return (unit.speed == 0)
ScenEdit_SetCondition({mode='add', Description=eName, type='LuaScript', ScriptText=cScript})
ScenEdit_SetEventCondition( eName, {Mode='add', name=eName})From what I can find in the help, I am supposed to return true for success (proceed with he action) or false, for fail the condition, to block the action. This is what I have done, but it registers fail at every call.
What am I missing?[&:]
On a side note: the documentation of intervals for recurring event triggers should be rewritten to tell the reader that the parameter is an integer, with 0 being '1 sec', 1 being 5 seconds, 2 being 15 seconds, and so forth. I had to crash my scenario 3 times to figure that out.