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
Locked doors
Storfigge Offline
Member

Posts: 101
Threads: 31
Joined: Sep 2012
Reputation: 0
#1
Locked doors

Hello!

I am very new with HPL editor and im working on my first custom story. I have no real coding experience but it's gone quite good so far. The problem I have right now is that i first made a locked door and managed to create a key that opens it. Now I've made a new locked door with a key that's suppose to open it. The thing is that when i unlock my first door the second one also unlocks. I can still use my second key on my second unlocked door. I've put the door on locked in the editor so I don't know what the problem is Sad

Here is the code for the doors.


{
AddUseItemCallback("", "key1", "bedroomdoor1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "key2", "bedroomdoor2", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("bedroomdoor1", false, true);
PlaySoundAtEntity("", "unlock_door", "bedroomdoor1", 0, false);
RemoveItem("key1");

SetSwingDoorLocked("bedroomdoor2", false, true);
PlaySoundAtEntity("", "unlock_door", "bedroomdoor2", 0, false);
RemoveItem("key2");

}

09-21-2012, 09:17 AM
Find
Chap Offline
Member

Posts: 99
Threads: 16
Joined: Jul 2012
Reputation: 2
#2
RE: Locked doors

I'm not so good with code but from my assumption you've put both unlock statements in the same method. So any time someone unlocks bedroomdoor1 or 2, both doors are called to be unlocked. Try making another method for each door. Otherwise if all doors are under this same function, then every door in your level will have the same problem.

Something like this:
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("bedroomdoor2", false, true);
PlaySoundAtEntity("", "unlock_door", "bedroomdoor2", 0, false);
RemoveItem("key2");

}


I'm not so great with scripting so this could be the wrong way to do it but this is how I assume it's done properly - If not i'm sure someone will correct me soon =) GL

[Image: 20643.png]
09-21-2012, 11:54 AM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#3
RE: Locked doors

Try using

SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);

Those never failed me. Of course, it only works if you do what Chap1400 said.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
09-21-2012, 01:11 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: Locked doors

Chap1400 is right!

You see:

This line calls the function UsedKeyOnDoor:
AddUseItemCallback("", "key1", "bedroomdoor1", "UsedKeyOnDoor", true);



Which is here:
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("bedroomdoor1", false, true);
PlaySoundAtEntity("", "unlock_door", "bedroomdoor1", 0, false);
RemoveItem("key1");

}


You'll have to make a new one, otherwise it will just link to the same function as the first one did.
results in: Key1 works on door1 but opens both door1 and door2

Trying is the first step to success.
09-21-2012, 01:16 PM
Find
Storfigge Offline
Member

Posts: 101
Threads: 31
Joined: Sep 2012
Reputation: 0
#5
RE: Locked doors

Hey thank you guys for the help Smile

As I said I'm very new when it comes to coding so I'm just experimenting my way through Tongue

Again thank you for the help!

09-21-2012, 02:00 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: Locked doors

Very good idea! Start by experiementing! Don't release anything before you know what you are working with Wink

Trying is the first step to success.
09-21-2012, 02:19 PM
Find




Users browsing this thread: 1 Guest(s)