[SCRIPT] Need help to make a lever puzzle - 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] Need help to make a lever puzzle (/thread-12581.html) |
RE: Need help to make a lever puzzle - Shadowfied - 01-15-2012 (01-15-2012, 11:30 AM)Tripication Wrote:No, it didn't. =/ Didn't make any noticeable difference.(01-15-2012, 11:28 AM)Shadowfied Wrote: You only added the 4 stuckstate lines at the end? (Just so I learn )I did, but did it work? Edit: I think I know why though, Statyk told me to check the box "InteractionDisablesStuck" That's probably it...right? RE: Need help to make a lever puzzle - Tripication - 01-15-2012 (01-15-2012, 11:31 AM)Shadowfied Wrote:That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.(01-15-2012, 11:30 AM)Tripication Wrote:No, it didn't. =/ Didn't make any noticeable difference.(01-15-2012, 11:28 AM)Shadowfied Wrote: You only added the 4 stuckstate lines at the end? (Just so I learn )I did, but did it work? (The levers should only get stuck once the puzzle is complete, i put the SetLeverStuckState lines in the last function, and statyk does say... custom function called each time a lever is correctly in place. when all are in place, the function continues. So assuming that the boxes are unticked, it should work. But i dont EXACTLY know what the boxes do so be sure that you can fix it if it does stuff up) RE: Need help to make a lever puzzle - Shadowfied - 01-15-2012 (01-15-2012, 11:39 AM)Tripication Wrote:I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?(01-15-2012, 11:31 AM)Shadowfied Wrote:That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.(01-15-2012, 11:30 AM)Tripication Wrote:No, it didn't. =/ Didn't make any noticeable difference.(01-15-2012, 11:28 AM)Shadowfied Wrote: You only added the 4 stuckstate lines at the end? (Just so I learn )I did, but did it work? Edit: Nevermind. They do get stuck.. Edit 2: Ok I saw that Statyk had them getting stuck in up and down states in every func. I removed them and now it works the way I want, they only get stuck once they are all correct. RE: Need help to make a lever puzzle - Tripication - 01-15-2012 (01-15-2012, 11:43 AM)Shadowfied Wrote:They shouldn't. Just try it anyway, im sure its nothing you cant undo.(01-15-2012, 11:39 AM)Tripication Wrote:I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?(01-15-2012, 11:31 AM)Shadowfied Wrote:That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.(01-15-2012, 11:30 AM)Tripication Wrote:No, it didn't. =/ Didn't make any noticeable difference.(01-15-2012, 11:28 AM)Shadowfied Wrote: You only added the 4 stuckstate lines at the end? (Just so I learn )I did, but did it work? RE: Need help to make a lever puzzle - Shadowfied - 01-15-2012 (01-15-2012, 11:46 AM)Tripication Wrote:Read my edit 2. ^^(01-15-2012, 11:43 AM)Shadowfied Wrote:They shouldn't. Just try it anyway, im sure its nothing you cant undo.(01-15-2012, 11:39 AM)Tripication Wrote:I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?(01-15-2012, 11:31 AM)Shadowfied Wrote:That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.(01-15-2012, 11:30 AM)Tripication Wrote: I did, but did it work?No, it didn't. =/ Didn't make any noticeable difference. RE: Need help to make a lever puzzle - Tripication - 01-15-2012 (01-15-2012, 11:47 AM)Shadowfied Wrote:Oh, that sucks, hang on, i've just had a brillian stroke of genius...(01-15-2012, 11:46 AM)Tripication Wrote:Read my edit 2. ^^(01-15-2012, 11:43 AM)Shadowfied Wrote:They shouldn't. Just try it anyway, im sure its nothing you cant undo.(01-15-2012, 11:39 AM)Tripication Wrote:I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?(01-15-2012, 11:31 AM)Shadowfied Wrote: No, it didn't. =/ Didn't make any noticeable difference.That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure. Next post... RE: Need help to make a lever puzzle - Shadowfied - 01-15-2012 (01-15-2012, 11:49 AM)Tripication Wrote:Well, thanks for your help. =)(01-15-2012, 11:47 AM)Shadowfied Wrote:Oh, that sucks, hang on, i've just had a brillian stroke of genius...(01-15-2012, 11:46 AM)Tripication Wrote:Read my edit 2. ^^(01-15-2012, 11:43 AM)Shadowfied Wrote:They shouldn't. Just try it anyway, im sure its nothing you cant undo.(01-15-2012, 11:39 AM)Tripication Wrote: That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they? RE: Need help to make a lever puzzle - Tripication - 01-15-2012 Try Duplicating the levers and deactivating the duplicates, turn the InteractionDisablesStuck off on the Inactive duplicates and do this void OnStart() { SetEntityConnectionStateChangeCallback("LEVER1", "lever1func"); //levercallback SetEntityConnectionStateChangeCallback("LEVER2", "lever2func"); //levercallback SetEntityConnectionStateChangeCallback("LEVER3", "lever3func"); //levercallback SetEntityConnectionStateChangeCallback("LEVER4", "lever4func"); //levercallback SetLocalVarInt("lever1bank", 0); //'dem banks! SetLocalVarInt("lever2bank", 0); //'dem banks! SetLocalVarInt("lever3bank", 0); //'dem banks! SetLocalVarInt("lever4bank", 0); //'dem banks! } ///////////////////////////////////////////////////////// void lever1func(string &in asEntity, int alState) { if(alState == 1) { SetLeverStuckState("LEVER1", 1, true); //sets it stuck SetLocalVarInt("lever1bank", 1); //add dat cash munay CheckFunction(); //follows function at the bottom, which activates the completed puzzle } if(alState == -1) { SetLeverStuckState("LEVER1", -1, true); SetLocalVarInt("lever1bank", 0); } } ////////////////////////////////////////////////////////////////////// void lever2func(string &in asEntity, int alState) { if(alState == 1) { SetLeverStuckState("LEVER2", 1, true); SetLocalVarInt("lever2bank", 1); CheckFunction(); } if(alState == -1) { SetLeverStuckState("LEVER2", -1, true); SetLocalVarInt("lever2bank", 0); } } ////////////////////////////////////////////////////////////////////// void lever3func(string &in asEntity, int alState) //follows a different "if" statement, making it opposite from the rest or... Down rather than Up. { if(alState == 1) { SetLeverStuckState("LEVER3", 1, true); SetLocalVarInt("lever3bank", 0); } if(alState == -1) { SetLeverStuckState("LEVER3", -1, true); SetLocalVarInt("lever3bank", 1); CheckFunction(); } } ////////////////////////////////////////////////////////////////////// void lever4func(string &in asEntity, int alState) { if(alState == 1) { SetLeverStuckState("LEVER4", 1, true); SetLocalVarInt("lever4bank", 1); CheckFunction(); } if(alState == -1) { SetLeverStuckState("LEVER4", -1, true); SetLocalVarInt("lever4bank", 0); } } ////////////////////////// void CheckFunction() //custom function called each time a lever is correctly in place. when all are in place, the function continues. { if(GetLocalVarInt("lever1bank") == 1 && GetLocalVarInt("lever2bank") == 1 && GetLocalVarInt("lever3bank") == 1 && GetLocalVarInt("lever4bank") == 1) { SetEntityActive("LEVER1", false); SetEntityActive("LEVER2", false); SetEntityActive("LEVER3", false); SetEntityActive("LEVER4", false); SetEntityActive("LEVER1_1", true); SetEntityActive("LEVER2_1", true); SetEntityActive("LEVER3_1", true); SetEntityActive("LEVER4_1", true); SetLeverStuckState("LEVER1_1", 1, false);SetLeverStuckState("LEVER2_1", 1, false); SetLeverStuckState("LEVER3_1", -1, false); SetLeverStuckState("LEVER4_1", 1, false); GiveSanityBoost(); SetSwingDoorLocked("LEVERDOOR", false, true); } } I'm assuming the Duplicates will have a _1 at the end of the original name. Ya dig? (NOTE:May not be Genius...BACKUPS BEFORE COMPLAINING) RE: Need help to make a lever puzzle - Shadowfied - 01-15-2012 Uhm..I thought I already told you I solved it? Statyk had put "SetLeverStuckState("LEVER4", 1, true);" in every function, removing all of those and adding your "SetLeverStuckState" scripts at the end solved it. There was no reason (not that I understand anyway) to make them stuck all the time and using the InteractDisablesStuck checkbox for this situation. RE: Need help to make a lever puzzle - Your Computer - 01-15-2012 Here's a more efficient way of doing it (though entirely untested). PHP Code: const string[] lever_names = {"LEVER1", "LEVER2", "LEVER3", "LEVER4"} |