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


Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to unlock door with key?
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#1
How to unlock door with key?

Okay im making my first Amnesia map and i need help to unlock door with key..

I make script with mulledk 19 tutorial instructions but.. It doesnt work..

Please help! Blush

“Life is a game, play it”
12-09-2010, 10:48 PM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#2
RE: How to unlock door with key?

The script. Post it.


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
12-09-2010, 10:57 PM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#3
RE: How to unlock door with key?

(12-09-2010, 10:57 PM)Frontcannon Wrote: The script. Post it.

////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key1", "mansion_1" "UsedKeyOnDoor", true);

}

void USedKeyOnDoor(string &in asItem, string &in asEntity)
}
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door," "mansion_1", 0, false);
{ RemoveItem(key1
////////////////////////////
// Run when entering map
void OnEnter()
{

}

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

}

Thats my first script ever. Sorry im new at this one.. Sad

“Life is a game, play it”
12-09-2010, 11:16 PM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#4
RE: How to unlock door with key?

This screws up your script:

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

Way too many syntax errors.
Fixed:

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0.0f, false);
RemoveItem("key1");
}

You also should take a look here.

edits
With every other read, I find a new syntax error. Do you check your script after saving?
-
There's a comma missing in your callback.


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
(This post was last modified: 12-09-2010, 11:31 PM by Frontcannon.)
12-09-2010, 11:25 PM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#5
RE: How to unlock door with key?

(12-09-2010, 11:25 PM)Frontcannon Wrote: This screws up your script:

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

Way too many syntax errors.
Fixed:

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0.0f, false);
RemoveItem("key1");
}

You also should take a look here.

edits
With every other read, I find a new syntax error. Do you check your script after saving?
-
There's a comma missing in your callback.

I dont understand i dont see any scripting code errors.. i save after i change scripting and test door and key.. i fixed that command but doesnt work Sad This is hard... Confused

“Life is a game, play it”
12-09-2010, 11:36 PM
Find
house Offline
Member

Posts: 195
Threads: 11
Joined: Oct 2010
Reputation: 1
#6
RE: How to unlock door with key?

It takes years of practicing coding... Just kidding, Here, look at this:

void OnStart()
{
AddUseItemCallback("", "key1", "mansion_1" "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0.0f, false);
RemoveItem("key1");
}

mansion_1 is: The name of your door you want to unlock.
key1: The name of the key you want to open the door with.

So now, replace everything from the code above from mansion_1 to the door to unlock, and key1 to the name of the key to use to open the door.

Then copy it into your .hps file for your level!
12-10-2010, 04:42 AM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#7
RE: How to unlock door with key?

(12-10-2010, 04:42 AM)house Wrote: It takes years of practicing coding... Just kidding, Here, look at this:

void OnStart()
{
AddUseItemCallback("", "key1", "mansion_1" "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0.0f, false);
RemoveItem("key1");
}

mansion_1 is: The name of your door you want to unlock.
key1: The name of the key you want to open the door with.

So now, replace everything from the code above from mansion_1 to the door to unlock, and key1 to the name of the key to use to open the door.

Then copy it into your .hps file for your level!

Okay, but i renamed that "mansion_1" that door but im getting message its already named object somewhere.. then i renamed it "door_1" and "key1" but doesnt work :I

Here: //===========================================
// Starter's Script File!
//===========================================

//===========================================
// This runs when the map first starts
void OnStart()
{
AddUseItemCallback("", "key1", "door_1" "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0.0f, false);
RemoveItem("key1");
}

//===========================================
// This runs when the player enters the map
void OnEnter()
{
}

//===========================================
// This runs when the player leaves the map
void OnLeave()
{
}

This is pissing me off..

“Life is a game, play it”
12-10-2010, 01:53 PM
Find
Oscar House Offline
Senior Member

Posts: 302
Threads: 3
Joined: Nov 2010
Reputation: 9
#8
RE: How to unlock door with key?

Are you sure your key is named key1 and your door named door_1 ?

[Image: 2exldzm.png]
12-10-2010, 02:29 PM
Find
LoneWolf Offline
Senior Member

Posts: 308
Threads: 43
Joined: Sep 2010
Reputation: 0
#9
RE: How to unlock door with key?

Remeber the name doesnt just go in the name box it also goes in the callback box too. in the right tab.
12-10-2010, 04:12 PM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#10
RE: How to unlock door with key?

(12-10-2010, 02:29 PM)Oscar House Wrote: Are you sure your key is named key1 and your door named door_1 ?

Yes im sure.
(12-10-2010, 04:12 PM)LoneWolf Wrote: Remeber the name doesnt just go in the name box it also goes in the callback box too. in the right tab.

Yeah i know but it doesnt work this is probably some unknown error or my map has bugs.. I have "key1" named key in my first room then first door is named "door_1" because previously named was "mansion_1" but i get this message which says "This same name has already somewhere in this object too etc."

I dont know just please write the right code i dont care what name calls it has to be! I copy paste it... Or i just quit scripting and never finish the map Sad

And sorry my crappy english!

“Life is a game, play it”
(This post was last modified: 12-11-2010, 12:27 AM by HumiliatioN.)
12-11-2010, 12:22 AM
Find




Users browsing this thread: 2 Guest(s)