Frictional Games Forum (read-only)
HELP! - 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: HELP! (/thread-17947.html)



HELP! - ryan223456 - 08-25-2012

i am making a new custom story and i am naming it "Forever" i am having troubles with scripting, though,
here is what i have in there,


////////////////////////////
//Run when starting map
void OnStart()

{
AddEntityCollideCallback("Player", "explode_scare", "Explode", true, 1);
}


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

{
SetPropHealth("boom", 0);
}

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

{
AddUseItemCallback("", "key", "Locked Door", "KeyOnDoor", true);
}


{
SetSwingDoorLocked("Locked Door", false, true);
PlaySoundEntity("", "unlock_door", "Locked Door", 0, false);
RemoveItem("key");
}

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

}

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

,everytime i go in the game it says "unexpected token "{"
any revisions would be greatly appreciated, and hopefully i will figure everything out from there.
thanks, bye.


RE: HELP! - Adny - 08-25-2012

2 main issues:

Lock Door isn't a valid string; you should never use spaces in the middle of a string name, just use underscores "_". I changed it to locked_door in the hps file; you should use that name in the level editor.

All callbacks (AddUseItemCallback, EntityCollideCallback, etc) go under void OnStart().


Here's a revision:


void OnStart()
{
AddEntityCollideCallback("Player", "explode_scare", "Explode", true, 1);
AddUseItemCallback("", "key", "locked_door", "KeyOnDoor", true); ///not Lock Door
}


void Explode(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("boom", 0);
}


void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door", false, true);
PlaySoundEntity("", "unlock_door", "locked_door", 0, false);
RemoveItem("key");
}


void OnEnter()
{


}


void OnLeave()
{


}


Hope that helped!


RE: HELP! - ryan223456 - 08-25-2012

now it's having problems with the sound...i'll just remove it and see what happens

thank you though, i felt kind of hopeless when i couldnt figure out how to get a door to unlock XD


RE: HELP! - FlawlessHappiness - 08-25-2012

The sound problem was that you wrote: PlaySoundEntity.
It's: PlaySoundAtEntity