From 2875830962a2f72d3341856020bc6bc20db3bbc8 Mon Sep 17 00:00:00 2001 From: Florian Berthold Date: Mon, 8 Dec 2025 18:43:46 +0100 Subject: [PATCH] Enhance talent collection with debug output and Ascension API integration - Added detailed debug logs for talent collection, including tab and talent-level data. - Integrated Ascension-specific talent export API (`C_CharacterAdvancement.ExportBuild`) as a primary method. - Implemented fallback using standard WoW API for non-Ascension servers. - Improved handling of unselected talents with descriptive messages. --- AscensionExporter/Collectors/Talents.lua | 80 ++++++++++++++++++++++-- AscensionExporter/Core.lua | 19 +++++- 2 files changed, 92 insertions(+), 7 deletions(-) diff --git a/AscensionExporter/Collectors/Talents.lua b/AscensionExporter/Collectors/Talents.lua index bf0d673..83eead8 100644 --- a/AscensionExporter/Collectors/Talents.lua +++ b/AscensionExporter/Collectors/Talents.lua @@ -16,9 +16,43 @@ end local function collect_selected_for_tab(tabIndex, talentGroup) local arr = {} + local debug = {} local numTalents = GetNumTalents(tabIndex) + for talentIndex = 1, numTalents do - local name, _, _, _, rank, maxRank = GetTalentInfo(tabIndex, talentIndex, false, false, talentGroup) + -- Ascension API signature test - try different parameter combinations + local name, iconTexture, tier, column, rank, maxRank, isExceptional, available + + -- Standard WoW API: GetTalentInfo(tabIndex, talentIndex, inspect, pet, talentGroup) + -- Try 1: Just tab and talent index + name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(tabIndex, talentIndex) + + -- Try 2: With nil for inspect/pet + if rank == 0 or rank == nil then + name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(tabIndex, talentIndex, nil, nil, talentGroup) + end + + -- Try 3: With explicit false for inspect/pet + if rank == 0 or rank == nil then + name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(tabIndex, talentIndex, false, nil, talentGroup) + end + + -- Try 4: No talentGroup at all + if rank == 0 or rank == nil then + name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(tabIndex, talentIndex, false, false) + end + + -- Debug first few of each tab to see what we're getting + if tabIndex == 3 and talentIndex <= 5 then + table.insert(debug, string.format("tab%d [%d]: %s rank=%s/%s tier=%s col=%s", + tabIndex, talentIndex, tostring(name), tostring(rank), tostring(maxRank), tostring(tier), tostring(column))) + end + + -- Debug: scan ALL talents looking for any with rank > 0 + if rank and rank > 0 then + table.insert(debug, string.format("FOUND: tab%d talent%d: name=%s rank=%d/%d", tabIndex, talentIndex, tostring(name), rank, maxRank)) + end + if rank and rank > 0 then local link = GetTalentLink(tabIndex, talentIndex) local spellId = 0 @@ -35,21 +69,57 @@ local function collect_selected_for_tab(tabIndex, talentGroup) }) end end - return arr + return arr, debug end function AE.CollectTalents() - local active = get_active_group() local out = { - activeTalentGroup = active, selected = {}, + debug = {}, + buildString = nil, } + -- Use Ascension's native talent export API + if C_CharacterAdvancement and C_CharacterAdvancement.ExportBuild then + local buildString = C_CharacterAdvancement.ExportBuild(true) + out.buildString = buildString + table.insert(out.debug, "Ascension API: C_CharacterAdvancement.ExportBuild() = " .. tostring(buildString)) + + -- For now, we'll store the build string and parse it later + -- The build string format is Ascension's native format + if buildString and buildString ~= "" then + out.hasTalents = true + end + + return out + end + + -- Fallback to standard WoW API (for non-Ascension servers) + local active = get_active_group() + out.activeTalentGroup = active + local numTabs = GetNumTalentTabs() + table.insert(out.debug, "Fallback: using GetNumTalentTabs, numTabs=" .. tostring(numTabs)) + for tabIndex = 1, numTabs do local tabName, _, pointsSpent = GetTalentTabInfo(tabIndex, false, false, active) + table.insert(out.debug, string.format("tab%d: name=%s points=%d", tabIndex, tostring(tabName), tonumber(pointsSpent) or 0)) + + local numTalents = GetNumTalents(tabIndex) + table.insert(out.debug, string.format("tab%d: numTalents=%d", tabIndex, numTalents)) + -- Only export selected ranks for the active group - local selected = collect_selected_for_tab(tabIndex, active) + local selected, talentDebug = collect_selected_for_tab(tabIndex, active) + + -- Add talent-level debug info + if talentDebug then + for _, msg in ipairs(talentDebug) do + table.insert(out.debug, msg) + end + end + + table.insert(out.debug, string.format("tab%d: collected=%d talents", tabIndex, #selected)) + for _, v in ipairs(selected) do table.insert(out.selected, v) end diff --git a/AscensionExporter/Core.lua b/AscensionExporter/Core.lua index e658d85..3c95f97 100644 --- a/AscensionExporter/Core.lua +++ b/AscensionExporter/Core.lua @@ -345,8 +345,11 @@ function AE:GenerateMarkdownTalents() local lines = {} table.insert(lines, "## Talents\n") - if #(talents.selected or {}) == 0 then - table.insert(lines, "*No talents selected.*\n") + -- Count talents + local count = #(talents.selected or {}) + + if count == 0 then + table.insert(lines, "*No talents selected. Make sure you have spent talent points on your character.*\n") return table.concat(lines, "\n") end @@ -412,6 +415,18 @@ SlashCmdList["ASCX"] = function(msg) local t = SafeCall(AE.CollectTalents) or {} local n = #(t.selected or {}) add(string.format("Talents: OK, selected=%d", n)) + -- Show debug info + if t.debug then + for _, msg in ipairs(t.debug) do + add(" " .. msg) + end + end + -- Show raw talent data for debugging + if n > 0 then + for i, tal in ipairs(t.selected) do + add(string.format(" [%d] tab=%d idx=%d rank=%d/%d name=%s", i, tal.tabIndex or 0, tal.talentIndex or 0, tal.rank or 0, tal.maxRank or 0, tal.name or "?")) + end + end else add("Talents: MISSING function") end