#IF nesting in ZMud

by Unknown

Back to Mechanic's Corner.

Unknown2006-06-02 13:54:19
Greetings, I'm kind of new to ZMud (and, admittedly, reflexes in general). I recently switched from ALClient to ZMud, and was wondering about the #IF system - in particular, how it relates to multiple checks.

For example, my basic herbcure alias (upon recovering herb balance) goes something like

#IF (@1staffliction = 1) {
cure}
{#IF (@2ndaffliction = 1)
{cure}
{#IF (@3rdaffliction = 1)
{cure} } }

And so forth. It ends up being a tangled mess with multiple afflictions to check. My question, though, is as follows - is there a less complicated way of arranging this? Something like an #elseif command would be great, along the lines of

#IF (@1staffliction = 1)
{cure}
#ELSEIF (@2ndaffliction = 1)
{cure}
#ELSEIF (@3rdaffliction = 1)
{cure}

So instead of working through one insanely long #IF sequence, it's a lot of smaller #ELSEIFs. I know the effect is basically the same, I just find working with #ELSEIF a little more convenient. Easier to add new afflictions, remove old ones, debug ones that don't work, or just change the order of importance, if you see where I'm coming from.

Also, is it a good idea to base balance and equilibrium checks off the prompt rather than off the recovery messages? Something like
#TRIGGER {^*h, *m, *e, *p, *en &stat-} {#IF @stat = "elrx" {whatever}}
You get the idea. Maybe adjust it to pick up health, mana, and ego. But I'm really interested to see if the idea is sound - I think I heard someone mention it recently?
Murphy2006-06-02 13:55:58
As far as the prompt goes, just so #IF %pos(x, @stat) {whatever}
Unknown2006-06-02 14:04:14
Ahhh, I see.... so it could be something like

#TRIGGER {^*h, *m, *e, *p, *en &stat-} {#IF %pos(x, @stat) {#va balance = 0}}

Thanks, that's a much simpler way of doing things.
Unknown2006-06-02 14:05:43
Don't mix-and-match variable syntax, though. Use either "balance = 0" or "#var balance 0" to set the variable.
Unknown2006-06-02 14:11:02
Ack, my mistake. I'm too used to ALClient. Making that mistake when I first started using ZMud screwed a lot of my reflexes up, but I think I've weeded most of it out now. Thanks for the heads up, though.
Murphy2006-06-02 15:34:10
yeh, keep it all @balance = 0

Personally i use add mechanics balance, as i keep my mechanics on a stringlist

you can do it a few ways, i prefer @balance = 0 rather than balance=0 i think it's neater.
Unknown2006-06-02 15:38:47
Hm, someone mentioned a stringlist before, but I'm not familiar with it...

I'm using #va balance 0 for the time being, mainly because that's the way I was introduced to variables in ZMud... and, as you can see, I'm using the #IF THEN system of curing. Speaking of which...

I had an idea while hunting for a system that would keep track of which vials you had emptied - something like

#TRIGGER {^You drain the last drop from a (*) vial.} {#va healthvial (@healthvial + 1)} (I'm not sure about that @healthvial + 1 - can #VARIABLE handle it?)
#ALIAS emptyvials {#ECHO You have @healthvial empty health vials.}

But, the problem with that is that most people don't have a single vial type for each elixir/salve type (at least, most people who can't afford to be picky at the moment, heh). So I was wondering if there's a way to pick up the next line, to identify exactly which vial you've just emptied - say the next line is "The potion heals and soothes you.", then that quantifies the newly-empty vial as a health vial.
Murphy2006-06-02 15:43:11
I don't bother with that, i have a potionlist script and i keep kegs of health on me, so when i see myself out of health i just rip the keg into empties and go on
Unknown2006-06-02 15:48:37
Heh... I don't think my resources are up to buying kegs at the moment. This just got to me because I tend not to notice empty messages when the happen. So it'd be nice to be able to finish off the denizen, then do a quick check to see what was on my shopping list, so to speak, rather than finding out when a spectre ices me multiple times and I've run out of fire vials.
Ekard2006-06-02 17:48:48
Invest in potion list. Its great skill and making script to track your potions is easy with it.

And to make if elseif, try:

#if @aff1=1 {cure aff 1} {#if @aff2=1 {cure aff 2} {#if @aff3=1 {cure aff 3} {}}}

And so on.

So affliction 2 qand 3 will be only checking if you dont have affiliction 1.

EDIT: Meh i have read your post wrong. My script is same as your.
Daganev2006-06-02 18:38:37
zmud has a Paramater option that allows you to check for another trigger after one fires.

people tend to use them for putting up all thier defences.
Unknown2006-06-02 21:04:21
QUOTE(Haertyn @ Jun 2 2006, 11:38 AM) 293283

#TRIGGER {^You drain the last drop from a (*) vial.} {#va healthvial (@healthvial + 1)} (I'm not sure about that @healthvial + 1 - can #VARIABLE handle it?)


You would do "#ADD healthvial 1"
Unknown2006-06-05 19:35:53
Tracking your emptied vials would require you to know what vial you just sipped. If you take your last sip of quicksilver, you don't want to bump your empty health vials counter. Also, that pattern wouldn't work for vial types beginning with a vowel (e.g., "an opal vial") and the parentheses are superfluous anyway if you don't need to know what the wildcard matched.

My recommendation is to use the #COLOR command and highlight that line. You should be able to recognize with your eyes and brain fairly easily then how fast you're emptying vials and what types they are.

CODE

#TRIGGER {^You drain the last drop from * vial.$} {#COLOR white,red}