Frictional Games Forum (read-only)
[SCRIPT] Unlock Door by picking up the lantern [Solved] - 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] Unlock Door by picking up the lantern [Solved] (/thread-25125.html)



Unlock Door by picking up the lantern [Solved] - ShipinShen - 04-21-2014

Hey, does anyone know how to unlock a door by picking up the lantern ?

Thanks for the help Smile


RE: Unlock Door by picking up the lantern - Romulator - 04-21-2014

Firstly, FrictionalGames did do this in their second map, so it would be a good idea to look at how they did it Smile
Search up in the 01_old_archives.hps code for "//BEGIN PICK LANTERN & OIL//"

If you still can't figure it out, let us know where you're getting stuck! (While we can help just by giving code, it's still a good idea to learn about doing these things through looking at other code) Smile


RE: Unlock Door by picking up the lantern - ShipinShen - 04-21-2014

(04-21-2014, 03:30 AM)Romulator Wrote: Firstly, FrictionalGames did do this in their second map, so it would be a good idea to look at how they did it Smile
Search up in the 01_old_archives.hps code for "//BEGIN PICK LANTERN & OIL//"

If you still can't figure it out, let us know where you're getting stuck! (While we can help just by giving code, it's still a good idea to learn about doing these things through looking at other code) Smile

sure its better to learn things from other codes, but i saw these.. its to high for me, because i think i dont need some if-statements.. also i dont understand this part Big Grin


RE: Unlock Door by picking up the lantern - PutraenusAlivius - 04-21-2014

Spoiler below!

PHP Code:
void OnStart()
{
SetEntityCallbackFunc("Lantern""OpenDoor");
SetLocalVarInt("Door"0);
}

void OpenDoor(string &in asEntitystring &in type
{
AddLocalVarInt("Door"1);
CheckLocal();
}

void CheckLocal()
{
if (
GetLocalVarInt("Door") == 1)
{
SetSwingDoorLocked("DoorName"falsetrue);
}





RE: Unlock Door by picking up the lantern - FlawlessHappiness - 04-21-2014

Actually you don't need a single if-statement.
Just use an interaction-callback.

Think about it like a sentence:
When touching the lantern
---unlock the door.

Now this can be made into an if-statement like this:
When walking through area
---IF the player has the lantern
------unlock the door


RE: Unlock Door by picking up the lantern - ShipinShen - 04-21-2014

(04-21-2014, 07:14 AM)SomethingRidiculous Wrote:
Spoiler below!

PHP Code:
void OnStart()
{
SetEntityCallbackFunc("Lantern""OpenDoor");
SetLocalVarInt("Door"0);
}

void OpenDoor(string &in asEntitystring &in type
{
AddLocalVarInt("Door"1);
CheckLocal();
}

void CheckLocal()
{
if (
GetLocalVarInt("Door") == 1)
{
SetSwingDoorLocked("DoorName"falsetrue);
}



Thanks a lot man!