Winona Battery High
Based on game build 722832 | Last updated: 2026-04-22
Overview
winona_battery_high defines the placeable structure and inventory item for Winona's high-tier battery. It manages fuel consumption, gem socketing (Pure Brilliance and Alter Guardian Hat Shards), and connection to the engineering circuit network. The prefab handles overload mechanics, skill tree efficiency bonuses, and visual/audio feedback for power states. It also includes definitions for the placement placer and shatter FX prefabs.
Usage example
local inst = SpawnPrefab("winona_battery_high")
inst.components.fueled:StartConsuming()
inst.components.circuitnode:ConnectTo("engineeringbatterypowered")
local is_overloaded = inst:IsOverloaded()
local element_type = inst:CheckElementalBattery()
inst:ConsumeBatteryAmount({ fuel = 100, shard = 1 }, 1, player)
Dependencies & tags
External dependencies:
prefabutil-- helper functions for prefab creation and setupTUNING-- balance constants for fuel capacity, range, and skill multipliersTheNet-- checks for engineer player presence and user IDsTheWorld-- listens for global skill tree change events
Components used:
deployhelper-- manages placement preview and validation logicupdatelooper-- handles periodic visual and sound updatesportablestructure-- allows dismantling the structure back into an iteminspectable-- provides status text (e.g., "OVERLOADED", "LOWPOWER")trader-- accepts gem items via socketing interactionfueled-- manages charge levels, sections, and consumption ratetimer-- tracks overload duration and shard regeneration delayslootdropper-- drops socketed gems on destructionworkable-- allows hammering to dismantle the structurecircuitnode-- connects to the engineering power networkbattery-- defines power output behavior and usage callbacksburnable-- handles fire damage, burning, and burnt statehauntable-- allows ghost players to haunt the structureinventoryitem-- (Item variant) enables carrying in inventorydeployable-- (Item variant) enables placing into the world
Tags:
structure-- identifies entity as a buildingengineering-- part of Winona's engineering systemengineeringbattery-- specifically identifies as a power sourcegemsocket-- indicates acceptance of gem itemstrader-- enables trading/socketing interactionportableitem-- (Item variant) identifies as carryableNOCLICK-- temporarily prevents interaction during animationsFX-- (Shatter FX) identifies as visual effect onlyCLASSIFIED-- (Helper entities) hides from normal entity searches
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
_gems | table | {} | List of currently socketed gem prefabs or save records. |
_gemsymfollowers | table | {} | Map of slot index to follower FX entities for socketed gems. |
_shard_level | number | 0 | Count of Alter Guardian Hat Shards currently socketed. |
_brilliance_level | number | 0 | Count of Pure Brilliance gems currently socketed. |
_noidledrain | boolean | false | If true, prevents fuel drain when connected loads are idle. |
_efficiency | number | 0 | Skill tree efficiency tier (0-3) applied to consumption. |
_engineerid | string | nil | User ID of the Winona who placed or last modified the battery. |
_batterytask | task | nil | Periodic task reference for adding battery power to nodes. |
_inittask | task | nil | Delayed task reference for initial circuit connection. |
_updatingshardload | boolean | nil | Flag indicating if shard load update loop is active. |
_lastchargeframe | number | nil | Tracks animation frame for idle charge sound timing. |
_hitanim | string | nil | Stores the name of the current hit animation. |
_circuittask | task | nil | Task reference for recalculating circuit power load. |
helper | entity | nil | Deploy helper entity for placement preview. |
scrapbook_anim | string | "idle_empty" | Animation name used for scrapbook display. |
scrapbook_specialinfo | string | "WINONABATTERYHIGH" | Info key for scrapbook entry. |
Main functions
fn()
- Description: Constructor function for the placed structure entity. Attaches all components, initializes state variables, and sets up network replication.
- Parameters: None.
- Returns: Entity instance.
- Error states: None.
itemfn()
- Description: Constructor function for the inventory item variant. Configures physics, inventory component, and deployable logic.
- Parameters: None.
- Returns: Entity instance.
- Error states: None.
fxfn()
- Description: Constructor function for the gem shatter visual effect entity.
- Parameters: None.
- Returns: Entity instance.
- Error states: None.
CheckElementalBattery()
- Description: Returns the type of elemental power source active based on socketed gems.
- Parameters: None.
- Returns:
"brilliance","shard", ornil. - Error states: None.
ConsumeBatteryAmount(cost, share, doer)
- Description: Consumes fuel or shard charge based on usage. Handles overload logic for shards and updates timers. Requires
costtable withfuelandshardfields. - Parameters:
cost-- table withfuelandshardamounts.share-- number divisor for shared cost (optional).doer-- player entity performing the action (optional).
- Returns: None.
- Error states: Errors if
inst.components.fueledorinst.components.timeris missing.
IsOverloaded()
- Description: Checks if the battery is currently in an overloaded state by verifying the overload timer.
- Parameters: None.
- Returns: Boolean.
- Error states: Errors if
inst.components.timeris missing.
OnUsedIndirectly(doer)
- Description: Updates skill tree bonuses when the battery is used by a device connected to the circuit.
- Parameters:
doer-- player entity using power. - Returns: None.
- Error states: None.
OnSave(data)
- Description: Serializes gem data, fuel state, and skill upgrades for persistence.
- Parameters:
data-- table to populate with save data. - Returns: None.
- Error states: None.
OnLoad(data, ents)
- Description: Restores gem sockets, fuel level, and skill upgrades from save data.
- Parameters:
data-- table containing saved state (can be nil).ents-- entity reference map (unused).
- Returns: None.
- Error states: None.
OnLoadPostPass()
- Description: Finalizes loading by ensuring circuit connection task runs if not cancelled.
- Parameters: None.
- Returns: None.
- Error states: None.
OnEntitySleep()
- Description: Stops sound loops and update tasks when the entity goes out of simulation range.
- Parameters: None.
- Returns: None.
- Error states: None.
OnEntityWake()
- Description: Restarts sound loops and update tasks when the entity comes back into simulation range.
- Parameters: None.
- Returns: None.
- Error states: None.
Events & listeners
- Listens to:
onbuilt-- triggers placement animation and circuit connection.ondeconstructstructure-- drops socketed gems before removal.engineeringcircuitchanged-- recalculates power load and consumption rate.timerdone-- handles overload expiry and shard regeneration delays.winona_batteryskillchanged-- updates efficiency bonuses when Winona changes skills.animover-- manages animation state transitions (e.g., hit, build).
- Pushes:
- None directly (relies on component events like
percentusedchangeandengineeringcircuitchangedvia circuitnode).
- None directly (relies on component events like