Frictional Games Forum (read-only)
[SCRIPT] Having a "while" loop problem(possible overload) - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Having a "while" loop problem(possible overload) (/thread-23273.html)



Having a "while" loop problem(possible overload) - Silent Darkness - 09-19-2013

I want to have a section of script that temporarily makes it so that the player is forced to crouch.

PHP Code:
while(OnyourKnees >= 1)
  {
  
SetPlayerCrouching(true);
  } 

Running this at any point in the script causes any script code further along the line to simply not run at all, putting the map at a complete standstill. I'm not sure why this is.

Are while loops supposed to risk freezing up the entire script file?


RE: Having a "while" loop problem(possible overload) - DamnNoHtml - 09-19-2013

That simple block should work. Where are you setting OnyourKnees to >=1?

Alternatively, why not just set the player to crouching, then use void SetPlayerCrouchDisabled(bool abX);


RE: Having a "while" loop problem(possible overload) - Silent Darkness - 09-19-2013

1. Initially, it was on OnEnter(), but putting it elsewhere only made it freeze up elsewhere.

2. Ooh. Alright, I already found a seperate solution to this problem by accident, but i'll keep this in mind.