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
veek
Beginner


Joined: 28 Sep 2006
Posts: 21

PostPosted: Wed Nov 22, 2006 9:28 am   

Breaking or returning from a ALIAS. (return?)
 
#ALIAS WalkAroundVillage {
#FORALL @pechRoomList {
WalkToRoom/Main %i
#WHILE (!@moved) {#WAIT 2000}
moved = 0
#WHILE (@pechInRoom) { #IF (@_noCombat = 1) {#WALK 504; pechInRoom = 0} {pechInRoom = 0; kill pech; look; #WAIT 10000} }
}
}

When _noCombat is set i want to WALK 504 and then exit the ALIAS. How do i do this? Normally i'd just call return in C or Perl, in this case it's the FORALL
that is causing problems :(
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Nov 22, 2006 3:30 pm   
 
Try
#ABORT 1

to break the loop.
Reply with quote
veek
Beginner


Joined: 28 Sep 2006
Posts: 21

PostPosted: Thu Nov 23, 2006 4:59 am   
 
I've pasted the whole code. ABORT does not break out of the FORALL :(. Perhaps there is some other way to code this.
I'm trying to process a list of rooms. Enter a room, check if there are pechs. Kill them and if the room is empty move to
the next room. I'll get rid of the compulsory 10 second wait later. Right now, when my hit points fall below 3000 i can't break
out of the FORALL loop and run away. I could change the FORALL into a IF/WHILE thing..but, any other way?


#CLASS {Initialise}
#Alias Main {#RESET %1}
#CLASS 0
;
;
#CLASS {KillPech}
#VAR moved {0}
#VAR pechInRoom {}
#VAR pechSafeRoom {}
#VAR pechSafeHp {3000}
;
; Killable Pech's. We don't want to kill women and children.
#VAR pechKillList {pech tribesman|pech warrior|pech hunter|pech stalker|pech fighter|pech guard|pech tracker|pech tribeleader}
;
; Walk through the following rooms in the Pech-village.
#VAR pechRoomList {579|580|581|582|583|591|3072|592|3073|593|3074|585|586|3075|587|588|589|590|584}
;
; monitor on Set _noCombat if hp falls below a safe limit.
#TRIGGER pechSafety {^Hp:(\w+)\/(\w+) Tactics:(\w+)\/(\w+).+$} {#IF (%1<@pechSafeHp) {_noCombat = 1} {}} "" {regex|disable}
;
; If there is a killable pech in the room then set pechInRoom.
; pechInRoom is unset only in the WHILE loop.
#TRIGGER killPech {(@pechKillList).+here\.$} {#COLOR 87;pechInRoom = 1} "" {regex|disable}
;
; Used to synchronise MUD with script. Check to see if you received the new room
; directions and then set moved.
#TRIGGER check {[.+]} {moved = 1}
;
#ALIAS WalkToPechVillage {
#WALK 578
#WAIT 10000
#T+ check
#T+ killPech
#T+ pechSafety
}
;
#ALIAS WalkAroundVillage {
#FORALL @pechRoomList {
WalkToRoom/Main %i
#WHILE (!@moved) {#WAIT 2000}
moved = 0
#WHILE (@pechInRoom) { #IF (@_noCombat = 1) {#WALK 504; pechInRoom = 0; #ABORT 1} {pechInRoom = 0; kill pech; look; #WAIT 10000} }
}
}
;
#ALIAS Main {Initialise/Main KillPech; WalkToPechVillage; WalkAroundVillage}
#CLASS 0
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