Sewing
Overview
This component provides a DoSewing method that repairs eligible targets (those with the "needssewing" tag) by consuming fuel or stackable quantity from the sewing kit entity. It is typically attached to items like the Sewing Kit and coordinates interactions with the target’s fueled component, the kit’s own consumable components (finiteuses or stackable), and supports optional post-repair callbacks and achievement tracking.
Dependencies & Tags
target.components.fueled: Required to apply repair (viaDoDelta).inst.components.finiteusesorinst.components.stackable: Used to consume the tool (optional).inst: Must be an entity capable of acting as a tool (e.g., Sewing Kit); no tags are added/removed by this component itself.- Listens for no internal events itself, but triggers side effects like achievements.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
repair_value | number | 1 | The amount of fuel (HP) restored to a target per sewing operation. |
inst | EntityInstance | (passed in constructor) | Reference to the entity this component is attached to (e.g., Sewing Kit). |
onsewn | function | nil | Optional callback invoked after successful sewing; accepts (self.inst, target, doer) arguments. |
Main Functions
DoSewing(target, doer)
- Description: Attempts to repair the given
targetentity if it has the"needssewing"tag. Consumes one use of the sewing kit (either viafiniteusesorstackable), appliesrepair_valueto the target’sfueledcomponent, triggers an achievement for thedoer, and invokes the optionalonsewncallback if defined. Returnstrueon success ornilif the target is not eligible. - Parameters:
target: Entity – The entity to repair; must have the"needssewing"tag and afueledcomponent.doer: Entity – The entity performing the sewing (e.g., a player); used for achievement granting and context.
Events & Listeners
None.