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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
TiberSeptim
Beginner


Joined: 20 Jun 2006
Posts: 24

PostPosted: Mon Jan 21, 2008 10:10 am   

Seems simple enough, why isn't it working?
 
#if {@incasting = 0} {gt Sanctuary down!}


Elsewhere I have triggers to set incasting to 1 if I'm in the process of doing something that could be interrupted by the grouptell command. These work and when I mouse over the "incasting" variable in the above trigger it even reads 1... however, the gt command still executes regardless.

I'm confused as it seems like a simple if-statement and the gt command should only execute if incasting = 0?
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Mon Jan 21, 2008 10:44 am   
 
Syntax: #IF (expression) {true-command} {false-command} (source: #I)

There is the syntax error - you must use parentheses for your expression. Since you do not have parentheses with expression, I guess that your #IF statement always evaluates to False and therefore it always execute {false-command} part in second braces, i.e. gt Sanctuary down! script.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Jan 21, 2008 11:40 am   
 
Arde is correct - {@incasting = 0} is what's called an expanded string, where variables are expanded but the result is still a string. So the string "1 = 0" and not the expression "1 = 0" is passed to the #if. A non-null string is true, so the true command is executed.

In order for the result to be considered an expression, use brackets () rather than braces {}.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Mon Jan 21, 2008 11:54 am   
 
Thanks for correcting me, Fang!
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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