Files
ascension-char-exporter/AscensionExporter/Collectors/Enchants.lua
T
florian.berthold 94f6f55fb6 Add installation script and enhance addon functionality
- Introduced `install_addon_sub.sh` to automate addon installation.
- Improved argument normalization with a new `Norm` helper function.
- Added debug command for enhanced diagnostics and collector status visibility.
- Ensured global addon table initialization for flexible load order.
- Marked modules as loaded for better debug tracking.
- Fixed TOC path formatting for Windows compatibility.
- Updated `.gitignore` rules for IDE folders.
2025-12-08 15:25:07 +01:00

66 lines
2.4 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)
-- Ensure global addon table exists even if load order varies
AscensionExporter = _G.AscensionExporter or {}
_G.AscensionExporter = AscensionExporter
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
-- Mark module as loaded for debug visibility
AE._loadedEnchants = true