@@ -44,20 +44,50 @@ local itemTypes = {
44
44
" flask" ,
45
45
" soulcore" ,
46
46
}
47
+ local function writeMods (out , statOrder )
48
+ local orders = { }
49
+ for order , _ in pairs (statOrder ) do
50
+ table.insert (orders , order )
51
+ end
52
+ table.sort (orders )
53
+ for _ , order in pairs (orders ) do
54
+ for _ , line in ipairs (statOrder [order ]) do
55
+ out :write (line , " \n " )
56
+ end
57
+ end
58
+ end
47
59
48
60
local uniqueMods = LoadModule (" ../Data/ModItemExlusive.lua" )
49
61
for _ , name in ipairs (itemTypes ) do
50
62
local out = io.open (" ../Data/Uniques/" .. name .. " .lua" , " w" )
63
+ local statOrder = {}
64
+ local postModLines = {}
65
+ local modLines = 0
66
+ local implicits
51
67
for line in io.lines (" Uniques/" .. name .. " .lua" ) do
52
- local specName , _ = line :match (" ^([%a ]+): (.+)$" )
53
- if not specName and line ~= " ]],[[" then
68
+ if implicits then -- remove 1 downs to 0
69
+ implicits = implicits - 1
70
+ end
71
+ local specName , specVal = line :match (" ^([%a ]+): (.+)$" )
72
+ if line :match (" ]]," ) then -- start new unique
73
+ writeMods (out , statOrder )
74
+ for _ , line in ipairs (postModLines ) do
75
+ out :write (line , " \n " )
76
+ end
77
+ out :write (line , " \n " )
78
+ statOrder = { }
79
+ postModLines = { }
80
+ modLines = 0
81
+ elseif not specName then
82
+ local prefix = " "
54
83
local variantString = line :match (" ({variant:[%d,]+})" )
55
84
local fractured = line :match (" ({fractured})" ) or " "
56
85
local modName , legacy = line :gsub (" {.+}" , " " ):match (" ^([%a%d_]+)([%[%]-,%d]*)" )
57
86
local mod = uniqueMods [modName ]
58
87
if mod then
88
+ modLines = modLines + 1
59
89
if variantString then
60
- out : write ( variantString )
90
+ prefix = prefix .. variantString
61
91
end
62
92
local tags = {}
63
93
if isValueInArray ({" amulet" , " ring" }, name ) then
@@ -68,9 +98,9 @@ for _, name in ipairs(itemTypes) do
68
98
end
69
99
end
70
100
if tags [1 ] then
71
- out : write ( " {tags:" .. table.concat (tags , " ," ) .. " }" )
101
+ prefix = prefix .. " {tags:" .. table.concat (tags , " ," ).. " }"
72
102
end
73
- out : write ( fractured )
103
+ prefix = prefix .. fractured
74
104
local legacyMod
75
105
if legacy ~= " " then
76
106
local values = { }
@@ -89,14 +119,34 @@ for _, name in ipairs(itemTypes) do
89
119
stats .Type = mod .Type
90
120
end
91
121
legacyMod = describeStats (stats )
122
+ end
123
+ for i , line in ipairs (legacyMod or mod ) do
124
+ local order = mod .statOrder [i ]
125
+ if statOrder [order ] then
126
+ table.insert (statOrder [order ], prefix .. line )
127
+ else
128
+ statOrder [order ] = { prefix .. line }
129
+ end
92
130
end
93
- out :write (table.concat (legacyMod or mod , " \n " .. (variantString or " " )), " \n " )
94
131
else
95
- out :write (line , " \n " )
132
+ if modLines > 0 then -- treat as post line e.g. mirrored
133
+ table.insert (postModLines , line )
134
+ else
135
+ out :write (line , " \n " )
136
+ end
96
137
end
97
138
else
139
+ if specName == " Implicits" then
140
+ implicits = tonumber (specVal )
141
+ end
98
142
out :write (line , " \n " )
99
143
end
144
+ if implicits and implicits == 0 then
145
+ writeMods (out , statOrder )
146
+ implicits = nil
147
+ statOrder = { }
148
+ modLines = 0
149
+ end
100
150
end
101
151
out :close ()
102
152
end
0 commit comments