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
Martyl
Newbie


Joined: 30 May 2007
Posts: 7

PostPosted: Wed Apr 02, 2008 5:25 pm   

Navigating a Maze with SPY
 
I have some experience with the #IF statement, but not enough for this.

I've got a small maze in front of me, and if I spy into the room, and see a particular mobile, then I know THAT is the way to go.

So, I want to spy in all directions, and go in the direction that holds the mob, and then turn off the trigger.

so basically :
1) Enter the room, spy in all directions - syntax is spy <direction> (UP, DOWN, EAST, WEST, SOUTH, DOWN)
2) IF there is a mobile in that room (lets say, 'The Guardian of the Underworld stands here') - then move in that direction
3) Turn off the trigger so I don't go anywhere else accidentally.

Any ideas? I've been toying with a few triggers, but nothing so far works for me. I think this is pretty simple, but its beyond my feeble Zmud skills!

thanks,
Martyl
Reply with quote
meyn
Beginner


Joined: 06 Mar 2008
Posts: 27

PostPosted: Mon Apr 14, 2008 7:12 pm   
 
Not been tested but should work. Use the first trigger and remove kill @tgt for navagational aid, or adapt second and third triggers + add however many more for basic bot

Code:
#CLA {Spy}
#AL spyall {
  #VAR mobile 0
  spy north
  #IF (@mobile) {
    north
    kill @tgt
  } {
    spy east
    #IF (@mobile) {
      east
      kill @tgt
    } {
      spy south
      #IF (@mobile) {
        south
        kill @tgt
      } {
        spy west
        #IF (@mobile) {
          west
          kill @tgt
        } {
          spy up
          #IF (@mobile) {
            up
            kill @tgt 
          } {
            spy down
            #IF (@mobile) {
              down
              kill @tgt
            } {
              #SHOW %ansi( bold,white)No target found!
            }
          }
        }
      }
    }
  }
}
#TR {Line of text for spy to decect} {#VAR mobile 1}
#TR {Thers a cute brown (%w) ready to run {
  #VAR tgt %1
  #VAR mobile 1
}
#TR {Theres a big scary (%w) standing here} {
  #VAR tgt %1
  #VAR mobile 1
}
#CLA 0


EDIT: Cheers that looks much better


Last edited by meyn on Mon Apr 14, 2008 8:07 pm; edited 1 time in total
Reply with quote
Martyl
Newbie


Joined: 30 May 2007
Posts: 7

PostPosted: Mon Apr 14, 2008 7:27 pm   
 
Awesome, thanks, I'll give it a shot.
Martyl
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Apr 14, 2008 7:52 pm   
 
Spaces that begin lines and multiple spaces are removed by the forums. You can use the code tag to stop it. I actually could've done it for you if you hadn't put those underscores in :P
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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