Frictional Games Forum (read-only)
How to unlock door with key? - 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: How to unlock door with key? (/thread-5650.html)

Pages: 1 2 3


How to unlock door with key? - HumiliatioN - 12-09-2010

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


RE: How to unlock door with key? - Frontcannon - 12-09-2010

The script. Post it.


RE: How to unlock door with key? - HumiliatioN - 12-09-2010

(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


RE: How to unlock door with key? - Frontcannon - 12-09-2010

This screws up your script:

Code:
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:

Code:
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.


RE: How to unlock door with key? - HumiliatioN - 12-09-2010

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

Code:
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:

Code:
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


RE: How to unlock door with key? - house - 12-10-2010

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

Code:
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!


RE: How to unlock door with key? - HumiliatioN - 12-10-2010

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

Code:
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..


RE: How to unlock door with key? - Oscar House - 12-10-2010

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


RE: How to unlock door with key? - LoneWolf - 12-10-2010

Remeber the name doesnt just go in the name box it also goes in the callback box too. in the right tab.


RE: How to unlock door with key? - HumiliatioN - 12-11-2010

(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!