Frictional Games Forum (read-only)
A Scripting Question - 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: A Scripting Question (/thread-7576.html)



A Scripting Question - Kyle - 04-23-2011

I'm trying to make a local variable integer to check to see if the player picked something up and if they didn't, to display a message once they enter an area.

Eh, here's the code:

Code:
void OnStart()
{
AddLocalVarInt("LeverTouchCheck", 0);
SetEntityPlayerInteractCallback("lever_small_lever_1", "LeverCheck", true);
AddEntityCollideCallback("Player", "ScriptArea_4", "MissingLever", true, 1);
}

void MissingLever(string &in asParent, string &in asChild, int alState)
{
If (GetLocalVarInt("LeverTouchCheck") == 0)
{
SetMessage("Message", "Hint04", 4);
}
}

void LeverCheck(string &in asEntity)
{
    SetLocalVarInt("LeverTouchCheck", 1);
}

The error report is confusing... I could have sworn it changed a few times in awkward ways. I hope you can help. :/


RE: A Scripting Question - laser50 - 04-23-2011

What is the error?


RE: A Scripting Question - Pandemoneus - 04-23-2011

You do not use AddLocalVarInt("blabla", 0);
Add means addition (like 1 + 1).
Use SetLocalVarInt("blabla", 0); in your OnStart().


RE: A Scripting Question - Kyle - 04-23-2011

Well um, thanks for your help. It still didn't work so I just used my own work-around. I never used variables before like this, I'm only used to making them like: "int x = 0;" and then setting it to "x = 1;"