Frictional Games Forum (read-only)
Need help with scripting! - 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: Need help with scripting! (/thread-12118.html)

Pages: 1 2


Need help with scripting! - Zaapeer - 12-27-2011

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!


RE: Need help with scripting! - Your Computer - 12-27-2011

It's telling you have you two dangling code blocks. Were they supposed to be functions, or are you new to scripting in general?


RE: Need help with scripting! - Zaapeer - 12-28-2011

Well I am new to scripting Tongue


RE: Need help with scripting! - ferryadams10 - 12-28-2011

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





RE: Need help with scripting! - Zaapeer - 12-28-2011

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:


RE: Need help with scripting! - Tripication - 12-28-2011

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


RE: Need help with scripting! - Zaapeer - 12-28-2011

(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...


RE: Need help with scripting! - flamez3 - 12-28-2011

(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.


RE: Need help with scripting! - ferryadams10 - 12-28-2011

Add me and I'll help you with all your problems xD

Much easier.

Skype: ferryadams10

Steam: ferryadams10

Msn: ferry_hooligan@live.nl



RE: Need help with scripting! - SilentStriker - 12-28-2011

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