Lighter
Overview
The Lighter component provides the ability for an entity (typically an item or character) to ignite burnable targets. It manages a callback function (onlight) triggered upon successful ignition and ensures appropriate event propagation.
Dependencies & Tags
- Adds the tag
"lighter"to the entity on construction. - Removes the
"lighter"tag on entity removal viaOnRemoveFromEntity. - Relies on the
burnablecomponent being present on target entities for ignition logic.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | — | Reference to the owning entity. |
onlight | function | nil | Optional callback executed after successful ignition. |
Main Functions
SetOnLightFn(fn)
- Description: Sets or replaces the callback function that is invoked when the lighter successfully ignites a target. The callback receives two arguments: the lighter entity and the target entity.
- Parameters:
fn(functionornil): The callback to invoke on successful ignition;nilclears the callback.
Light(target, doer)
- Description: Attempts to ignite the given
targetentity. Ignition succeeds only if the target has aburnablecomponent and does not meet exclusion criteria (e.g., depleted fuel without override, or being in limbo). Upon success, the callback (onlight) is executed (if set), and theonlighterlightevent is pushed on the target regardless of success or failure. - Parameters:
target(Entity): The entity to ignite.doer(Entity): The entity performing the ignition (e.g., the player).
Events & Listeners
- Listens for: None.
- Triggers:
- Pushes the
"onlighterlight"event on thetargetentity in all cases viatarget:PushEvent("onlighterlight"), regardless of whether ignition succeeded.
- Pushes the