|
Toshiki Beginner
Joined: 20 Nov 2004 Posts: 14
|
Posted: Mon Dec 11, 2006 6:15 pm
Trigger returns same value reguardless |
#if {(@total) == (16)} {Do this} {Do that}
For some reason, this always returns "Do this"... even is @total doesn't equal 16
I've tried this with > < = and !=
It always returns "Do this" |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Dec 11, 2006 6:34 pm |
That's because the proper syntax is to use brackets around the expression you want expanded:
#if (@total=16) {do this} {do that}
Brackets () are used for expression evaluation, braces {} are used for command evaluation. |
|
Last edited by Fang Xianfu on Mon Dec 11, 2006 6:37 pm; edited 1 time in total |
|
|
|
Toshiki Beginner
Joined: 20 Nov 2004 Posts: 14
|
Posted: Mon Dec 11, 2006 6:37 pm |
So now i gotta use ( ) when evaluating #'s? Or words too?
e.g. would
#if (@spell="Magic Missile") {Do this} {Do that}
work? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Dec 11, 2006 6:38 pm |
Sorry, I thought this was a zMUD thread and ended up telling you completely the wrong thing. I've edited my post above to be a little more sensible. Yes, that'll work just fine.
|
|
|
|
Toshiki Beginner
Joined: 20 Nov 2004 Posts: 14
|
Posted: Mon Dec 11, 2006 6:41 pm |
Thanks man. Great help. I'm too used to using #if {This = That} in Zmud. lol
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Dec 11, 2006 6:43 pm |
That was wrong in zMUD too, but zMUD's parser was funny and let you do it anyway. CMUD's parser is more strict so the code can be compiled (and thus run faster), which sometimes means learning how to do stuff the right way rather than the way that works :P
@variable=value is another one you might run across. That's always been wrong, but zMUD let you do it. The actual syntax is "variable=value" unless you're VERY SURE you actually want to use the CONTENTS of @variable as the NAME of the variable you're defining. |
|
|
|
Toshiki Beginner
Joined: 20 Nov 2004 Posts: 14
|
Posted: Mon Dec 11, 2006 6:53 pm |
Looks like i gotta learn my scripting all over again then. Zmud made things sooo much easier on me. From what your telling me, i took the "easy way" rather than the "right" way for everything i did. It all worked great on zmud, but now i'm running into new problems. Thanks for the help though. Any new questions i got i'll send ya a PM if thats alright with you.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Dec 11, 2006 6:57 pm |
Sure thing.
|
|
|
|
|
|