|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Jan 12, 2009 10:45 am
Lua and alarm |
First, how do you translate #T+ and #T- to LUA for permanent alarms and also triggers?
Second, whats the best way to use an alarm in LUA? For example, if I were doing it in zscript I would create a permanent alarm then enable and disable it. Is this still the best way or should I use wait or what?
Sorry if the question is stupid but the help files are not exactly stellar and filled with examples. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Jan 12, 2009 12:02 pm |
You just call the command for #t- the same way you do any other command, like I used #show in the other thread. Though because it has a special character in the name, you need to use the longer syntax zs["t-"]() rather than zs.show() or whatever. So, to disable a trigger with the ID "cake", you do zs["t-"]("cake").
You can also use the slightly more complex, object-oriented Lua interface though. The zs.gettrigger() function will return an object for the named trigger, which you can then store if you want to (trigger=zs.gettrigger("cake")) and then you can set the values of this object using the handle stored in the variable (trigger.enabled=false). If you're not doing many operations on any single trigger, you can operate directly on the returned result rather than storing it (zs.gettrigger("cake").enabled=false).
All the properties for each of the different kinds of objects are listed in the help - the common properties belong to every kind of object, and then each different kind of setting (trigger, alias, etc) has a few options of its own.
Does that explain what you were after? |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Jan 12, 2009 12:11 pm |
Yes sort of. Are the alarms the best way to go about it in LUA or does it have its own timer?
Also see my comment in the other thread about this I posted to regarding zs.gettrigger() and zs.trigger(). I found no reference to zs.trigger() under the zs.object section but it worked to disable an alarm too.
Thanks. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Jan 12, 2009 12:17 pm |
I'm just replying to the other thread now ;)
And no, Lua doesn't have its own timer. CMUD just includes the standard Lua libraries, all the functions here and that's it. If you want anything else, you'll need to download it yourself. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Jan 12, 2009 2:56 pm |
Do you do the same thing to enable and disable classes?
Such as...
zs["t+"]("Class/subclass")
? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Jan 13, 2009 3:10 am |
Yep, zs["t+"] just calls the normal #t+ command. If you want to use the OO method, obviously you need to use zs.getclass("name") to return the object for that class - or you could use the class property of something else you've returned to change the options of its parent class. So you could do zs.gettrigger("cake").class.enabled=false to disable the class that contains the trigger "cake".
|
|
|
|
|
|