Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Fatal Error : ERR : Unexpected token '{'
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#1
Fatal Error : ERR : Unexpected token '{'

Hey guys,

I have been working on a custom story and i wanted to add a door slam script, but when i added it to the .hps file it gave me an error saying Unexpected token "{" , I have no clue what to do in order to fix it, i'd appreciate any help.


////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key1", "DoorName01", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("DoorName01", false, true);
PlaySoundAtEntity("", "unlock_door", "DoorName01", 0, false);
RemoveItem("key1");
}

{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("DoorName01", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false); PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}


Image of the Error: http://gyazo.com/aba925b567f80c526ccc156c420efce7
05-24-2012, 12:53 PM
Find
Stepper321 Offline
Senior Member

Posts: 263
Threads: 26
Joined: Nov 2011
Reputation: 8
#2
RE: Fatal Error : ERR : Unexpected token '{'

Check it yourself!

14 is the line and 1 is the location in that line.


{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}


Theres no void etc...

Signature to awesome to be displayed.
05-24-2012, 12:56 PM
Find
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#3
RE: Fatal Error : ERR : Unexpected token '{'

(05-24-2012, 12:56 PM)Stepper321 Wrote: Check it yourself!

14 is the line and 1 is the location in that line.


{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}


Theres no void etc...

Soory if the problem is way obvious than i expected but i'm new at scripting and making custom stories in amnesia, can you please explain me how to fix it?
Like, where to put the void and such.
Thanks! Smile
05-24-2012, 01:01 PM
Find
Stepper321 Offline
Senior Member

Posts: 263
Threads: 26
Joined: Nov 2011
Reputation: 8
#4
RE: Fatal Error : ERR : Unexpected token '{'

(05-24-2012, 01:01 PM)Clear Wrote:
(05-24-2012, 12:56 PM)Stepper321 Wrote: Check it yourself!

14 is the line and 1 is the location in that line.


{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}


Theres no void etc...

Soory if the problem is way obvious than i expected but i'm new at scripting and making custom stories in amnesia, can you please explain me how to fix it?
Like, where to put the void and such.
Thanks! Smile
First i need to know WHEN you want to enable that part of the script.

Signature to awesome to be displayed.
05-24-2012, 01:05 PM
Find
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#5
RE: Fatal Error : ERR : Unexpected token '{'

(05-24-2012, 01:05 PM)Stepper321 Wrote:
(05-24-2012, 01:01 PM)Clear Wrote:
(05-24-2012, 12:56 PM)Stepper321 Wrote: Check it yourself!

14 is the line and 1 is the location in that line.


{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}


Theres no void etc...

Soory if the problem is way obvious than i expected but i'm new at scripting and making custom stories in amnesia, can you please explain me how to fix it?
Like, where to put the void and such.
Thanks! Smile
First i need to know WHEN you want to enable that part of the script.
http://gyazo.com/c66a95e14f81787915194e1c29bc7208

My goal is to make the door slam as soon as i walk infront of the area, i have a key & door script on the top and the script with error, the slam script, if that's what you wanted to know
05-24-2012, 01:10 PM
Find
Stepper321 Offline
Senior Member

Posts: 263
Threads: 26
Joined: Nov 2011
Reputation: 8
#6
RE: Fatal Error : ERR : Unexpected token '{'

Put
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
in void OnStart(){
put it here!


}

Signature to awesome to be displayed.
05-24-2012, 01:39 PM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#7
RE: Fatal Error : ERR : Unexpected token '{'

Nevermind Big Grin

(This post was last modified: 05-24-2012, 01:41 PM by Datguy5.)
05-24-2012, 01:41 PM
Find
Clear Offline
Junior Member

Posts: 19
Threads: 4
Joined: May 2012
Reputation: 0
#8
RE: Fatal Error : ERR : Unexpected token '{'

(05-24-2012, 01:41 PM)Datguy5 Wrote: Nevermind Big Grin
Do you have any clue what do i need to do in order to solve this error?
05-24-2012, 02:23 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#9
RE: Fatal Error : ERR : Unexpected token '{'

(05-24-2012, 02:23 PM)Clear Wrote: Do you have any clue what do i need to do in order to solve this error?
You cannot declare functions inside other functions. Read up on basic curly bracket ( "{" and "}" ) use.

Noob scripting tutorial: From Noob to Pro

05-24-2012, 02:29 PM
Find




Users browsing this thread: 1 Guest(s)