Frictional Games Forum (read-only)
Error: Unexpected token { - 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: Error: Unexpected token { (/thread-6068.html)



Error: Unexpected token { - Neatherblade - 01-05-2011

After i have made this script



void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}




{ <------- Complain about this one

AddUseItemCallback("", "Elevator_key", "elevator_door_1", "KeyOnDoor", true);

}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("elevator_door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "elevator_door_1", 0.0f, true);
}

I get this Error: Unexpected token { and if i remove the script for the door and key it works, but why wont it work with the key script?


RE: Error: Unexpected token { - ModManDann - 01-05-2011

try putting void OnEnter()
above it


RE: Error: Unexpected token { - Mofo - 01-05-2011

Quote:void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}




{ <------- remove

AddUseItemCallback("", "Elevator_key", "elevator_door_1", "KeyOnDoor", true); <------- put inside OnStart or OnEnter.

} <------- remove

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("elevator_door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "elevator_door_1", 0.0f, true);
}



RE: Error: Unexpected token { - Neatherblade - 01-06-2011

None of that did work, all i get is new errors.
Either i already have a void OnStart() or it want indentifiers when i remove { and use void onEnter() or that i should use , or ; efter ()
but none of that work.

Did remove the key and door for the moment, and was going to try this


void OnEnter();
AddEntityCollideCallback("Player" , "ScriptArea_3" , true , 1);


SetEntityActive("wind_1" , true);
SetEntityActive("wind_sound" , true);
PlaySoundAtEntity("wind_sound", "ambience_wind_eerie.snt", "player", 2.0f, false);


I have not added any { }, if i do it says i should remove them or i should add them.


RE: Error: Unexpected token { - Russ Money - 01-06-2011

If you intend on using like this

void OnEnter();
AddEntityCollideCallback("Player" , "ScriptArea_3" , true , 1);

You'll need to add { and }

Like this

void OnEnter();
{
AddEntityCollideCallback("Player" , "ScriptArea_3" , true , 1);
}


RE: Error: Unexpected token { - Neatherblade - 01-06-2011

But if i do like you did i get the error unexpected token { and expected indentifier.


RE: Error: Unexpected token { - ModManDann - 01-06-2011

void OnEnter();
{
AddEntityCollideCallback("Player" , "ScriptArea_3" , true , 1);
}

remove the ; from void onEnter(), when you create a function you NEVER put ; behind that. This is also the case for if statements, for loops etc.

It should look like:

void OnEnter()
{
AddEntityCollideCallback("Player" , "ScriptArea_3" , true , 1);
}


RE: Error: Unexpected token { - ThePaSch - 01-06-2011

Code:
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddUseItemCallback("", "Elevator_key", "elevator_door_1", "KeyOnDoor", true);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("elevator_door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "elevator_door_1", 0.0f, true);
}



RE: Error: Unexpected token { - Neatherblade - 01-06-2011

Its working now, thanks all Big Grin