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
Can't for the problem with the unexpected token [SOLVED]
Pinkamena Diane Pie Offline
Junior Member

Posts: 5
Threads: 2
Joined: Jun 2012
Reputation: 0
#1
Can't for the problem with the unexpected token [SOLVED]

This is solved, thank you.
I kind of just started scripting and map making yesterday, keep it clean and simple for a small newbie, thanks.



Anyway, In my map, I want to create a small door slam scare. But I keep getting an error when testing the map, I think its just a mishap somewhere in the script. I also have a key, and a crowbar function in here, possibly interfering? I hope that isnt the case.



The error ATM is saying: 40, 1: ERR: Unexpected Token {



From that, it sounds like just some stupid mistake, but the help would be appreciated.



Here is my hsp.:



///////////////////////////

// Run when the map starts

void OnStart()

{

AddUseItemCallback("", "crowbar", "crowbardoor", "UsedCrowbarOnDoor", true);

AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);

}





void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)

{

AddTimer("", 0.2, "TimerSwitchShovel");

RemoveItem("crowbar");

}



void TimerSwitchShovel(string &in asTimer)

{

PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false);

SetEntityActive("crowbar_joint_1", true);

}





void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)

{

AddPlayerSanity(25);

PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);

SetSwingDoorLocked("crowbardoor", false, true);

AddPropImpulse("crowbardoor", 0, 0, -50, "World");

SetSwingDoorDisableAutoClose("crowbardoor", true);

SetSwingDoorClosed("crowbardoor", false, false);

SetMoveObjectState("crowbardoor", 1);

PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);

CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);

SetEntityActive("crowbar_joint_1", false);

SetLocalVarInt("Door", 1);

}



///////////////////////////



{

SetEntityPlayerInteractCallback("slamdoor", "func_slam", true);

}

void func_slam(string &in asParent, string &in asChild, int alState)

{

SetPropHealth("slamdoor", 0.0f);

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);

}



////////////////////////////

// Run when entering map

void OnEnter()



{

AddUseItemCallback("", "key1", "lockeddoor1", "unlock", true);

}



void unlock(string &in item, string &in door)



{

SetSwingDoorLocked(door, false, true);

PlaySoundAtEntity("", "unlock_door", door, 0, false);

RemoveItem(item);

}



////////////////////////////

// Run when leaving map

void OnLeave()

{



}
(This post was last modified: 06-18-2012, 04:42 PM by Pinkamena Diane Pie.)
06-18-2012, 04:06 PM
Find
Rownbear Offline
Member

Posts: 157
Threads: 13
Joined: Apr 2011
Reputation: 2
#2
RE: Can't for the problem with the unexpected token

{
SetEntityPlayerInteractCallback("slamdoor", "func_slam", true);
}

is supposed to be onstart, not a callback itself.

////////////////////////////

// Run when entering map

void OnEnter()
{
AddUseItemCallback("", "key1", "lockeddoor1", "unlock", true);
}



void unlock(string &in item, string &in door)
{
SetSwingDoorLocked(door, false, true);
PlaySoundAtEntity("", "unlock_door", door, 0, false);
RemoveItem(item);
}

remove the spaceing between

(This post was last modified: 06-18-2012, 04:18 PM by Rownbear.)
06-18-2012, 04:17 PM
Find
Pinkamena Diane Pie Offline
Junior Member

Posts: 5
Threads: 2
Joined: Jun 2012
Reputation: 0
#3
RE: Can't for the problem with the unexpected token

(06-18-2012, 04:17 PM)Rownbear Wrote: *SNIP*
That seems to be something wrong with the forums, in note++ there are no spaces.
06-18-2012, 04:18 PM
Find
Rownbear Offline
Member

Posts: 157
Threads: 13
Joined: Apr 2011
Reputation: 2
#4
RE: Can't for the problem with the unexpected token

(06-18-2012, 04:18 PM)Pinkamena Diane Pie Wrote:
(06-18-2012, 04:17 PM)Rownbear Wrote: *SNIP*
That seems to be something wrong with the forums, in note++ there are no spaces.
ok. put SetEntityPlayerInteractCallback("slamdoor", "func_slam", true);
and
AddUseItemCallback("", "key1", "lockeddoor1", "unlock", true);
with the others OnStart

