I am trying to control when a scene gets set as a result of a scheduler event. I am trying it this way because I have not been able to control a scheduler from a script. The requirement is actually fairly simply: I want to set a scene only if a Flag (part of another scene) is not set. So I have done this in the SHAC, but it does not work: -- Get phantom scene trigger if GetTriggerLevel(0, 202, 31) and -- check if flag is OFF GetCBusLevel(0, 48, 6) ==0 then -- Set real trigger level SetTriggerLevel(0, 202, 34) -- wait for 1.5 seconds os.sleep(1.5) -- reset Trigger level for next event SetTriggerLevel(0, 202, 0) end The script is set up to listen to TriggerLevel 0,202,31. In my mind I shouldn't even have to test for that within the script, but whether or not I do this makes anyway no difference. Any help would be appreciated. Of course first price would be a way to control schedulers via a script.
Hmm, no takers. Might it help if I said that this routine is running perfectly on a PAC, just with the right syntax? Surely the NAC or SHAC should be able to process this sort of thing, or am I too optimistic?
There is no such statement as GetTriggerLevel(0, 202, 31). The correct statement is GetTriggerLevel(31) Lua is an appallingly designed language that lets you shoot yourself in the foot all the time. It allows you to add any number of arguments to a function without producing an error, so GetTriggerLevel(0, 202, 31) is interpreted as GetTriggerLevel(0). You have the same problem with SetTriggerLevel. Also, GetTriggerLevel returns an integer, so it is always True (in Lua only Nil or Undefined are False), so GetTriggerLevel will always return True. You need to compare it with an integer. An event is triggered whenever the group changes, so you need to test the value if you only want to execute when it is set to a particular level.
Thank you Ashley, Thank you for your reply. I share your sentiments of course. Trying to make do with this product, but it seems tedious. What I don't understand in what you are saying, is how Lua distinguishes between the various trigger groups. So if I want to get or set 202,0 to level 45, as opposed to, say 202,1 to level 45? Btw, it seems that in my post I mixed up the sequence in any case (should be first application 202, then the rest).
GetTriggerLevel take a single parameter which specifies the trigger group on the local network. You don't need to specify the application (202) as that is always the trigger application. It returns the current action selector for that trigger group. So to get trigger group 0 level would be GetTriggerLevel(0) and to get trigger group 1 level would be GetTriggerLevel(1) SetTriggerLevel take 2 parameters. The first is the trigger group and the second the action selector to set. So to set trigger group 0 to 45 would be SetTriggerLevel(0,45), and to set trigger group 1 to 45 would be SetTriggerLevel(1, 45). You don't need to specify the network or application as they are assumed.