South8028 Posted July 26, 2021 Share Posted July 26, 2021 Update: Okay I pulled the lever assembly out from the solar array nif and make its own nif. The solar panel array now consists of the solar panels, the electrical cabinet and the electrical connector. It make sense to me to keep the connector as part of the cabinet. I set the array up as an activator, and put block player activation on it. Per Niston's suggestion, I added the two NiNodes to the Solar Panel Array nif,  REF_ATTACH_NODE and SolarArray_AttachPowerSwitch. Added a script to spawn the lever at the named node. [Credit: deadbeeftffn for the script from the forum post, Is it possible to conjoin different activators into a single NIF?] Next steps, gen up a little script for the lever to change the state of the solar panel array when the lever is activated.much easier to do like mine. Prefabricated panels at the docking points so that you can pick up power indefinitely, and a separate switch. For realism, you can add a battery assembly and something like a control station. Non-animated activators (without logic) do not affect the engine limit, I checked, paved an assembly of more than a hundred panels. The number of non-animated activators can be any. Also ... The default wire connection point (if there is no such point) is the parent mesh's pivot point. Link to comment Share on other sites More sharing options...
pepperman35 Posted July 27, 2021 Author Share Posted July 27, 2021 Okay, got it mostly sorted out. Script A and Script B are applied to the Solar Panel Array, while Script C is applied the lever.' Script A Scriptname MysticLake:Switch_AttachmentScript extends ObjectReference ; Script written by deadbeeftffn ; https://forums.nexusmods.com/index.php?/topic/8103523-is-it-possible-to-conjoin-different-activators-into-a-single-nif/?hl=%2Bplaceatnode#entry74533893 ; ;-- Properties -------------------------------------- Form Property attachForm Auto Const String Property attachPoint Auto Const ;-- Events ------------------------------------------ Event OnWorkshopObjectDestroyed(ObjectReference akReference) ObjectReference attachment = Self.GetLinkedRef() if (attachment As Bool) attachment.DisableNoWait(false) attachment.Delete() Self.SetLinkedRef(None) EndIf EndEvent Event OnInit() ObjectReference attachment if (Self.HasNode(attachPoint)) attachment = Self.PlaceAtNode(attachPoint, attachForm, 1, TRUE, FALSE, FALSE, TRUE) if (attachment As Bool) attachment.EnableNoWait(false) attachment.SetMotionType(Motion_Keyframed, FALSE) Self.SetLinkedRef(attachment) Else Debug.Trace(Self + " : cannot attach addon") EndIf Else Debug.Trace(Self + " : Node not found: " + attachPoint) EndIf EndEvent Event OnLoad() ObjectReference attachment = Self.GetLinkedRef() if (attachment As Bool) attachment.MoveToNode(Self As ObjectReference, attachPoint) attachment.AttachTo(Self As ObjectReference) EndIf EndEvent Event OnWorkshopObjectMoved(ObjectReference akReference) ObjectReference attachment = Self.GetLinkedRef() if (attachment As Bool) attachment.MoveToNode(Self As ObjectReference, attachPoint) attachment.AttachTo(Self As ObjectReference) EndIf EndEvent Script B Scriptname MysticLake:GeneratorStateMachine extends ObjectReference Hidden Conditional {Script designed to set the initial state of a generator/reactor to OFF so that it can be turned on via a switch (lever). Script is placed on generator/reactor of interest.} ; ;-- Properties -------------------------------------- ; ; ObjectReference Property theGenerator Auto Const Mandatory GlobalVariable Property GeneratorStateGlobal Auto Const Mandatory ; ;-- Variables --------------------------------------- ; ;-- States --------------------------------------- ; auto state InitializeGenOFF Event OnLoad() Utility.Wait(5.0) if (theGenerator.Is3DLoaded() && GeneratorStateGlobal.GetValue() == 0 as float) theGenerator.SetOpen(True) GeneratorStateGlobal.SetValue(1 as float) Else gotoState("DoNothing") EndIf EndEvent endState State GeneratorON Event OnBeginState(string asOldState) theGenerator.SetOpen(False) GeneratorStateGlobal.SetValue(2 as float) EndEvent EndState State GeneratorOFF Event OnBeginState(string asOldState) theGenerator.SetOpen(True) GeneratorStateGlobal.SetValue(3 as float) EndEvent EndState State DoNothing ;do nothing endState ; ; Functions ; Function StateMachine() ; ; GeneratorStateGlobal = 1 generator is initial state of the generator (off) ; GeneratorStateGlobal = 2 generator is on producing power ; GeneratorStateGlobal = 3 generator is off and not producing power ; If GeneratorStateGlobal.GetValue() == 2 gotoState("GeneratorON") EndIf If GeneratorStateGlobal.GetValue() == 3 gotoState("GeneratorOFF") EndIf EndFunction Script C Scriptname MysticLake:MLS_PowerLever extends ObjectReference Const ; ;-- Properties -------------------------------------- ; ObjectReference Property theGenerator Auto Const Mandatory GlobalVariable Property GeneratorStateGlobal Auto Const Mandatory ; ; Events ; EVENT OnActivate(ObjectReference akActionRef) If (GeneratorStateGlobal.GetValue() == 1 as float || GeneratorStateGlobal.GetValue() == 3 as float) GeneratorStateGlobal.SetValue(2 as float) (theGenerator as MysticLake:GeneratorStateMachine).StateMachine() ElseIF (GeneratorStateGlobal.GetValue() == 2 as float) GeneratorStateGlobal.SetValue(3 as float) (theGenerator as MysticLake:GeneratorStateMachine).StateMachine() EndIF EndEVENT Seems to work okay in game; however, the case where GeneratorStateGlobal.GetValue() == 0 need to get resolved. If the Solar Panel Array and associated lever are workshop items buildable via the workshop this case probably isn't an issue. But if one builds the Solar Panel Array and associated lever via the creation kit then this condition could exist, especially before the player took ownership of the workshop. In this case activating the lever wouldn't do anything but it would get the level out of sync (I think). Link to comment Share on other sites More sharing options...
Recommended Posts