(This post was last modified: 06-18-2012, 04:21 PM by Rownbear.)
06-18-2012, 04:20 PM
Find
Pinkamena Diane Pie Offline
Junior Member

Posts: 5
Threads: 2
Joined: Jun 2012
Reputation: 0
#5
RE: Can't for the problem with the unexpected token

(06-18-2012, 04:20 PM)Rownbear Wrote:
(06-18-2012, 04:18 PM)Pinkamena Diane Pie Wrote:
(06-18-2012, 04:17 PM)Rownbear Wrote: *SNIP*

That seems to be something wrong with the forums, in note++ there are no spaces.

ok. put SetEntityPlayerInteractCallback("slamdoor", "func_slam", true);

and

AddUseItemCallback("", "key1", "lockeddoor1", "unlock", true);

with the others OnStart
Now I am having more errors than before.

15, 1 unexpected token.
24, 1 unxpected token.
Shall I repost the updated hsp.?
06-18-2012, 04:24 PM
Find
Rownbear Offline
Member

Posts: 157
Threads: 13
Joined: Apr 2011
Reputation: 2
#6
RE: Can't for the problem with the unexpected token

///////////////////////////
// Run when the map starts
void OnStart()
{
AddUseItemCallback("", "crowbar", "crowbardoor", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);
SetEntityPlayerInteractCallback("slamdoor", "func_slam", true);
AddUseItemCallback("", "key1", "lockeddoor1", "unlock", true);
}


void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar");
}

void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false);
SetEntityActive("crowbar_joint_1", true);
}


void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("crowbardoor", false, true);
AddPropImpulse("crowbardoor", 0, 0, -50, "World");
SetSwingDoorDisableAutoClose("crowbardoor", true);
SetSwingDoorClosed("crowbardoor", false, false);
SetMoveObjectState("crowbardoor", 1);
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}


void func_slam(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("slamdoor", 0.0f);
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);
}

void unlock(string &in item, string &in door)
{
SetSwingDoorLocked(door, false, true);
PlaySoundAtEntity("", "unlock_door", door, 0, false);
RemoveItem("key1");
}


////////////////////////////
// Run when entering map
void OnEnter()
{

}


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

}

(This post was last modified: 06-18-2012, 04:28 PM by Rownbear.)
06-18-2012, 04:28 PM
Find
Pinkamena Diane Pie Offline
Junior Member

Posts: 5
Threads: 2
Joined: Jun 2012
Reputation: 0
#7
RE: Can't for the problem with the unexpected token

(06-18-2012, 04:28 PM)Rownbear Wrote: SNIP

Thank you very much for this, do you mind telling me what the issue was? For further notice.
06-18-2012, 04:31 PM
Find
Rownbear Offline
Member

Posts: 157
Threads: 13
Joined: Apr 2011
Reputation: 2
#8
RE: Can't for the problem with the unexpected token

(06-18-2012, 04:31 PM)Pinkamena Diane Pie Wrote:
(06-18-2012, 04:28 PM)Rownbear Wrote: SNIP

Thank you very much for this, do you mind telling me what the issue was? For further notice.
AddUseItemCallback
AddEntityCollideCallback
SetEntityPlayerInteractCallback
AddUseItemCallback

these are callbacks, they belong on start, they call or activate the:

Void blabla(string &in asParent, string &in asChild, int alState)
{
///stuff that happens
}

You put callbacks inbetween the voids, and you had something between OnEnter and Onleave, just keep them empty and alone at the bottom unless you want to put out loading screens and preload particles, you'll probably use them more as you get used to scripting.

*I don't exactly know the technical names for all of this but hopefully you got my point*


(This post was last modified: 06-18-2012, 04:41 PM by Rownbear.)
06-18-2012, 04:37 PM
Find
Pinkamena Diane Pie Offline
Junior Member

Posts: 5
Threads: 2
Joined: Jun 2012
Reputation: 0
#9
RE: Can't for the problem with the unexpected token

Thank you very much for your help. I probably missed something inside the wiki's tutorials. Anyways, this is solved. Thanks, again.
06-18-2012, 04:41 PM
Find




Users browsing this thread: 1 Guest(s)