Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Ishmael on Mon 25/08/2003 20:06:52

Title: Non-blocking wait
Post by: Ishmael on Mon 25/08/2003 20:06:52
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
Title: Re:Non-blocking wait
Post by: Pumaman on Mon 25/08/2003 21:54:31
I'm not really sure what you're asking.

If you want some code run once every cycle, simply place it in repeatedly_execute.
Title: Re:Non-blocking wait
Post by: Archangel (aka SoupDragon) on Mon 25/08/2003 22:27:40
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
Title: Re:Non-blocking wait
Post by: Gilbert on Tue 26/08/2003 05:07:17
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;
}
Title: Re:Non-blocking wait
Post by: Ishmael on Tue 26/08/2003 05:23:44
Thanks! That's just what I meant! :D Sorry if I explained it a bit unclearly.