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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Cruscian
Newbie


Joined: 12 Jul 2009
Posts: 2

PostPosted: Sun Jul 12, 2009 10:29 am   

AND operator problems
 
Alright, I have no idea what I'm doing wrong.

For the trigger: H:%1 M:%2

Code:
#var HP %1
#var MP %2
#IF (@HP < @TargetHP AND @SipBusy = False) {#SA Sipping} {#SA Not Sipping}



It's having no problems harvesting the HP and MP totals but it refuses to register the third statement as successful no matter what I set TargetHP and SipBusy to. Am I mishandling the AND operator, or is my context messed up somewhere else?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Jul 12, 2009 11:01 am   
 
You have to be careful with the priority of operators - I can't remember what the priorities are, but I suspect that AND comes before <, which means that rather than ((@HP < @TargetHP) AND (@SipBusy = False)), you're getting (@HP < (@TargetHP AND (@SipBusy = False))), which is completely different. Also beware if you're trying to use "false" like a boolean value, because zScript doesn't have them. It'll be doing a string comparison.

In short, use brackets in complex expressions so there's no ambiguity.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Cruscian
Newbie


Joined: 12 Jul 2009
Posts: 2

PostPosted: Sun Jul 12, 2009 11:09 am   
 
Nevermind, got it working. Thanks for the help.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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