Skip to content

Commit

Permalink
Merge pull request #18 from wowsims/tharre/fix-mage-talent-export
Browse files Browse the repository at this point in the history
Fix mage talent exports being broken
  • Loading branch information
kayla-glick authored Jun 10, 2024
2 parents 50e445e + 1d64415 commit 191ab67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions ExportStructures/Misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ end
---@return string
function Env.CreateTalentString()
local GetTalentRank = Env.GetTalentRankOrdered
local GetNumTalents = Env.GetNumTalentsFixed
local tabs = {}
for tab = 1, GetNumTalentTabs() do
local talents = {}
Expand Down
20 changes: 14 additions & 6 deletions extras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ do
temp[tab] = {}
local products = {}
for i = 1, GetNumTalents(tab) do
local name, _, tier, column = GetTalentInfo(tab, i)
local product = (tier - 1) * 4 + column
temp[tab][product] = i
table.insert(products, product)
local name, _, tier, column, _, _, _, avail, _ = GetTalentInfo(tab, i)
if avail then -- sometimes indices are empty ...
local product = (tier - 1) * 4 + column
temp[tab][product] = i
table.insert(products, product)
end
end

table.sort(products)

orderedTalentCache[tab] = {}
local j = 1
for _, product in ipairs(products) do
orderedTalentCache[tab][j] = temp[tab][product]
j = j + 1
if product then
orderedTalentCache[tab][j] = temp[tab][product]
j = j + 1
end
end
end
f:UnregisterEvent("SPELLS_CHANGED")
Expand All @@ -41,6 +45,10 @@ function Env.GetTalentRankOrdered(tab, num)
return select(5, GetTalentInfo(tab, orderedTalentCache[tab][num]))
end

function Env.GetNumTalentsFixed(tab)
return #orderedTalentCache[tab]
end

-- table extension contains
function table.contains(table, element)
for _, value in pairs(table) do
Expand Down

0 comments on commit 191ab67

Please sign in to comment.