generated from fgardt/factorio-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathdata-final-fixes.lua
More file actions
366 lines (286 loc) · 14.7 KB
/
data-final-fixes.lua
File metadata and controls
366 lines (286 loc) · 14.7 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
local rro = Muluna.rro
local function delete_tech(deleted_tech,new_tech)
for _,effect in pairs(data.raw["technology"][deleted_tech].effects) do
if effect.type == "unlock-recipe" then
if new_tech then
rro.soft_insert(data.raw["technology"][new_tech].effects,
{
type = "unlock-recipe",
recipe = data.raw["recipe"][effect.recipe].name,
}
)
else
data.raw["recipe"][effect.recipe].enabled = true
end
end
end
data.raw["technology"][deleted_tech] = nil
for _,technology in pairs(data.raw["technology"]) do
if rro.contains(technology.prerequisites,deleted_tech) then
rro.remove(technology.prerequisites,deleted_tech)
if new_tech and (not technology.prerequisites or #technology.prerequisites == 0) then
rro.soft_insert(technology.prerequisites,new_tech)
end
end
end
end
if mods["bztitanium"] or mods["bzcarbon"] or mods["bztin"] or mods["bzlead"] or mods["bzzirconium"] or mods["bzsilicon"] then
require("prototypes.recipe.vanilla-alternate-recipes")
end
require("prototypes.technology.interstellar-technologies")
require("prototypes.final-fixes.ground-digger")
require("prototypes.final-fixes.recipe-productivity-technology")
require("prototypes.final-fixes.telescope-prototype")
--Overrides any mods which add their own techs to space platform thruster as a prereq.
--Moves prereq to asteroid collector, which is roughly equivalent to space platform thruster's place in the vanilla tech tree.
local new_prereqs={}
if settings.startup["muluna-easy-vanilla-rocket-part-costs"].value == false then
for _,silo in pairs(data.raw["rocket-silo"]) do
silo.crafting_speed = silo.crafting_speed/2
if silo.module_slots then
silo.module_slots = silo.module_slots * 2
end
end
end
for _,technology in pairs(data.raw["technology"]["space-platform-thruster"].prerequisites) do
if technology ~= "afterburner" and technology ~= "aai-signal-transmission" and technology ~= "space-platform" then
--rro.remove(data.raw["technology"]["space-platform-thruster"].prerequisistes,technology)
rro.soft_insert(data.raw["technology"]["asteroid-collector"].prerequisites,technology)
else
rro.soft_insert(new_prereqs,technology)
end
end
data.raw["technology"]["space-platform-thruster"].prerequisites = new_prereqs
if settings.startup["muluna-easy-vanilla-rocket-part-costs"].value == false then
--Doubles the change associated with infinite rocket part productivity technology.
--Also adds support in case Hardcore is installed.
if data.raw["technology"]["rocket-part-productivity-aquilo"] then
for _,effect in pairs(data.raw["technology"]["rocket-part-productivity-aquilo"].effects) do
effect.change = effect.change * 2
end
--game.print("Error: Technology \"rocket-part-productivity-aquilo\" deleted by another mod. Please report this error to MeteorSwarm.")
end
for i = 1,10,1 do
if data.raw["technology"]["rocket-part-productivity-aquilo-"..tostring(i)] then
for _,effect in pairs(data.raw["technology"]["rocket-part-productivity-aquilo-"..tostring(i)].effects) do
effect.change = effect.change * 2
end
--game.print("Error: Technology \"rocket-part-productivity-aquilo\" deleted by another mod. Please report this error to MeteorSwarm.")
end
end
end
if data.raw["technology"]["fluid-handling"] then
local barreling_tech = rro.merge(data.raw["technology"]["fluid-handling"],{
type = "technology",
name = "fluid-barreling",
prerequisites = {"fluid-handling"},
effects = {},
icons = {
{
icon = data.raw["technology"]["fluid-handling"].icon or "__base__/graphics/technology/fluid-handling.png",
icon_size = data.raw["technology"]["fluid-handling"].icon_size or 256,
},
{
icon = data.raw["item"]["barrel"].icon,
icon_size=data.raw["item"]["barrel"].icon_size,
--scale=0.3,
shift = {45,45},
scale=0.75,
},
},
unit = "_nil",
research_trigger = {
type = "craft-item",
item = "barrel",
}
})
-- for i,effect in pairs(data.raw["technology"]["fluid-handling"].effects) do
-- if effect.type == "unlock-recipe" and string.find(effect.recipe,"%-barrel") then
-- table.insert(barreling_tech.effects,effect)
-- data.raw["technology"]["fluid-handling"].effects[i] = nil
-- end
-- end
for i = #data.raw["technology"]["fluid-handling"].effects, 1, -1 do -- Iterate backward to avoid index shifting
local effect = data.raw["technology"]["fluid-handling"].effects[i]
if effect.type == "unlock-recipe" and string.find(effect.recipe,"%-barrel") then
table.insert(barreling_tech.effects,effect)
table.remove(data.raw["technology"]["fluid-handling"].effects, i)
end
end
rro.soft_insert(data.raw["technology"]["thruster-oxidizer"].prerequisites,barreling_tech.name)
data:extend{barreling_tech}
end
if data.raw["technology"]["planet-discovery-nauvis"] then
rro.replace(data.raw["technology"]["planet-discovery-nauvis"].prerequisites,"space-platform-thruster","asteroid-collector")
end
data.raw["lab"]["cryolab"].inputs = data.raw["lab"]["biolab"].inputs
-- if mods["metal-and-stars"] then
-- data.raw["technology"]["space-chest-muluna"] = nil
-- end
local function get_boiler_quality_description(quality)
local quality_name = quality.localised_name or {"quality-name." .. quality.name}
local quality_level = quality.level
--if quality_level >= 5 and not mods["infinite-quality-tiers"] then quality_level = quality_level - 1 end
local efficiency = 150*(1+0.3*quality_level)
return {"recipe-description.global-advanced-boiler-quality-description", quality.name, tostring(efficiency)}
end
local electricity_description = {""} --Based on Maraxsis code for custom quality labels
local boiler_description = {""}
local i = 0
for _, quality in pairs(data.raw.quality) do
if quality.hidden or i >= 8 then goto continue end
local quality_name = quality.localised_name or {"quality-name." .. quality.name}
local quality_level = quality.level
--if quality_level >= 5 and not mods["infinite-quality-tiers"] then quality_level = quality_level - 1 end
local multiplier = 1/(1+0.3*quality_level)
local drain = string.format("%.2f",settings.startup["platform-power-consumption"].value * multiplier)
local tiles = tostring(100 *(1+0.3*quality_level))
table.insert(electricity_description, {"recipe-description.global-nav-beacon-quality-description", quality.name, drain, tiles})
table.insert(electricity_description, "\n")
table.insert(boiler_description, get_boiler_quality_description(quality))
table.insert(boiler_description, "\n")
i = i + 1
::continue::
end
electricity_description[#electricity_description] = nil
boiler_description[#boiler_description] = nil
--electricity_description = maraxsis.shorten_localised_string(electricity_description)
if data.raw["assembling-machine"]["muluna-advanced-boiler"] then
if not data.raw["assembling-machine"]["muluna-advanced-boiler"].quality_affects_energy_usage then
data.raw["assembling-machine"]["muluna-advanced-boiler"].factoriopedia_description = {"",{"entity-description.muluna-advanced-boiler"},"\n",boiler_description}
else
--data.raw["assembling-machine"]["muluna-advanced-boiler"].localised_description = {"",{"entity-description.muluna-advanced-boiler"},"\n",{"recipe-description.global-advanced-boiler-efficiency-description","150"}}
end
end
if helpers.compare_versions(helpers.game_version,"2.0.59") == -1 then
if data.raw["accumulator"]["muluna-satellite-radar"] then
data.raw["accumulator"]["muluna-satellite-radar"].factoriopedia_description = {"",{"entity-description.muluna-satellite-radar"},"\n",electricity_description}
end
if data.raw["item"]["muluna-satellite-radar"] then
data.raw["item"]["muluna-satellite-radar"].factoriopedia_description = {"",{"item-description.muluna-satellite-radar"},"\n",electricity_description}
end
end
-- navBeaconItem.localised_description = {"",{"item-description.nav-beacon"},"\n",electricity_description}
data.raw["recipe"]["copper-cable"].localised_name={"recipe-name.copper-cable"}
require("compat.aai-industry")
--require("prototypes.technology.interstellar-science-pack-final-fix")
require("prototypes.final-fixes.nav-beacon-final-fix")
require("prototypes.final-fixes.data-cells")
require("prototypes.final-fixes.interstellar-science-pack")
--require("prototypes.entity.vanilla-entity-shadows")
if data.raw["technology"]["tree-seeding"] and not data.raw.planet.lignumis then --Removed vanilla/wood-gasification recipes from tree seeding, then deletes the tech if no other mods add recipes to the tech.
--Technologies that have this tech as a prerequisite are moved to having agricultural science pack as the prerequisite.
--rro.remove(data.raw["technology"]["tree-seeding"].effects, {type = "unlock-recipe", recipe = "wood-processing"})
rro.remove(data.raw["technology"]["tree-seeding"].effects, {type = "unlock-recipe", recipe = "wood-seed-greenhouse"})
-- if #data.raw["technology"]["tree-seeding"].effects == 0 then
-- delete_tech("tree-seeding","agricultural-science-pack")
-- end
end
local flib_prototypes = require("__flib__.prototypes")
-- Train gravity conditions: All train-related entities with min gravity <=1 will be further lowered to 0.1
for _,entity in pairs(flib_prototypes.all("entity")) do
--print(entity.name)
if
rro.contains({
"car","locomotive","cargo-wagon",
"fluid-wagon","train-stop","artillery-wagon",
"rail-signal","rail-chain-signal","curved-rail-b",
"curved-rail-a","half-diagonal-rail","straight-rail",
"rail-ramp","elevated-straight-rail","elevated-half-diagonal-rail",
"elevated-curved-rail-a","elevated-curved-rail-b",
"rail-support","car","spider-vehicle","cargo-landing-pad"
},
entity.type)
and
(entity.surface_conditions and rro.contains(entity.surface_conditions,{property="gravity",min=rro.predicates.compare("<=",1)}))
then
--print("Burner energy source in " .. entity.name)
PlanetsLib.relax_surface_conditions(entity, {
property = "gravity",
min = 0.1,
})
end
end
--Recycling recipe fixes
local recipes_to_fix = Muluna.constants.recycling_recipes_to_fix
for _,recipe_name in pairs(recipes_to_fix) do
local recipe = table.deepcopy(data.raw["recipe"][recipe_name .. "-recycling"])
local recipe_muluna = table.deepcopy(recipe)
recipe_muluna.name = recipe.name .. "-muluna"
recipe_muluna.results[1].name = "aluminum-plate"
if not recipe_muluna.surface_conditions then recipe_muluna.surface_conditions = {} end
if not recipe.surface_conditions then recipe.surface_conditions = {} end
table.insert(recipe_muluna.surface_conditions ,
{
property = "is-muluna",
min = 1,
max = 1,
}
-- {
-- property = "oxygen",
-- min = 0,
-- max = 0,
-- }
)
table.insert(recipe.surface_conditions ,
{
property = "is-muluna",
min = 0,
max = 0,
}
)
data:extend{recipe_muluna,recipe}
end
local function add_oxygen_condition(entity)
--print(entity.name)
if (entity.burner and
rro.contains(entity.burner.fuel_categories,"chemical"))
or
entity.energy_source and
((
entity.energy_source.type == "burner" and
rro.contains(entity.energy_source.fuel_categories,"chemical") and
not rro.contains({"car","locomotive"},entity.type) and
not rro.contains(Muluna.constants.oxygen_restriction_blacklist,entity.name) and
--not (entity.type == "assembling-machine" or entity.type == "furnace" and (rro.contains(entity.crafting_categories,"double-boiler") or rro.contains(entity.crafting_categories,"muluna-vacuum-heating-tower") or rro.contains(entity.crafting_categories,"fuel-processing")))
not ((entity.type == "assembling-machine" or entity.type == "heat-assembling-machine" or entity.type == "furnace") and (rro.contains(entity.crafting_categories,"double-boiler") or rro.contains(entity.crafting_categories,"muluna-vacuum-heating-tower") or rro.contains(entity.crafting_categories,"fuel-processing")))
)
or
(
entity.energy_source.type == "fluid" and
entity.energy_source.burns_fluid == true
))
then
--print("Burner energy source in " .. entity.name)
PlanetsLib.restrict_surface_conditions(entity, {
property = "oxygen",
min = 1,
})
end
end
for _,entity in pairs(Muluna.flib_prototypes.all("entity")) do
add_oxygen_condition(entity)
end
-- for _,entity in pairs(data.raw["burner-generator"]) do
-- add_oxygen_condition(entity)
-- end
if settings.startup["override-space-connection"].value == true then
for _,connection in pairs(data.raw["space-connection"]) do
local from = data.raw["planet"][connection.from] or data.raw["space-location"][connection.from]
local to = data.raw["planet"][connection.to] or data.raw["space-location"][connection.to]
if connection.name ~= "nauvis-muluna" then
if connection.from == "nauvis" and to.subgroup ~= "satellites" then connection.from = "muluna" end
if connection.to == "nauvis" and from.subgroup ~= "satellites" then connection.to = "muluna" end
--rro.replace(connection.to,"nauvis","muluna")
end
end
end
if data.raw["container"]["bottomless-chest"] then --If version >= 2.0.57
for _,quality in pairs(data.raw["quality"]) do
quality.crafting_machine_energy_usage_multiplier = quality.default_multiplier or (1+ 0.3*quality.level)
end
end
require("prototypes.custom-prototypes.final-fixes.heat-assembling-machine-final-fix")
for _,location in pairs(Muluna.flib_prototypes.all("space-location")) do
print(location.name .. ": " .. tostring(Muluna.telescopes.shortest_space_distance("nauvis",location.name)))
end