Jump to content

Yet another scripting question


pepperman35

Recommended Posts

If SIIR_WSPowerNode01 is a workshop generator and it is placed into the world, do these statements accomplish the same thing. If I understand the CK wiki correctly, .setopen(false) should place the switch (i.e., generator) in a closed position thus allow electricity to flow. Similarly, setopen(true) should place the switch (i.e., generator) in an open position and not allow electricity to flow. It seems Activate should simply change the state of the switch to opposite of what it was to begin with.


SIIR_WSPowerNode01.SetOpen(false)

SIIR_WSPowerNode01.Activate(Game.GetPlayer(), true)


Am I understanding this correctly, or totally FUBAR.



Link to comment
Share on other sites

Generator added with keyword WorkshopStartUnpoweredOff and linked to workshop with workshopitem keyword
Script fragment added to terminal
int openState = SIIR_WSPowerNode01.GetOpenState()
Debug.Trace("Initial state of WSP Node is , " + openState)
if (openState == 1 || openState == 2) ; Open or opening
Debug.Trace("Initial state of WSP Node is open or opening, " + openState)
Debug.Trace("We have no power, " + openState)
SIIR_WSPowerNode01.Activate(Game.GetPlayer(), true)
; give it some time to register
Utility.Wait(5.0)
Debug.Trace("State of WSP Node after activating , " + SIIR_WSPowerNode01.GetOpenState())
Endif
SIIR_RadWeatherController01.enable()
SIIR_FireworksMortar01.enable()
; SIIR_FireworksMortar01.Activate(Game.GetPlayer(), true)
; Add some shells to the mortar
SIIR_FireworksMortar01.addItem(DLC05FireworkShellWeatherClear, 100, true)

 

It appears to be working and the debug trace shows the follow
[02/06/2021 - 12:59:57AM] Initial state of WSP Node is , 1
[02/06/2021 - 12:59:57AM] Initial state of WSP Node is open or opening, 1
[02/06/2021 - 12:59:57AM] We have no power, 1
[02/06/2021 - 01:00:02AM] State of WSP Node after activating , 3
Edited by pepperman35
Link to comment
Share on other sites

You can use SetOpen() on anything that has the power switch keyword. Similar with GetOpenState().

Open = Circuit Open = Power does not flow, Closed = Circuit Closed = Power does flow.

The issue with .Activate() is that it may take an arbitrary amount of time to complete, depending on the on/off animations of the object - But the function call returns immediately.

Link to comment
Share on other sites

First, I freely admit my Padawan status when it comes to scripting but niston and SKK50 have helped me understand a lot more than I did when I first started. Much more to learn of course, but wanted to give these guys a big shout out. Here is the script that seems to work okay. It activates the generator which provides power to the monitoring switch. Monitoring switch from UncleChubby's Electronics mod keeps a lookout for radstorms and sends power to the mortar launcher as required to fire a clear weather shell. The script also loads up the mortar with the clear weather shells.

 

 

Scriptname SpecIslandInstReborn:InitalizeWCSScript extends ObjectReference Const
{ Script designed to initialize the custom weather control station on Spectacle Island.
Power connections have been made via F04edit. Script placed on terminal to activate.
}
;
;-- Properties --------------------------------------
;
Group BaseGame
Quest Property pWorkshopParent Auto Const mandatory
Keyword Property pWorkshopItemKeyword Auto Const mandatory
EndGroup

Group Pepper
GlobalVariable Property pSIIR_WCSStatusGlobal Auto Const mandatory
ObjectReference Property pSIIR_WSPowerNode01 Auto Const mandatory
ObjectReference Property pSIIR_RadWeatherController01 Auto Const mandatory
ObjectReference Property pSIIR_FusionPulseChargeDummy Auto Const mandatory
ObjectReference Property pSIIR_FireworksMortar01 Auto Const mandatory
MiscObject Property pDLC05FireworkShellWeatherClear Auto Const mandatory
Message Property pSIIR_NoWorkshopMsg Auto Const mandatory
EndGroup

