Frictional Games Forum (read-only)
if statement isn't working - 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: if statement isn't working (/thread-26579.html)



if statement isn't working - Spazatron - 10-05-2014

I have a note that when you finish reading, teleports you to a new map. This is a map that the player will have already been in before, therefore I need to tell the script that the player is revisiting the map for the second time, and to execute a certain script, otherwise it'd just execute the script from when they were in the map before. So, I have this code when the player reads the note:
Code:
void NoteRead(string &in asEntity, string &in asType)
{
    AddGlobalVarInt("SwitchBack", 1);
}
Then on the map that they're teleported to:
Code:
void OnStart()
{
    if(GetGlobalVarInt("SwitchBack") == 1)
    {
         [script for second visit]
    }    
    else
    {
         [script for first visit]
    }
}
But when the map is loaded and the player teleports, neither of the codes are executed.


RE: if statement isn't working - Wapez - 10-05-2014

Try using
SetGlobalVarInt("SwitchBack", 1);
instead.

EDIT:

NVM, you need to put the if statement in the OnEnter() Function instead, OnStart is only used the first time the level is started.


RE: if statement isn't working - Spazatron - 10-05-2014

(10-05-2014, 06:24 PM)Wapez Wrote: Try using
SetGlobalVarInt("SwitchBack", 1);
instead.

EDIT:

NVM, you need to put the if statement in the OnEnter() Function instead, OnStart is only used the first time the level is started.

Thanks a lot Smile