Can't for the problem with the unexpected token [SOLVED] - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: Can't for the problem with the unexpected token [SOLVED] (/thread-16271.html) |
Can't for the problem with the unexpected token [SOLVED] - Pinkamena Diane Pie - 06-18-2012 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() { } RE: Can't for the problem with the unexpected token - Rownbear - 06-18-2012 { 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 RE: Can't for the problem with the unexpected token - Pinkamena Diane Pie - 06-18-2012 (06-18-2012, 04:17 PM)Rownbear Wrote: *SNIP*That seems to be something wrong with the forums, in note++ there are no spaces. RE: Can't for the problem with the unexpected token - Rownbear - 06-18-2012 (06-18-2012, 04:18 PM)Pinkamena Diane Pie Wrote:ok. put SetEntityPlayerInteractCallback("slamdoor", "func_slam", true);(06-18-2012, 04:17 PM)Rownbear Wrote: *SNIP*That seems to be something wrong with the forums, in note++ there are no spaces. and AddUseItemCallback("", "key1", "lockeddoor1", "unlock", true); with the others OnStart RE: Can't for the problem with the unexpected token - Pinkamena Diane Pie - 06-18-2012 (06-18-2012, 04:20 PM)Rownbear Wrote:Now I am having more errors than before.(06-18-2012, 04:18 PM)Pinkamena Diane Pie Wrote:(06-18-2012, 04:17 PM)Rownbear Wrote: *SNIP* 15, 1 unexpected token. 24, 1 unxpected token. Shall I repost the updated hsp.? RE: Can't for the problem with the unexpected token - Rownbear - 06-18-2012 /////////////////////////// // 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() { } RE: Can't for the problem with the unexpected token - Pinkamena Diane Pie - 06-18-2012 (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. RE: Can't for the problem with the unexpected token - Rownbear - 06-18-2012 (06-18-2012, 04:31 PM)Pinkamena Diane Pie Wrote:AddUseItemCallback(06-18-2012, 04:28 PM)Rownbear Wrote: SNIP 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* RE: Can't for the problem with the unexpected token - Pinkamena Diane Pie - 06-18-2012 Thank you very much for your help. I probably missed something inside the wiki's tutorials. Anyways, this is solved. Thanks, again. |