Frictional Games Forum (read-only)
[SCRIPT] getting a needle to unlock a 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: [SCRIPT] getting a needle to unlock a door (/thread-14370.html)



getting a needle to unlock a door - zombiehacker595 - 03-31-2012

what is the script used to get a hollow need to unlock a wooden door?


RE: getting a needle to unlock a door - SilentStriker - 03-31-2012

AddUseItemCallback

SetSwingDoorLocked

RemoveItem

PlaySoundAtEntity



RE: getting a needle to unlock a door - HollowRiku13 - 03-31-2012


void OnStart()
{
AddUseItemCallback("", "Nameofyourneedle", "Nameofyourdoor", "Needle", true);
}


void Needle(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("nameofyourdoor", false);
PlaySoundAtEntity("", "unlock_door", "nameofyourdoor", 0, false);
RemoveItem("nameofyourneedle");
}

I hope it works, sorry if it's kinda rushed, I'm in a hurry.


RE: getting a needle to unlock a door - Kreekakon - 03-31-2012

Here's a tutorial. It helped me when I was first in this pinch.
http://wiki.frictionalgames.com/hpl2/tutorials/script/scripting_by_xtron_-_item_that_unlocks_a_door


RE: getting a needle to unlock a door - SilentStriker - 03-31-2012

(03-31-2012, 10:17 AM)HollowRiku13 Wrote: void OnStart()
{
AddUseItemCallback("", "Nameofyourneedle", "Nameofyourdoor", "Needle", true);
}


void Needle(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("nameofyourdoor", false);
PlaySoundAtEntity("", "unlock_door", "nameofyourdoor", 0, false);
RemoveItem("nameofyourneedle");
}

I hope it works, sorry if it's kinda rushed, I'm in a hurry.
or he can just write RemoveItem(asItem);




RE: getting a needle to unlock a door - zombiehacker595 - 03-31-2012

(03-31-2012, 10:52 AM)SilentStriker Wrote:
(03-31-2012, 10:17 AM)HollowRiku13 Wrote: void OnStart()
{
AddUseItemCallback("", "Nameofyourneedle", "Nameofyourdoor", "Needle", true);
}


void Needle(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("nameofyourdoor", false);
PlaySoundAtEntity("", "unlock_door", "nameofyourdoor", 0, false);
RemoveItem("nameofyourneedle");
}

I hope it works, sorry if it's kinda rushed, I'm in a hurry.
or he can just write RemoveItem(asItem);
works great thanks Smile




RE: getting a needle to unlock a door - flamez3 - 03-31-2012

(03-31-2012, 10:52 AM)SilentStriker Wrote:
(03-31-2012, 10:17 AM)HollowRiku13 Wrote: void OnStart()
{
AddUseItemCallback("", "Nameofyourneedle", "Nameofyourdoor", "Needle", true);
}


void Needle(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("nameofyourdoor", false);
PlaySoundAtEntity("", "unlock_door", "nameofyourdoor", 0, false);
RemoveItem("nameofyourneedle");
}

I hope it works, sorry if it's kinda rushed, I'm in a hurry.
or he can just write RemoveItem(asItem);
Technically he could just write


SetLevelDoorLocked(asEntity , false);

PlaySoundAtEntity("", "unlock_door", "asEntity", 0, false); c:



RE: getting a needle to unlock a door - HollowRiku13 - 04-01-2012

I'm sorry, as I said, yesterday I was in a hurry, I just copied a part of my script.


RE: getting a needle to unlock a door - Iyiyt - 08-07-2012

Actually, I'm having a problem with this. I set the door as "locked" in my level editor, and when I use the needle on it, it makes the noise but it stays locked. So I set the door as unlocked, and in my script, in OnEnter, I put "SetLevelDoorLocked(true);", so it would hopefully stay locked until I used the needle. But no, the door is just unlocked. What am I doing wrong? Here's my script:
Code:
void OnEnter()
{
ChangePlayerStateToNormal();
SetLanternDisabled(false);
SetEntityPlayerLookAtCallback("JimmyOne", "JimmyOne", true);
SetLevelDoorLocked("RoomDoor", true);
AddUseItemCallback("", "JimmyOne", "RoomDoor", "UnlockOne", true);
}

void JimmyOne(string &in asEntity, int alState)
{
SetMessage("Message", "JimmyMessageOne", 6.0f);
}

void UnlockOne(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("RoomDoor", false);
PlaySoundAtEntity("", "unlock_door", "RoomDoor", 0, false);
RemoveItem("JimmyOne");
}