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
Xolademoness
Wanderer


Joined: 18 Jun 2004
Posts: 73
Location: United Kingdom

PostPosted: Fri Aug 31, 2007 5:01 am   

#IF in macro not working, always acting as if it is true, worked fine in zmud:(
 
i have MULT do this macro

#IF {@snipermag=1} {~shr @targetname} {~sh @targetname}

so if the sniper rifle magazine has less than 1 when I shoot it does a shoot then reload, otherwise just normal shoot - this worked fine in Zmud, but now in Cmud it just always acts if it is true, I have no idea why - the variable definitely is NOT 1... :(

can anyone help?
_________________
mhm..
Reply with quote
Arlie
Wanderer


Joined: 09 Jun 2006
Posts: 62
Location: Florida

PostPosted: Fri Aug 31, 2007 5:07 am   
 
I'm not sure if it would cause the expression to fail, but you should use #IF () {} {} syntax for an if statement, not #IF {} {} {}. So basically, your statement would be...

#IF (@snipermag=1) {~shr @targetname} {~sh @targetname}

If it doesn't solve the problem, hopefully you'll get that resolved... but otherwise, proper syntax is always a good thing :)
Reply with quote
Xolademoness
Wanderer


Joined: 18 Jun 2004
Posts: 73
Location: United Kingdom

PostPosted: Fri Aug 31, 2007 5:18 am   
 
thanks that fixed it :D
_________________
mhm..
Reply with quote
DanteX
Apprentice


Joined: 13 Aug 2007
Posts: 166

PostPosted: Fri Aug 31, 2007 8:37 am   
 
How wierd. For me

Code:
#IF {1} {#SHOW TRUE} {#SHOW FALSE}


shows TRUE, meaning the other syntax should still work.
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Fri Aug 31, 2007 10:54 am   
 
Yeah, but the problem is that for some reason if your expression changed to false, it was still showing the true response.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Aug 31, 2007 11:42 am   
 
The reason this happens is because the braces {} treat the content as an expandable string. After the expansion is done then it is looked at by the #IF. Being a string the expression is considered true for anything that isn't %null.

All of these will show true all the time:
#IF {1} {true}
#IF {0} {true}
#IF {-1} {true}
#IF {0=1} {true}
This is what they convert to:
#IF ("1") {true}
#IF ("0") {true}
#IF ("-1") {true}
#IF ("0=1") {true}

The only one that would be false is:
#IF {} {true} {false}

That is a really long way of saying CMud is much more strict about writing the scripts correctly, and the use of braces for the expression portion of an #IF has always been wrong.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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