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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Mon Mar 26, 2007 12:32 pm   

Executing a trigger using prompt vars
 
Howdy folks. Alright, I have a question. We all know you can use the Preference settings to detect your prompt and set variables accordingly. Now, how can I execute a trigger to check those vars. For example, an autohealing trigger. If my HP is below a certain amount and my mana is above 90%, I want to cast a restoration spell. If my mana is below that, I want to quaff a potion. I can do that by a specific trigger matching my prompt pattern, but it seems redundant to me that you can detect your prompt and set vars, but you can't also execute a trigger the same way.
Thanks, Danlo.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Mar 26, 2007 3:23 pm   
 
Simple enough, just make an expression trigger that fires off of the variable math.

(@hp<(@maxhp-amount))and(@autoheal=1)

(@mana<((@maxmana/10)*9))and(@autoheal=1)

Since this is in the Zmud forums I'm gonna add a little more as cmud handles expression triggers better than zmud does.

(@hp<(@maxhp-amount))and(@autoheal=1)and(@fired=0)

Zmud tends to fire twice or more on expression triggers which can be very annoying adding a variable change within the script stops this. Just be sure that you have trigger text that tells you when it is ok to sip again and that it also sets the @fired variable back to 0
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Mon Mar 26, 2007 3:30 pm   
 
What you want is an expression trigger.

Code:
#TRIGGER (@HP<300) {cast spell}


Be sure to specify it is as an expression trigger by going to the Options tab and selecting 'Expression' from the Type drop down menu.


[Edit] Got beaten to it. Dang flights! Smile [/edit]
_________________
Asati di tempari!
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Mar 26, 2007 3:32 pm   
 
Yes, you are STILL seemingly making redundant triggers but using this method makes things easier to read over all as you have one trigger per task. As opposed to overloading a prompt trigger.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Thu Mar 29, 2007 1:18 pm   
 
That's unfortunate. Expression triggers don't seem to be parsed every line you receive. They seem to fire infrequently, as if on a timer. That would not be useful for an autoheal trigger, which boils back down to a prompt trigger. Anywho, thanks for your ideas, guys.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Mar 29, 2007 11:36 pm   
 
expression triggers are evaluated every time a variable gets assigned to (which includes assigning it an identical value as what it currently had). Also, in ZMud it doesn't matter what variable got updated. If you are checking the @Health variable and only the @Spirit variable was assigned the @Health expression trigger would still fire so long as the expression was true.
_________________
EDIT: I didn't like my old signature
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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