59 lines
2.2 KiB
Lua
59 lines
2.2 KiB
Lua
-- AscensionExporter - Mystic Enchants collector (from equipped item tooltips)
|
||
|
||
local AE = AscensionExporter
|
||
|
||
local SLOT_NAMES = {
|
||
[1] = "HEAD", [2] = "NECK", [3] = "SHOULDER", [4] = "SHIRT", [5] = "CHEST",
|
||
[6] = "WAIST", [7] = "LEGS", [8] = "FEET", [9] = "WRIST", [10] = "HANDS",
|
||
[11] = "FINGER1", [12] = "FINGER2", [13] = "TRINKET1", [14] = "TRINKET2",
|
||
[15] = "BACK", [16] = "MAINHAND", [17] = "OFFHAND", [18] = "RANGED", [19] = "TABARD",
|
||
}
|
||
|
||
local function extract_mystic_from_tooltip(slot)
|
||
GameTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||
GameTooltip:SetInventoryItem("player", slot)
|
||
local found = nil
|
||
for i = 1, GameTooltip:NumLines() do
|
||
local line = _G["GameTooltipTextLeft" .. i]
|
||
if line then
|
||
local txt = tostring(line:GetText() or "")
|
||
if txt and txt ~= "" then
|
||
local l = txt:lower()
|
||
if (l:find("mystic") or l:find("mythic")) and (l:find("enchant") or l:find("rune")) then
|
||
-- Try to pull the enchant name after a colon, else use the whole line
|
||
local name = txt
|
||
local after = txt:match("[::]%s*(.+)$")
|
||
if after and after ~= "" then name = after end
|
||
-- Trim color codes if any
|
||
name = name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
|
||
found = name
|
||
break
|
||
end
|
||
end
|
||
end
|
||
end
|
||
GameTooltip:Hide()
|
||
return found
|
||
end
|
||
|
||
function AE.CollectMysticEnchants()
|
||
local perSlot = {}
|
||
local activeSet = {}
|
||
for slot = 1, 19 do
|
||
local link = GetInventoryItemLink("player", slot)
|
||
if link then
|
||
local name = extract_mystic_from_tooltip(slot)
|
||
if name and name ~= "" then
|
||
table.insert(perSlot, { slot = slot, slotName = SLOT_NAMES[slot] or tostring(slot), name = name })
|
||
activeSet[name] = true
|
||
end
|
||
end
|
||
end
|
||
local active = {}
|
||
for n, _ in pairs(activeSet) do
|
||
table.insert(active, { name = n })
|
||
end
|
||
table.sort(active, function(a,b) return a.name < b.name end)
|
||
return { perSlot = perSlot, active = active }
|
||
end
|