Waxable
Based on game build 714014 | Last updated: 2026-03-03
Overview
Waxable enables an entity to be processed by waxing (wax application) mechanics. It stores whether the entity needs wax spray and delegates the actual waxing behavior to a custom callback (waxfn). The component manages the waxable and needswaxspray tags automatically, and integrates with finiteuses, stackable, and wax components on the waxing item to consume it appropriately.
Usage example
local inst = CreateEntity()
inst:AddComponent("waxable")
-- Register a custom waxing function
inst.components.waxable:SetWaxfn(function(inst, doer, waxitem)
-- Apply wax logic here; return true on success
inst:RemoveTag("wet")
return true
end)
-- Mark that the entity needs wax spray (e.g., after being wet)
inst.components.waxable:SetNeedsSpray(true)
-- Attempt to wax the entity
local success = inst.components.waxable:Wax(player, wax_item)
Dependencies & tags
Components used: wax, finiteuses, stackable
Tags: Adds waxable (when waxfn is set), needswaxspray (when needs_spray is true); removes both on removal.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil | The entity instance this component belongs to. |
needs_spray | boolean | false | Whether the entity currently needs wax spray. |
waxfn | function | nil | Callback function defining how waxing is applied. Signature: (inst, doer, waxitem) → (result: boolean, reason?: string). |
Main functions
SetWaxfn(fn)
- Description: Sets the callback function executed when
Waxis called. Ifnil, the entity is not consideredwaxable. - Parameters:
fn(function?) — optional callback with signature(inst, doer, waxitem) → (result: boolean, reason?: string). - Returns: Nothing.
SetNeedsSpray(val)
- Description: Sets whether the entity needs wax spray. Adds or removes the
needswaxspraytag accordingly. - Parameters:
val(boolean) — whether spray is needed. Treats any non-falsevalue astrue. - Returns: Nothing.
NeedsSpray()
- Description: Returns whether the entity currently needs wax spray.
- Parameters: None.
- Returns:
boolean—trueifneeds_sprayistrue, otherwisefalse.
Wax(doer, waxitem)
- Description: Attempts to apply wax to the entity using the provided wax item. Calls the
waxfncallback if present, and consumes the wax item on success. - Parameters:
doer(Entity) — the entity performing the waxing action.
waxitem(Entity) — the item used to apply wax. - Returns:
boolean, string?—trueand optionally a reason string on success;false(and optionally a reason) on failure. Fails ifwaxfnisnilor ifwaxitemis a spray but the entity does not need spray. - Error states:
- Returns
falseimmediately ifwaxitem.components.waxexists andGetIsSpray()returnstrue, butNeedsSpray()isfalse. - Returns the result and optional reason from
waxfn(which may befalseand a reason string). - Consumes
waxitemonly on success (result == true), viafiniteuses:Use(),stackable:Get():Remove(), or directwaxitem:Remove()depending on available components.
- Returns
OnRemoveFromEntity()
- Description: Cleanup callback invoked when this component is removed from its entity. Removes
waxableandneedswaxspraytags. - Parameters: None.
- Returns: Nothing.
Events & listeners
None identified.