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
batman2227
Beginner


Joined: 19 Nov 2002
Posts: 25
Location: USA

PostPosted: Thu Jun 12, 2003 11:12 pm   

Dumb If syntax question
 
Look, I am dumb when it comes to ZMUD. No, no everyone says that, but I am really dumb. This one should be easy, but stonebrain that I am, I can't figure it. Is it possible to evaluate an if statement to another word? I am trying to set a variable named busy to either 1 or 0 if my Achaea based prompt tells me I have eq and balance or not, using an if based trigger. ex:
2021h, 2021m ex-
#trigger {(%d)h, (%d)m (%w)} {#IF %3=ex {#var busy 0} #var busy 1}

I know this is the kind of question that must drive you crazy, but i have read the help library, the help files, and searched the Zugg Forum (kept getting timed out), and tried every combination of syntax/prayer/voodoo magic I know, to no avail. A very brief tutorial on #IF syntax (when to use parentheses, when quotes, what do they mean to ZMUD) would be manna from heaven, but just the syntax on this script would get me out of the desert. Thanks for your time.

"To start press any key... Where's the anykey?"
Reply with quote
batman2227
Beginner


Joined: 19 Nov 2002
Posts: 25
Location: USA

PostPosted: Thu Jun 12, 2003 11:46 pm   
 
Hey, did you guys know there was this buton that stopped all triggers. Yeah, apparently I sued to know it, because I hit it, but then forgot right before I started testing all my #IF triggers. I told you I was dumb. But you didn't want to listen. That explanation of #IF syntax would still be appreciated, because you can see how dumb i am, and I just kind of stumbled on to success. Thanks for reading.

"To start press any key... Where's the anykey?"
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Fri Jun 13, 2003 12:01 am   
 
When in doubt, use braces:

#trigger {(%d)h, (%d)m (%w)} {#IF {%3=ex} {#var busy 0} {#var busy 1}}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Jun 13, 2003 1:22 am   
 
geniusclown's syntax does work.

However, the accepted syntax (as used in helpfile examples and stated frequently by Zugg) is to enclose the expression (%3=ex) portion in parentheses. In addition, both the true-command (#var busy 0) and, if used, the false-command (#var busy 1) should be enclosed in curly-braces.
#TR {(%d)h, (%d)m (%w)} {#IF (%3=ex) {#VAR busy 0} {#VAR busy 1}}

Since this is a prompt, you'll probably need to change the Trigger on options so that it doesn't wait for another entry before processing. This can easily be done in the settings editor, by unchecking Newline and checking Prompt on the trigger's Options tab. It can also be done from the command line:
#TR {(%d)h, (%d)m (%w)} {#IF (%3=ex) {#VAR busy 0} {#VAR busy 1}} {} {nocr|prompt}

Finally, you can expect to have additional characters in your prompt as your character progresses. %w doesn't match the -, but it will match these other characters (such as k for kola) which will cause the trigger to set @busy to 1 even though you have both e and x. Therefore, a different expression would probably be best. e and x, in that order, are always the first two characters if present, so the %begins function would probably be a good choice.
#TR {(%d)h, (%d)m (%w)} {#IF (%begins( %3, ex)) {#VAR busy 0} {#VAR busy 1}} {} {nocr|prompt}

LightBulb
Advanced Member
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Fri Jun 13, 2003 3:05 am   
 
Ahh..caught LightBulb on something.....if cloak is up then c is before ex
Reply with quote
batman2227
Beginner


Joined: 19 Nov 2002
Posts: 25
Location: USA

PostPosted: Fri Jun 13, 2003 3:58 am   
 
Hey, I really appreciate the explanation. It really helped me get a better grasp on #if triggers, and cleared up a couple of triggers I had that weren't firing right. Just out of curiousity, although I am not really using the trigger while cloaked, how would one deal with the cloak before? Anyways, thanks again. Saving my sanity one post at a time.

"To start press any key... Where's the anykey?"
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Jun 13, 2003 5:53 am   
 
In that case, you'll need to use a different function and %pos is probably the best.
#TR {(%d)h, (%d)m (%w)} {#IF (%pos( ex, %3)) {#VAR busy 0} {#VAR busy 1}} {} {nocr|prompt}

LightBulb
Advanced Member
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