Jump to content

Recommended Posts

Posted

I am trying to switch on and off the power in a settlement via terminal. The set-up looks as follows:

  • RLZPowerGeneratorConnector is an activator, which contains the workshopobjectscript without edits .
  • In the terminal the switching ON fragment looks like this:
    • RLZPowerGeneratorConnector.SetValue(PowerGenerated, 100)
    • RLZPowerGeneratorConnector.SetValue(PowerRadiation, 5000)
    • The OFF fragment in the terminal just sets these values to 0. This is the default value in the base object as well.
  • Additionally to the AVIFs above mentioned RLZPowerGeneratorConnector has the AVIF WorkshopResourceObject (value = 1.00).
  • The RLZPowerGeneratorConnector has the following KYWDs:
    • AO_Type_WorkshopResouceObject
    • BlockPlayerActivation
    • UnscrappableObject
    • WorshopPowerConnectionDUPLICATE00
    • WorshopStarPoweredON
    • WorshopSwitchActivatorKeyword

It is only partially successful: In building mode, with the activator ON, lights placed are automatically ON. If the activator is set to OFF, when placing new lights these are automatically OFF. However, those placed lights that are ON remain ON despite switching OFF via terminal the activator, and therefore the power.

I am familiar with the enablemarker solution and the circuit breaker, but I wanted to go a step forward.

What am I missing? Should I loop finding all items with the KYWD "WorkshopCanBePowered" and switching them off? However, not all of them have the same ON/OFF mechanisms.

Does anyone know of an example of this kind of terminal total control over the power in a settlement? Of course it would be better if the scripts are public. Those cases I found are not.

Posted

I recall doing this or doing this in part with one of my settlement mods.  If I recall, I setup the generators, water pumps, and switches to start in the off state using a script assigned to each piece.  I had a script on the terminal that was used to turn things on depending on the choice the player made at the terminal (e.g., turn the generators on; turn the water pumps on if the power was on; etc).  I used FO4edit to setup the power grid behind the scenes (i.e., no wires).

Posted
1 hour ago, pepperman35 said:

I recall doing this or doing this in part with one of my settlement mods.  If I recall, I setup the generators, water pumps, and switches to start in the off state using a script assigned to each piece.  I had a script on the terminal that was used to turn things on depending on the choice the player made at the terminal (e.g., turn the generators on; turn the water pumps on if the power was on; etc).  I used FO4edit to setup the power grid behind the scenes (i.e., no wires).

Thanks. Do you recall how did you manage to control newly created items in building mode? From your description it seems that all controlled items where preset, if I am not mistaken.

Posted

I tried with searching for all objects having the kwyd WorkshopCanBePowered and PlayGamebryoAnimation ON and OFF. At most the meshes stop glowing but the actual light is still there. 

Then, I tried disabling, switch on or off the power, and then enabling the lights. The same. 

Then deleting them and recreating new ones in the same position. The same result.

I also explored disabling any linkedrefs to the lights just in case the actual lights are kind of hidden and linked to them. The same result.

Nothing works: the final state of the light is as before entering the terminal. Still, when touched in building mod they get to the state at which the power is.

What does actually controls the sate of powered items in the workshop? I cannot see it in the workshopscript.


I am out of ideas now.

Posted

Thanks to Exoclyps for helping me with this.

The solution is to use the F4SE function "TransmitConnectedPower".

Certainly, it can be done better or more elegantly, but the example here provided works:

In the terminal fragments: 

For ON (for OFF just with 0 argument): (ThisTerminal as RLZ:RLZTerminalSwitch).SwitchONOFF(1)

Script attached to the terminal:

scriptname RLZ:RLZTerminalSwitch extends Objectreference
Form property workshopcanbepowered auto const
Form property WorkshopPowerConnectionDUPLICATE000 auto const
objectreference property RLZPowerGeneratorConnector auto const
actorvalue property PowerGenerated auto const
actorvalue property PowerRadiation auto const

Function SwitchONOFF(int ONOFF)
    ObjectReference[] klightsArray = self.FindAllReferencesWithKeyword(workshopcanbepowered, 2000)
    ObjectReference[] kconnectorsArray = self.FindAllReferencesWithKeyword(WorkshopPowerConnectionDUPLICATE000, 2000)
    int i=0
    int j=0
    int kAlength=klightsArray.length
    int kBlength=kconnectorsArray.length

    if ONOFF == 1
        RLZPowerGeneratorConnector.SetValue(PowerGenerated, 100)
        RLZPowerGeneratorConnector.SetValue(PowerRadiation, 5000)
        Debug.Notification("Switching ON")
    elseif ONOFF == 0
        RLZPowerGeneratorConnector.SetValue(PowerGenerated, 0)
        RLZPowerGeneratorConnector.SetValue(PowerRadiation, 0)
        Debug.Notification("Switching OFF")
    endif
    Utility.Wait(0.2)
    i=0
    while i<kAlength
        klightsArray.TransmitConnectedPower()
        i+=1
    endwhile
    j=0
    while j<kBlength
        kconnectorsArray[j].TransmitConnectedPower()
        j+=1
    endwhile
EndFunction

  • Recently Browsing   0 members

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