Frictional Games Forum (read-only)
Scripting Problem - 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: Scripting Problem (/thread-21561.html)

Pages: 1 2


Scripting Problem - amnesiaplayer321 - 05-20-2013

Hi.I am looking forward to create a new custom story for amnesia.But i have problems with my script.And i see nothing wrong.And when i launch my story,it gives that error:
FATAL ERROR: Could not load script file
'custom_stories/mystory/maps/lvl1.hps'!
main (17, 21): ERR :Unexpected end of file
My script file:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "Key", "Mansion_door", "UsedKeyonDoor", true);
AddUseItemCallback("", "Key2", "Door2", "UsedKeyOnDoor", true);

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

{
SetSwingDoorLocked("Mansion_door", false, true);
PlaySoundAtEntity("", "unlock_door", "Mansion", 0, false);
SetSwingDoorLocked("Door2", false, true);
PlaySoundAtEntity("", "unlock_door", "Door2", 0, false);

RemoveItem("Key");
RemoveItem("Key2");

Whats wrong about it and how to i fix?


RE: Scripting Problem - Bridge - 05-20-2013

You have to use the } character to designate the end of your function declarations.

Code:
////////////////////////////

// Run first time starting map

void OnStart()

{

    AddUseItemCallback("", "Key", "Mansion_door", "UsedKeyonDoor", true);

    AddUseItemCallback("", "Key2", "Door2", "UsedKeyOnDoor", true);

}


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

{

    SetSwingDoorLocked("Mansion_door", false, true);

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

    SetSwingDoorLocked("Door2", false, true);

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



    RemoveItem("Key");

    RemoveItem("Key2");

}



RE: Scripting Problem - amnesiaplayer321 - 05-20-2013

Thanks it did work but why is second door not locked?I did same thing on the first door's script.First door's locked but second is isn't.I downloaded beginneer set from youtube.


RE: Scripting Problem - Bridge - 05-20-2013

Are you certain the door is called "Door2"? The strings are probably case-sensitive.


RE: Scripting Problem - amnesiaplayer321 - 05-20-2013

I am sure its called Door2 in both name and PlayerInteractCallBack and locked is checked.


RE: Scripting Problem - Tomato Cat - 05-20-2013

Minor discrepancy in your callback function.


PHP Code:
AddUseItemCallback("""Key""Mansion_door""UsedKeyonDoor"true);
AddUseItemCallback("""Key2""Door2""UsedKeyOnDoor"true);

//Two variations. UsedKeyOnDoor & UsedKeyonDoor

void UsedKeyonDoor(string &in asItemstring &in asEntity)

//It's "UsedKeyonDoor" here 

Try fixing that.


RE: Scripting Problem - amnesiaplayer321 - 05-20-2013

Thanks again,key gones for nothing,because the door isn't still locked.I am searching a fix for this.Is there anyway to set Door2 locked on script?


RE: Scripting Problem - OriginalUsername - 05-20-2013

Derp. Ignore what I just said.


RE: Scripting Problem - amnesiaplayer321 - 05-20-2013

Its even locked after i use the key.Why?


RE: Scripting Problem - Bridge - 05-20-2013

Did you see what Tomato Cat said? You're calling a function that doesn't exist.

Code:
AddUseItemCallback("", "Key2", "Door2", "UsedKeyOnDoor", true);

Should be:

Code:
AddUseItemCallback("", "Key2", "Door2", "UsedKeyonDoor", true);