Files
barotrauma-gamefiles/cooktalents.yml
2025-03-28 22:51:52 +01:00

99 lines
2.8 KiB
YAML

- name: talentnoblocks
isolate: true
regex: (\s?blocks="[^"]+")
lua: |
s1 = ""
files:
- "Content/**/TalentTrees.xml"
- name: maxchosentalents
isolate: true
regex: (<TalentOptions!any</TalentOptions>)
lua: |
local talentOptions = 0
local lines = strsplit(s1, "\n")
for i, line in pairs(lines) do
if string.find(line, "<TalentOption ") then
talentOptions = talentOptions + 1
end
end
if lines[1]:find("maxchosentalents") then
--print("maxchosentalents found, updating")
local optionsElement = lines[1]
optionsElement = optionsElement:gsub("maxchosentalents=\"%d+\"", "maxchosentalents=\"" .. talentOptions .. "\"")
replacement = s1:gsub(lines[1], optionsElement)
return false
end
print("maxchosentalents not found, creating")
local optionsElement = lines[1]
local optionsElement = optionsElement:gsub("<TalentOptions", "<TalentOptions maxchosentalents=\"" .. talentOptions .. "\"")
replacement = s1:gsub(lines[1], optionsElement)
files:
- "Content/**/TalentTrees.xml"
- name: norequiredtalents
isolate: true
regex: (?-s)(<TalentOptions )(?:!anyrequiredtalents="(?<requiredtalents>!num)")?
lua: |
if requiredtalents then
requiredtalents = 1
else
print("requiredtalents not found, creating")
replacement = s1 .. "requiredtalents=\"1\" "
end
files:
- "Content/**/TalentTrees.xml"
- name: alltalents
isolate: true
regex: <TalentTrees>(!any)</TalentTrees>
lua: |
-- group by job
local subtrees = {}
local lines = strsplit(s1, "\n")
local cookedlines = {}
local isInSubtree = false
local currentjob = nil
for i, line in pairs(lines) do
if line:match("<TalentTree jobidentifier=\"(%w+)\"") then
currentjob = line:match("<TalentTree jobidentifier=\"(%w+)\"")
subtrees[currentjob] = subtrees[currentjob] or {}
end
if line:find("<SubTree") then
isInSubtree = true
end
if line:find("</SubTree") then
isInSubtree = false
subtrees[currentjob][#subtrees[currentjob] + 1] = line
end
if isInSubtree then
subtrees[currentjob][#subtrees[currentjob] + 1] = line
else
if not line:find("SubTree") then
cookedlines[#cookedlines + 1] = line
end
end
end
currentjob = nil
local alltalents = {}
for i, line in pairs(cookedlines) do
alltalents[#alltalents + 1] = line
if line:match("<TalentTree jobidentifier=\"(%w+)\"") then
currentjob = line:match("<TalentTree jobidentifier=\"(%w+)\"")
if currentjob then
for job, subtree in pairs(subtrees) do
alltalents[#alltalents + 1] = table.concat(subtree, "\n")
end
end
end
end
s1 = table.concat(alltalents, "\n")
files:
- "Content/**/TalentTrees.xml"