I searched, and found non, so I think no-one has asked before... unless there's something I have missed again, so no-one ever needed to ask. Well, anyway:
Is there a way to create a non-blocking wait? I mean, If I have a while loop, which should be run only once in a cycle, but be not blocking, how do I do this? And is it possible to make a while loop that is paused for only each 2nd cycle, so it doubles the speed of the loop? I tired using timers, no succes. I'd really like to get rid of the Wait(1); blocking the game while the loop runs...
In case I have missed something, which ofcourse then makes me look stupid, someone puch me on #ags... ;D
I'm not really sure what you're asking.
If you want some code run once every cycle, simply place it in repeatedly_execute.
Erm... this is kindof a silly question, because:
1. The whole purpose of Wait() is to block whatever's happening at the time, so what do you want? A DoNothing() function?
2. Whilst in a while loop nothing will happen until the loop exits anyway
I think what you're actually asking for is multi-threading, which obviously isn't going to be put into AGS for a long time ;D
TK, just use a timer, or just some integer incrementing every loop (which I always use).
For example if you want a "loop" that runs every 2 cycles and runs 100 times since it starts, just do:
on top of script, usual stuffs:
int count, cycle;
When you want to start the "loop", just do:
count = 100; //do 100 times
cycle = 0;
In rep_exec:
if (count){
cycle++;
if (cycle==2){//do it every 2 cycle
//blah blah whatever you want to do here
count--;
cycle=0;
}
Thanks! That's just what I meant! :D Sorry if I explained it a bit unclearly.