What is it for?
I wrote this library to use with my JunkIt Addon. When I added the ability to auto-loot items based on junk filters I found the need to be able to handle items by both (BagId, SlotId) and by Links. At the time a lot of the newer GetItemLink functions weren't available. So I wrote a library to handle gathering that information, and for other common tasks, whether I passed in a (bagId, SlotId) or a (link).
Scroll down for available functions
Instructions
To use it install the library folder into libs folder (your library folder or wherever)
Lua Code:
-- <Your Addon Folder> --> <libs> --> <LibItemInfo-1.0>
-- <Your Addon> --> <libs> --> <LibStub>
-- In your Addon.txt file Add a reference to the LibStub.lua file:
libs\LibStub\LibStub.lua
-- Then Add a reference to the LibItemInfo-1.0.lua file:
libs\LibItemInfo-1.0\LibItemInfo-1.0.lua
Then to use it in any of your code files, at the top of the file include the line:
Note: this must be done in each code file you wish to use the library in.
Lua Code:
local LII = LibStub:GetLibrary("LibItemInfo-1.0")
The library can then be used to gather information with (BagId, SlotId) or a (link). For example each function can be called by either:
Lua Code:
local LII = LibStub:GetLibrary("LibItemInfo-1.0")
LII:HasKnownTrait(iBagId, iSlotId)
-- or
LII:HasKnownTrait(lLink)
Available Functions
General Functions
Lua Code:
------------------------------------------------------------------------
-- General Functions --
------------------------------------------------------------------------
-- Returns an unformatted link of the item
function lii:GetItemLink(_BagIdOrLink, _iSlotId)
-- Returns a zo_strformat(..)'d Link --
function lii:GetFormattedItemLink(_BagIdOrLink, _iSlotId)
-- Returns the zo_strformat(..)'d ToolTipName of the item
function lii:GetItemToolTipName(_BagIdOrLink, _iSlotId)
-- Same returns as the built in GetItemInfo
-- sIcon, iStack, iSellPrice, bMeetsUsageRequirement, bLocked, iEquipType, iItemStyle, iItemQuality
-- Links do not have stack sizes or a locked property
-- If you pass in a link iStack & bLocked will return nil
function lii:GetItemInfo(_BagIdOrLink, _iSlotId)
Item SubType
Lua Code:
------------------------------------------------------------------------
-- Item SubType (ArmorType/WeaponType) Info --
------------------------------------------------------------------------
-- Returns the appropriate ArmorType, WeaponType,
-- or 0 if not a piece of Armor or Weapon
-- 0 is the same value as WEAPONTYPE_NONE & ARMORTYPE_NONE
function lii:GetSubType(_BagIdOrLink, _iSlotId)
Item Properties
Lua Code:
------------------------------------------------------------------------
-- ItemType Group Properties --
------------------------------------------------------------------------
-- Returns: true/false if the item is jewelry
function lii:IsJewelry(_BagIdOrLink, _iSlotId)
-- Returns: true/false if the item is a one handed weapon
function lii:IsWeaponOneHanded(_BagIdOrLink, _iSlotId)
-- Returns: true/false if the item is a two handed weapon
function lii:IsWeaponTwoHanded(_BagIdOrLink, _iSlotId)
-- Returns: true/false if the item is a crafting mat
-- NOTE: This include Glyphs. Does not include Style material or trait stones.
function lii:IsCrafingMaterial(_BagIdOrLink, _iSlotId)
-- Returns: true/false if the item is a glyph
function lii:IsGlyph(_BagIdOrLink, _iSlotId)
Crafting Info
Lua Code:
------------------------------------------------------------------------
-- Crafting Info Functions --
------------------------------------------------------------------------
-- Pass in a CraftingSkill Type and it Returns a zo_strFormat(..)'d name for the CraftingSkillType in the games current language or CRAFTING_TYPE_INVALID
-- In English it returns:
-- CRAFTING_TYPE_ALCHEMY returns "Alchemy"
-- CRAFTING_TYPE_BLACKSMITHING returns "Blacksmithing"
-- CRAFTING_TYPE_CLOTHIER returns "Clothing"
-- CRAFTING_TYPE_ENCHANTING returns "Enchanting"
-- CRAFTING_TYPE_INVALID returns CRAFTING_TYPE_INVALID (NOT a formatted string, it returns 0)
-- CRAFTING_TYPE_PROVISIONING returns "Provisioning"
-- CRAFTING_TYPE_WOODWORKING returns "Woodworking"
function lii:GetCraftingSkillTypeLabelName(_iCraftingSkillType)
-- Possible Returns: CRAFTING_TYPE_CLOTHIER, CRAFTING_TYPE_BLACKSMITHING, CRAFTING_TYPE_WOODWORKING, or CRAFTING_TYPE_INVALID
-- Returns: the CraftingSkillType of an item IF it is a researchable ItemType
-- Returns: CRAFTING_TYPE_INVALID if it is not a researchable ItemType
function lii:GetResearchableCraftingSkillType(_BagIdOrLink, _iSlotId)
Research Specific
Lua Code:
------------------------------------------------------------------------
-- Research Specific Functions --
------------------------------------------------------------------------
-- Returns: bool IsResearchableItem, integer CraftingSkillType, Integer ResearchLineIndex, integer TraitIndex
--
-- IsResearchableItem: Returns: True if itemType is researchable AND has a researchable trait on it, But that does not mean it is an unknown trait --
-- CraftingSkillType: Returns the CraftingSkillType of an item IF it is a researchable ItemType or CRAFTING_TYPE_INVALID (item does not have to have a trait on it to return a CraftingSkillType)
-- GetResearchLineIndex: Returns the ResearchLineIndex for an item if it is a researchable ItemType Or returns CRAFTING_TYPE_INVALID (item does not have to have a trait on it to return a ResearchLineIndex) --
-- TraitIndex: Returns the TraitIndex of the trait on the item or CRAFTING_TYPE_INVALID (Armor/Weapon Trait Stones will return a TraitIndex)
function lii:GetResearchInfo(_BagIdOrLink, _iSlotId)
-- Returns: True if the ItemType is Armor or Weapon and the subtype is not WEAPONTYPE_RUNE and not xxx_NONE --
function lii:IsResearchableItemType(_BagIdOrLink, _iSlotId)
-- Returns: True if itemType is researchable AND has a researchable trait on it --
-- That does not mean it is an unknown trait --
-- Make sure you note the distinction between this & HasResearchableTrait, they are not the same --
-- (Armor/Weapon Trait Stones will return false)
function lii:IsResearchableItem(_BagIdOrLink, _iSlotId)
-- Returns: True or False
-- True if the item is a researchable ItemType, it has a researchable trait
-- on it that is unknown, and that trait is not currently being researched
function lii:NeedForResearch(_BagIdOrLink, _iSlotId)
-- Possible Returns: The Items ResearchLine Index or CRAFTING_TYPE_INVALID
-- Returns: The ResearchLineIndex for an item if it is a researchable ItemType
-- This does not mean it has a trait on it.
-- Returns: CRAFTING_TYPE_INVALID if the item is not a Researchable ItemType
function lii:GetResearchLineIndex(_BagIdOrLink, _iSlotId)
Trait Specific
Lua Code:
------------------------------------------------------------------------
-- Item Trait Specific Functions --
------------------------------------------------------------------------
-- Returns: the TraitIndex of the trait on an item or CRAFTING_TYPE_INVALID
-- Does not mean the ItemType is researchable (Armor/Weapon Trait Stones will return a TraitIndex)
function lii:GetTraitIndex(_BagIdOrLink, _iSlotId)
-- Returns true if the itemType is researchable and has a known researchable trait
function lii:HasKnownTrait(_BagIdOrLink, _iSlotId)
-- Returns true/false if the itemType is researchable and has an unknown researchable trait
function lii:HasUnKnownTrait(_BagIdOrLink, _iSlotId)
-- Returns true/false if the item has a researchable trait
-- This does not mean the trait is unknown to you or that it is
-- a researchable ItemType only that it is one of the researchable
-- TraitTypes (Armor/Weapon Trait Stones will return true)
-- Make sure you note the distinction between this & IsResearchableItem, they are not the same --
function lii:HasResearchableTrait(_BagIdOrLink, _iSlotId)
-- If the TraitType on the item is currently being researched
-- Returns: True, TotalResearchTime, timeLeftInSeconds
-- If the TraitType on the item is not currently being researched
-- Returns: False, nil, nil
function lii:IsItemTraitBeingResearched(_BagIdOrLink, _iSlotId)
Recipe
Lua Code:
------------------------------------------------------------------------
-- Recipe Functions --
------------------------------------------------------------------------
-- If the recipe is know it returns:
-- Returns: bool IsKnownRecipe, string (ToolTipFormatted)RecipeName, integer RecipeListIndex, integer RecipeIndex
-- If the recipe is unknown it returns:
-- Returns: false, nil, nil, nil
function lii:GetRecipeInfo(_BagIdOrLink, _iSlotId)