Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a lever unlock a door?
Wyz Offline
Junior Member

Posts: 12
Threads: 3
Joined: Jul 2012
Reputation: 0
#1
Making a lever unlock a door?

Thanks for answering my last question, but a new one has arisen. In my cs, I have a .map called 'The Undercroft', where you need to go down a few levels and pull a lever. This lever, I pictured, would open a door back up on the main floor that was previously locked for security reasons. How should I go about this? Should I make a GetLeverState function of sorts that will set a global variable to true, unlock the door in a different map? The separation of maps is the tricky part Tongue Thanks
07-13-2012, 05:14 PM
Find
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#2
RE: Making a lever unlock a door?

You should use a
SetEntityConnectionStateChangeCallback

Along with SetGlobalVarInt.
Then, when entering the map with the door, use an if statement to determine if the global variable has been changed to 1(or whatever you changed it to when you pulled the lever) and then set the door to unlocked if it evaluates to true.

07-13-2012, 08:18 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: Making a lever unlock a door?

void OnStart()
{
SetEntityConnectionStateChangeCallback("LEVER", "LEVER_CALLBACK");
}

void LEVER_CALLBACK(string &in asEntity, int alState)

{
if(alState == 1)
{
SetGlobalVarInt("OPENDOORINT", 1);
}
}

In the other level:

void OnEnter()
{
if(GetGlobalVarInt("OPENDOORINT") == 1)
{
SetSwingDoorLocked("DOOR", false, true);
}
}

Trying is the first step to success.
(This post was last modified: 07-13-2012, 08:18 PM by FlawlessHappiness.)
07-13-2012, 08:18 PM
Find
Wyz Offline
Junior Member

Posts: 12
Threads: 3
Joined: Jul 2012
Reputation: 0
#4
RE: Making a lever unlock a door?

(07-13-2012, 08:18 PM)beecake Wrote: void OnStart()
{
SetEntityConnectionStateChangeCallback("LEVER", "LEVER_CALLBACK");
}

void LEVER_CALLBACK(string &in asEntity, int alState)

{
if(alState == 1)
{
SetGlobalVarInt("OPENDOORINT", 1);
}
}

In the other level:

void OnEnter()
{
if(GetGlobalVarInt("OPENDOORINT") == 1)
{
SetSwingDoorLocked("DOOR", false, true);
}
}
Thanks! For that if statement, is the alState on the lever all the way up or down? And the global variable gets declared in an HPS file in the maps folder called 'global'?
(This post was last modified: 07-13-2012, 08:43 PM by Wyz.)
07-13-2012, 08:40 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#5
RE: Making a lever unlock a door?

1 = up
0 = middle
-1 = down

[Image: 18694.png]
07-13-2012, 08:42 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: Making a lever unlock a door?

No you don't have to create a folder... It just is there somewhere i guess.. I don't know maybe i'm wrong, but in the custom story i'm making right now, i have no folder for the globals, and it worked fine ^^

Trying is the first step to success.
07-13-2012, 10:33 PM
Find
Brothersvv09 Offline
Member

Posts: 57
Threads: 29
Joined: Aug 2012
Reputation: 0
#7
RE: Making a lever unlock a door?

<removed><removed><removed>
(This post was last modified: 01-19-2019, 02:24 AM by Brothersvv09.)
08-04-2012, 01:18 AM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#8
RE: Making a lever unlock a door?

SetGlobalVarInt("Ongka", 1); // This creates a number called Ongka, which has the value 1.
if(GetGlobalVarInt("Ongka") == 1) // == means equal to; this functions asks if the number Ongka has the value 1. If you didn't set the value to 1, nothing will happen. Global vars can be used in other levels too.

[Image: 18694.png]
08-04-2012, 04:34 AM
Find




Users browsing this thread: 3 Guest(s)