Skip to content

Commit 45e09d3

Browse files
Fix bugs in unique updater scripts (PR PathOfBuildingCommunity#8700)
- Fix jewel radius regex: ^%[a ]+ is invalid Lua pattern syntax, corrected to ^[%a ]+ (character class of letters and spaces). This was breaking ALL jewel radius parsing, not just "Very Large". Also fixed inconsistency where line 448 used a different pattern. - Fix mod selection in uTextToMods.lua: split into two-pass approach (type match first, unused fallback second) with break statements to prevent non-type-matching mods from overwriting type matches. - Fix greedy gsub {.+} to non-greedy {.-} in both export scripts to prevent consuming too much text on lines with multiple brace groups. - Fix statOrder bounds in uModsToText.lua: guard against nil mod or mismatched line counts between legacy and current descriptions. Falls back to high order number to append at end. - Make usedMods local and hoist ModTextMap load outside the item type loop in uTextToMods.lua.
1 parent 395ccc7 commit 45e09d3

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

src/Classes/Item.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,13 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
444444
end
445445
end
446446
elseif specName == "Radius" and self.type == "Jewel" then
447-
self.jewelRadiusLabel = specVal:match("^%[a ]+")
448-
if specVal:match("^%a+") == "Variable" then
447+
self.jewelRadiusLabel = specVal:match("^[%a ]+")
448+
if specVal:match("^[%a ]+") == "Variable" then
449449
-- Jewel radius is variable and must be read from it's mods instead after they are parsed
450450
deferJewelRadiusIndexAssignment = true
451451
else
452452
for index, data in pairs(data.jewelRadius) do
453-
if specVal:match("^%[a ]+") == data.label then
453+
if specVal:match("^[%a ]+") == data.label then
454454
self.jewelRadiusIndex = index
455455
break
456456
end

src/Export/Scripts/uModsToText.lua

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ for _, name in ipairs(itemTypes) do
7979
local prefix = ""
8080
local variantString = line:match("({variant:[%d,]+})")
8181
local fractured = line:match("({fractured})") or ""
82-
local modName, legacy = line:gsub("{.+}", ""):match("^([%a%d_]+)([%[%]-,%d]*)")
82+
local modName, legacy = line:gsub("{.-}", ""):match("^([%a%d_]+)([%[%]-,%d]*)")
8383
local mod = uniqueMods[modName]
8484
if mod or (legacy and legacy ~= "") then
8585
modLines = modLines + 1
@@ -124,12 +124,15 @@ for _, name in ipairs(itemTypes) do
124124
ConPrintf("Warning: Could not find mod data for legacy mod '%s' in %s", modName, name)
125125
end
126126
end
127-
for i, line in ipairs(legacyMod or mod) do
128-
local order = mod.statOrder[i]
129-
if statOrder[order] then
130-
table.insert(statOrder[order], prefix..line)
131-
else
132-
statOrder[order] = { prefix..line }
127+
local modText = legacyMod or mod
128+
if modText then
129+
for i, line in ipairs(modText) do
130+
local order = mod and mod.statOrder and mod.statOrder[i] or (99999 + i)
131+
if statOrder[order] then
132+
table.insert(statOrder[order], prefix..line)
133+
else
134+
statOrder[order] = { prefix..line }
135+
end
133136
end
134137
end
135138
else

src/Export/Scripts/uTextToMods.lua

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,36 @@ local itemTypes = {
2929
-- "tincture",
3030
}
3131

32-
usedMods = {}
32+
local usedMods = {}
33+
local modTextMap = LoadModule("Uniques/ModTextMap.lua")
3334

3435
for _, name in pairs(itemTypes) do
35-
local modTextMap = LoadModule("Uniques/ModTextMap.lua")
3636
local out = io.open("Uniques/"..name..".lua", "w")
3737
for line in io.lines("../Data/Uniques/"..name..".lua") do
3838
local specName, specVal = line:match("^([%a ]+): (.+)$")
3939
if not specName and line ~= "]],[[" then
4040
local variants = line:match("{[vV]ariant:([%d,.]+)}")
4141
local fractured = line:match("({fractured})") or ""
42-
local modText = line:gsub("{.+}", ""):gsub("{.+}", ""):gsub("", "-") -- Clean EM dash
42+
local modText = line:gsub("{.-}", ""):gsub("\xe2\x80\x93", "-") -- Clean tag prefixes and EM dash
4343
local possibleMods = modTextMap[modText]
4444
local gggMod
4545
if possibleMods then
46+
-- First pass: prefer mods that match the item type
4647
for _, modName in ipairs(possibleMods) do
47-
if modName:lower():match(name) then -- prefer mods that match the item type
48-
gggMod = modName
49-
usedMods[modName] = true
50-
elseif not usedMods[modName] then -- prefer mods that haven't already been used
48+
if modName:lower():match(name) then
5149
gggMod = modName
5250
usedMods[modName] = true
51+
break
52+
end
53+
end
54+
-- Second pass: prefer mods that haven't already been used
55+
if not gggMod then
56+
for _, modName in ipairs(possibleMods) do
57+
if not usedMods[modName] then
58+
gggMod = modName
59+
usedMods[modName] = true
60+
break
61+
end
5362
end
5463
end
5564
if not gggMod then

0 commit comments

Comments
 (0)