Frictional Games Forum (read-only)
Timer troubles - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Timer troubles (/thread-7383.html)



Timer troubles - evertuy - 04-15-2011

When you make a function inside of a function with a timer, I don't know how to write that correctly, please tell me how to fix?

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Scare_1", true, 1);
}
void Scare_1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "general_chain_rattle_single.snt", 0, false);
GiveSanityDamage(5.0f, true);
AddTimer("Timer_1", 4.0f, "looking");

void looking(string &in asTimer)
{
SetEntityActive("human_skull_1", true);
StartPlayerLookAt("human_skull_1", 6.0f, 7.0f, "");
GiveSanityDamage(5.0f, true);
}


RE: Timer troubles - Tanshaydar - 04-15-2011

Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "ScriptArea_1", "Scare_1", true, 1);
}

void Scare_1(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("", "general_chain_rattle_single.snt", 0, false);
    GiveSanityDamage(5.0f, true);
    AddTimer("Timer_1", 4.0f, "looking");
}

void looking(string &in asTimer)
{
    SetEntityActive("human_skull_1", true);
    StartPlayerLookAt("human_skull_1", 6.0f, 7.0f, "");
    GiveSanityDamage(5.0f, true);
}

You forgot a '}' after adding timer.


RE: Timer troubles - evertuy - 04-15-2011

Ohh, I didn't think you needed a } after it, since more or less it is ONE function, (or one and a half).


RE: Timer troubles - Dalroc - 04-15-2011

(04-15-2011, 03:05 AM)evertuy Wrote: Ohh, I didn't think you needed a } after it, since more or less it is ONE function, (or one and a half).
No, it is 2 functions actually.. The timer calls a whole new function after x amount of seconds, it doesn't pause the script or something.