Frictional Games Forum (read-only)
-Simple- key open door - 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: -Simple- key open door (/thread-16418.html)

Pages: 1 2


-Simple- key open door - Jagsrs28 - 06-23-2012

I dunno how to get a key to open a door. How do I do this.


RE: -Simple- key open door - Adny - 06-23-2012

Fun with scripting! Assuming you have a basic understanding of how to write scripts, it will need to look like this:


void OnStart()
{
AddUseItemCallback("", "NAMEOFKEY", "NAMEOFDOOR", "NAMEOFFUNCTION", true);
}

void NAMEOFFUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("NAMEOFDOOR", false, true);
RemoveItem("NAMEOFKEY");
}

If you already have an OnStart function in your script, add the "AddUseItemCallback" to it.
NAMEOFKEY - Replace with the name of your key

NAMEOFDOOR - Replace with the name of your door

NAMEOFFUNCTION - Can be named anything you'd like


RE: -Simple- key open door - Jagsrs28 - 06-23-2012

It keeps saying Item cannot be used this way.

This is what I have:


void OnStart()
{
AddUseItemCallback("", "key1", "door1", "OpenS", true);
}

void OpenS(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door1", false, true);
RemoveItem("key1");
}

See anything wrong?

Keyname: key1
Doorname: door1


RE: -Simple- key open door - MaZiCUT - 06-23-2012

(06-23-2012, 09:12 AM)andyrockin123 Wrote: Fun with scripting! Assuming you have a basic understanding of how to write scripts, it will need to look like this:


void OnStart()
{
AddUseItemCallback("", "NAMEOFKEY", "NAMEOFDOOR", "NAMEOFFUNCTION", true);
}

void NAMEOFFUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("NAMEOFDOOR", false, true);
RemoveItem("NAMEOFKEY");
}

If you already have an OnStart function in your script, add the "AddUseItemCallback" to it.
NAMEOFKEY - Replace with the name of your key

NAMEOFDOOR - Replace with the name of your door

NAMEOFFUNCTION - Can be named anything you'd like
Y U NO Play sound at entity? Tongue

Anyways Andy, I've had a goddamned problem ever since i couldn't get that closet open with a crowbar, I can't make a key unlock a door no matter every right thing i do Huh


RE: -Simple- key open door - Jagsrs28 - 06-23-2012

(06-23-2012, 11:07 AM)CrazyArts Wrote:
(06-23-2012, 09:12 AM)andyrockin123 Wrote: Fun with scripting! Assuming you have a basic understanding of how to write scripts, it will need to look like this:


void OnStart()
{
AddUseItemCallback("", "NAMEOFKEY", "NAMEOFDOOR", "NAMEOFFUNCTION", true);
}

void NAMEOFFUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("NAMEOFDOOR", false, true);
RemoveItem("NAMEOFKEY");
}

If you already have an OnStart function in your script, add the "AddUseItemCallback" to it.
NAMEOFKEY - Replace with the name of your key

NAMEOFDOOR - Replace with the name of your door

NAMEOFFUNCTION - Can be named anything you'd like
Y U NO Play sound at entity? Tongue

Anyways Andy, I've had a goddamned problem ever since i couldn't get that closet open with a crowbar, I can't make a key unlock a door no matter every right thing i do Huh
ME TO


RE: -Simple- key open door - Your Computer - 06-23-2012

Have you checked the file name of the HPS file to see if it matches the file name of the MAP file?


RE: -Simple- key open door - MaZiCUT - 06-23-2012

(06-23-2012, 12:28 PM)Your Computer Wrote: Have you checked the file name of the HPS file to see if it matches the file name of the MAP file?
Ofcourse i have, i have checked everything.

Heck, desperately i've even copied the script from another custom story to see if it works, still no.


RE: -Simple- key open door - Adny - 06-23-2012

Did you make an hps file by renaming a text file .hps? I'm pretty sure that doesn't work; you need an hps file template to work with.


RE: -Simple- key open door - Jagsrs28 - 06-23-2012

(06-23-2012, 12:35 PM)andyrockin123 Wrote: Did you make an hps file by renaming a text file .hps? I'm pretty sure that doesn't work; you need an hps file template to work with.
How do I get a hps file template?


RE: -Simple- key open door - MaZiCUT - 06-23-2012

(06-23-2012, 12:35 PM)andyrockin123 Wrote: Did you make an hps file by renaming a text file .hps? I'm pretty sure that doesn't work; you need an hps file template to work with.
I've got that alredy! It's the same problem with the closet, Cannot use item this way. Dammit this is slowing down my development every day Sad