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

Called by ItemEquipable:can_transfer before the item is equipped.
Returns the bodygroups that the player gets when they equip the item.
Returns the model that the player gets when they equip the item.
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.
Builds 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.
Returns the pattern that the player's model has to contain for them to wear the item.
Returns the player models that are able to wear the item.
Called when the item gets equipped.
Called when the item gets unequipped.

Methods

ItemWearable:can_equip(owner)

shared plugins/items/plugin/items/bases/sh_item_wearable.lua:82

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

ItemWearable:get_bodygroups(_owner)

shared plugins/items/plugin/items/bases/sh_item_wearable.lua:62

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

ItemWearable:get_equip_model(owner)

shared plugins/items/plugin/items/bases/sh_item_wearable.lua:54

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

ItemWearable:get_icon_model()

client plugins/items/plugin/items/bases/sh_item_wearable.lua:29

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:39

Builds 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:74

Returns 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

ItemWearable:get_valid_models()

shared plugins/items/plugin/items/bases/sh_item_wearable.lua:68

Returns the player models that are able to wear the item.

Returns

  • List<String> paths to the models, or nil if any model fits

ItemWearable:post_equipped(owner)

shared plugins/items/plugin/items/bases/sh_item_wearable.lua:111

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:145

Called when the item gets unequipped. Gives the player their model and bodygroups back.

Parameters

  • owner Player

Defined in