Kohdi Posted September 24, 2012 Share Posted September 24, 2012 Hey all,Recently I've been working on an area which includes a Dwemer valve that, when turned, shuts off a waterfall and its associated splashes, water dynamics, and sounds. When turned again all this would become active again. I'm having a good deal of trouble with the script, though, and I was wondering if anyone would mind giving me a hand. Here's the default valve script, for starters - Scriptname KohdiWaterfallValveScript extends ObjectReference bool property bidirectional = True Auto bool flip = True Auto STATE Waiting EVENT onActivate (objectReference triggerRef) self.BlockActivation(true) if (flip) playAnimationandWait("trigger02","Trans02") Else playAnimationandWait("trigger01","Trans01") EndIf flip = !flip self.BlockActivation(false) endEVENT endState Now what I'm thinking is that I need to have this script either enable or disable an arbitrary object, then link up all the water effects to follow its enabled state. It would also be nice to have a fade-in/out time for the transition. If anyone thinks they can help, please don't hesitate. Thanks for any and all replies! Link to comment Share on other sites More sharing options...
Kohdi Posted September 25, 2012 Author Share Posted September 25, 2012 Alright, here's an update - I've tried merging the Valve script above with one designed to enable/disable the items in a FormList on command, fond on the CK wiki. This is what that looks like - Scriptname KohdiWaterfallValveScript extends ObjectReference bool property bidirectional = True Auto bool flip = True Int iIndex ObjectReference Reference FormList Property KohdiWaterfallList Auto Event OnActivate(ObjectReference TriggerRef) Self.BlockActivation(true) If (flip) PlayAnimationAndWait("Trigger01" , "Trans01") iIndex = KohdiWaterfallList.GetSize() While(iIndex > 0) iIndex -= 1 Reference = KohdiWaterfallList.GetAt(iIndex) as ObjectReference If Reference.IsEnabled() Reference.Disable(true) Else Reference.Enable(true) EndIf EndWhile Else PlayAnimationAndWait("Trigger02" , "Trans02") iIndex = KohdiWaterfallList.GetSize() While(iIndex > 0) iIndex -= 1 Reference = KohdiWaterfallList.GetAt(iIndex) as ObjectReference If Reference.IsEnabled() Reference.Disable(true) Else Reference.Enable(true) EndIf EndWhile EndIf Flip = !flip Self.BlockActivation(false) EndEventThis compiles fine, but when the valve is turned (and it does turn) the objects are not disabled, since their starting state is enabled. I'm not entirely sure what's going on with the ("Trigger01" , "Trans01") bits or the iIndex -= 1 part, though they appear to be necessary. If anyone can spot where I've gone wrong I would be grateful. Link to comment Share on other sites More sharing options...
Sjogga Posted September 25, 2012 Share Posted September 25, 2012 Replace the formlist with an array of objectreferences, filled with everything you want to disable. A formlist only contains the base objects and not the references, which is why you cant disable them. Link to comment Share on other sites More sharing options...
Kohdi Posted September 26, 2012 Author Share Posted September 26, 2012 (edited) Thanks for the suggestion, I've modified the script to fit the new style but the objects are still refusing to disable, and now the valve won't turn either. Here's what I've got - (see next post) I made a LinkedRef chain with some of the biggest objects (just for easy testing), but they aren't affected by the script as-is. Again, I'm not sure what some of the meatier bits are doing, I'm just retrofitting the obvious parts from the pertinent examples on the wiki. Any ideas? Edited September 26, 2012 by Kohdi Link to comment Share on other sites More sharing options...
Kohdi Posted September 26, 2012 Author Share Posted September 26, 2012 The above post got weird with the script, here's another try - ScriptName KohdiWaterfallValveScript Extends ObjectReference Actor Property PlayerREF Auto Bool Property Bidirectional = True Auto Bool Flip = True Event OnActivate(ObjectReference akActionRef) If akActionRef == PlayerREF Self.BlockActivation(True) If (Flip) PlayAnimation("Trigger01") PerformAction01On(Self) ObjectReference TempRef = GetLinkedRef() while (TempRef && TempRef != Self) PerformAction01On(TempRef) TempRef = TempRef.GetLinkedRef() endwhile Else PlayAnimation("Trigger02") PerformAction02On(Self) ObjectReference TempRef = GetLinkedRef() while (TempRef && TempRef != Self) PerformAction02On(TempRef) TempRef = TempRef.GetLinkedRef() endwhile EndIf Flip = !Flip Self.BlockActivation(False) EndIf EndEvent Function PerformAction01On(ObjectReference Target) If Target.IsEnabled() Target.Disable(True) Else Target.Enable(True) EndIf EndFunction Function PerformAction02On(ObjectReference Target) If Target.IsDisabled() Target.Enable(True) Else Target.Disable(True) EndIf EndFunction Link to comment Share on other sites More sharing options...
Kohdi Posted September 26, 2012 Author Share Posted September 26, 2012 Okay, problem solved! I worked with the script I posted some more, and after removing the PlayerREF check and PerformActionXXOn(self), the wheel is turning and my chain of objects is disabled then re-enabled nicely. Thanks again for the nudge in the right direction Sjogga, I wouldn't have even considered the ObjectReference method if not for you. Link to comment Share on other sites More sharing options...
Recommended Posts