Frictional Games Forum (read-only)
Script File crashing - 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: Script File crashing (/thread-8290.html)



Script File crashing - willochill - 05-28-2011

so i just started scripting one of my maps and i went on it to test it and it's crashing and saying this error:
FATAL ERROR: Could not load script file (blahbitty blah, map file name)
main (5,1) :ERR :Unexpected token '{'

Can you take a look at my script so far and see what ive done wrong?


void OnStart()
{
PlayMusic("amb_guardian.ogg", true, 1.0f, 0, 0, true);
}
{
AddUseItemCallback("", "bone_saw_2", "wooden_boards_block_1", "SawGruntAlert", true);
}
void SawGruntAlert(string &in asItem, string &in asEntity)
{
SetEntityActive("wooden_boards_block_1", false);
SetEntityActive("wooden_boards_block_broken_1", true);
PlaySoundAtEntity("", "23_saw2.snt", "Player", 0, false);
AddTimer("", 1, "TimerFunc");
AddTimer("", 1, "TimerFunc2");
}
void TimerFunc(string &in asTimer)
{
SetEntityActive("servant_grunt_1", true);
}
void TimerFunc2(string &in asTimer)
{
StopSound("23_saw2.snt", 0f);
}



RE: Script File crashing - Tanshaydar - 05-28-2011

void OnStart()
{
PlayMusic("amb_guardian.ogg", true, 1.0f, 0, 0, true);
}
{

AddUseItemCallback("", "bone_saw_2", "wooden_boards_block_1", "SawGruntAlert", true);
}

So, bold characters are completely needless. {'s are to open and close function blocks. Like in:
void TimerFunc2(string &in asTimer)
{
StopSound("23_saw2.snt", 0f);
}

See, void TimerFunc2(string &in asTimer) is the header, and { & } is to open and close the function block.


RE: Script File crashing - willochill - 05-28-2011

okay, well i deleted the bold characters there and understand your point but now its saying the same error except like this:
main(20,32) : ERR : Expected ')' or ','
help?!?!?!?


RE: Script File crashing - Tanshaydar - 05-28-2011

StopSound("23_saw2.snt", 0f);

0.0f or just 0


RE: Script File crashing - willochill - 05-28-2011


(05-28-2011, 11:10 AM)Tanshaydar Wrote: StopSound("23_saw2.snt", 0f);

0.0f or just 0

didn't do anything, just says the same error message.


RE: Script File crashing - Tanshaydar - 05-28-2011

Can you post your script again?


RE: Script File crashing - willochill - 05-28-2011

void OnStart()
{
PlayMusic("amb_guardian.ogg", true, 1.0f, 0, 0, true);
AddUseItemCallback("", "bone_saw_2", "wooden_boards_block_1", "SawGruntAlert", true);
}
void SawGruntAlert(string &in asItem, string &in asEntity)
{
SetEntityActive("wooden_boards_block_1", false);
SetEntityActive("wooden_boards_block_broken_1", true);
PlaySoundAtEntity("", "23_saw2.snt", "Player", 0, false);
AddTimer("", 1.0f, "TimerFunc");
AddTimer("", 1.0f, "TimerFunc2");
}
void TimerFunc(string &in asTimer)
{
SetEntityActive("servant_grunt_1", true);
}
void TimerFunc2(string &in asTimer)
{
StopSound("23_saw2.snt", 0f);
}


RE: Script File crashing - Kyle - 05-28-2011

Don't tell me, the StopSound command won't work.

Give the PlaySoundAtEntity a name.

Example:

PlaySoundAtEntity("Sound01", "23_saw2.snt", "Player", 0, false);

Then the StopSound.

StopSound("Sound01", 0);

Try this:

Code:
void OnStart()
{
     PlayMusic("amb_guardian.ogg", true, 1, 0, 0, true);
     AddUseItemCallback("", "bone_saw_2", "wooden_boards_block_1", "SawGruntAlert", true);
}
void SawGruntAlert(string &in asItem, string &in asEntity)
{
     SetEntityActive("wooden_boards_block_1", false);
     SetEntityActive("wooden_boards_block_broken_1", true);
     PlaySoundAtEntity("Sound01", "23_saw2.snt", "Player", 0, false);
     AddTimer("", 1.0f, "TimerFunc");
}
void TimerFunc(string &in asTimer)
{
     SetEntityActive("servant_grunt_1", true);
     StopSound("Sound01", 0);
}



RE: Script File crashing - Kyle - 05-28-2011

Try this:

Code:
void OnStart()
{
     PlayMusic("amb_guardian.ogg", true, 1, 0, 0, true);
     AddUseItemCallback("", "bone_saw_2", "wooden_boards_block_1", "SawGruntAlert", true);
}
void SawGruntAlert(string &in asItem, string &in asEntity)
{
     SetEntityActive("wooden_boards_block_1", false);
     SetEntityActive("wooden_boards_block_broken_1", true);
     PlaySoundAtEntity("Sound01", "23_saw2.snt", "Player", 0, false);
     AddTimer("", 1.0f, "TimerFunc");
}
void TimerFunc(string &in asTimer)
{
     SetEntityActive("servant_grunt_1", true);
     StopSound("Sound01", 0);
}



RE: Script File crashing - willochill - 05-28-2011

okay i get it, it works now. but im still having issues with another script, for a different map. this time the error message says:
main (21,1) :ERR :Expected expression value
main (27,1) :ERR :Expected expression value
here's the script:
void OnStart()
{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 4.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_11", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_12", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_13", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_14", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_15", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_16", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_17", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_18", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_19", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_20", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_21", 2.0f, "");
    AddEntityCollideCallback("Player", "AreaActivateGrunt", "Func01", true, 1);
AddEntityCollideCallback("servant_grunt_1", "AreaDisableGrunt", "Func02", false, 1);
PlayMusic("00_creak.ogg", true, 1.0f, 0, 0, true);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
     if (HasItem("lantern_1") == true)
     {
          SetEntityActive("servant_grunt_1", true);
     }
}
void Func02(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", false);
}