;-- Variables ---------------------------------------

;-- Functions ---------------------------------------

Function ActivateWCS()
If (pSIIR_WCSStatusGlobal.GetValue() == 0 as float)
ObjectReference ThisWorkshop = Self.GetLinkedRef(pWorkshopItemKeyword)
If (ThisWorkshop == None)
Debug.Trace("SpecIslandInstReborn:InitalizeWCSScript.ActivateWCS ERROR NoWorkshop", 0)
pSIIR_NoWorkshopMsg.Show(0, 0, 0, 0, 0, 0, 0, 0, 0)
Else
; Swap out dummy generator with a live one
; live generator has WorkshopStartUnpoweredOff keyword
pSIIR_WSPowerNode01.disable()
pSIIR_FusionPulseChargeDummy.enable()
pSIIR_WSPowerNode01.enable()
pSIIR_FusionPulseChargeDummy.disable()
pSIIR_WSPowerNode01.enable(False)
int iWorkshopID = (ThisWorkshop as workshopscript).GetWorkshopID()
If ((pSIIR_WSPowerNode01 as workshopobjectscript).WorkshopID != iWorkshopID)
(pWorkshopParent as workshopparentscript).BuildObjectPUBLIC(pSIIR_WSPowerNode01, ThisWorkshop as workshopscript)
Debug.Trace("SpecIslandInstReborn:InitalizeWCSScript.ActivateWCS pSIIR_WSPowerNode01.WorkshopID " + pSIIR_WSPowerNode01 as string + " " + (pSIIR_WSPowerNode01 as workshopobjectscript).WorkshopID as string, 0)
EndIf

; Check generator state and turn it on
int openState = pSIIR_WSPowerNode01.GetOpenState()
Debug.Trace("Initial state of power supply node is , " + openState)
If (openState == 1 || openState == 2) ; Open or opening
Debug.Trace("Initial state of power supply node is open or opening, " + openState)
Debug.Trace("We have no power, " + openState)
pSIIR_WSPowerNode01.Activate(Game.GetPlayer(), true)
; give it some time to register
Utility.Wait(5.0)
If (openState == 3 || openState == 4) ; Open or opening
Debug.Trace("State of power supply node after activating , " + pSIIR_WSPowerNode01.GetOpenState())
Debug.Trace("We have power, " + pSIIR_WSPowerNode01.GetOpenState())
Endif
Endif
pSIIR_RadWeatherController01.enable()
If ((pSIIR_RadWeatherController01 as workshopobjectscript).WorkshopID != iWorkshopID)
(pWorkshopParent as workshopparentscript).BuildObjectPUBLIC(pSIIR_RadWeatherController01, ThisWorkshop as workshopscript)
Debug.Trace("SpecIslandInstReborn:InitalizeWCSScript.ActivateWCS pSIIR_RadWeatherController01.WorkshopID " + pSIIR_RadWeatherController01 as string + " " + (pSIIR_WSPowerNode01 as workshopobjectscript).WorkshopID as string, 0)
EndIf
pSIIR_FireworksMortar01.enable()
If ((pSIIR_FireworksMortar01 as workshopobjectscript).WorkshopID != iWorkshopID)
(pWorkshopParent as workshopparentscript).BuildObjectPUBLIC(pSIIR_FireworksMortar01, ThisWorkshop as workshopscript)
Debug.Trace("SpecIslandInstReborn:InitalizeWCSScript.ActivateWCS pSIIR_FireworksMortar01.WorkshopID " + pSIIR_FireworksMortar01 as string + " " + (pSIIR_WSPowerNode01 as workshopobjectscript).WorkshopID as string, 0)
EndIf
pSIIR_FireworksMortar01.addItem(pDLC05FireworkShellWeatherClear, 100, true)
Endif
Endif
EndFunction

 

Edited by pepperman35
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...