Skip to content

Item

The Item library contains methods relating to item game objects.

ItemLib Class

Inherits from Library.

Methods

CanUse
function ItemLib.CanUse(char, item)
   -> boolean

Returns whether char meets the requirements to use an item.

@param char Character

@param item Item

CountItemsInInventory
function ItemLib.CountItemsInInventory(entity, predicate)
   -> number

Count the items in an entity's inventory that match a predicate function.

Predicate is passed Item and should return true for items to be counted.

@param entity Entity

@param predicate fun(item: EsvItem)

Get
function ItemLib.Get(identifier, isFlashHandle)
   -> Item

@param identifier GUID|NetId|EntityHandle

@param isFlashHandle boolean?

GetContainedItems
function ItemLib.GetContainedItems(container, predicate)
   -> Item[]

Returns the items contained within a container item, optionally filtered by predicate.

@param container Item

@param predicate (fun(item:Item):boolean)? The predicate should return `true` for items to be included. If `nil`, all items will be included.

GetCurrentDye
function ItemLib.GetCurrentDye(item)
   -> string,Dye The dye ID and data table.-- dye ID and data table.

Returns the ID and data for the most recently-applied dye deltamod on the item.

@param item Item

GetDisplayName
function ItemLib.GetDisplayName(item)
   -> string

Returns the display name of the item.

Considers overrides and identification status.

Does not append item amount.

@param item Item

GetEquipmentSubtype
function ItemLib.GetEquipmentSubtype(item)
   -> ItemLib_EquipmentType|ItemSlot

Returns the subtype of item (ex. "Knife" or "Platemail").

Returns ItemSlot for items with no subtypes.

@param item Item

GetEquippedItem
function ItemLib.GetEquippedItem(char, slot)
   -> Item?

@param char Character

@param slot ItemSlot

GetEquippedSlot
function ItemLib.GetEquippedSlot(item, char)
   -> EquipSlot? -- As string.

Returns the slot that an item is equipped in, or nil if it is not.

@param item Item

@param char Character? Defaults to item's owner.

