forked from pyanodon/pypostprocessing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata-final-fixes.lua
332 lines (287 loc) · 9.85 KB
/
data-final-fixes.lua
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
local dev_mode = settings.startup["pypp-dev-mode"].value
local create_cache_mode = settings.startup["pypp-create-cache"].value
require('__stdlib__/stdlib/data/data').Util.create_data_globals()
local table = require('__stdlib__/stdlib/utils/table')
local config = require "prototypes.config"
for _, module in pairs(data.raw.module) do
local remove_recipe = {}
for _, r in pairs(module.limitation or {}) do
if not data.raw.recipe[r] then
remove_recipe[r] = true
end
end
if not table.is_empty(remove_recipe) then
local limit = table.array_to_dictionary(module.limitation, true)
for r, _ in pairs(remove_recipe) do
limit[r] = nil
end
module.limitation = table.keys(limit)
end
remove_recipe = {}
for _, r in pairs(module.limitation_blacklist or {}) do
if not data.raw.recipe[r] then
remove_recipe[r] = true
end
end
if not table.is_empty(remove_recipe) then
local limit = table.array_to_dictionary(module.limitation_blacklist, true)
for r, _ in pairs(remove_recipe) do
limit[r] = nil
end
module.limitation_blacklist = table.keys(limit)
end
end
for _, recipe in pairs(data.raw.recipe) do
recipe.always_show_products = true
recipe.always_show_made_in = true
if recipe.results or recipe.result then
if not recipe.results then
recipe.results = {{name = recipe.result, amount = recipe.result_count or 1, type = 'item'}}
recipe.result = nil
recipe.result_count = nil
end
for i, result in pairs(recipe.results) do
local name = result.name or result[1]
local amount = result.amount or result[2]
if name and config.NON_PRODDABLE_ITEMS[name] and not result.catalyst_amount then
if result[1] then
recipe.results[i] = {type = result.type or 'item', name = name, amount = amount, catalyst_amount = amount}
else
result.catalyst_amount = amount
end
end
end
end
end
-------------------------------------------
-- Resource category locale builder --
-------------------------------------------
-- List below only includes py resource category names
local category_data = {
--borax = {'raw-borax', 'ore-quartz'}
['borax'] = {''},
['niobium'] = {''},
['volcanic-pipe'] = {''},
['molybdenum'] = {''},
['regolite'] = {''},
['ore-quartz'] = {''},
['salt-rock'] = {''},
['phosphate-rock-02'] = {''},
['iron-rock'] = {''},
['coal-rock'] = {''},
['lead-rock'] = {''},
['quartz-rock'] = {''},
['aluminium-rock'] = {''},
['chromium-rock'] = {''},
['copper-rock'] = {''},
['nexelit-rock'] = {''},
['nickel-rock'] = {''},
['tin-rock'] = {''},
['titanium-rock'] = {''},
['uranium-rock'] = {''},
['zinc-rock'] = {''},
['phosphate'] = {''},
['rare-earth'] = {''},
['oil-sand'] = {''},
['oil-mk01'] = {''},
['oil-mk02'] = {''},
['tar-patch'] = {''},
['sulfur-patch'] = {''},
['oil-mk03'] = {''},
['oil-mk04'] = {''},
['bitumen-seep'] = {''},
['natural-gas'] = {''},
['ralesia-flowers'] = {''},
['tuuphra-tuber'] = {''},
['rennea-flowers'] = {''},
['grod-flower'] = {''},
['yotoi-tree'] = {''},
['yotoi-tree-fruit'] = {''},
['kicalk-tree'] = {''},
['arum'] = {''},
['ore-bioreserve'] = {''},
['ore-nexelit'] = {''},
['geothermal-crack'] = {''},
['ree'] = {''},
['antimonium'] = {''},
['mova'] = {''}
}
for resource, proto in pairs(data.raw.resource) do
local category_name = proto.category or 'basic-solid'
local entry = category_data[category_name]
if entry then
-- Add our autoplace control name which helpfully has the icon
entry[#entry+1] = {
'?',
{
'',
#entry > 1 and ', ' or '',
{
'?',
{
'autoplace-control-names.' .. resource
},
{
'',
'[img=entity.' .. resource .. ']',
{'entity-name.' .. resource}
}
}
}
}
end
end
for category_name, proto in pairs(data.raw['resource-category']) do
local resource_list = category_data[category_name]
if resource_list then
-- Just one entry besides the string concat
if #resource_list == 2 then
-- resource name, not autoplace - no icon. absolutely cursed indexing.
local ore_locale = resource_list[2][2][3][3][3][1]
-- {'!'} here just functions to tell '?' to skip the entry
proto.localised_name = {'?', proto.localised_name or {'!'}, {ore_locale}}
-- resource description just transposed here
ore_locale = ore_locale:gsub('%-name%.', '-description.')
proto.localised_description = {'?', proto.localised_description or {'!'}, {ore_locale}}
else
proto.localised_description = {
'?',
{
'',
proto.localised_description or {'resource-category-description.' .. category_name},
'\n',
resource_list
},
resource_list
}
end
end
end
-- End resource category locale builder
local function create_tmp_tech(recipe, original_tech, add_dependency)
local new_tech = TECHNOLOGY {
type = "technology",
name = "tmp-" .. recipe .. "-tech",
icon = "__pypostprocessing__/graphics/placeholder.png",
icon_size = 128,
order = "c-a",
prerequisites = {},
effects = {
{ type = "unlock-recipe", recipe = recipe }
},
unit = {
count = 30,
ingredients = {
{"automation-science-pack", 1}
},
time = 30
}
}
RECIPE(recipe):set_enabled(false)
if original_tech then
RECIPE(recipe):remove_unlock(original_tech)
if add_dependency then
new_tech.dependencies = { original_tech }
end
end
return new_tech
end
if mods["PyBlock"] then
create_tmp_tech("fake-bioreserve-ore")
create_tmp_tech("fake-kerogen-ore")
create_tmp_tech("flavonoids", "yaedols")
create_tmp_tech("biofactory-mk01", "yaedols")
--aluminium
create_tmp_tech("borax-mine", "glass")
end
local function create_tmp_tech(recipe, original_tech, add_dependency)
local new_tech = TECHNOLOGY {
type = "technology",
name = "tmp-" .. recipe .. "-tech",
icon = "__pypostprocessing__/graphics/placeholder.png",
icon_size = 128,
order = "c-a",
prerequisites = {},
effects = {
{ type = "unlock-recipe", recipe = recipe }
},
unit = {
count = 30,
ingredients = {
{"automation-science-pack", 1}
},
time = 30
}
}
RECIPE(recipe):set_enabled(false)
if original_tech then
RECIPE(recipe):remove_unlock(original_tech)
if add_dependency then
new_tech.dependencies = { original_tech }
end
end
return new_tech
end
-- TMP TECHS HERE --
-- create_tmp_tech(<recipe-name>): Create tmp tech with only that recipe
-- create_tmp_tech(<recipe-name>, <tech-name>): Create tmp tech with only that recipe, and remove it from tech
if mods["pyalienlife"] and mods["pyhightech"] then
-- create_tmp_tech("salt-mine", "electrolysis")
end
if mods["pyalternativeenergy"] then
end
----------------------------------------------------
-- TECHNOLOGY CHANGES
----------------------------------------------------
for _, tech in pairs(data.raw.technology) do
local science_packs = {}
local function add_science_pack_dep(t, science_pack, dep_pack)
if science_packs[science_pack] and not science_packs[dep_pack] then
TECHNOLOGY(t):add_pack(dep_pack)
science_packs[dep_pack] = true
end
end
for _, pack in pairs(tech.unit and tech.unit.ingredients or {}) do
science_packs[pack.name or pack[1]] = true
end
add_science_pack_dep(tech, "utility-science-pack", "military-science-pack")
if mods["pyalienlife"] then
add_science_pack_dep(tech, "utility-science-pack", "py-science-pack-4")
add_science_pack_dep(tech, "production-science-pack", "py-science-pack-3")
add_science_pack_dep(tech, "chemical-science-pack", "py-science-pack-2")
add_science_pack_dep(tech, "logistic-science-pack", "py-science-pack-1")
add_science_pack_dep(tech, "py-science-pack-4", "military-science-pack")
end
if mods["pyalternativeenergy"] then
add_science_pack_dep(tech, "production-science-pack", "military-science-pack")
end
end
if dev_mode then
log("AUTOTECH START")
local at = require("prototypes.functions.auto_tech").create()
at:run()
if create_cache_mode then
at:create_cachefile_code()
end
log("AUTOTECH END")
else
require "cached-configs.run"
end
for _, lab in pairs(data.raw.lab) do
table.sort(lab.inputs, function (i1, i2) return data.raw.tool[i1].order < data.raw.tool[i2].order end)
end
if mods['pycoalprocessing'] then
for _, subgroup in pairs(data.raw['item-subgroup']) do
if subgroup.group == 'intermediate-products' then
subgroup.group = 'coal-processing'
subgroup.order = 'b'
end
end
end
----------------------------------------------------
-- THIRD PARTY COMPATIBILITY
----------------------------------------------------
require('prototypes/functions/compatibility')
if type(data.data_crawler) == 'string' and string.sub(data.data_crawler, 1, 5) == 'yafc ' then
require('prototypes/yafc')
end