Frictional Games Forum (read-only)
Whats wrong with my 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: Whats wrong with my script? (/thread-8295.html)



Whats wrong with my script? - Henriksen - 05-28-2011

Hi, I was trying to script random events today but it doesnt work, can anyone see whats wrong with my script'?

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Func01", true, 1);
}

void Func01(string &in asParent, string &in asChild, int alState)
{
int x = RandInt(1, 3);
if (x == 1)
{
[SetEntityActive("servant_grunt_1", true);]
return;
}
if (x == 2)
{
[SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);]
return;
}
if (x == 3)
{
[SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);
SetEntityActive("servant_grunt_3", true);]
return;
}
}

////////////////////////////
// Run when entering map
void OnEnter()
{    
PlayMusic("ambience_voice.ogg", true, 0.7f, 1, 0, false);
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}




RE: Whats wrong with my script? - Tanshaydar - 05-28-2011

[SetEntityActive("servant_grunt_1", true);]

'[' & ']' needless. Omit all of them.


RE: Whats wrong with my script? - Henriksen - 05-28-2011

(05-28-2011, 11:13 AM)Tanshaydar Wrote: [SetEntityActive("servant_grunt_1", true);]

'[' & ']' needless. Omit all of them.

My script now looks like this but it still doesnt work:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Func01", true, 1);
}

void Func01(string &in asParent, string &in asChild, int alState)
{
int x = RandInt(1, 3);
if (x == 1)
{
SetEntityActive("servant_grunt_1", true);
return;
}
if (x == 2)
{
SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);
return;
}
if (x == 3)
{
SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);
SetEntityActive("servant_grunt_3", true);
return;
}
}

////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic("ambience_voice.ogg", true, 0.7f, 1, 0, false);
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}



RE: Whats wrong with my script? - Tanshaydar - 05-28-2011

I'm not sure what's wrong since script looks right. There might be something wrong with the map file. Try to add debug messages to see if player collides with the area and if statements are working.