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
Davos
Adept


Joined: 30 Jan 2003
Posts: 228
Location: USA

PostPosted: Sat Mar 08, 2003 8:11 pm   

Looping
 
This is what I want to do, I want to put an alias (or something) in my timer and evertime the timer ticks i want it to go thru the next value in my string variable, example

If I had a var with n|e|s|w in it the first time i call that var i want it to go N
then the second time E and so on, and when it gets to the end I want it to start back at the beggining and continue, any ideas? Let me know thanks

The Seaworthy
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Sat Mar 08, 2003 8:52 pm   
 
#var commandlist {n|e|s|w}
#alias execitem {
#var doit %pop(commandlist)
@doit
#additem commandlist @doit
}

enter this at the command line, and put execitem as the timeout command

--------

moon.icebound.net:9000
Reply with quote
Davos
Adept


Joined: 30 Jan 2003
Posts: 228
Location: USA

PostPosted: Sun Mar 09, 2003 8:37 pm   
 
Ok I have
#ALIAS execitem {#var doit %pop(commandlist)
@doit
#additem commandlist @doit}

#VAR commandlist {e|s|w|w|w|s|s|s|w|s|s|w|w|n|nw|s|w|s|w|s|w|s|w|w|e|e|e|n|e|n|e|e|e|s|s|s|s|s|e|e|n|n|n|n|n|n|n|n|n|n|w|w|w|w}

#VAR doit {}


Ok the first time thru this works wonderful, then when I get to the end it doesnt start over correctly it starts over in my string values where I have it Highlighted Red...any idea why? Let me know, Is there someway that i can have it start over correctly? Thanks


The Seaworthy
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Sun Mar 09, 2003 11:56 pm   
 
It happens because #additem checks for duplicates before adding. Change your alias to this one.

#alias execitem {
#var doit %pop(commandlist)
@doit
#var commandlist {%additem(@doit, @commandlist)}
}

--------

moon.icebound.net:9000
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