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


Joined: 15 Oct 2000
Posts: 29
Location: USA

PostPosted: Fri Jul 04, 2003 8:51 pm   

Forall
 
Would really be helpful to me to be able to put a timer in the FORALL
loop, so it would continue, say, with the next item in the list after 5 seconds.

FORALL example

list="sword|ring|shield"
#FORALL @list {repair %i}

Loops through the equipment in the list and repairs each one in turn.
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Fri Jul 04, 2003 10:18 pm   
 
Can you just create an Index variable, and every time the 5 second timer fires increment the index and do the repair on the (index)th item in the list? (Stopping when the index is equal to the number of list members)

For this example, there might be another solution entirely: do you get a message when the repair is complete that you can trigger on?

Do you need the list variable to stay the same, or are you adding/removing items from it as equipment is broken/repaired?

-Tarn
Reply with quote
broadnax
Beginner


Joined: 15 Oct 2000
Posts: 29
Location: USA

PostPosted: Sat Jul 05, 2003 4:37 am   
 
Is there an easy way for me to increment through my variable list? I thought maybe I could #delitem after it was repaired so it would cycle to the next item. Was hoping for an easier fix as #forall would work perfectly if I could just put in a timer between each one.
Reply with quote
broadnax
Beginner


Joined: 15 Oct 2000
Posts: 29
Location: USA

PostPosted: Sat Jul 05, 2003 6:09 am   
 
I figured out a way to do it by including #YESNO in my #FORALL statement. Only drawback is that if someone enters the room to kill me while im clicking yes, no, cancel, or the "x" i cant move. I have to click an answer for every item in my variable list. This is my button:

#FORALL @list {#yesno "Repairing damage to %i" {repair %i}}
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Jul 05, 2003 6:28 am   
 
;if you no longer need the list when you are done with it
#alarm *5 {repair %pop(@list)}

;if you still need the original list when the repair action is done
#alarm "tRepair" *5 {#additem List "Beginning";#if (%item(@List,1) != "Beginning") {List = %additem(%item(@list,1),@list);repair %pop(@list)} {List = %pop(@list);#T- tRepair}}
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