mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-28 08:54:43 +00:00
update GetItemInfoByName
This commit is contained in:
@@ -10,6 +10,7 @@ local unpack = unpack
|
|||||||
local format, gsub, lower, match, upper = string.format, string.gsub, string.lower, string.match, string.upper
|
local format, gsub, lower, match, upper = string.format, string.gsub, string.lower, string.match, string.upper
|
||||||
local getn = table.getn
|
local getn = table.getn
|
||||||
--WoW API
|
--WoW API
|
||||||
|
local GetItemInfo = GetItemInfo
|
||||||
local GetQuestGreenRange = GetQuestGreenRange
|
local GetQuestGreenRange = GetQuestGreenRange
|
||||||
local GetRealZoneText = GetRealZoneText
|
local GetRealZoneText = GetRealZoneText
|
||||||
local IsInInstance = IsInInstance
|
local IsInInstance = IsInInstance
|
||||||
@@ -374,14 +375,30 @@ function GetThreatStatus(currentThreat, maxThreat)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Credits: @Shagu - pfUI
|
local LAST_ITEM_ID = 24283
|
||||||
-- https://github.com/shagu/pfUI/blob/7999f612ad464261306bbf6f309bb63b54bd44af/api/api.lua#L123
|
local itemInfoDB = {}
|
||||||
function GetItemLinkByName(name)
|
|
||||||
for itemID = 1, 25818 do
|
function GetItemInfoByName(itemName)
|
||||||
local itemName, itemLink, itemQuality = GetItemInfo(itemID)
|
if type(itemName) ~= "string" then
|
||||||
if itemName and itemName == name then
|
error("Usage: GetItemInfoByName(itemName)", 2)
|
||||||
local hex = select(4, GetItemQualityColor(tonumber(itemQuality)))
|
end
|
||||||
return hex.. "|H"..itemLink.."|h["..itemName.."]|h|r"
|
|
||||||
|
if not itemInfoDB[itemName] then
|
||||||
|
local name
|
||||||
|
for itemID = 1, LAST_ITEM_ID do
|
||||||
|
name = GetItemInfo(itemID)
|
||||||
|
|
||||||
|
if name ~= "" then
|
||||||
|
itemInfoDB[name] = itemID
|
||||||
|
|
||||||
|
if name == itemName then
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not itemInfoDB[itemName] then return end
|
||||||
|
|
||||||
|
return GetItemInfo(itemInfoDB[itemName])
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user