GetHandedness
function ItemLib.GetHandedness(item)
   -> ("One-- `nil` if the item has no handedness.

Returns the handedness of a weapon item.

@param item Item

GetIcon
function ItemLib.GetIcon(item)
   -> string

Returns the icon of the item.

Fetching the icon is technically different per context; the server only cares about root template icon (except for the gold template). This function uses the client logic (which also checks icon override and icon from stats).

@param item Item

GetIdentifyRequirement
function ItemLib.GetIdentifyRequirement(item)
   -> number

Gets the amount of Loremaster necessary to identify an item.

Ignores whether the item is already identified.

@param item Item

GetItemSlot
function ItemLib.GetItemSlot(item)
   -> ItemSlot? -- Nil if the item has no stats.

Alias for Item.Stats.ItemSlot

@param item Item

GetItemsInInventory
function ItemLib.GetItemsInInventory(entity, predicate)
   -> Item[]

Returns a list of the items in the entity's inventory that match an optional predicate function.

Predicate is passed the EclItem/EsvItem and should return true for items to be included.

@param entity Entity

@param predicate fun(item: Item)

GetItemsInPartyInventory
function ItemLib.GetItemsInPartyInventory(char, predicate, recursive)

Returns all items in the party inventory of char matching the predicate, or all if no predicate is passed.

@param char Character

@param predicate (fun(item:Item):boolean)?

@param recursive boolean? Defaults to `false`.

GetLevel
function ItemLib.GetLevel(item)
   -> integer? -- `nil` if the item has no stats.

Returns the level of an item.

@param item Item

GetNamedBoosts
function ItemLib.GetNamedBoosts(item)
   -> string[]

Returns a list of the named boosts on the item.

@param item Item

GetOwner
function ItemLib.GetOwner(item)
   -> Character?

Returns the current owner of the item.

This refers to the character that has legal ownership of the item; player characters will trigger crimes by attempting most interactions with owned items.

This character might be a player.

The owner will be nil if the character who owned the item died, except for player-owned items.

@param item Item

GetPartyTemplateCount
function ItemLib.GetPartyTemplateCount(template) -- (Client-only)
   -> number

Count the amount of template instances (prefix + guid) in the client party's inventory.

@param template string

GetRarityIcon
function ItemLib.GetRarityIcon(rarity)
   -> icon? -- Not all rarities have icons.

Returns the icon frame for a rarity, if any.

@param rarity ItemLib_Rarity|EclItem

GetRarityName
function ItemLib.GetRarityName(rarity)

Returns the name of a rarity.

@param rarity Item|ItemLib_Rarity

GetRune
function ItemLib.GetRune(item, index)
   -> StatItem? -- `nil` if no rune is inserted at the index.

Gets the stats object of the rune inserted at rune index index on item.

@param item Item

@param index integer **0-based.**

GetRuneSlots
function ItemLib.GetRuneSlots(item)
   -> integer

Returns the amount of rune slots an item has.

@param item Item

GetRuneSlotsIcon
function ItemLib.GetRuneSlotsIcon(item)
   -> icon? -- `nil` if the item has no rune slots.

Returns the icon displaying the state of item's rune slots.

@param item Item

GetRunes
function ItemLib.GetRunes(item)
   -> table<number, StatItem> -- Empty slots are nil.

Returns a list of runes on the item.

@param item Item

GetUseAPCost
function ItemLib.GetUseAPCost(item)
   -> integer

Returns the base AP cost of using an item, independent of the character.

@param item Item

GetUseActions
function ItemLib.GetUseActions(item, actionType)
   -> IActionData[]

Returns the use actions of an item, optionally filtered by type.

@param item Item|ItemTemplate

@param actionType ActionDataType

HasFlag
function ItemLib.HasFlag(item, flag)

Returns whether the item has a flag.

@param item Item

@param flag EclItemFlags|EsvItemFlags|EclItemFlags2|EsvItemFlags2

HasRunes
function ItemLib.HasRunes(item)
   -> boolean

Returns true if item has any runes slotted.

@param item Item

HasUseAction
function ItemLib.HasUseAction(item, useActionID)
   -> boolean

Returns whether the item has a OnUsePeaceAction of the passed type.

@param item Item

@param useActionID ActionDataType

HasUseActions
function ItemLib.HasUseActions(item)
   -> boolean

Returns whether an item has any use actions.

@param item Item

IsArtifact
function ItemLib.IsArtifact(item)
   -> boolean

Returns true if the item is an Artifact by checking the AMER_UNI tag.

@param item Item

IsContainer
function ItemLib.IsContainer(item)
   -> boolean

Returns whether an item is a container.

@param item Item

IsDagger
function ItemLib.IsDagger(item)
   -> boolean

Returns whether item is a dagger (satisfying a DaggerWeapon requirement)

@param item Item

IsDyeable
function ItemLib.IsDyeable(item)
   -> boolean

Returns true for dyeable items (equipment, except rings/amulet/belt).

@param item Item

IsEquipment
function ItemLib.IsEquipment(item)
   -> boolean

Returns true if the item is an armor piece or a weapon.

@param item Item

IsEquipped
function ItemLib.IsEquipped(char, item)
   -> boolean

Returns true if item is equipped by char. Assumes the item cannot be equipped into an unintended slot. Rings and weapons are checked for both slots.

@param char Character

@param item Item

IsIdentified
function ItemLib.IsIdentified(item)
   -> boolean

Returns whether an item is identified.

@param item Item

IsLegal
function ItemLib.IsLegal(item)
   -> boolean

Returns whether interacting with an item is legal.

@param item Item

IsMarkedAsWares
function ItemLib.IsMarkedAsWares(item)
   -> boolean

Returns whether an item is marked as wares.

@param item Item

IsMeleeWeapon
function ItemLib.IsMeleeWeapon(item)
   -> boolean

Returns whether item is a melee weapon (satisfying a MeleeWeapon requirement)

Returns true for None-type weaponry.

@param item Item

IsRangedWeapon
function ItemLib.IsRangedWeapon(item)
   -> boolean

Returns whether item is a ranged weapon; bow or crossbow only!

@param item Item

IsRune
function ItemLib.IsRune(item)
   -> boolean

Returns whether the item is a rune.

@param item Item

IsShield
function ItemLib.IsShield(item)
   -> boolean

Returns whether item is a shield (satisfying a ShieldWeapon requirement)

@param item Item

IsSkillbook
function ItemLib.IsSkillbook(item)
   -> boolean

Returns whether item is a skillbook.

@param item Item

IsUnique
function ItemLib.IsUnique(item)
   -> boolean

Returns whether an item is of Unique rarity.

Returns true for Artifact items.

@param item Item

IsWeapon
function ItemLib.IsWeapon(item)
   -> boolean

Returns true if the item is a weapon (shields don't count!)

@param item Item

SetIconOverride
function ItemLib.SetIconOverride(item, icon) -- (Client-only)

Sets a custom icon for an item.

Not persistent!

@param item Item

@param icon string