Wait for something within a for loop

Post Reply
Scardon
Posts: 3
Joined: Fri Apr 26, 2013 9:52 am

Wait for something within a for loop

Post by Scardon »

I currently have a situation where I am running through a for loop which iterates through a list of rooms in an area.
I have set various temp triggers which would run functions to confirm if the room is the correct room after going into it.

With the triggers created and waiting while the character is moving to the first room, the for loop is still running, thus causing it to run to the 2nd room. Is there a solution to this? Is there a way to pause after the first iteration and let the triggers do their thing and continue the iteration afterwards?

Jor'Mox
Posts: 1101
Joined: Wed Apr 03, 2013 2:19 am

Re: Wait for something within a for loop

Post by Jor'Mox »

You can't use a for loop for that, you need to set up an iterating function instead. Your for loop will run from start to finish before any of your triggers ever gets anything, so you need to set up a trigger, then wait. When it triggers, call your iterating function to set things up for the next thing you are waiting for.

Scardon
Posts: 3
Joined: Fri Apr 26, 2013 9:52 am

Re: Wait for something within a for loop

Post by Scardon »

If that is the case, I will still need to setup a busy wait for the case you have mention?

Currently, with a busy wait, mudlet just hang and I would have to force quit it.

Jor'Mox
Posts: 1101
Joined: Wed Apr 03, 2013 2:19 am

Re: Wait for something within a for loop

Post by Jor'Mox »

No, there is no waiting.

You call the iterator function the first time, and it sets up things for your triggers and then ends.
The triggers get triggered and call the iterator function, which makes it set things up for the next thing you are waiting for.

The triggers act in the place of any sort of waiting function.

Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: Wait for something within a for loop

Post by Delrayne »

if you are using vadi's mapper try if (not mmp.autowalking) then do "this stuff" end

Post Reply