Events
Things to know
PoweredChangedfires when a furniture device or a battery gains or loses power.IsPoweredin the event is the new state. ReadGet(id)for the rest. For furniture it also fires when the cause is somewhere else, for example a generator running out or a device being removed. (For furniture it is raised from the game’sFurnitureStats.OutputONandOutputOFF, so it covers the switch, grid changes from other devices, and the device’s own changes. For a battery it is raised whenBatteryPowerSource.poweringflips, through its privatePowerONandPowerOFF, after the game’s own signals for that change have run.)- A battery can lose or gain power with no action by the player. A battery checks its items shortly after it starts, and after a load it works out how much it drained while you were away. Both can switch it, and both fire the event. If your handler should ignore them, compare
Get(id)with your own record. (LateStartrunsCheckItemstwo frames after the battery starts, and the post-load offline drain (LoadDelay) can switch it off after loading has finished.) FuelRanOutfires once when a fuel burner’s fuel runs out. It covers every crafting station with a fuel source, generators and stoves alike.FuelRanOutArgs.Idis the station’s id. (It is raised from the game’sFuel.OnFuelConsumeStopped, when the fuel counter was on andBurnTimeRemainingis 0.)- A crafting station switching on or off does not fire
PoweredChanged. UseWorldPower.GeneratorToggledfor a generator’s switch, andFuelRanOutfor a generator running out of fuel. (Crafting station power changes that go throughOnPowerOnorOnPowerOff(on load) raise nothing.)
Limits
PoweredChangeddoes not fire while a save is loading. A change that happens while the game restores its furniture on load is not reported.FuelRanOutdoes not fire while a save is loading or saving.- Switching a burner off in the one moment after its fuel hits zero can also report a run-out. This is a known quirk: the game runs its own run-out logic on that moment too. (It is a manual switch-off (
SetOn(id, false)) in the one game tick afterBurnTimeRemainingreaches 0.) IsAvailableisfalsewhen the power events could not be set up. ThenPoweredChangedstops. The reads andSetOnkeep working. See If something fails to set up.