Files
ascension-char-exporter/AscensionExporter/Collectors/Enchants.lua
T
florian.berthold 06704f628f Add fallback export UI and improve gem data handling
- Implemented a fallback lightweight export window for cases where the UI module is not loaded.
- Abstracted export display logic into a unified `ShowExport` function.
- Added gem `enchantId` to gem data for better clarity.
2025-12-08 14:03:52 +01:00

60 lines
2.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 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:ClearLines()
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