Is there any way to make an infinite loop in Amnesia?
I've tried:
PHP Code:
for(int k = 20; k > 50; k+=5)
PHP Code:
for(int k = 2; k == 1; k+=5)
and
But none have worked. They have just resulted in crashes of different kinds :/
The crash is caused by the infinite loop working. The game will hang until the script function call is finished - which obviously won't happen if you are stuck in an infinite loop. I am assuming you want some form of event which is fired once per step, in which case, try the following:
Code:
void OnStart()
{
loopStep("LoopTimer1");
}
//Loop the specified timer with delay of fDelay
const float fDelay = 1.0f / 60.0f; //60 steps per second
void loopStep(string &in asTimer) {
OnStep(asTimer);
AddTimer(asTimer,fDelay,"loopStep");
}
//Our loopStep code will call this once per step.
void OnStep(string &in asTimer)
{
//CODE HERE
}
Would you mind explaining that a bit more detailed? I don't understand very much of it :/
In other words: Use a timer where the function that gets called also resets the timer, where the timer loops about every 16ms.
Why didn't I think about that?! I feel so stupid... But thank you very much