|
Cruscian Newbie
Joined: 12 Jul 2009 Posts: 2
|
Posted: 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? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
Cruscian Newbie
Joined: 12 Jul 2009 Posts: 2
|
Posted: Sun Jul 12, 2009 11:09 am |
Nevermind, got it working. Thanks for the help.
|
|
|
|
|
|