Lua Code:
-- Construct your saarch pattern based on the existing global string:
local S_ITEM_LEVEL = "^" .. gsub(ITEM_LEVEL, "%%d", "(%%d+)")
local strmatch = string.match
-- Create the tooltip:
local scantip = CreateFrame("GameTooltip", "MyScanningTooltip", nil, "GameTooltipTemplate")
scantip:SetOwner(UIParent, "ANCHOR_NONE")
local function GetItemLevelFromTooltip(itemLink)
-- Pass the item link to the tooltip:
scantip:SetHyperlink(itemLink)
-- Scan the tooltip:
for i = 2, scantip:NumLines() do -- Line 1 is always the name so you can skip it.
local text = _G["MyScanningTooltipTextLeft"..i]:GetText()
if text and text ~= "" then
local itemLevel = strmatch(text, S_ITEM_LEVEL)
if itemLevel then
return itemLevel
end
end
end
end