Rework alltalents to be more user friendlier

This commit is contained in:
2025-03-28 16:33:08 +01:00
parent 38771b643e
commit 8f8f797a73

View File

@@ -90,72 +90,52 @@
- name: alltalents - name: alltalents
regex: <TalentTrees>(!any)</TalentTrees> regex: <TalentTrees>(!any)</TalentTrees>
lua: | lua: |
-- group by job, tier, identifier -- group by job
local talents = {} local subtrees = {}
local numtalents = 0
local lines = strsplit(s1, "\n") local lines = strsplit(s1, "\n")
local cookedlines = {} local cookedlines = {}
local currentTier = 0 local isInSubtree = false
local currentjob = nil local currentjob = nil
-- print(#lines)
for i, line in pairs(lines) do for i, line in pairs(lines) do
if line:match("<TalentTree jobidentifier=\"(%w+)\"") then if line:match("<TalentTree jobidentifier=\"(%w+)\"") then
currentjob = line:match("<TalentTree jobidentifier=\"(%w+)\"") currentjob = line:match("<TalentTree jobidentifier=\"(%w+)\"")
talents[currentjob] = talents[currentjob] or {} subtrees[currentjob] = subtrees[currentjob] or {}
-- print(currentjob)
currentTier = 0
end end
if line:find("<TalentOptions") then if line:find("<SubTree") then
currentTier = currentTier + 1 isInSubtree = true
talents[currentjob] = talents[currentjob] or {}
talents[currentjob][currentTier] = talents[currentjob][currentTier] or {}
end end
if line:find("</SubTree") then
local identifier = line:match("TalentOption identifier=\"(%w+)\"") isInSubtree = false
-- print(identifier) subtrees[currentjob][#subtrees[currentjob] + 1] = line
if identifier then end
numtalents = numtalents + 1 if isInSubtree then
--print(currentjob, currentTier, identifier) subtrees[currentjob][#subtrees[currentjob] + 1] = line
talents[currentjob][currentTier][identifier] = true
else else
-- Filter out the "TalentOption" lines if not line:find("SubTree") then
cookedlines[#cookedlines + 1] = line cookedlines[#cookedlines + 1] = line
end
end end
end end
--DumpTable(talents)
currentTier = 0
currentjob = nil currentjob = nil
local alltalents = {} local alltalents = {}
for lineidx, line in pairs(cookedlines) do for i, line in pairs(cookedlines) do
alltalents[#alltalents + 1] = line
if line:match("<TalentTree jobidentifier=\"(%w+)\"") then if line:match("<TalentTree jobidentifier=\"(%w+)\"") then
currentjob = line:match("<TalentTree jobidentifier=\"(%w+)\"") currentjob = line:match("<TalentTree jobidentifier=\"(%w+)\"")
talents[currentjob] = talents[currentjob] or {}
-- print(currentjob)
currentTier = 0
end
if line:find("<TalentOptions") then currentTier = currentTier + 1 end
alltalents[#alltalents + 1] = line
if currentTier > 0 and line:find("<TalentOptions") then if currentjob then
local currentIndent = line:match("^%s*") for job, subtree in pairs(subtrees) do
for _, job in pairs(talents) do alltalents[#alltalents + 1] = table.concat(subtree, "\n")
--print(currentTier, job[currentTier])
if not job[currentTier] then
print("no tier ??? at " .. currentTier .. " for " .. currentjob)
end
for talentid, _ in pairs(job[currentTier]) do
-- print(talent)
local talent = "<TalentOption identifier=\"" .. talentid .. "\" />"
alltalents[#alltalents + 1] = currentIndent .. talent
end end
end end
end end
end end
s1 = table.concat(alltalents, "\n") s1 = table.concat(alltalents, "\n")
files: files:
- "**/TalentTrees.xml" - "Content/**/TalentTrees.xml"
- name: talenttrees - name: talenttrees
regex: (<TalentOptions!any>!any</TalentOptions>) regex: (<TalentOptions!any>!any</TalentOptions>)