94f6f55fb6
- 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.
63 lines
1.8 KiB
Lua
63 lines
1.8 KiB
Lua
-- AscensionExporter - Talents collector (active spec only)
|
|
|
|
-- Ensure global addon table exists even if load order varies
|
|
AscensionExporter = _G.AscensionExporter or {}
|
|
_G.AscensionExporter = AscensionExporter
|
|
local AE = AscensionExporter
|
|
|
|
local function get_active_group()
|
|
if GetActiveTalentGroup then
|
|
local g = GetActiveTalentGroup()
|
|
if g == 0 then g = 1 end
|
|
return g or 1
|
|
end
|
|
return 1
|
|
end
|
|
|
|
local function collect_selected_for_tab(tabIndex, talentGroup)
|
|
local arr = {}
|
|
local numTalents = GetNumTalents(tabIndex)
|
|
for talentIndex = 1, numTalents do
|
|
local name, _, _, _, rank, maxRank = GetTalentInfo(tabIndex, talentIndex, false, false, talentGroup)
|
|
if rank and rank > 0 then
|
|
local link = GetTalentLink(tabIndex, talentIndex)
|
|
local spellId = 0
|
|
if link then
|
|
spellId = tonumber(string.match(link, "talent:(%d+)")) or 0
|
|
end
|
|
table.insert(arr, {
|
|
tabIndex = tabIndex,
|
|
talentIndex = talentIndex,
|
|
name = name or "",
|
|
rank = rank or 0,
|
|
maxRank = maxRank or 0,
|
|
spellId = spellId,
|
|
})
|
|
end
|
|
end
|
|
return arr
|
|
end
|
|
|
|
function AE.CollectTalents()
|
|
local active = get_active_group()
|
|
local out = {
|
|
activeTalentGroup = active,
|
|
selected = {},
|
|
}
|
|
|
|
local numTabs = GetNumTalentTabs()
|
|
for tabIndex = 1, numTabs do
|
|
local tabName, _, pointsSpent = GetTalentTabInfo(tabIndex, false, false, active)
|
|
-- Only export selected ranks for the active group
|
|
local selected = collect_selected_for_tab(tabIndex, active)
|
|
for _, v in ipairs(selected) do
|
|
table.insert(out.selected, v)
|
|
end
|
|
end
|
|
|
|
return out
|
|
end
|
|
|
|
-- Mark module as loaded for debug visibility
|
|
AE._loadedTalents = true
|