Leif Idol
Based on game build 714014 | Last updated: 2026-03-05
Overview
The leif_idol prefab functions as a specialized fuel item that triggers environmental responses upon ignition or fuel consumption. It interacts with the burnable, fuel, sleeper, combat, and stackable components to wake sleeping leif entities within range and convert eligible nearby trees into new leif entities. It is non-functional on the client and only active on the master simulation.
Usage example
local inst = SpawnPrefab("leif_idol")
inst.components.stackable:Push(5)
-- When lit or placed in a furnace:
inst.components.fuel:OnTaken(some_doer) -- triggers wake/spawn behavior
-- When burned:
inst.components.burnable:Burn() -- triggers wake/spawn behavior
Dependencies & tags
Components used: burnable, combat, fuel, growable, inspectable, inventoryitem, sleeper, stackable
Tags added on creation: None.
Tags checked (via HasTag): leif, tree, evergreens, birchnut, fire, stump, burnt, monster, FX, NOCLICK, DECOR, INLIMBO
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
_igniter | Entity or nil | nil | Stores the valid doer (combat-capable entity) that ignited the idol. Used as the doer argument during wake/spawn events. |
WakeUpNearbyLeifs | function | WakeUpNearbyLeifs (see below) | Public function to manually trigger waking nearby sleeping Leif entities and suggesting combat targets. |
SpawnNewLeifs | function | SpawnNewLeifs (see below) | Public function to convert eligible nearby trees into new Leif entities. |
CanTransformIntoLeifTest | function | CanTransformIntoLeifTest (see below) | Public function returning true if a given entity can be transformed into a Leif. |
Main functions
WakeUpNearbyLeifs(x, y, z, doer)
- Description: Finds all
leifentities withinTUNING.LEIF_REAWAKEN_RADIUS, wakes up those that are asleep, and suggests thedoeras a combat target for all nearby leifs. - Parameters:
x,y,z(number) – Coordinates for radius search.doer(Entity ornil) – The entity to suggest as a target to nearby leifs (must have acombatcomponent to be valid).
- Returns:
table– List of entities found (may be empty). - Error states: No-op if no matching entities found; silently skips entities missing
sleeperorcombatcomponents.
SpawnNewLeifs(x, y, z, doer, multiplier)
- Description: Finds eligible tree entities within
TUNING.LEIF_IDOL_SPAWN_RADIUSand transforms them into Leif entities, up to a calculated count based onTUNING.LEIF_IDOL_NUM_SPAWNSandmultiplier. UsesCanTransformIntoLeifTestfor validation. - Parameters:
x,y,z(number) – Coordinates for radius search.doer(Entity ornil) – The entity performing the transformation (passed toTransformIntoLeiforStartMonster).multiplier(number ornil) – Scaling factor for number of spawns.
- Returns:
table– List of entities transformed or attempted.number– Remaining spawn count (can be negative if over-allocated).
- Error states: Silently skips entities missing required methods (
TransformIntoLeif,StartMonster) or failingCanTransformIntoLeifTest.
CanTransformIntoLeifTest(inst, target)
- Description: Validates whether
targetcan be transformed into a Leif. Handles two cases:evergreens(stage ≤ 3) orbirchnut(non-barren, non-monster). - Parameters:
inst(Entity) – Unused (present for signature compatibility).target(Entity) – The entity to test.
- Returns:
boolean–trueiftargetis eligible, otherwisefalse.
Events & listeners
- Listens to: None directly via
inst:ListenForEvent. Event-based logic is implemented through component hooks (SetOnBurntFn,SetOnIgniteFn,SetOnTakenFn). - Pushes:
onwakeup– Indirectly viaSleeper:WakeUp()for each awakened Leif entity. - Component hooks:
burnable.onburnt→OnBurntburnable.onignite→OnIgnitefuel.ontaken→OnFuelTaken