Frictional Games Forum (read-only)

Full Version: Unlock Door by picking up the lantern [Solved]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, does anyone know how to unlock a door by picking up the lantern ?

Thanks for the help Smile
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
(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
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);
}


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