Frictional Games Forum (read-only)
Key to Unlock Chest - 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: Key to Unlock Chest (/thread-9297.html)

Pages: 1 2


Key to Unlock Chest - Obliviator27 - 07-22-2011

Alright, so thanks to you wonderful people on this forum, I've been able to start my own custom story with very little knowledge to begin with. Anyhow, I can't seem to find a way to allow a key to unlock a chest and was just wondering if anybody here knows how to do it.


RE: Key to Unlock Chest - Ouroboros - 07-22-2011

You have to add a useitemcallback
Code:
/
AddUseItemCallback("can be empty", "key name", "chest name", "function name to call", true/false for removing the callback);
And then you have the function it calls look something like
Code:
void MyFunc(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("name of chest", false, true);
//if you want the item removed after use,
RemoveItem("name of key");
}



RE: Key to Unlock Chest - Obliviator27 - 07-22-2011

Ah, of course. I didn't realize that the chest counted as a swing door. Thank you very much.


RE: Key to Unlock Chest - Ouroboros - 07-22-2011

(07-22-2011, 07:30 AM)Obliviator27 Wrote: Ah, of course. I didn't realize that the chest counted as a swing door. Thank you very much.

No problem, cabinets/closets also count as swing doors, should you want to unlock one of those in the future.


RE: Key to Unlock Chest - Obliviator27 - 07-22-2011

Right, so I now have a new, fun problem. Odds are the problem is right in front of my eyes, but I'll let you guys see for yourselves. Basically, I have all the script for opening the chest. However, it refuses to be locked in the first place.

void OnStart()
{
FadeIn(0);
AddPlayerHealth(100);
SetPlayerLampOil(30);
SetSwingDoorLocked("MedChest", true, true);
AddUseItemCallback("", "MedChestKey", "MedChest", "UnlockMedicineChest", true);
}
void UnlockMedicineChest(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("MedChest", false, true);
RemoveItem("MedChestKey");
}

All in-game file names correspond properly.


RE: Key to Unlock Chest - ferryadams11 - 07-22-2011

I'm not sure if a chest counts as a swingdoor Undecided

But I think it is Big Grin cause else I don't remember me another unlock command xD

Whatever Tongue

Add me if u have questions.
Msn: ferry_hooligan@live.nl
Steam: ferryadams1


RE: Key to Unlock Chest - Rokotain - 07-22-2011

(07-22-2011, 09:01 AM)Obliviator27 Wrote: Right, so I now have a new, fun problem. Odds are the problem is right in front of my eyes, but I'll let you guys see for yourselves. Basically, I have all the script for opening the chest. However, it refuses to be locked in the first place.

void OnStart()
{
FadeIn(0);
AddPlayerHealth(100);
SetPlayerLampOil(30);
SetSwingDoorLocked("MedChest", true, true);
AddUseItemCallback("", "MedChestKey", "MedChest", "UnlockMedicineChest", true);
}
void UnlockMedicineChest(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("MedChest", false, true);
RemoveItem("MedChestKey");
}

All in-game file names correspond properly.

Hello Big Grin

I'm no expert, but I think it is because you have an extra(unecessary?) true on the SetSwingDoorLocked.

I did [ b] true [ /b] around the true you could remove^^

Hope it helped, RokotainAngel


RE: Key to Unlock Chest - Poppuhik42 - 07-22-2011

-----


RE: Key to Unlock Chest - WatzUpzPeepz - 07-22-2011

(07-22-2011, 10:40 AM)Rokotain Wrote:
(07-22-2011, 09:01 AM)Obliviator27 Wrote: Right, so I now have a new, fun problem. Odds are the problem is right in front of my eyes, but I'll let you guys see for yourselves. Basically, I have all the script for opening the chest. However, it refuses to be locked in the first place.

void OnStart()
{
FadeIn(0);
AddPlayerHealth(100);
SetPlayerLampOil(30);
SetSwingDoorLocked("MedChest", true, true);
AddUseItemCallback("", "MedChestKey", "MedChest", "UnlockMedicineChest", true);
}
void UnlockMedicineChest(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("MedChest", false, true);
RemoveItem("MedChestKey");
}

All in-game file names correspond properly.

Hello Big Grin

I'm no expert, but I think it is because you have an extra(unecessary?) true on the SetSwingDoorLocked.

I did [ b] true [ /b] around the true you could remove^^

Hope it helped, RokotainAngel

I dont see the need for setting the player health to 100 and I think the fade in thing is: FadeIn(1.0f);


RE: Key to Unlock Chest - Ouroboros - 07-22-2011

(07-22-2011, 01:27 PM)Swistrobl Wrote: I think the game actually considers chests equal to levers. If they were swingdoors, wouldn't there at least be a "Locked" checkbox in the entity attributes menu?

I checked and I was wrong actually, they are counted as levers.

Try adding SetLeverStuckState("chestname", 1, true); in OnStart(), or set it to min stuck state in the editor.
And then, add SetLeverStuckState("chestname", 0, true); instead of SetSwingDoorLocked and see if that works.

I apologize for the confusion Sad