pepperman35 Posted February 11, 2020 Share Posted February 11, 2020 Building #1. Electric Power Plant. I plan to turn on a reactor(s) with a terminal which in turn will generate enough electric power to the settlement. Building #2. Water Purification Facility. I plan to turn on several water purification units with a terminal if and only if the reactors have been turned on. Question #1. Within the script(s) to turn the reactors on, can I set a global variable similar to that shown below to indicate whether the reactor is on or off, and then use that global variable as a condition within the water purification plant activation script? GlobalVariable Property InstSpecIslandPowerOnGlobal Auto Const Mandatory Link to comment Share on other sites More sharing options...
SKKmods Posted February 12, 2020 Share Posted February 12, 2020 If each GlobalVariable is associated with one power plant and water facility set in the game then yes, it is probably the simple solution. But how do you set the global variable .. OnPowerOn event ? As your terminal will need to know about either the water ObjectReference to switch it on, to support multiple sets another approach would be to set up LinkedReference associations between the Terminal > Water > Electric objects and use that to check real time object state. The terminal script fragments could look like;;Terminal linked direct to power and water plants If (Self.GetLinkedRef(MyPowerLinkKeyword).IsPowered() == TRUE) Self.GetLinkedRef(MyWaterLinkKeyword).Activate() EndIf ;Terminal linked to water plant, water linked to power If (Self.GetLinkedRef(MyWaterLinkKeyword).GetLinkedRef(MyPowerLinkKeyword).IsPowered() == TRUE) Self.GetLinkedRef(MyWaterLinkKeyword).Activate() EndIf Link to comment Share on other sites More sharing options...
niston Posted February 12, 2020 Share Posted February 12, 2020 No need for global variables and other hackery. Here's a little trick: - Use GetOpenState() to determine if a reactor/generator is turned on or off- Use SetOpen() to turn a reactor/generator on or off Open = circuit open = power does not flow = reactor not poweredClosed = circuit closed = power does flow = reactor powered up I never tried, but I'd guess SetOpen() also works to turn on/off a water pump. Link to comment Share on other sites More sharing options...
SKKmods Posted February 12, 2020 Share Posted February 12, 2020 Agree that GetOpenState is more robust than IsPowered which will flip instantly from False to True, but then lags reporting True for a while after switch off (see last debug line) Activate will flip state without any logic whereas SetOpen needs to feed State value.SKK_Power Activate START [workshopobjectscript < (FF001895)>] IsPowered False GetOpenState 1 SKK_Power Activate END [workshopobjectscript < (FF001895)>] IsPowered True GetOpenState 3 SKK_Power SetOpen START [workshopobjectscript < (FF001895)>] IsPowered True GetOpenState 3 SKK_Power SetOpen END [workshopobjectscript < (FF001895)>] IsPowered True GetOpenState 1 Link to comment Share on other sites More sharing options...
niston Posted February 12, 2020 Share Posted February 12, 2020 I would guess that GetOpenState result depends on the power up / power down animation to actually finish playing? Also it only works on things that have the switchactivator keyword. Does IsPowered work at all on things that don't have the CanBePowered keyword? Link to comment Share on other sites More sharing options...
SKKmods Posted February 12, 2020 Share Posted February 12, 2020 On 2/12/2020 at 5:57 PM, niston said: Does IsPowered work at all on things that don't have the CanBePowered keyword? I dont know in general, but it does specifically work on generators (the debug is from a small workshop generator) which don't have the WorkshopCanBePowered keyword or PowerRequired AV, but do have the PowerGenerated AV. Link to comment Share on other sites More sharing options...
niston Posted February 12, 2020 Share Posted February 12, 2020 Alright, I guess the CanBePowered keyword then really just determines if an object will receive power on/off events (and possibly changes animation states based on said events). Link to comment Share on other sites More sharing options...
pepperman35 Posted February 12, 2020 Author Share Posted February 12, 2020 Thanks gents for the response and dialog. For a scripting noob such as myself my knowledge increases a little bit more every time I read your posts Link to comment Share on other sites More sharing options...
Recommended Posts