Frictional Games Forum (read-only)

Full Version: Scripting Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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?
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");

}
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.
Are you certain the door is called "Door2"? The strings are probably case-sensitive.
I am sure its called Door2 in both name and PlayerInteractCallBack and locked is checked.
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.
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?
Derp. Ignore what I just said.
Its even locked after i use the key.Why?
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);
Pages: 1 2