Frictional Games Forum (read-only)

Full Version: Need help with scripting!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
So I'm making my map in amnesia level editor, everything's just fine. But then I wanna start my scripting. So I add a function, and it's works perfectly fine, but when I try to add a new function there's an error when I start up my custom story! D: I dunno what the problem is D:
Here's the error message:

[Image: amnesiaerror.png]

Uploaded with ImageShack.us

Here's my script:

void OnStart()

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

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("HousekeeperDoor", true, false);
PlaySoundAtEntity("DoorSlamSound", "scare_slam_door.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}

{
AddEntityCollideCallback("Player", "NoOil", "Collide_Area", true, 1);
}

void Collide_Area(string &in asParent, string &in asChild, int alState)
{
SetPlayerLampOil(0.0f);
}

{
AddUseItemCallback("", "FirstRoomKey_1", "BedroomDoorFirst_1", "unlock_door", true);
}

void unlock_door(string &in FirstRoomKey_1, string &in BedroomDoorFirst_1)
{
SetSwingDoorLocked(BedroomDoorFirst_1, false, true);
PlaySoundAtEntity("", "unlock_door", BedroomDoorFirst_1, 0, false);
RemoveItem(FirstRoomKey_1);
}

void OnEnter()
{


}

void OnLeave()
{

}

Please help me!
It's telling you have you two dangling code blocks. Were they supposed to be functions, or are you new to scripting in general?
Well I am new to scripting Tongue
these once aren't announced with a special function.

When should they use them.

Most likely it'll have to be connected with AddEntityCollideCallback or AddUseItemCallback but now the game doesn't know WHEN to use those things so I think you'll have to place those two scripts (without the brackets "{}") into void OnStart()



PHP Code:

AddEntityCollideCallback("Player""NoOil""Collide_Area"true1);
}

{
AddEntityCollideCallback("Player""NoOil""Collide_Area"true1);


Okay so I looked a little more at the error, and it says unexpected token. So I removed the unexpected token (wich was the: { ) and start up my map again. But then I get an error saying that the ending bracket is an unexpected token too. And it also says that it expected an identifier AddEntityCollideCallback--->here<---("Player", "door_slamHousekeeper", "func_slam", true, 1); D:
Im just skimming ur script, and im not really concentrating on what your problem is, but try this

GiveSanityDamage(5, true); rather than GiveSanityDamage(5.0f, true);

same with the oil, remove the .0f
(12-28-2011, 11:47 AM)Tripication Wrote: [ -> ]Im just skimming ur script, and im not really concentrating on what your problem is, but try this

GiveSanityDamage(5, true); rather than GiveSanityDamage(5.0f, true);

same with the oil, remove the .0f
yeah I tried that too...
(12-28-2011, 11:42 AM)Zaapeer Wrote: [ -> ]Okay so I looked a little more at the error, and it says unexpected token. So I removed the unexpected token (wich was the: { ) and start up my map again. But then I get an error saying that the ending bracket is an unexpected token too. And it also says that it expected an identifier AddEntityCollideCallback--->here<---("Player", "door_slamHousekeeper", "func_slam", true, 1); D:


The message doesn't specify where the error is. It tells you what block it is in. If it says (for e.g) main (45,5), it doesn't directly mean there is something wrong with that line and character. It means in the entire block; something's wrong. Post your script again and I'll see if I can help.
Add me and I'll help you with all your problems xD

Much easier.

Skype: ferryadams10

Steam: ferryadams10

Msn: ferry_hooligan@live.nl
Have you got it to work? Smile becuse i think i know what the problem is Smile

If im not mistaken it should look like this:
(12-27-2011, 07:56 PM)Zaapeer Wrote: [ -> ]void OnStart()

{
AddEntityCollideCallback("Player", "door_slamHousekeeper", "func_slam", true, 1);
AddUseItemCallback("", "FirstRoomKey_1", "BedroomDoorFirst_1", "unlock_door", true);
AddEntityCollideCallback("Player", "NoOil", "Collide_Area", true, 1);

}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("HousekeeperDoor", true, false);
PlaySoundAtEntity("DoorSlamSound", "scare_slam_door.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}

void Collide_Area(string &in asParent, string &in asChild, int alState)
{
SetPlayerLampOil(0.0f);
}

void unlock_door(string &in FirstRoomKey_1, string &in BedroomDoorFirst_1)
{
SetSwingDoorLocked(BedroomDoorFirst_1, false, true);
PlaySoundAtEntity("", "unlock_door", BedroomDoorFirst_1, 0, false);
RemoveItem(FirstRoomKey_1);
}

void OnEnter()
{


}

void OnLeave()
{

}
the bolded ones is the ones I moved Smile You need to have them in either void onstart, void onenter or void onleave


Correct me if i'm mistaken Smile
Pages: 1 2