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


Joined: 21 Feb 2001
Posts: 28
Location: Finland

PostPosted: Wed Mar 01, 2006 12:14 pm   

Bug in #IF?
 
Maybe I didn't notice some small "Don't use" text in somewhere but

Code:
#IF (%1 = "on") {#echo It's now %1}
#IF (%1 = "off") {#echo It's now %1}


ain't working (%1 never matches to on/off, tried with =~ operator too).

Using 7.21.
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Mar 01, 2006 2:29 pm   
 
Used in a trigger?

#TRIGGER {The button is (%w).} {
#IF (%1 = "on") {#echo It's now %1}
#IF (%1 = "off") {#echo It's now %1}
}
Reply with quote
anylo
Beginner


Joined: 21 Feb 2001
Posts: 28
Location: Finland

PostPosted: Wed Mar 01, 2006 2:32 pm   
 
TonDiening wrote:
Used in a trigger?


Nope, in alias

Code:
#ALIAS dig_grave {#if (%1 = "on") {#var dig_grave 1}}
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Mar 01, 2006 4:57 pm   
 
Try a string compare?

#ALIAS dig_grave {#if (%1 ~= "on") {#var dig_grave 1}}
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Mar 01, 2006 6:01 pm   
 
Also, you probably need to put quotes around the %1:

#IF ("%1" = "on") {#echo It's now %1}
#IF ("%1" = "off") {#echo It's now %1}

zMUD is picky about quotes in string comparisons and remember that the %1 is a straight string replacement, so without the quotes you end up with something like:

#IF (on = "on") ...

and zMUD doesn't know that the first part is another literal string without the quotes.
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Wed Mar 01, 2006 6:22 pm   
 
i would love to emphasize just how much i love zuggsoft, where else do you get an answer from the man himself?
Reply with quote
anylo
Beginner


Joined: 21 Feb 2001
Posts: 28
Location: Finland

PostPosted: Thu Mar 02, 2006 7:51 am   
 
Zugg wrote:
Also, you probably need to put quotes around the %1:

#IF ("%1" = "on") {#echo It's now %1}


Thanks, it works now. What confused me was that if the comparable value was something else than on or off (like "jon" etc) it worked. Only on and off wasn't.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Mar 02, 2006 4:57 pm   
 
From the expressions help file

The constants: true, yes, on are defined with a value of 1, and the constants: false, no, off are defined with a value of 0.

on is a constant that equals 1
"on" is a string that equals "on"

jon="jon" because jon isn't a constant for anything

Since you can't declare what a variable will hold in zmud (number, string, etc) you have be explicit as possible using " "s tells zmud to treat it as a string
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
anylo
Beginner


Joined: 21 Feb 2001
Posts: 28
Location: Finland

PostPosted: Fri Mar 03, 2006 6:59 am   
 
nexela wrote:
From the expressions help file

The constants: true, yes, on are defined with a value of 1, and the constants: false, no, off are defined with a value of 0.


So I missed some information about "on" (just as I was suspecting).

Thanks to all.
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