Frictional Games Forum (read-only)
Looping a "if statement" - 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: Looping a "if statement" (/thread-13134.html)



Looping a "if statement" - Ninami - 02-06-2012

Hey so I want to loop a if statement. The reason:
When the player collides with a Area I want the "if loop" to start and always check if the door is closed. When it closes (And believe me, it will get closed) some stuff will happen. But since I haven't done a loop, it only checks it once and it's not possible to have the door closed at that time, so I need a loop.

Here's how far I've gotten:

void Area_If(string &in asParent, string &in asChild, int alState)
{
if (GetSwingDoorClosed("Door_2") == true)
{
SetEntityActive("Monster_1", false);
SetMessage("Messages", "Text_2", 3);
}
else()
{

}
}


So when player enters Area_If, the "if statement" begins, but what do I write in the "else" statement in order to make it loop?

Appreciate any help!


RE: Looping a "if statement" - Your Computer - 02-06-2012

Technically, a while loop is a looping "if" statement. But since a while loop that loops on to infinity will prevent the game from functioning, you should use timers.


RE: Looping a "if statement" - Ninami - 02-06-2012

Oh my gooooooood, why didn't I think of timers!??! Big Grin

Tyyyy!
Works perfect!

+rep