Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Oct 13, 2008 2:46 am   

Hmmm... is there a list of predefined zs.* for lua purposes?
 
I'm curious... it'd make things a bit more interesting if I could use lua for some things, but don't know where to start with the zs.* bit at all... perhaps someone can point me in the right direction...

Charneus
Reply with quote
Daagar
Magician


Joined: 25 Oct 2000
Posts: 461
Location: USA

PostPosted: Mon Oct 13, 2008 3:01 am   
 
As you can see from my other post, I'm clearly not the authority on LUA integration yet, but the help file you are looking for is 'zs Object'. For pretty much every object in cmud (aliases, triggers, functions, variables, etc) there is a corresponding LUA table of the form zs.<whatever> (zs.alias, zs.trigger, zs.func., zs.var) that lets you get at it.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Oct 13, 2008 8:20 am   
 
Full docs here, list of zs functions and objects here.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
brrant
Beginner


Joined: 19 Nov 2008
Posts: 14

PostPosted: Wed Nov 26, 2008 3:13 am   enable/disable trigger in Lua
 
I'm having some trouble enabling and disabling triggers via a lua script. I did some reading and searching. In this thread http://forums.zuggsoft.com/forums/viewtopic.php?t=27719 the syntax :

Code:
t = zs.trigger("idname")
t.enabled = false


and

Code:
zs.trigger("idname").enabled = false


is quoted, but I'm not able to get either to work. I've tried populating "idname" with name, pattern and id#, but I don't get it to reference the existing trigger. In each case a new trigger is created with the pattern equal to the value I place in the "idname" slot.

Even if I'm not taking the best approach to the programming question, I'd appreciate any help with the above. Enabling/Disabling triggers is pretty commonly useful.

What I'm trying to do is execute a script that iterates through a loop (removing all spellbooks from a container and looking at them) and stops when it no longer finds spellbooks. I want this to be dynamic, because I want the script to surving having duplicate/missing spellbooks since I'm organizationally challenged.

I searched for a function that would capture the *next* line of output from the mud, (not trigger on and capture previous), but the only way I see of doing that is by using nested triggers which again would have to be dynamically enabled/disabled anyway.

Thanks in advance.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Nov 26, 2008 7:05 am   
 
Firstly, you need to use zs.gettrigger() and not zs.trigger(), because they do very different things.

Secondly, there's a bug in the current version where the zs.gettrigger() function where it doesn't return settings by name if they're disabled - so once you've disabled it, there's no way to enable it again by name. If you store the trigger object in a variable (as in the first code example above, like t=zs.gettrigger("something");t.enabled=0;t.enabled=1) or refer to it by its ID number, returned by the index property (so index=zs.gettrigger("something").index;zs.gettrigger(index).enabled=0;zs.gettrigger(index).enabled=1) then it should work properly.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Wed Nov 26, 2008 10:44 am   
 
its fixed mate, zs.get* functions work on disabled settings now
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Nov 26, 2008 12:54 pm   
 
I stand corrected; it's just that you need to use gettrigger() instead of trigger()
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Mon Jan 12, 2009 11:01 am   
 
zs.trigger("id").enabled = false works to disable an alarm.

I don't see anything in the help files regarding zs.trigger(). There is only zs.gettrigger() and zs.maketrigger() and zs.numtrigger(). Where is the information regarding zs.trigger()????
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Jan 12, 2009 12:20 pm   
 
zs.trigger() is the %trigger function (or perhaps the #trigger command, I can't remember). When you try to use zs.xxx, CMUD first looks to see if there's a Lua-specific function with that name, like the getyyy, makeyyy, numyyy functions, or the aborted or isvalid properties (full list of those is in the docs). If there's no Lua-specific function for a particular string ("xxx" in this case) then CMUD will look for zScript commands with that name. If there's no command, then it'll try zScript functions.

I can't remember if that's the order the lookups are in, but I know it looks up both. I can't remember if it looks up variables as well, or if you have to return them with zs.getvar() - try it and see. You can force a command or function with a particular name with zs.cmd.xxx or zs.func.xxx.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net