Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Key to Unlock Chest
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#1
Key to Unlock Chest

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.
07-22-2011, 06:59 AM
Find
Ouroboros Offline
Junior Member

Posts: 20
Threads: 0
Joined: Jul 2011
Reputation: 0
#2
RE: Key to Unlock Chest

You have to add a useitemcallback
/
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
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");
}
(This post was last modified: 07-22-2011, 07:19 AM by Ouroboros.)
07-22-2011, 07:18 AM
Find
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#3
RE: Key to Unlock Chest

Ah, of course. I didn't realize that the chest counted as a swing door. Thank you very much.
07-22-2011, 07:30 AM
Find
Ouroboros Offline
Junior Member

Posts: 20
Threads: 0
Joined: Jul 2011
Reputation: 0
#4
RE: Key to Unlock Chest

(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.
07-22-2011, 07:33 AM
Find
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#5
RE: Key to Unlock Chest

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.
07-22-2011, 09:01 AM
Find
ferryadams11 Offline
Junior Member

Posts: 17
Threads: 1
Joined: Apr 2011
Reputation: 0
#6
RE: Key to Unlock Chest

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
(This post was last modified: 07-22-2011, 09:37 AM by ferryadams11.)
07-22-2011, 09:31 AM
Find
Rokotain Offline
Member

Posts: 54
Threads: 9
Joined: Jul 2011
Reputation: 0
#7
RE: Key to Unlock Chest

(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
07-22-2011, 10:40 AM
Find
Poppuhik42 Offline
Junior Member

Posts: 20
Threads: 1
Joined: Apr 2011
Reputation: 0
#8
RE: Key to Unlock Chest

-----
(This post was last modified: 12-13-2012, 10:33 PM by Poppuhik42.)
07-22-2011, 01:27 PM
Find
WatzUpzPeepz Offline
Member

Posts: 106
Threads: 12
Joined: May 2011
Reputation: 0
#9
RE: Key to Unlock Chest

(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);

07-22-2011, 01:35 PM
Find
Ouroboros Offline
Junior Member

Posts: 20
Threads: 0
Joined: Jul 2011
Reputation: 0
#10
RE: Key to Unlock Chest

(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
(This post was last modified: 07-22-2011, 02:01 PM by Ouroboros.)
07-22-2011, 02:00 PM
Find




Users browsing this thread: 1 Guest(s)