Item¶
The Item
library contains methods relating to item game objects.
ItemLib Class¶
Inherits from Library
.
Events and Hooks¶
ItemUsed (event)¶
@field Character Character
@field Item Item
Methods¶
CanUse¶
Returns whether char meets the requirements to use an item.
@param char Character
@param item Item
CountItemsInInventory¶
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)
GenerateDefaultTreasure¶
function ItemLib.GenerateDefaultTreasure(item, char)
-> boolean -- `true` if the container did not have treasure generated before.
Generates treasure in an item as if char had opened it.
Does nothing if the item already had treasure generated.
@param item EsvItem
Must be a container.
@param char EsvCharacter
Get¶
@param identifier GUID|NetId|EntityHandle
@param isFlashHandle boolean?
GetContainedItems¶
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¶
Returns the display name of the item.
Considers overrides and identification status.
Does not append item amount.
@param item Item
GetEquipmentSubtype¶
Returns the subtype of item (ex. "Knife" or "Platemail").
Returns "None"
for armor items with no subtypes (ex. Amulet
).
@param item Item
GetEquippedItem¶
@param char Character
@param slot ItemSlot
GetEquippedSlot¶
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¶
Returns the handedness of a weapon item.
@param item Item
GetIcon¶
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¶
Gets the amount of Loremaster necessary to identify an item.
Ignores whether the item is already identified.
@param item Item
GetInventoryParent¶
function ItemLib.GetInventoryParent(item)
-> (Character|Item)? -- `nil` if the item is not in an inventory.
Returns the character or item that contains the item passed.
@param item Item
GetInventoryRoot¶
function ItemLib.GetInventoryRoot(item)
-> (Character|Item)? -- `nil` if the item is not in an inventory.
Returns the top-most character or item that contains the item passed.
@param item Item
GetItemSlot¶
Alias for Item.Stats.ItemSlot
@param item Item
GetItemsInInventory¶
Returns a list of the items in the entity's inventory that match an optional predicate function.
@param entity Entity
@param predicate (fun(item:Item):boolean)?
Should return `true` for items to be included?
GetItemsInPartyInventory¶
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¶
Returns the level of an item.
@param item Item
GetNamedBoosts¶
Returns a list of the named boosts on the item.
@param item Item
GetOwner¶
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¶
Counts the amount of template instances in the client party's inventory recursively, considering item stacks.
@param template GUID|PrefixedGUID
GetRarityIcon¶
Returns the icon frame for a rarity, if any.
@param rarity ItemLib_Rarity|EclItem
GetRarityName¶
Returns the name of a rarity.
@param rarity Item|ItemLib_Rarity
GetRune¶
Gets the stats object of the rune inserted at rune index index
on item.
@param item Item
@param index integer
**0-based.**
GetRuneSlots¶
Returns the amount of rune slots an item has.
@param item Item
GetRuneSlotsIcon¶
Returns the icon displaying the state of item's rune slots.
@param item Item
GetRunes¶
Returns a list of runes on the item.
@param item Item
GetTreasureLevel¶
Returns the level of treasure that would generate in the item
if opened by char.
This is an approximation based on DOS1 code; might have inaccuracies.
@param item EsvItem
@param char EsvCharacter
GetUseAPCost¶
Returns the base AP cost of using an item, independent of the character.
@param item Item
GetUseActions¶
Returns the use actions of an item, optionally filtered by type.
@param item Item|ItemTemplate
@param actionType ActionDataType
HasFlag¶
Returns whether the item has a flag.
@param item Item
@param flag EclItemFlags|EsvItemFlags|EclItemFlags2|EsvItemFlags2
HasRunes¶
Returns true if item has any runes slotted.
@param item Item
HasUseAction¶
Returns whether the item has a OnUsePeaceAction of the passed type.
@param item Item
@param useActionID ActionDataType
HasUseActions¶
Returns whether an item has any use actions.
@param item Item
IsArrow¶
Returns whether an item has a UseSkill action of an arrow skill.
@param item Item
IsBook¶
Returns whether an item has a Book use action.
@param item Item
IsContainer¶
Returns whether an item is a container.
@param item Item
IsDagger¶
Returns whether item is a dagger (satisfying a DaggerWeapon requirement)
@param item Item
IsDyeable¶
Returns true for dyeable items (equipment, except rings/amulet/belt).
@param item Item
IsEquipment¶
Returns true if the item is an armor piece or a weapon.
@param item Item
IsEquipped¶
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
IsFood¶
Returns whether an item is consumable and marked as food.
@param item Item
IsGold¶
Returns whether an item is a stack of gold.
@param item Item
IsGrenade¶
Returns whether an item has a UseSkill action of a grenade skill.
@param item Item
IsIdentified¶
Returns whether an item is identified.
@param item Item
IsIngredient¶
Returns whether an item is considered an ingredient for inventory categorization.
@param item Item
IsKey¶
Returns whether an item is a key.
@param item Item
IsLegal¶
Returns whether interacting with an item is legal.
@param item Item
IsLocked¶
Returns whether an item is locked.
@param item Item
IsMarkedAsWares¶
Returns whether an item is marked as wares.
@param item Item
IsMeleeWeapon¶
Returns whether item is a melee weapon (satisfying a MeleeWeapon requirement)
Returns true for None-type weaponry.
@param item Item
IsPotion¶
Returns whether an item has a Consume action and any common potion tag.
@param item Item
IsRangedWeapon¶
Returns whether item is a ranged weapon; bow or crossbow only!
@param item Item
IsRune¶
Returns whether the item is a rune.
@param item Item
IsScroll¶
Returns whether an item has a UseSkill action of a non-projectile, non-grenade skill.
@param item Item
IsShield¶
Returns whether item is a shield (satisfying a ShieldWeapon requirement)
@param item Item
IsSkillbook¶
Returns whether item is a skillbook.
@param item Item
IsUnique¶
Returns whether an item is of Unique rarity.
Returns true
for Artifact items.
@param item Item
IsWeapon¶
Returns true if the item is a weapon (shields don't count!)
@param item Item
SetIconOverride¶
Sets a custom icon for an item.
Not persistent!
@param item Item
@param icon string