Frictional Games Forum (read-only)
[SCRIPT] Two doors, one key? - 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: [SCRIPT] Two doors, one key? (/thread-14269.html)



Two doors, one key? - KamenRiderSun - 03-26-2012

I'm currently working on a CS that's very choice driven. [Is "Bump in the Night" taken as a CS name? Blush ]
Right now, I'm having a little issue with making one key able to unlock two doors, removing the other choice in the process. My question is, is this even possible?

First I tried this:

void OnStart()
{
SetMessage("Messages", "Intro", 0);
AddUseItemCallback("OpenDoor", "ChoiceKey", "LevelDoor_Mansion", "UnlockLevelDoor", true);
AddUseItemCallback("OpenDoor", "ChoiceKey", "LevelDoor_Basement", "UnlockLevelDoor", true);
}

void UnlockLevelDoor(string &in item, string &in entity)
{
SetLevelDoorLocked(entity, false);
RemoveItem(item);

But no results. I then tried:

AddUseItemCallback("OpenDoor", "ChoiceKey", "LevelDoor_Mansion", "UnlockLevelDoor1", true);
AddUseItemCallback("OpenDoor", "ChoiceKey", "LevelDoor_Basement", "UnlockLevelDoor2", true);
}

void UnlockLevelDoor1(string &in item, string &in entity)
{
SetLevelDoorLocked(entity, false);
RemoveItem(item);
}
void UnlockLevelDoor2(string &in item, string &in entity)
{
SetLevelDoorLocked(entity, false);
RemoveItem(item);
}

Also, no results. My confusion is whether my scripting method or syntax are wrong, or if it's just not possible.
Thanks for any advice!



RE: Two doors, one key? - Your Computer - 03-26-2012

For starters, don't give both callbacks the same internal name and don't tell the game to remove the key from inventory when used on one door.


RE: Two doors, one key? - KamenRiderSun - 03-27-2012

Thanks, I'll change the callback names. I'm guessing there isn't a work-around way of having the key still be destroyed when used? I hoped to use that as a way of cutting the other route off, but I suppose I can either lock the door behind the player, or just get rid of the key altogether.




RE: Two doors, one key? - Your Computer - 03-27-2012

(03-27-2012, 12:04 AM)KamenRiderSun Wrote: Thanks, I'll change the callback names. I'm guessing there isn't a work-around way of having the key still be destroyed when used? I hoped to use that as a way of cutting the other route off, but I suppose I can either lock the door behind the player, or just get rid of the key altogether.

I'm not sure if i was understood, but i intended "internal names" to differ from "callback names." Also, you would need local map variables and an extra function to check if the key has unlocked both doors and, if so, remove the key from inventory.


RE: Two doors, one key? - KamenRiderSun - 03-27-2012

Thanks for the help, I'll figure something out, hopefully.