Frictional Games Forum (read-only)
What's wrong with this script? - 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: What's wrong with this script? (/thread-7755.html)



What's wrong with this script? - NylePudding - 05-02-2011

What's wrong with this script? It says this line: "void Timer02 (string &in asTimer)" has a missing "(" but I can't see how. So I guess I've made a mistake somewhere else?

Huh

void Timer01(string &in asTimer)

{

int RanEve_1 = RandInt(1,2);

if (RanEve_1 == 1)
{
SetEntityActive("servant_grunt_1", true);
}

else if (RanEve_1 == 2)
{
SetEntityActive("servant_brute_1", true);
}

SetEntityActive("ScriptArea_1", true);
SetMessage("Example", "Entry2", 0);
PlayMusic("10_event_coming.ogg", false, 1.0f, 0, 0, true);

void Timer02 (string &in asTimer)
{
if (RanEve_1 == 1)
{
ShowEnemyPlayerPosition("servant_grunt_1");
}

if (RanEve_1 == 2)
{
ShowEnemyPlayerPosition("servant_brute_1");
}

SetSwingDoorLocked("mansion_1", false, false);

}
}


And I thought I was just getting a grip with C++... Thanks for any help. Smile


RE: What's wrong with this script? - Tanshaydar - 05-02-2011

This is whole script? You don't have an "OnStart" section, and you have placed a second timer function inside first timer which you shouldn't. The functions you want to call should be same level with others.


RE: What's wrong with this script? - NylePudding - 05-02-2011

(05-02-2011, 08:08 AM)Tanshaydar Wrote: This is whole script? You don't have an "OnStart" section, and you have placed a second timer function inside first timer which you shouldn't. The functions you want to call should be same level with others.

This isn't the whole script only the area which has the problem.

Here's the whole script if it helps:

void OnStart()
{
AddTimer("tut01", 3, "Intro");
AddTimer("tut02", 30, "Timer01");

SetEnemyIsHallucination("servant_grunt_1", true);
SetEnemyIsHallucination("servant_brute_1", true);

SetSwingDoorLocked("mansion_1", true, false);

PlayMusic("ambience_wind_eerie.ogg", true, 0.5f, 0, 0, true);

AddEntityCollideCallback("Player" , "ScriptArea_1" , "BodyFunc1" , true , 1);
}
void BodyFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("corpse_male_1" , true);
AddTimer("tut03", 10, "Timer02");
AddTimer("tut03", 10, "Timer03");
}


void Intro(string &in asTimer)
{
SetMessage("Example", "Entry1", 0);

}

void Timer01(string &in asTimer)

{

int RanEve_1 = RandInt(1,2);

if (RanEve_1 == 1)
{
SetEntityActive("servant_grunt_1", true);
}

else if (RanEve_1 == 2)
{
SetEntityActive("servant_brute_1", true);
}

SetEntityActive("ScriptArea_1", true);
SetMessage("Example", "Entry2", 0);
PlayMusic("10_event_coming.ogg", false, 1.0f, 0, 0, true);

void Timer02 (string &in asTimer)
{
if (RanEve_1 == 1)
{
ShowEnemyPlayerPosition("servant_grunt_1");
}

if (RanEve_1 == 2)
{
ShowEnemyPlayerPosition("servant_brute_1");
}

SetSwingDoorLocked("mansion_1", false, false);

}
}

void OnEnter()
{

}

void OnLeave()
{

}

(05-02-2011, 08:08 AM)Tanshaydar Wrote: This is whole script? You don't have an "OnStart" section, and you have placed a second timer function inside first timer which you shouldn't. The functions you want to call should be same level with others.

Okay, I'll arrange my script differently.

So you can't have another timer function within another? I just thought it would save time with the RanEve_1 variable.

So how would you make a variable effective throughout the script?


RE: What's wrong with this script? - jens - 05-02-2011

you should move one of the } above void OnEnter to above void Timer02. Currently you have (short version)

void Timer01()
{
void Timer02()
{
}
}

which will result in an error.


RE: What's wrong with this script? - Tanshaydar - 05-02-2011

One local variable can be used in one hps file and all functions will see it.


RE: What's wrong with this script? - NylePudding - 05-02-2011

(05-02-2011, 08:35 AM)Tanshaydar Wrote: One local variable can be used in one hps file and all functions will see it.

Okay thank you, with everyone's help I've managed to see sense and I've fixed my script. Big Grin