Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Toshiki
Beginner


Joined: 20 Nov 2004
Posts: 14

PostPosted: 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"
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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
Reply with quote
Toshiki
Beginner


Joined: 20 Nov 2004
Posts: 14

PostPosted: 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?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toshiki
Beginner


Joined: 20 Nov 2004
Posts: 14

PostPosted: Mon Dec 11, 2006 6:41 pm   
 
Thanks man. Great help. I'm too used to using #if {This = That} in Zmud. lol
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toshiki
Beginner


Joined: 20 Nov 2004
Posts: 14

PostPosted: 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.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Dec 11, 2006 6:57 pm   
 
Sure thing.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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