Using "wait" in a while loop

Hi folks,

I am somewhat afraid that this may be a simple question as I am a beginner, but I am having trouble with a while loop. Essentially I am trying to create a loop that will incorporates a wait time that increases each time it iterates. Here is what I have:

	while waitinc!=10 do
	  log "{waitinc}"
	  wait waitinc then
	    waitinc++
	  end
	end

For some reason the loop doesn't seem to end and freezes the game when it hits the 400 iteration threshold. The original value of "waiting" is 0, so I would expect this to loop until it hits 10 and then stop.

Thanks for any help!

Only the code inside the wait block is delayed by the wait - the while loop itself will loop immediately.

If you want a delayed loop you can make an event that calls itself recursively like this:

on delayedLoop do
  if waitinc==10 then
    done
  end
  wait waitinc then
    waitinc++
    call "delayedLoop"
  end
end