Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support


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

Posts: 1,155
Joined: Dec 2010
Reputation: 16
Post: #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 all posts by this user Quote this message in a reply
Frontcannon Offline
Senior Member

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

The script. Post it.


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
12-09-2010 10:57 PM
Find all posts by this user Quote this message in a reply
HumiliatioN Offline
Posting Freak

Posts: 1,155
Joined: Dec 2010
Reputation: 16
Post: #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 all posts by this user Quote this message in a reply
Frontcannon Offline
Senior Member

Posts: 538
Joined: Jul 2010
Reputation: 2
Post: #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 all posts by this user Quote this message in a reply
HumiliatioN Offline
Posting Freak

Posts: 1,155
Joined: Dec 2010
Reputation: 16
Post: #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 all posts by this user Quote this message in a reply
house Offline
Member

Posts: 195
Joined: Oct 2010
Reputation: 1
Post: #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 all posts by this user Quote this message in a reply
HumiliatioN Offline
Posting Freak

Posts: 1,155
Joined: Dec 2010
Reputation: 16
Post: #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 all posts by this user Quote this message in a reply
Oscar House Offline
Senior Member

Posts: 285
Joined: Nov 2010
Reputation: 7
Post: #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 all posts by this user Quote this message in a reply
LoneWolf Offline
Senior Member

Posts: 308
Joined: Sep 2010
Reputation: 0
Post: #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 all posts by this user Quote this message in a reply
HumiliatioN Offline
Posting Freak

Posts: 1,155
Joined: Dec 2010
Reputation: 16
Post: #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 all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)