ItemWearable is the base class for clothing: items that change the model or the
bodygroups of the player while equipped.
A derived item sets equip_inv ('equipment_torso' by default) and equip_slot, and
says what it changes. The model the player gets is, in this order: their current model
with the last folder of its path replaced by model_group, or equip_model, or the
model of the item itself. equip_bodygroups maps bodygroup ids or names to the
values they are set to. valid_models, a list of model paths, or valid_model_group,
a pattern that the path of the player's model has to contain, restrict who can wear the
item. The model and the bodygroups the player had before are kept in the data of the
item and given back when it is unequipped.
Summary
Methods
Methods
Called by ItemEquipable:can_transfer before the item is equipped. Checks whether the model of the player is able to wear the item.
Parameters
- owner Player the player who is about to wear the item
Returns
- Boolean
Returns the bodygroups that the player gets when they equip the item.
Parameters
- _owner Player
Returns
- Map bodygroup id (Number) or bodygroup name (String) to its value, or nil if the item does not change bodygroups
Returns the model that the player gets when they equip the item.
Parameters
- owner Player
Returns
- String path to the model; the item's own model if it has no other one
Returns the model that is shown in inventory slots: the one the item would put on the local player, or the item's own model if there is none. Client-side only.
Returns
- String path to the model
ItemWearable:get_model_by_group(owner)
shared plugins/items/plugin/items/bases/sh_item_wearable.lua:39Builds the model for the player to wear by replacing the last folder in the path of their current model with the item's model_group.
Parameters
- owner Player
Returns
- String path to the model
- Number amount of replacements made; nil if the item has no model_group or the model is not inside of a suitable folder
ItemWearable:get_valid_model_group()
shared plugins/items/plugin/items/bases/sh_item_wearable.lua:74Returns the pattern that the player's model has to contain for them to wear the item.
Returns
- String pattern, or nil if any model fits
Returns the player models that are able to wear the item.
Returns
- List<String> paths to the models, or nil if any model fits
Called when the item gets equipped. Applies the model and the bodygroups of the item to the player, storing the ones they had before in the item's data.
Parameters
- owner Player
ItemWearable:post_unequipped(owner)
shared plugins/items/plugin/items/bases/sh_item_wearable.lua:145Called when the item gets unequipped. Gives the player their model and bodygroups back.
Parameters
- owner Player