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.

 

 

  Reveal hidden contents

 

Edited by pepperman35
Link to comment
Share on other sites

  • Recently Browsing   0 members

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