Equippable
Based on game build 722832 | Last updated: 2026-04-27
Overview
Equippable tracks whether an item is currently equipped, which equipment slot it occupies, and manages callbacks for equip/unequip events. It integrates with inventoryitem for owner tracking and burnable to stop smoldering when equipped. The component also handles walk speed modifiers, dapperness calculations, moisture accumulation, and equipment restriction tags for player-gated items.
Usage example
local inst = CreateEntity()
inst:AddComponent("equippable")
inst:AddComponent("inventoryitem")
inst.components.equippable:SetOnEquip(function(item, owner)
print("Item equipped by", owner.prefab)
end)
inst.components.equippable:SetOnUnequip(function(item, owner)
print("Item unequipped by", owner.prefab)
end)
inst.components.equippable:Equip(player, false)
print("Is equipped:", inst.components.equippable:IsEquipped())
Dependencies & tags
External dependencies:
EQUIPSLOTS-- global enum for equipment slot constants (HANDS, HEAD, BODY, etc.)TUNING.WET_ITEM_DAPPERNESS-- dapperness penalty when item is wetSKILLTREE_EQUIPPABLE_RESTRICTED_TAGS-- skill tree restriction mapping
Components used:
burnable-- callsStopSmoldering()when item is equippedinventoryitem-- accessesownerproperty for walk speed and restriction checkslinkeditem-- checksIsEquippableRestrictedToOwner()andGetOwnerUserID()for ownership restrictionsreplica.equippable-- syncs equip slot and prevent unequipping state to clientsreplica.inventoryitem-- syncs walk speed multiplier and equip restriction tags to clients
Tags:
player-- checked inIsRestricted()to apply restrictions only to playerspossessedbody-- checked alongsideplayerinIsRestricted()equipmentmodel-- checked before callingonequiptomodelfncallbackmerm-- checked in GetDapperness() but flipdapperonmerms property is never initialized in source, making this check non-functionalvigorbuff-- grants walk speed bonus when speed < 1 and owner has this tag
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
isequipped | boolean | false | Whether the item is currently equipped. |
equipslot | EQUIPSLOTS | EQUIPSLOTS.HANDS | The equipment slot this item occupies. |
onequipfn | function | nil | Callback fired when item is equipped. Signature: fn(inst, owner, from_ground). |
onunequipfn | function | nil | Callback fired when item is unequipped. Signature: fn(inst, owner). |
onpocketfn | function | nil | Callback fired when item is moved to pocket. Signature: fn(inst, owner). |
onequiptomodelfn | function | nil | Callback for equipment model changes. Signature: fn(inst, owner, from_ground). |
equipstack | boolean | false | Whether the item can be stacked when equipped. |
walkspeedmult | number | nil | Walk speed multiplier applied when item is equipped. |
dapperness | number | 0 | Base dapperness value granted by this item. |
dapperfn | function | nil | Custom function to calculate dapperness. Signature: fn(inst, owner). |
insulated | boolean | false | Whether the item provides electrical insulation. |
equippedmoisture | number | 0 | Current moisture accumulation while equipped. |
maxequippedmoisture | number | 0 | Maximum moisture capacity while equipped. |
preventunequipping | boolean | nil | If true, blocks unequipping via onremove event listener. |
restrictedtag | string | nil | Tag required on target to equip this item. Only players with this tag can equip. |
flipdapperonmerms | boolean | nil | If true, flips dapperness sign for merm entities. Set externally by prefabs; never initialized in constructor (see Tags section note on merm tag). |
Main functions
OnRemoveFromEntity()
- Description: Cleanup handler called when component is removed from entity. Resets prevent unequipping state and clears walk speed multiplier and restriction tags on replica.
- Parameters: None
- Returns: nil
- Error states: None
IsInsulated()
- Description: Returns whether the item provides electrical insulation (not temperature insulation).
- Parameters: None
- Returns: boolean --
trueif insulated,falseotherwise - Error states: None
SetOnEquip(fn)
- Description: Sets the callback function fired when the item is equipped.
- Parameters:
fn-- function with signaturefn(inst, owner, from_ground) - Returns: nil
- Error states: None
SetOnPocket(fn)
- Description: Sets the callback function fired when the item is moved to pocket.
- Parameters:
fn-- function with signaturefn(inst, owner) - Returns: nil
- Error states: None
SetOnUnequip(fn)
- Description: Sets the callback function fired when the item is unequipped.
- Parameters:
fn-- function with signaturefn(inst, owner) - Returns: nil
- Error states: None
SetDappernessFn(fn)
- Description: Sets a custom function to calculate dapperness instead of using the base
dappernessvalue. - Parameters:
fn-- function with signaturefn(inst, owner) - Returns: nil
- Error states: None
SetOnEquipToModel(fn)
- Description: Sets the callback function for equipment model changes. Only called if owner has
equipmentmodeltag. - Parameters:
fn-- function with signaturefn(inst, owner, from_ground) - Returns: nil
- Error states: None
IsEquipped()
- Description: Returns whether the item is currently equipped.
- Parameters: None
- Returns: boolean --
trueif equipped,falseotherwise - Error states: None
Equip(owner, from_ground)
- Description: Marks the item as equipped, stops smoldering if burnable, fires the equip callback, and pushes the
equippedevent. Callsonequiptomodelfnif owner hasequipmentmodeltag. - Parameters:
owner-- entity that is equipping the itemfrom_ground-- boolean indicating if item was picked up from ground
- Returns: nil
- Error states: Errors if owner is nil (no nil guard before passing to onequipfn, PushEvent, and onequiptomodelfn).
ToPocket(owner)
- Description: Fires the pocket callback when item is moved to pocket slot.
- Parameters:
owner-- entity that owns the item - Returns: nil
- Error states: Errors if owner is nil and onpocketfn callback accesses owner (no nil guard before callback invocation).
Unequip(owner)
- Description: Marks the item as unequipped, fires the unequip callback, and pushes the
unequippedevent. - Parameters:
owner-- entity that is unequipping the item - Returns: nil
- Error states: Errors if owner is nil (no nil guard before passing to onunequipfn and PushEvent).
GetWalkSpeedMult()
- Description: Calculates the effective walk speed multiplier. Applies a +0.25 bonus (capped at 1.0) if speed < 1 and owner has
vigorbufftag. Callsinventory_EquippableWalkSpeedMultModifierfunction on owner if present for further modification. - Parameters: None
- Returns: number -- walk speed multiplier (default 1.0 if not set)
- Error states: None
IsRestricted(target)
- Description: Checks if the target is restricted from equipping this item. Returns
falsefor non-player/non-possessedbody targets. Checkslinkeditemownership restrictions first, then checks if target lacks the requiredrestrictedtag. - Parameters:
target-- entity to check restrictions against - Returns: boolean --
trueif restricted,falseif allowed - Error states: Errors if
targetis nil (callsHasAnyTag()without nil guard).
IsRestricted_FromLoad(target)
- Description: Restriction check used during snapshot load. Returns
falseif the restricted tag matches a skill tree entry for the target prefab (assumes player has the tag on load). Otherwise delegates toIsRestricted(). - Parameters:
target-- entity to check restrictions against - Returns: boolean --
trueif restricted,falseif allowed - Error states: Errors if
targetis nil ortarget.prefabis nil.
ShouldPreventUnequipping()
- Description: Returns whether unequipping is currently blocked.
- Parameters: None
- Returns: boolean --
trueif unequipping is prevented,falseotherwise - Error states: None
SetPreventUnequipping(shouldprevent)
- Description: Enables or disables unequipping prevention. When enabled, listens for
onremoveevent to block removal. When disabled, removes the event listener. - Parameters:
shouldprevent-- boolean to enable or disable prevention - Returns: nil
- Error states: None
GetDapperness(owner, ignore_wetness)
- Description: Calculates the total dapperness value. Flips sign if
flipdapperonmermsis set and owner hasmermtag. Callsdapperfnif set. AddsTUNING.WET_ITEM_DAPPERNESSpenalty if item is wet andignore_wetnessis false. - Parameters:
owner-- entity wearing the itemignore_wetness-- boolean to skip wetness penalty
- Returns: number -- total dapperness value
- Error states: None
GetEquippedMoisture()
- Description: Returns the current and maximum moisture accumulation while equipped.
- Parameters: None
- Returns: table --
{ moisture = number, max = number } - Error states: None
Events & listeners
- Listens to:
onremove- registered whenpreventunequippingis enabled to block item removal - Pushes:
equipped- fired inEquip()with{ owner = owner }data - Pushes:
unequipped- fired inUnequip()with{ owner = owner }data