|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: 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. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: 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 |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: 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! [/edit] |
|
_________________ Asati di tempari! |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: 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 |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: 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.
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
|
|