-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-final-fixes.lua
More file actions
312 lines (295 loc) · 14.1 KB
/
data-final-fixes.lua
File metadata and controls
312 lines (295 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
local categories = { "default" }
local infinity_categories = {}
local pipes = {}
local blacklist = {
["black-pipe"] = true,
["4-to-4-pipe"] = true
}
local function unify(t)
return type(t) == "table" and t or {t}
end
local function has_default_category(pipe_connection)
if pipe_connection.connection_category == nil or #pipe_connection.connection_category == 0 then return true end
pipe_connection.connection_category = unify(pipe_connection.connection_category)
for _, category in pairs(pipe_connection.connection_category) do
if category == "default" then return true end
end
return false
end
local function contains_default_category(pipe_connections)
for _, pipe_connection in pairs(pipe_connections) do
if has_default_category(pipe_connection) then return true end
end
return false
end
if mods["plasma-duct"] then
data.raw.pipe["plasma-duct"].npt_compat = { ignore = true }
end
if mods["RGBPipes"] then
categories = {
"default",
"red-pipe-machine-connection",
"yellow-pipe-machine-connection",
"green-pipe-machine-connection",
"teal-pipe-machine-connection",
"blue-pipe-machine-connection",
"purple-pipe-machine-connection"
}
blacklist = {
["black-pipe"] = true,
["red-pipe"] = true,
["yellow-pipe"] = true,
["green-pipe"] = true,
["teal-pipe"] = true,
["blue-pipe"] = true,
["purple-pipe"] = true,
["4-to-4-pipe"] = true
}
end
-- collect pipe types
for p, pipe in pairs(data.raw.pipe) do
if pipe.npt_compat and pipe.npt_compat.tag then
local tag = pipe.npt_compat.mod .. "-" .. pipe.npt_compat.tag
pipes[#pipes+1] = tag
infinity_categories[tag] = true
if not blacklist[p] then
categories[#categories+1] = tag
end
elseif not pipe.npt_compat or not pipe.npt_compat.ignore then
pipes[#pipes+1] = p
infinity_categories[p] = true
if not blacklist[p] and contains_default_category(pipe.fluid_box.pipe_connections) then
categories[#categories+1] = p
end
end
end
-- do after pipe category collection to reduce reduntant categories
if mods["Flow Control"] then
data.raw["storage-tank"]["pipe-junction"].npt_compat = {override = "pipe"}
data.raw["storage-tank"]["pipe-elbow"].npt_compat = {override = "pipe"}
data.raw["storage-tank"]["pipe-straight"].npt_compat = {override = "pipe"}
end
-- do after pipe category collection to reduce reduntant categories
if mods["pipe_plus"] then
data.raw["pipe-to-ground"]["pipe-to-ground-2"].npt_compat = {override = "pipe", override_underground = "pipe-to-ground"}
data.raw["pipe-to-ground"]["pipe-to-ground-3"].npt_compat = {override = "pipe", override_underground = "pipe-to-ground"}
data.raw["pipe-to-ground"]["pipe-to-ground-north"].npt_compat = {override = "pipe", override_underground = "pipe-to-ground"}
data.raw["pipe-to-ground"]["pipe-to-ground-east"].npt_compat = {override = "pipe", override_underground = "pipe-to-ground"}
data.raw["pipe-to-ground"]["pipe-to-ground-south"].npt_compat = {override = "pipe", override_underground = "pipe-to-ground"}
data.raw["pipe-to-ground"]["pipe-to-ground-west"].npt_compat = {override = "pipe", override_underground = "pipe-to-ground"}
end
-- all prototypes with fluidboxes
local prototypes = {
"pump",
"storage-tank",
"assembling-machine",
"rocket-silo",
"furnace",
"boiler",
"fluid-turret",
"mining-drill",
"offshore-pump",
"generator",
"fusion-generator",
"fusion-reactor",
"thruster",
"inserter",
"agricultural-tower",
"lab",
"radar",
"reactor",
"loader",
"valve"
}
for _, prototype_category in pairs(prototypes) do
for _, prototype in pairs(data.raw[prototype_category] or {}) do
local fluid_boxes = {}
-- multiple fluid_boxes
for _, fluid_box in pairs(prototype.fluid_boxes or {}) do
fluid_boxes[#fluid_boxes + 1] = fluid_box
end
-- single fluid_box
if prototype.fluid_box then fluid_boxes[#fluid_boxes + 1] = prototype.fluid_box end
-- input fluid_box
if prototype.input_fluid_box then fluid_boxes[#fluid_boxes + 1] = prototype.input_fluid_box end
-- output fluid_box
if prototype.output_fluid_box then fluid_boxes[#fluid_boxes + 1] = prototype.output_fluid_box end
-- fuel fluid_box
if prototype.fuel_fluid_box then fluid_boxes[#fluid_boxes + 1] = prototype.fuel_fluid_box end
-- oxidizer fluid_box
if prototype.oxidizer_fluid_box then fluid_boxes[#fluid_boxes + 1] = prototype.oxidizer_fluid_box end
-- energy source fluid_box
if prototype.energy_source and prototype.energy_source.type == "fluid" then fluid_boxes[#fluid_boxes + 1] = prototype.energy_source.fluid_box end
-- change!
for f, fluid_box in pairs(fluid_boxes) do
if type(fluid_box) == "table" and contains_default_category(fluid_box.pipe_connections) then
for _, pipe_connection in pairs(fluid_box.pipe_connections or {}) do
if not prototype.npt_compat and not has_default_category(pipe_connection) then
-- ignore if doesn't have the default category (custom connections, like plasma)
pipe_connection.connection_category = unify(pipe_connection.connection_category)
for _, category in pairs(pipe_connection.connection_category) do
infinity_categories[category] = true -- add to the infinity pipe categories
end
elseif not prototype.npt_compat and has_default_category(pipe_connection) then
local connection_category = {}
for _, category in pairs(categories) do
connection_category[#connection_category + 1] = category
end
pipe_connection.connection_category = connection_category
if pipe_connection.connection_type == "underground" then pipe_connection.connection_category = "pipe-to-ground" end
elseif prototype.npt_compat then -- manual compat of some variety
if prototype.npt_compat.tag then
pipe_connection.connection_category = { prototype.npt_compat.mod .. "-" .. prototype.npt_compat.tag }
elseif prototype.npt_compat.mod == "afh" then
pipe_connection.connection_category = "afh-underground-" .. prototype.npt_compat.tier
elseif prototype.npt_compat.override or prototype.npt_compat.override_underground then
if pipe_connection.connection_type ~= "underground" then
pipe_connection.connection_category = prototype.npt_compat.override or nil
else
pipe_connection.connection_category = prototype.npt_compat.override_underground or nil
end
end
-- otherwise, ignore
end
end
else -- has no normal connection, so must have some fancy connections
for _, pipe_connection in pairs(fluid_box.pipe_connections) do
pipe_connection.connection_category = unify(pipe_connection.connection_category)
for _, category in pairs(pipe_connection.connection_category) do
infinity_categories[category] = true -- add to the infinity pipe categories
end
end
end
end
prototype.npt_compat = nil
end
end
for p, pipe in pairs(data.raw.pipe) do
if pipe.npt_compat == nil and contains_default_category(pipe.fluid_box.pipe_connections) then
for _, pipe_connection in pairs(pipe.fluid_box.pipe_connections) do
if has_default_category(pipe_connection) then
pipe_connection.connection_category = { p }
if mods["RGBPipes"] and (p == "red-pipe" or p == "yellow-pipe" or p == "green-pipe" or p == "teal-pipe" or p == "blue-pipe" or p == "purple-pipe") then
pipe_connection.connection_category[#pipe_connection.connection_category + 1] = p .. "-machine-connection"
end
if mods["RGBPipes"] and p == "black-pipe" then
pipe_connection.connection_category = {
"red-pipe",
"yellow-pipe",
"green-pipe",
"teal-pipe",
"blue-pipe",
"purple-pipe"
}
end
end
end
for u, underground in pairs(data.raw["pipe-to-ground"]) do
if u:sub(1,-11) == p and contains_default_category(underground.fluid_box.pipe_connections) then
for i, pipe_connection in pairs(underground.fluid_box.pipe_connections) do
if pipe_connection.connection_type ~= "underground" and has_default_category(pipe_connection) then
pipe_connection.connection_category = table.deepcopy(pipe.fluid_box.pipe_connections[1].connection_category)
elseif pipe_connection.connection_type == "underground" and has_default_category(pipe_connection) then
pipe_connection.connection_category = u
end
end
underground.solved_by_npt = true
break
end
end
elseif pipe.npt_compat and pipe.npt_compat.ignore then
-- do nothing
elseif pipe.npt_compat and pipe.npt_compat.tag then
for _, pipe_connection in pairs(pipe.fluid_box.pipe_connections) do
pipe_connection.connection_category = { pipe.npt_compat.mod .. "-" .. pipe.npt_compat.tag }
end
elseif pipe.npt_compat and (pipe.npt_compat.override or pipe.npt_compat.override_underground) then
for _, pipe_connection in pairs(pipe.fluid_box.pipe_connections) do
if pipe_connection.connection_type ~= "underground" then
pipe_connection.connection_category = pipe.npt_compat.override or nil
else
pipe_connection.connection_category = pipe.npt_compat.override_underground or nil
end
end
end
pipe.npt_compat = nil
end
-- update locale
if mods["RGBPipes"] then
data.raw.pipe["red-pipe"].localised_description = "Connects to Black pipes and machines"
data.raw.pipe["yellow-pipe"].localised_description = "Connects to Black pipes and machines"
data.raw.pipe["green-pipe"].localised_description = "Connects to Black pipes and machines"
data.raw.pipe["teal-pipe"].localised_description = "Connects to Black pipes and machines"
data.raw.pipe["blue-pipe"].localised_description = "Connects to Black pipes and machines"
data.raw.pipe["purple-pipe"].localised_description = "Connects to Black pipes and machines"
data.raw.pipe["pipe"].localised_description = "(White) Does not connect to colored pipes, only machines"
data.raw["pipe-to-ground"]["red-pipe-to-ground"].localised_description = "Connects to Black pipes and machines"
data.raw["pipe-to-ground"]["yellow-pipe-to-ground"].localised_description = "Connects to Black pipes and machines"
data.raw["pipe-to-ground"]["green-pipe-to-ground"].localised_description = "Connects to Black pipes and machines"
data.raw["pipe-to-ground"]["teal-pipe-to-ground"].localised_description = "Connects to Black pipes and machines"
data.raw["pipe-to-ground"]["blue-pipe-to-ground"].localised_description = "Connects to Black pipes and machines"
data.raw["pipe-to-ground"]["purple-pipe-to-ground"].localised_description = "Connects to Black pipes and machines"
data.raw["pipe-to-ground"]["pipe-to-ground"].localised_description = "(White) Does not connect to colored pipes, only machines"
end
-- check for other tyoes if underground pipes
for u, underground in pairs(data.raw["pipe-to-ground"]) do
if underground.npt_compat and underground.npt_compat.mod == "afh" then
-- handle advanced fluid handling pipes
for _, pipe_connection in pairs(underground.fluid_box.pipe_connections) do
if pipe_connection.connection_type ~= "underground" then
-- generic pipe connection, should connect to everything
pipe_connection.connection_category = unify(pipe_connection.connection_category)
for _, pipe_category in pairs(pipes) do
pipe_connection.connection_category[#pipe_connection.connection_category+1] = pipe_category
end
else
pipe_connection.connection_category = "afh-underground-" .. underground.npt_compat.tier
end
end
elseif underground.npt_compat and underground.npt_compat.tag then
-- handle specific compatability
for _, pipe_connection in pairs(underground.fluid_box.pipe_connections) do
pipe_connection.connection_category = underground.npt_compat.mod .. "-" .. underground.npt_compat.tag
end
elseif underground.npt_compat and (underground.npt_compat.override or underground.npt_compat.override_underground) then
for _, pipe_connection in pairs(underground.fluid_box.pipe_connections) do
if pipe_connection.connection_type ~= "underground" then
pipe_connection.connection_category = underground.npt_compat.override or nil
else
pipe_connection.connection_category = underground.npt_compat.override_underground or nil
end
end
elseif not underground.solved_by_npt and not (underground.npt_compat and underground.npt_compat.ignore) and not contains_default_category(underground.fluid_box.pipe_connections) then
for _, pipe_connection in pairs(underground.fluid_box.pipe_connections) do
if pipe_connection.connection_type ~= "underground" then
-- generic pipe connection, should connect to everything
pipe_connection.connection_category = unify(pipe_connection.connection_category)
for _, pipe_category in pairs(pipes) do
pipe_connection.connection_category[#pipe_connection.connection_category+1] = pipe_category
end
else -- type is underground
pipe_connection.connection_category = "pipe-to-ground"
end
end
end
underground.solved_by_npt = nil
if not mods["the-one-mod-with-underground-bits"] then
underground.npt_compat = nil
end
end
-- add all the things to infinity pipes, only adds categories and doesn't remove them
for _, pipe in pairs(data.raw["infinity-pipe"]) do
local infinity_categories = infinity_categories -- duplicate for local manipulation
for _, pipe_connection in pairs(pipe.fluid_box.pipe_connections) do
pipe_connection.connection_category = unify(pipe_connection.connection_category)
for _, category in pairs(pipe_connection.connection_category) do
infinity_categories[category] = nil -- remove already existing categories
end
end
for _, pipe_connection in pairs(pipe.fluid_box.pipe_connections) do
-- now add new categories
for category in pairs(infinity_categories) do
pipe_connection.connection_category[#pipe_connection.connection_category+1] = category
end
end
end