LibItemUpgradeInfo-1.0

LibItemUpgradeInfo-1.0 provides information about item upgrades applied to items.


Functions

:GetUpgradeID(itemString)

Arguments

itemString
String - An itemLink or itemString denoting the item

Returns

upgradeID
Number - The upgrade ID (possibly 0), or nil if the input is invalid or does not contain upgrade info


:GetCurrentUpgrade(id)

Returns the current upgrade level of the item, e.g. 1 for a 1/2 item.

Arguments

id
Number - The upgrade ID of the item (obtained via GetUpgradeID())

Returns

upgradeLevel
Number - The current upgrade level of the item, or nil if the item cannot be upgraded


:GetMaximumUpgrade(id)

Returns the maximum upgrade level of the item, e.g. 2 for a 1/2 item.

Arguments

id
Number - The upgrade ID of the item (obtained via GetUpgradeID())

Returns

upgradeLevel
Number - The maximum upgrade level of the item, or nil if the item cannot be upgraded


:GetItemLevelUpgrade(id)

Returns the item level increase that this upgrade is worth, e.g. 4 for a 1/2 item or 8 for a 2/2 item.

Arguments

id
Number - The upgrade ID of the item (obtained via GetUpgradeID())

Returns

ilvlDelta
Number - The item level increase of the item, or 0 if the item cannot be or has not been upgraded


:GetItemUpgradeInfo(itemString)

Returns the current upgrade level, maximum upgrade level, and item level increase for an item.

Arguments

itemString
String - An itemLink or itemString denoting the item

Returns

nil if the item is invalid or cannot be upgraded, otherwise:

curUpgradeLevel
Number - The current upgrade level of the item
maxUpgradeLevel
Number - The maximum upgrade level of the item
lvlDelta
Number - The item level increase of the item

:GetUpgradedItemLevel(itemString)

Returns the true item level of the item, including upgrades.

Arguments

itemString
String - An itemLink or itemString denoting the item

Returns

ilvl
Number - The true item level of the item, or nil if the input is invalid

Example

local ItemUpgradeInfo = LibStub("LibItemUpgradeInfo-1.0")
local item = GetInventoryItemLink("player", 1)
local id = ItemUpgradeInfo:GetUpgradeID(item)
local upgrade = ItemUpgradeInfo:GetCurrentUpgrade(id)
if upgrade then
	local max = ItemUpgradeInfo:GetMaximumUpgrade(id)
	local delta = ItemUpgradeInfo:GetItemLevelUpgrade(id)
	local ilvl = ItemUpgradeInfo:GetUpgradedItemLevel(item)
	DEFAULT_CHAT_FRAME:AddMessage(("%s %d/%d (+%d -> %d)"):format(item, upgrade, max, delta, ilvl))
else
	DEFAULT_CHAT_FRAME:AddMessage(item .. " cannot be upgraded")
end

Same code using the GetItemUpgradeInfo() convenience function:

local ItemUpgradeInfo = LibStub("LibItemUpgradeInfo-1.0")
local item = GetInventoryItemLink("player", 1)
local upgrade, max, delta = ItemUpgradeInfo:GetItemUpgradeInfo(item)
if upgrade then
	local ilvl = ItemUpgradeInfo:GetUpgradedItemLevel(item)
	DEFAULT_CHAT_FRAME:AddMessage(("%s %d/%d (+%d -> %d)"):format(item, upgrade, max, delta, ilvl))
else
	DEFAULT_CHAT_FRAME:AddMessage(item .. " cannot be upgraded")
end

You must login to post a comment. Don't have an account? Register to get one!

  • 7 comments
  • Avatar of eridius eridius Sep 18, 2013 at 03:20 UTC - 0 likes

    @suicidalkatt: Go

    That's completely useless. The upgrade information is stored as one of the components of the itemLink. If you don't have an itemLink, then you have no upgrade info. GetItemInfo() isn't smart enough either to give you the base (un-upgraded) version of the item; an itemLink produced that way has no upgrade information at all.

  • Avatar of suicidalkatt suicidalkatt Sep 18, 2013 at 02:59 UTC - 0 likes

    My point about being able to use itemID or itemName within the API functions to easily cut a corner to be able to get item upgrade info without having to find the item link within users addon code.

    A very simple function like this can get the required information within the library for the user:

    local function GetItemLink(input)
    	local output
    	if GetItemInfo(input) ~= nil then
    		output = select(2,GetItemInfo(input))
    	end	
    	if output then return output end
    end
    
    Last edited Sep 18, 2013 by suicidalkatt
  • Avatar of ckaotik ckaotik Sep 17, 2013 at 06:58 UTC - 0 likes

    Thanks! :) I'll check for 5.4 item upgrades again.

  • Avatar of eridius eridius Sep 16, 2013 at 21:30 UTC - 0 likes

    @ckaotik: Go

    v1.0.4 includes a new GetItemUpgradeInfo() function that returns cur, max, delta.

  • Avatar of eridius eridius Sep 16, 2013 at 21:09 UTC - 0 likes

    @ckaotik: Go

    I'll consider making the API changes you requested. However, v1.0.3 of this library should indeed include the new 5.4 item level upgrade ids. I'm not actually playing the game anymore, so I don't have any upgraded 5.4 gear to check, but I tested all ids up to 10000 to find the new 5.4 ones and they went into the v1.0.3 release. If you find some upgraded 5.4 gear that this library doesn't handle properly, please let me know what the itemString is.

  • Avatar of ckaotik ckaotik Sep 16, 2013 at 12:15 UTC - 0 likes

    @suicidalkatt: Go

    Using itemID or itemName will not work here, as those do not carry any information on item upgrades. You do need itemLinks (or the itemString portion of it) to get those pieces of data.

    However, whenever I want to use this library, I always want to use something along the lines of

    local current, max = LibItemUpgradeInfo:GetItemUpgradeInfo(itemLink)
    

    without having to grab the upgradeID first and then calculating those two values. Also, :GetItemLevelUpgrade should be callable with an itemLink/itemString, too.

    I just noticed, it seems the new 5.4 item level upgrade ids are not yet included. Definitely needed!

    Last edited Sep 16, 2013 by ckaotik
  • Avatar of suicidalkatt suicidalkatt Aug 10, 2013 at 15:06 UTC - 0 likes

    I've embedded your library in my addon !SyLevel.

    Thank you for your simple yet useful library!

    http://www.wowinterface.com/downloads/fileinfo.php?id=22452

    My one and only suggestion is perhaps expanding the library is the functionality of using itemName or itemID in place of itemString/itemLink.

    Perhaps a function to return min / max upgrade progression or 'master' return function.

    Last edited Aug 10, 2013 by suicidalkatt
  • 7 comments

Facts

Date created
Feb 15, 2013
Category
Last update
May 21, 2014
Development stage
Release
License
MIT License
Curse link
LibItemUpgradeInfo-1.0
Downloads
3,550
Recent files
  • R: v1.0.6 for 5.4.8 May 21, 2014
  • R: v1.0.5 for 5.4.1 Dec 10, 2013
  • R: v1.0.4 for 5.4.0 Sep 16, 2013
  • R: v1.0.3 for 5.4.0 Aug 26, 2013
  • R: v1.0.2 for 5.3.0 May 22, 2013

Authors