Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Script] Infinite Loop?
Dobbydoo Offline
Member

Posts: 50
Threads: 6
Joined: Aug 2011
Reputation: 0
#1
[Script] Infinite Loop?

Is there any way to make an infinite loop in Amnesia?

I've tried:
PHP Code: (Select All)
for(int k 2050k+=5
PHP Code: (Select All)
for (;;) 
PHP Code: (Select All)
while (== 1
PHP Code: (Select All)
for(int k 2== 1k+=5
and
PHP Code: (Select All)
while (1

But none have worked. They have just resulted in crashes of different kinds :/

12-30-2011, 07:35 PM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#2
RE: [Script] Infinite Loop?

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:

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
}
12-30-2011, 08:01 PM
Find
Dobbydoo Offline
Member

Posts: 50
Threads: 6
Joined: Aug 2011
Reputation: 0
#3
RE: [Script] Infinite Loop?

Would you mind explaining that a bit more detailed? I don't understand very much of it :/
12-30-2011, 08:26 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: [Script] Infinite Loop?

In other words: Use a timer where the function that gets called also resets the timer, where the timer loops about every 16ms.

Tutorials: From Noob to Pro
12-30-2011, 09:02 PM
Website Find
Dobbydoo Offline
Member

Posts: 50
Threads: 6
Joined: Aug 2011
Reputation: 0
#5
RE: [Script] Infinite Loop?

Why didn't I think about that?! I feel so stupid... But thank you very much Big Grin
12-30-2011, 09:20 PM
Find




Users browsing this thread: 1 Guest(s)