Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error: Unexpected token {
Author Message
Neatherblade Offline
Junior Member

Posts: 19
Joined: Jan 2011
Reputation: 0
Post: #1
Error: Unexpected token {
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?
01-05-2011 11:27 PM
Find all posts by this user Quote this message in a reply
ModManDann Offline
Member

Posts: 61
Joined: Dec 2010
Reputation: 0
Post: #2
RE: Error: Unexpected token {
try putting void OnEnter()
above it

Current project: Mind Trap
01-05-2011 11:49 PM
Find all posts by this user Quote this message in a reply
Mofo Offline
Member

Posts: 71
Joined: Sep 2010
Reputation: 2
Post: #3
RE: Error: Unexpected token {
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);
}
(This post was last modified: 01-05-2011 11:56 PM by Mofo.)
01-05-2011 11:51 PM
Find all posts by this user Quote this message in a reply
Neatherblade Offline
Junior Member

Posts: 19
Joined: Jan 2011
Reputation: 0
Post: #4
RE: Error: Unexpected token {
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.
01-06-2011 12:18 PM
Find all posts by this user Quote this message in a reply
Russ Money Offline
Senior Member

Posts: 360
Joined: Dec 2010
Reputation: 3
Post: #5
RE: Error: Unexpected token {
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);
}
(This post was last modified: 01-06-2011 12:22 PM by Russ Money.)
01-06-2011 12:22 PM
Find all posts by this user Quote this message in a reply
Neatherblade Offline
Junior Member

Posts: 19
Joined: Jan 2011
Reputation: 0
Post: #6
RE: Error: Unexpected token {
But if i do like you did i get the error unexpected token { and expected indentifier.
01-06-2011 12:38 PM
Find all posts by this user Quote this message in a reply
ModManDann Offline
Member

Posts: 61
Joined: Dec 2010
Reputation: 0
Post: #7
RE: Error: Unexpected token {
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);
}

Current project: Mind Trap
01-06-2011 12:45 PM
Find all posts by this user Quote this message in a reply
ThePaSch Offline
Member

Posts: 103
Joined: Sep 2010
Reputation: 0
Post: #8
RE: Error: Unexpected token {
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);
}

01-06-2011 03:10 PM
Find all posts by this user Quote this message in a reply
Neatherblade Offline
Junior Member

Posts: 19
Joined: Jan 2011
Reputation: 0
Post: #9
RE: Error: Unexpected token {
Its working now, thanks all Big Grin
01-06-2011 03:45 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)