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
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Wed Mar 21, 2012 5:13 pm   

Problem with "or" in an #IF statement?
 
When I'm walking and hit a wall:
Code:

#IF (@mango=1) {
  #SAY " "
  #SAY %ansi( bright, green)"ROW: "%ansi( bright, white)@row%ansi( bright, green)"    |     ROW_Direction: "%ansi( bright, white)@rowdir%ansi( bright, green)"    |     NS_Direction: "%ansi( bright, white)@direction
  #IF (@direction=north) {
    #IF (@row!=17&@row!=1) {
      #ADD row {-1}
      #IF (@rowdir=east) {
        #VAR rowdir {west}
        #IF (@row=2 OR @row=3 OR @row=4 OR @row=5 OR @row=6 OR @row=7 OR @row=9) {northeast} {north}
        } {
        #VAR rowdir {east}
        #IF (@row=2 OR @row=3 OR @row=4 OR @row=5 OR @row=6 OR @row=7 OR @row=8) {northwest} {north}
        }
      } {
      #IF (@row=1) {
        #VAR direction {south}
        #VAR row {2}
        #IF (@rowdir=east) {
          southeast
          #VAR rowdir {west}
          } {
          southwest
          #VAR rowdir {east}
          }
        }
      }
    } {
    #IF (@direction=south) {
      #IF (@row!=17&@row!=1) {
        #ADD row {1}
        #IF (@rowdir=east) {
          #VAR rowdir {west}
          #IF (@row=2|@row=3|@row=4|@row=5|@row=6|@row=7) {southeast} {south}
          } {
          #VAR rowdir {east}
          #IF (@row=2|@row=3|@row=4|@row=5|@row=6|@row=8) {southwest} {south}
          }
        } {
        #IF (@row=17&@direction=south) {
          #VAR direction {north}
          north
          #VAR row {16}
          }
        }
      }
    }
  }




As you can see, I tried formatting it differently to see if, for some reason, that affected it. It didn't.

The problem here is that in, say, #IF (@row=2 OR @row=3 OR @row=4 OR @row=5 OR @row=6 OR @row=7 OR @row=9) {northeast} {north}, it moves north. Never northeast, despite meeting all of the requirements to do so, that I can tell. My only guess is that zMUD hates my use of "or"? I'm not sure, though.

Can anyone provide insight and/or help me get this rolling? When it moves north, it hits a wall and ends up spamming until it meets the requirement to turn back around and head south again. I'm neglecting about half of the rooms I'm trying to move through because of it.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Mar 21, 2012 11:05 pm   
 
Use %ismember(@row,"2|3|4|5|6|7|9") instead of all those ORs.
_________________
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