Making a lever 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: Making a lever unlock a door? (/thread-16942.html) |
Making a lever unlock a door? - Wyz - 07-13-2012 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 RE: Making a lever unlock a door? - Obliviator27 - 07-13-2012 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. RE: Making a lever unlock a door? - FlawlessHappiness - 07-13-2012 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); } } RE: Making a lever unlock a door? - Wyz - 07-13-2012 (07-13-2012, 08:18 PM)beecake Wrote: void OnStart()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'? RE: Making a lever unlock a door? - Ongka - 07-13-2012 1 = up 0 = middle -1 = down RE: Making a lever unlock a door? - FlawlessHappiness - 07-13-2012 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 ^^ RE: Making a lever unlock a door? - Brothersvv09 - 08-04-2012 <removed><removed><removed> RE: Making a lever unlock a door? - Ongka - 08-04-2012 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. |