Frictional Games Forum (read-only)
Small little Issue. - 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: Small little Issue. (/thread-10638.html)



Small little Issue. - A Tricky Carnie - 10-06-2011

Okay...I have two keys in one map, however, when I unlock the first door (the second key is behind the first locked door), it actually ends up unlocking both doors at once.

How do I fix this?


RE: Small little Issue. - Your Computer - 10-06-2011

Help me help you: post your code.


RE: Small little Issue. - A Tricky Carnie - 10-06-2011

(10-06-2011, 11:06 PM)Your Computer Wrote: Help me help you: post your code.
This is what I have for my script:
Spoiler below!
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_2", "mansion_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_3", "mansion_2", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("key_2");
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem("key_3");

}

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

}



RE: Small little Issue. - Elven - 10-06-2011

Both functions call same function called "KeyOnDoor"

You need to make 2 different callbacks one is KeyOnDoor and other is KeyOnDoor2

And both of them opens different doors Smile!

Aka, it should be like this:

Code:
void OnEnter()
{
AddUseItemCallback("", "key_2", "mansion_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_3", "mansion_2", "KeyOnDoor2", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("key_2");
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem("key_3");
}



RE: Small little Issue. - Your Computer - 10-06-2011

I thought that was the case.

A more efficient method:
Code:
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}



RE: Small little Issue. - A Tricky Carnie - 10-06-2011

Thanks, both of you, I had a feeling it was something simple.