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


Joined: 04 May 2007
Posts: 1

PostPosted: Fri May 04, 2007 3:26 am   

Having troubles with triggers
 
I am attempting to make a trigger set that walks 30 north, turns to the west, and walks 30 west, south 30, and east 30.

I attack upon enter the room, using the failure to attack message as a trigger to move. It works fine, until I try to get to the west moving part:

Code:
#CLASS {laika|heaven}
#ALIAS hkil {iai-jutso}
#VAR dir {north}
#VAR heavenmove {30}
#VAR dir2 {west}
#VAR heavenmove2 {31}
#TRIGGER {You can't seem to find your target.} {
  #if {30>@heavenmove} {
    #wait 500
    @dir
    hkil deva,lammasu,boy,dog
    #math heavenmove @heavenmove+1
    } {
    #if {31>@heavenmove2} {
      @dir2
      hkil deva,lammasu,boy,dog
      #var heavenmove 0
      #math heavenmove2 @heavenmove2+1
      #if {@dir=north} {#math dir south} {#math dir north}
      } {
      #if {@dir2=east} {
        #if {@dir=north} {#math dir south} {#math dir north}
        #math dir2 west
        #var heavenmove2 0
        #var heavenmove 0
        }
      }
    }
  }
#TRIGGER {You killed (%w)} {hkil deva,lammasu,boy,dog}
#TRIGGER {You are already fighting} {iajaitsu deva,lammasu,dog,boy}
#TRIGGER {You look around and can't seem to find your target.} {hkil monsters}
#BUTTON 1 {Heaven on} {
  #T+ {heaven}
  #var heavenmove 0
  #var dir north
  #var heavemove2 0
  #var dir2 west
  #show Heaven bot on
  #show {Don't forget to start at the South East corner}
  } {Heaven off} {
  #t- {heaven}
  #show {Heaven bot off}
  } {} {1} {} {} {} {} {} {} {} {} {} {} {} "" {} {} {}
#CLASS 0

Any advice?
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sat May 05, 2007 2:39 pm   
 
Well you have a lot of bad code. I've cleaned it up a bit. I hope it helps. I added #EXEC commands to your direction commands and changed some #MATH commands you used to define a variable and changed it to #VAR. Not sure how this was able to work in the first place. I also changed the #WAIT to a #alarm.

Code:
#CLASS {laika|heaven}
#ALIAS hkil {iai-jutso %params}
#VAR dir {north}
#VAR heavenmove {30}
#VAR dir2 {west}
#VAR heavenmove2 {31}
#TRIGGER {You can't seem to find your target.} {
  #if {30>@heavenmove} {
    #ALARM {+0.5} {
          #EXEC @dir
          hkil deva,lammasu,boy,dog
          #math heavenmove @heavenmove+1
       }
    } {
    #if {31>@heavenmove2} {
      EXEC @dir2
      hkil deva,lammasu,boy,dog
      #var heavenmove 0
      #math heavenmove2 @heavenmove2+1
      #if {@dir=north} {#VAR dir south} {#var dir north}
      } {
      #if {@dir2=east} {
        #if {@dir=north} {#var dir south} {#var dir north}
        #var dir2 west
        #var heavenmove2 0
        #var heavenmove 0
        }
      }
    }
  }
#TRIGGER {You killed (%w)} {hkil deva,lammasu,boy,dog}
#TRIGGER {You are already fighting} {iajaitsu deva,lammasu,dog,boy}
#TRIGGER {You look around and can't seem to find your target.} {hkil monsters}
#BUTTON 1 {Heaven on} {
  #T+ {heaven}
  #var heavenmove 0
  #var dir north
  #var heavemove2 0
  #var dir2 west
  #show Heaven bot on
  #show {Don't forget to start at the South East corner}
  } {Heaven off} {
  #t- {heaven}
  #show {Heaven bot off}
  } {} {1} {} {} {} {} {} {} {} {} {} {} {} "" {} {} {}
#CLASS 0

_________________
Asati di tempari!
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sat May 05, 2007 3:58 pm   
 
My attempt.
I Tried to simplify a bit.

Code:
#CLASS {laika}
#BUTTON 1 {Heaven on} {
  #T+ {heaven}
  #var heaven_path %pathexpand( "30n30w30s30e")
  #var heaven_place 0
  #show Heaven bot on
  #show {Don't forget to start at the South East corner}
  } {Heaven off} {
  #t- {heaven}
  #show {Heaven bot off}
  } {} {1} {} {} {} {} {} {} {} {} {} {} {} "" {} {} {}
#CLASS 0
#CLASS {laika|heaven}
#ALIAS hkil {iai-jutso}
#VAR heaven_path {} {}
#VAR heaven_place {0} {0}
#TRIGGER {You can't seem to find your target.} {
  #add heaven_place 1
  #exec %item( @heaven_path, @heaven_place)
  hkil deva,lammasu,boy,dog
  }
#TRIGGER {You killed (%w)} {hkil deva,lammasu,boy,dog}
#TRIGGER {You are already fighting} {iajaitsu deva,lammasu,dog,boy}
#TRIGGER {You look around and can't seem to find your target.} {hkil monsters}
#CLASS 0

I moved the button into the laika class so that when you disable the heaven class the button doesn't vanish.
I wasn't sure how critical the wait was so i left it out, you can always put it back.
Instead of using all that if logic to figure out where you are.
The path is stored in the heaven_path variable by the %pathexpand function;
When we need to advance to the next room increase heaven_place by 1, then get the direction using %item.
Easy.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
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