Wyz
Junior Member
Posts: 12
Threads: 3
Joined: Jul 2012
Reputation:
0
|
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 Thanks
|
|
07-13-2012, 05:14 PM |
|
Obliviator27
Posting Freak
Posts: 792
Threads: 10
Joined: Jul 2011
Reputation:
66
|
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 |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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.
|
|
07-13-2012, 08:18 PM |
|
Wyz
Junior Member
Posts: 12
Threads: 3
Joined: Jul 2012
Reputation:
0
|
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 |
|
Ongka
Member
Posts: 225
Threads: 3
Joined: Nov 2010
Reputation:
20
|
RE: Making a lever unlock a door?
1 = up
0 = middle
-1 = down
|
|
07-13-2012, 08:42 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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 |
|
Brothersvv09
Member
Posts: 57
Threads: 29
Joined: Aug 2012
Reputation:
0
|
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 |
|
Ongka
Member
Posts: 225
Threads: 3
Joined: Nov 2010
Reputation:
20
|
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.
|
|
08-04-2012, 04:34 AM |
|
|