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
dime
Novice


Joined: 15 Dec 2002
Posts: 35

PostPosted: Wed Mar 12, 2003 7:54 pm   

#if syntax question
 
besides stacking if commands inside another, is there a way to give more than one condition to meet?

for example.. my door string for my map goes like this:
@door is controlled by a toggle button..

#IF (@door>0) {#IF (%2=call) {%2} {open %2 %1}}

i wanna make the 2nd #if command go something like #IF (%2={call|knock %w|say %w}).. trigger style... would that work? or do i have to do this

#IF (@door>0) {
#IF (%2=call) {%2}
#IF (%2=knock*) {%2}
#IF (%2=say*) {%2} {open %2 %1}
}

thanks for the help..
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Mar 12, 2003 8:04 pm   
 
You can test the contents of a variable agaisnt a pattern expression using the =~ operator. So, your #IF in this case would be:
#IF (@door > 0) {#IF (%2 =~ "{call|knock|say}*") {%2} {open %2 %1}}

Kjata
Reply with quote
dime
Novice


Joined: 15 Dec 2002
Posts: 35

PostPosted: Wed Mar 12, 2003 8:17 pm   
 
could
#IF (%1>7) {#IF (%1<10) {lvl=%eval(100000+(20000*(%1-8)))}}

be rewritten as
#IF (%1>7 and %1<10) {lvl=%eval(100000+(20000*(%1-8)))}

heh.. the help/reference menu could use a few more examples.. ;)
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Mar 12, 2003 8:26 pm   
 
Yes.

I also find it is always better if you help group things with brackets

#IF ((%1>7) and (%1<10)) {#NOOP stuff here}

Ton Diening
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