3b272c47c8
- Removed tooltip-based enchant parsing logic due to complexity and inconsistent results. - Simplified gear collection by discarding enchant-related data.
88 lines
3.0 KiB
Lua
88 lines
3.0 KiB
Lua
-- AscensionExporter - Gear collector (equipped items only)
|
|
|
|
-- 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 parse_item_link(itemLink)
|
|
if not itemLink then return nil end
|
|
local itemString = itemLink:match("Hitem:([%d:]+)")
|
|
if not itemString then return nil end
|
|
local parts = {}
|
|
for v in string.gmatch(itemString, "([^:]+)") do
|
|
parts[#parts+1] = tonumber(v) or 0
|
|
end
|
|
local itemId = parts[1] or 0
|
|
local enchantId = parts[2] or 0
|
|
local gems = { parts[3] or 0, parts[4] or 0, parts[5] or 0, parts[6] or 0 }
|
|
local suffixId = parts[7] or 0
|
|
return {
|
|
itemId = itemId,
|
|
enchantId = enchantId,
|
|
gems = gems,
|
|
suffixId = suffixId,
|
|
}
|
|
end
|
|
|
|
local function resolve_gems(itemLink, gemIds)
|
|
local arr = {}
|
|
for i = 1, 4 do
|
|
local gid = gemIds[i] or 0
|
|
if gid and gid > 0 then
|
|
-- GetItemGem gives name & link by index
|
|
local name, gemLink = GetItemGem(itemLink, i)
|
|
local gemItemId = 0
|
|
if gemLink then
|
|
local id = tonumber(string.match(gemLink, "item:(%d+)"))
|
|
if id then gemItemId = id end
|
|
end
|
|
-- gid from item link is the socket gem enchantId; expose it explicitly
|
|
table.insert(arr, { itemId = gemItemId, enchantId = gid, name = name or "", link = gemLink or "" })
|
|
end
|
|
end
|
|
return arr
|
|
end
|
|
|
|
function AE.CollectGear()
|
|
local out = { slots = {} }
|
|
for slot = 1, 19 do
|
|
local itemLink = GetInventoryItemLink("player", slot)
|
|
if itemLink then
|
|
local parsed = parse_item_link(itemLink) or {}
|
|
local itemId = parsed.itemId or 0
|
|
local itemName, _, itemQuality, itemLevel, _, itemType, itemSubType, _, equipSlot, texture = GetItemInfo(itemLink)
|
|
|
|
local gems = resolve_gems(itemLink, parsed.gems or {})
|
|
|
|
table.insert(out.slots, {
|
|
slot = slot,
|
|
slotName = SLOT_NAMES[slot] or tostring(slot),
|
|
itemId = itemId,
|
|
name = itemName or "",
|
|
quality = itemQuality or 0,
|
|
itemLevel = itemLevel or 0,
|
|
type = itemType or "",
|
|
subType = itemSubType or "",
|
|
equipSlot = equipSlot or "",
|
|
texture = texture or "",
|
|
link = itemLink,
|
|
gems = gems,
|
|
})
|
|
else
|
|
-- Empty slot omitted intentionally
|
|
end
|
|
end
|
|
return out
|
|
end
|
|
|
|
-- Mark module as loaded for debug visibility
|
|
AE._loadedGear = true
|