Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Pizzaman on Mon 24/01/2005 22:35:18

Title: How to stop infinite loop detection?
Post by: Pizzaman on Mon 24/01/2005 22:35:18
Ya speaking of infinite loops, uh how do you remove that detection thing?

Cuz I am trying to have a while loop which has the enemy attack you and there is a random number generated to see if he will succeed or not, and i set it to do a random seed every second.  And I also have the player push a button to attack back when he wishes. 

But if there is no activity for even a second, the game crashes with an error about infinite loop.  Although its not an infinite loop, its quite "controlled."  I thought the Turin Machine Problem was impossible. 

Is there a way to avoid doing this without a while loop?

-Pizzaman
Title: Re: How to stop infinite loop detection?
Post by: Etcher Squared Games on Mon 24/01/2005 23:17:36
Why not just hook into repeatedly_execute()?

Have some kind of state to get your random # only at certain times when you need.

But remember that gets executed every game CYCLE, so you'll need to know what the game speed is (default 40).  So you'd want to get a random # every 40 cycles.
Title: Re: How to stop infinite loop detection?
Post by: Goot on Tue 25/01/2005 04:55:50
Yeah, you have to put it in repeatedly execute. A script like this:
while(condition){
script here
}
will crash the game if the condition will be true untill the game continues. The script doesn't keep running until the while function has finished.
To do a while statement you either need a Wait(1); in the condition, to allow the game to continue for a split second, so that the condition might be changed to false, or to update a variable in the condition which will eventually end the loop.
Title: Re: How to stop infinite loop detection?
Post by: Gilbert on Tue 25/01/2005 06:33:42
If it's put in repeatedly execute, I'll recommend using "if" other than "while", as it would be checked every game loop already, and you don't need Wait().

All you need to do is to track the conditions with conditions, and use "if" "else" etc. to response accordingly.