TorakRennLykos Posted May 26, 2017 Share Posted May 26, 2017 (edited) I've been having a lot of trouble with a script for a "combination lock" puzzle. Perhaps I've over-complicated it, but the idea is that depending on what pipe is open, different placeable water levels are enabled/disabled. E.g. When the highest pipe is open, the higher water will be enabled and all the lower water objects will be disabled. scn EFWaterControlCheck ; call refs for doors ref RhT ; highest pipe door ref RhL ; one of two medium pipe doors ref RhR ; one of two medium pipe doors ref RhB ; lowest pipe door ref RlB ; water exit pipe door ; call refs for placeable water tiles ref L1a ref L1b ref L1c ref L1d ref L2a ref L2b ref L2c ref L2d ref L3a ref L3b ref L3c ref L3d ref L3e ref L4a ref L4b ref L4c ref L4d ref L4e begin OnActivate ; Electrical Switch Activator ; define refs set RhT to IDoorHighRoomTop set RhL to IDoorHighRoomLeft set RhR to IDoorHighRoomRight set RhB to IDoorHighRoomBottom set RlB to IDoorLowRoomBottom set L1a to EFWaterL1a set L1b to EFWaterL1b set L1c to EFWaterL1c set L1d to EFWaterL1d set L2a to EFWaterL2a set L2b to EFWaterL2b set L2c to EFWaterL2c set L2d to EFWaterL2d set L3a to EFWaterL3a set L3b to EFWaterL3b set L3c to EFWaterL3c set L3d to EFWaterL3d set L3e to EFWaterL3e set L4a to EFWaterL4a set L4b to EFWaterL4b set L4c to EFWaterL4c set L4d to EFWaterL4d set L4e to EFWaterL4e if RhT.GetOpenState == 1 ; if highest pipe is open, set water level to highest level (4) L4a.Enable L4b.Enable L4c.Enable L4d.Enable L4e.Enable L3a.Disable L3b.Disable L3c.Disable L3d.Disable L3e.Disable L2a.Disable L2b.Disable L2c.Disable L2d.Disable L1a.Disable L1b.Disable L1c.Disable L1d.Disable elseif RhT.GetOpenState == 0 && RhL.GetOpenState == 1 ; if middle pipe is open, set water level to High level (3) L4a.Disable L4b.Disable L4c.Disable L4d.Disable L4e.Disable L3a.Enable L3b.Enable L3c.Enable L3d.Enable L3e.Enable L2a.Disable L2b.Disable L2c.Disable L2d.Disable L1a.Disable L1b.Disable L1c.Disable L1d.Disable elseif RhT.GetOpenState == 0 && RhR.GetOpenState == 1 ; if alt.middle pipe is open, set water level to high L4a.Disable L4b.Disable L4c.Disable L4d.Disable L4e.Disable L3a.Enable L3b.Enable L3c.Enable L3d.Enable L3e.Enable L2a.Disable L2b.Disable L2c.Disable L2d.Disable L1a.Disable L1b.Disable L1c.Disable L1d.Disable elseif RhT.GetOpenState == 0 && RhR.GetOpenState == 0 && RhL.GetOpenState == 0 && RhB.GetOpenState == 1 ; if low pipe open, set water level to medium L4a.Disable L4b.Disable L4c.Disable L4d.Disable L4e.Disable L3a.Disable L3b.Disable L3c.Disable L3d.Disable L3e.Disable L2a.Enable L2b.Enable L2c.Enable L2d.Enable L1a.Disable L1b.Disable L1c.Disable L1d.Disable elseif RhT.GetOpenState == 0 && RhR.GetOpenState == 0 && RhL.GetOpenState==0 && RhB.GetOpenState==0 && RlB.GetOpenState==1 ; if only exit pipe open, disable all water L4a.Disable L4b.Disable L4c.Disable L4d.Disable L4e.Disable L3a.Disable L3b.Disable L3c.Disable L3d.Disable L3e.Disable L2a.Disable L2b.Disable L2c.Disable L2d.Disable L1a.Disable L1b.Disable L1c.Disable L1d.Disable elseif RhT.GetOpenState == 0 && RhR.GetOpenState == 0 && RhL.GetOpenState == 0 && RhB.GetOpenState == 0 ; if L4a.Disable L4b.Disable L4c.Disable L4d.Disable L4e.Disable L3a.Disable L3b.Disable L3c.Disable L3d.Disable L3e.Disable L2a.Disable L2b.Disable L2c.Disable L2d.Disable L1a.Enable L1b.Enable L1c.Enable L1d.Enable endif end The trouble doesn't come from the GECK not saving the script or not running it... In fact, if you take the aforementioned example and run the script when the highest pipe is open, the water level changes as it should. However, NONE of the other pipe configurations work. I've been working on this for a day now, and I've gone over the script carefully (in different fonts, even), but I have yet to solve this issue. The only potential issue I can see would have something to do with my use of the && logic operator, but I can't find anything wrong with that... Any help would be hugely appreciated. Thanks in advance. P.S. If anybody can tell me how to disable this godawful colour striping in the code block I'll fix that ASAP Edited May 26, 2017 by TorakRennLykos Link to comment Share on other sites More sharing options...
Mktavish Posted May 26, 2017 Share Posted May 26, 2017 I'd say number one ... I don't like your script post ... cheeze and rice ... who wants a bunch of stripes shoved in their face ??? Are you trying to move water up / down ? I just happen to have a script for that.But the key point is ... You have to place the water surface render ... back where you started moving int from before you disable it. Because the part you can swim in ... won't move with a script ,,, only the visual surface.So you have to enable a new water level which you had placed previously. But when you tell the water object to start moving with a script ... you cannot disable it untill you make the swim water and visual water back at the same level ... otherwise it will crash. Link to comment Share on other sites More sharing options...
TorakRennLykos Posted May 26, 2017 Author Share Posted May 26, 2017 (edited) First of all, thanks for the reply, Mktavish. I'd say number one ... I don't like your script post ... cheeze and rice ... who wants a bunch of stripes shoved in their face ??? P.S. If anybody can tell me how to disable this godawful colour striping in the code block I'll fix that ASAP Yeah look dude I know it's bad I just can't figure out how to fix it. Are you trying to move water up / down ? I just happen to have a script for that.But the key point is ... You have to place the water surface render ... back where you started moving int from before you disable it. Because the part you can swim in ... won't move with a script ,,, only the visual surface.So you have to enable a new water level which you had placed previously. But when you tell the water object to start moving with a script ... you cannot disable it untill you make the swim water and visual water back at the same level ... otherwise it will crash. I'm not moving the water at all. I have four identical groups of water at different heights. I am simply attempting to enable/disable each of them selectively. (I say identical, they have different refs, ofc.)EDIT: Fixed the striping. Edited May 26, 2017 by TorakRennLykos Link to comment Share on other sites More sharing options...
Ladez Posted May 26, 2017 Share Posted May 26, 2017 GetOpenState only returns 0 if the object doesn't have the appropriate animation states. It returns 1 when open and 3 when closed. Also, use enable parents. Link to comment Share on other sites More sharing options...
Mktavish Posted May 27, 2017 Share Posted May 27, 2017 (edited) Yeah look dude I know it's bad I just can't figure out how to fix it. EDIT: Fixed the striping. Thanks I can read it now .... LOL sorry for the salty initial response ... it was intended on the humorous side ... but I'm sure doesn't always translate that way. So to see if I have this straight ... This script is on an activator ... which is essentially acting like a compiler to check the open state of 5 doors ? That the player was able to go around and interact with setting them open/closed ? Which seems odd that you would only have 6 possible outcomes if that is the case. Are there other scripts involved ? Which I guess would explain why you are turning all the ref-id's into Ref variables. If not , then I would audios all the ref variables , and just use their actual ref-id's ... but like Ladez mentions , you only need 1 in each group called in the script ... then make all the others use it as an enable parent. On the GetOpenState ... I would switch to using variables for that. So keep all your door variables , but make them an Integer ,useing them like this after being declared. Begin OnActivate If GetIsReference IDoorHighRoomTop == 1 ; to see which pipe door is being activated Set RhT to 1 ; meaning it is open ; and if you want to close all other pipes at same time Set RhL to 0 Set RhR to 0 Set RhB to 0 Set RIB to 0 endif If GetIsReference ; making an If block for each door like above ... ===========================================================;Then the activate check for the compiler switch=========================================================== If GetIsReference MySwitchRef If RhT == 1 EFWaterL1a.Enable ; which will enable all it's children EFWaterL2a.Disable ; which will disable all it's children EFWaterL3a.Disable EFWaterL4a.Disable elseif RhL == 1 ; make one of these for each door like above endif endifEnd And you should be able to place this script on all 5 doors and the switch ... at least I think so without having tested it. Edited May 27, 2017 by Mktavish Link to comment Share on other sites More sharing options...
TorakRennLykos Posted May 28, 2017 Author Share Posted May 28, 2017 (edited) GetOpenState only returns 0 if the object doesn't have the appropriate animation states. It returns 1 when open and 3 when closed. Also, use enable parents.Holy heck, I almost tested the GetOpenState of the doors in each position. Thanks so much. Yeah look dude I know it's bad I just can't figure out how to fix it. EDIT: Fixed the striping. Thanks I can read it now .... LOL sorry for the salty initial response ... it was intended on the humorous side ... but I'm sure doesn't always translate that way. So to see if I have this straight ... This script is on an activator ... which is essentially acting like a compiler to check the open state of 5 doors ? That the player was able to go around and interact with setting them open/closed ? Which seems odd that you would only have 6 possible outcomes if that is the case. Are there other scripts involved ? Which I guess would explain why you are turning all the ref-id's into Ref variables. If not , then I would audios all the ref variables , and just use their actual ref-id's ... but like Ladez mentions , you only need 1 in each group called in the script ... then make all the others use it as an enable parent. On the GetOpenState ... I would switch to using variables for that. So keep all your door variables , but make them an Integer ,useing them like this after being declared. Begin OnActivate If GetIsReference IDoorHighRoomTop == 1 ; to see which pipe door is being activated Set RhT to 1 ; meaning it is open ; and if you want to close all other pipes at same time Set RhL to 0 Set RhR to 0 Set RhB to 0 Set RIB to 0 endif If GetIsReference ; making an If block for each door like above ... ===========================================================;Then the activate check for the compiler switch=========================================================== If GetIsReference MySwitchRef If RhT == 1 EFWaterL1a.Enable ; which will enable all it's children EFWaterL2a.Disable ; which will disable all it's children EFWaterL3a.Disable EFWaterL4a.Disable elseif RhL == 1 ; make one of these for each door like above endif endifEnd And you should be able to place this script on all 5 doors and the switch ... at least I think so without having tested it. Amen, hallelujah & peanut butter. I'm near certain these two solutions will solve my problems, so thank you both so much. I was at my wit's end with these scripts (mostly by virtue of my barely nascent scripting ability), and in you swooped to save my ass. I'll make sure to credit you both as the angels you've been if this mod ever gets off the ground. Thanks again. Edited May 28, 2017 by TorakRennLykos Link to comment Share on other sites More sharing options...
TorakRennLykos Posted May 29, 2017 Author Share Posted May 29, 2017 (edited) EDIT: I was trying to use "IsEnabled" when I should have been using "GetDisabled". Script saves now! F#@!?$# HELL. Script won't save. Threw it in cipcis's fnv validator but it came up clean. How many nested if statements can you run at once? I think my maximum depth is about 7. I'll admit this new script is a joke (As in it's probably vaguely traumatic to look at). I'm almost too embarrassed to post it... :pinch:This thing's supposed to be dealing with 64 different potential outcomes out of 6 variable inputs... So... Idk try not to roast me too hard- logic isn't exactly my jam and I tried to condense it in my head... scn EFWaterControlCheck begin OnActivate if IDoorHighRoomTop.GetOpenState == 3 if IDoorHighRoomRight.GetOpenState == 3 if IDoorHighRoomBottom.GetOpenState == 3 if IDoorLowRoomTop.GetOpenState == 3 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 ShowMessage EFGenericNothingHappensMsg elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomTop.GetOpenState == 1 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 if EFWaterL1a.IsEnabled == 1 ShowMessage EFGenericNothingHappensMsg elseif EFWaterL2a.IsEnabled == 1 EFWaterL1a.Enable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable elseif EFWaterL3a.IsEnabled == 1 EFWaterL1a.Enable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable elseif EFWaterL4a.IsEnabled == 1 EFWaterL1a.Enable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable else ShowMessage EFGenericNothingHappensMsg endif elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif endif elseif IDoorHighRoomBottom.GetOpenState == 1 if IDoorLowRoomTop.GetOpenState == 3 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomTop.GetOpenState == 1 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif endif endif elseif IDoorHighRoomRight.GetOpenState == 1 if IDoorHighRoomBottom.GetOpenState == 3 if IDoorLowRoomTop.GetOpenState == 3 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif endif elseif IDoorLowRoomTop.GetOpenState ==1 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Enable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif endif endif elseif IDoorHighRoomBottom.GetOpenState == 1 if IDoorLowRoomTop.GetOpenState == 3 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable endif endif elseif IDoorLowRoomTop.GetOpenState == 1 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Enable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif endif endif endif endif endif elseif IDoorHighRoomTop.GetOpenState == 1 if IDoorHighRoomRight.GetOpenState == 3 if IDoorHighRoomBottom.GetOpenState == 3 if IDoorLowRoomTop.GetOpenState == 3 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable endif endif elseif IDoorLowRoomTop.GetOpenState == 1 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Disable endif endif endif elseif IDoorHighRoomBottom.GetOpenState == 1 if IDoorLowRoomTop.GetOpenState == 3 if IDoorLowRoomLeft.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable endif endif elseif IDoorLowRoomTop.GetOpenState == 1 if IDoorLowRoomLeft.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable endif endif endif endif elseif IDoorHighRoomRight.GetOpenState == 1 if IDoorHighRoomBottom.GetOpenState == 3 if IDoorLowRoomTop.GetOpenState == 3 if IDoorLowRoomLeft.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable endif endif elseif IDoorLowRoomTop.GetOpenState == 1 if IDoorLowRoomLeft.GetOpenState == 3 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable endif elseif IDoorLowRoomLeft.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Enable EFWaterL3a.Disable EFWaterL4a.Disable endif endif endif elseif IDoorHighRoomBottom.GetOpenState == 1 if IDoorLowRoomTop.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable elseif IDoorLowRoomTop.GetOpenState == 1 if IDoorLowRoomBottom.GetOpenState == 1 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Enable EFWaterL4a.Disable elseif IDoorLowRoomBottom.GetOpenState == 3 EFWaterL1a.Disable EFWaterL2a.Disable EFWaterL3a.Disable EFWaterL4a.Enable endif endif endif endif endif end Edited May 29, 2017 by TorakRennLykos Link to comment Share on other sites More sharing options...
Recommended Posts