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


Joined: 02 Dec 2001
Posts: 80
Location: Canada

PostPosted: Fri Mar 18, 2005 2:55 am   

AND OR NOR statements
 
I think I am doing them wrong or something... I have one that doesn't appear to work properly in a button/ALIAS I have.

#ALAIS ac {#BU3)
Button 3: (the one side that isn't working right:

#VAR autocombat 1
#IF (@incombat = 0) {#VAR startcombat 1} {#VAR startcombat 0}
#IF (@ranged = 1) {#VAR incombat 1} {}
#IF (@incombat = 0 AND @startcombat = 1) {
#SAY DUH DUH DUH
#VAR startcombat 0
#TEMP {The * closes to melee range on you!} {#IF (@mobcount > 0) {} {1}}
} {}
#IF (@mobcount >0 AND @rt <1) {1} {}
#T+ autocombat
#SAY AUTO COMBAT ON

Now when I type ac or hit the button and it enters this state... here is what I get... I am showing the variables @mobcount and startcombat so you can see my problem.

Variable: mobcount 0
Variable: startcombat 0
DUH DUH DUH
AUTO COMBAT ON

(oh and the TEMP trigger is created, even though it shouldn't be)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Mar 18, 2005 4:29 am   
 
When using logical operators, surround the logical equation with parentheses. If I had to guess what's happening, it's that "@incombat = 0 AND @startcombat = 1" is evaluating true in this manner (or in right to left fashion, it also works that way):

@incombat = 0 AND @startcombat = 1 -- original equation
0 = 0 AND @startcombat = 1 -- evaluate @incombat (0 = 0 returns true)
1 AND 1 = 1 -- evaluate @startcombat (1 = 1 also returns true)
1 = 1 -- evaluate 1 AND 1, returns true
1 -- evaluate 1 = 1, returns true

This is what you want, it ensures that @incombat is evaluated, then @startcombat, and finally the results from both.

(@incombat = 0) AND (@startcombat = 1)
_________________
EDIT: I didn't like my old signature
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