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


Joined: 29 Jan 2008
Posts: 17

PostPosted: Tue Jan 29, 2008 8:00 pm   

For Next Loop
 
I would like to see an example of a for next loop, my goal is to loop rang of numbers, room numbers to be specific

Something like this, but Im lost at how to build it in ZMud

For %room = 1 to 30000
goto %room
next %room

Thanks in advance
Darklord
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Tue Jan 29, 2008 8:20 pm   
 
You need to use #FORALL.

In your specific case I think you're wanting to go through all rooms in your map and do something so you want

#FORALL %numrooms {#noop replace text inside these curly braces with what you want to do instead of no operation.}
_________________
Taz :)

Last edited by Taz on Tue Jan 29, 2008 8:26 pm; edited 1 time in total
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Jan 29, 2008 8:25 pm   
 
#loop is zScript's looping command. If you need to do something more complex (like speedwalking all the way to a room for each step) you might find it better to have your own variable to store the number in, and then add 1 to it as needed.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Darklord
Beginner


Joined: 29 Jan 2008
Posts: 17

PostPosted: Tue Jan 29, 2008 8:38 pm   Thanks using the #loop works perfectly
 
#LOOP 3005,3000 {goto %i}



Thanks for the prompt replys
You guys rock
Darklord
Reply with quote
Darklord
Beginner


Joined: 29 Jan 2008
Posts: 17

PostPosted: Sun Feb 03, 2008 4:19 pm   This fires a million times
 
on a small scale, Im using 'goto' to goto room then looking for items, in this case a Trophy is used for testing, I fires, but when it fires it fires more than once, just need it to fire for the specific room, room being %i



#LOOP 16009,16011 {
goto %i
#TRIGGER {Trophy} {say there is Trophy in room %i}
}


Told you guys I would be back :)
Darklord
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Feb 03, 2008 8:55 pm   
 
First the trigger is a seperate setting. You want to create it once and have it do whatever it is supposed to. Right now you have it being receated with each iteration of the loop. This is what is leading to your multiple firing situation.

Next you want to actually await some data after each goto command. In order to do this properly you need to have 2 distinct recognition patterns. One is is the data you want to see. The other is some data that you will definitely see, and specifically it will be seen after the data you want. That second condition is generally much harder to determine. Sometimes the second condition can only be met by recognizing some data that will be before what you want and then allowing time to elapse.

Without more specific information I can not tell you an exact way to do what you want. The general description of how to do it, that I gave above, might be enough.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Darklord
Beginner


Joined: 29 Jan 2008
Posts: 17

PostPosted: Sun Feb 03, 2008 9:34 pm   
 
Thanks for the quick reply

Specific is:
I have vnums for an area, ie 16001 to 16459
The #loop 16001, 16459 loops through the vnums doing goto %1

#loop 16001, 16459 { goto %1} * works great

Now I want use triggers ie (%w) Trophy
(%w) Trophy
clan Trophy was see in room %i * clan being ooc for a clan

I did get this to work, with out the repeating, but it uses the last value in the #loop this being 16459, where is needs to be the %i it fired in

Thanks again for the help
Darklord
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