|
anylo Beginner
Joined: 21 Feb 2001 Posts: 28 Location: Finland
|
Posted: 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. |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: 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}
} |
|
|
|
anylo Beginner
Joined: 21 Feb 2001 Posts: 28 Location: Finland
|
Posted: 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}} |
|
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Wed Mar 01, 2006 4:57 pm |
Try a string compare?
#ALIAS dig_grave {#if (%1 ~= "on") {#var dig_grave 1}} |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: 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. |
|
|
|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: 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?
|
|
|
|
anylo Beginner
Joined: 21 Feb 2001 Posts: 28 Location: Finland
|
Posted: 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. |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: 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 |
|
|
|
anylo Beginner
Joined: 21 Feb 2001 Posts: 28 Location: Finland
|
Posted: 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. |
|
|
|
|
|