Yots Lantern Post
Based on game build 714014 | Last updated: 2026-03-07
Overview
yots_lantern_post is the master prefab and component for a deployable post in DST that serves as a lighting anchor point. When placed, it detects up to two nearby posts within a fixed distance (CHAIN_DIST = 8), spawns suspended chains of links and lanterns between them, and lights the lanterns when batteries (items tagged lightbattery, spore, or lightcontainer) are placed in its container. The post supports perishing logic, visual flicker effects on its light, and dynamic lantern placement based on partner presence.
The component uses several core systems: container for battery storage, workable for hammering interaction, preserver for perish rate modulation, entitytracker for partner references, and updatelooper for client-side wall updates that animate chain sway and lantern positioning.
Usage example
-- Creating a Yots Lantern Post entity
local inst = Prefab("yots_lantern_post", fn, assets, prefabs)
-- Typical usage in-game after placement
inst:FindPartners() -- Detect and link to up to two nearby posts
inst:checklights() -- Check battery state and turn light on/off
inst.components.container:GiveItem(battery_item) -- Insert a battery
Dependencies & tags
Components used:
container(DropEverything,FindItems,GiveItem,WidgetSetup)workable(SetWorkAction,SetWorkLeft,SetOnWorkCallback,SetOnFinishCallback)lootdropper(DropLoot)preserver(SetPerishRateMultiplier)inspectable(getstatus)entitytracker(GetEntity,TrackEntity)updatelooper(AddOnUpdateFn,AddOnWallUpdateFn)placer(onupdatetransform)
Tags added/checked:
yots_post: Added to the post instance.lightbattery,spore,lightcontainer,fulllighter: Items checked in the container for light logic.FX,NOCLICK,CLASSIFIED,placer: Applied to non-networked FX child entities.
Properties
No public properties are exposed as writable attributes on the main yots_lantern_post instance. Internal state is stored in instance fields (inst.neighbour_lights, inst.light_obj, inst.partner1, inst.partner2, inst.chain, inst.lanterns, inst.old_chain_end_pos, inst.near), but these are not part of the component interface and should not be accessed directly by modders.
Main functions
checklights(inst)
- Description: Checks if any batteries are present in the container and turns the light on or off accordingly via
lightsonorlightsoff. - Parameters:
inst(entity) — the post entity. - Returns: Nothing.
FindPartners(inst)
- Description: Scans for up to two other
yots_postentities withinCHAIN_DIST(8 units), then spawnsyots_lantern_light_chainentities between the post and each partner, linking them viaentitytrackerand lighting the lanterns if either post is lit. - Parameters:
inst(entity) — the post entity. - Returns: Nothing.
UpdateLightState(inst)
- Description: Responds to
itemgetoritemloseevents. Determines the number ofis_battery_typeandis_fulllighteritems, updates the perish rate multiplier, and re-checks the light state. - Parameters:
inst(entity). - Returns: Nothing.
lightson(inst)
- Description: Enables the light visual (
light_onsymbol visible), spawns theyots_lantern_lightchild if needed, and incrementsenablelightcounter on all linked chain lights. - Parameters:
inst(entity). - Returns: Nothing.
lightsoff(inst)
- Description: Disables the light visual and removes the
light_obj, decrementingenablelightcounters on linked chain lights. - Parameters:
inst(entity). - Returns: Nothing.
OnWorkFinished(inst, worker)
- Description: Called on hammering completion. Drops all container contents and loot, spawns a
collapse_bigFX, and removes the post entity. - Parameters:
inst(entity),worker(entity or nil). - Returns: Nothing.
OnUpdateFlicker(inst, starttime)
- Description: Runs periodically on the light entities to modulate radius and colour using a summation of sine waves, creating a flicker effect.
- Parameters:
inst(entity),starttime(number or nil) — base timestamp for flicker phase. - Returns: Nothing.
Events & listeners
-
Listens to:
onbuilt— triggersonbuilt, which plays animation, gives a starting bulb, callsFindPartners, andchecklights.onremove— triggersonremove, which removes all linked chain lights.itemget— triggersUpdateLightState.itemlose— triggersUpdateLightState.partner1dirty,partner2dirty(client only) — triggersPartnerDirtyto spawn/remove chain FX.lightdirty(client only) — triggersOnLightDirtyto sync lantern visibility/light state.
-
Pushes: None directly (uses events for internal updates only).