Skip to content

Commit a657e68

Browse files
Refactor to split compat and tweaks into files
1 parent 2695084 commit a657e68

11 files changed

+255
-217
lines changed

compat/IndustrialRevolution3.lua

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
log("Applying Industrial Revolution 3 compatibility tweaks")
2+
3+
-- IR3 uses a barreling technology
4+
data.raw['technology']['plutonium-processing'].prerequisites = {
5+
"uranium-processing",
6+
"nuclear-fuel-reprocessing",
7+
"ir-barrelling"
8+
}
9+
10+
-- Tweak Plutonium Ammo technology cost
11+
if data.raw['technology']['plutonium-ammo'] then
12+
data.raw['technology']['plutonium-ammo'].unit.count = 2000
13+
data.raw['technology']['plutonium-ammo'].unit.time = 60
14+
end
15+
16+
-- Tweak the shell icon to be consistent with IR3
17+
data.raw['ammo']['plutonium-atomic-artillery-shell'].icon =
18+
'__PlutoniumEnergy__/graphics/icons/plutonium-atomic-artillery-shell-IR3.png'
19+
20+
-- Function to hide a recipe
21+
local function hide_recipe(name, technology_name)
22+
data.raw['recipe'][name].hidden = true
23+
data.raw['recipe'][name].enabled = false
24+
if technology_name ~= nil then
25+
for index, effect in pairs(data.raw['technology'][technology_name].effects) do
26+
if effect.recipe == name then
27+
table.remove(data.raw['technology'][technology_name].effects, index)
28+
end
29+
end
30+
end
31+
end
32+
33+
-- IR3 uses barreling machines, so hide the convenient recipes
34+
hide_recipe('advanced-nuclear-fuel-reprocessing-with-barrelling', 'plutonium-processing')
35+
hide_recipe('breeder-fuel-cell-reprocessing-with-barrelling', 'nuclear-breeding')
36+
37+
-- Set subgroup and order to an item
38+
local function subgroup_and_order(name, subgroup, order, item_type)
39+
if item_type == nil then
40+
item_type = 'item'
41+
end
42+
data.raw[item_type][name].subgroup = subgroup
43+
data.raw[item_type][name].order = order
44+
end
45+
46+
-- assign IR3 subgroups to items
47+
subgroup_and_order('MOX-reactor', 'ir-nuclear-machines', 'f[nuclear-energy]-a[mox-reactor]')
48+
subgroup_and_order('breeder-reactor', 'ir-nuclear-machines', 'f[nuclear-energy]-a[breeder-reactor]')
49+
subgroup_and_order('MOX-fuel', 'ir-fuels', 'zz[mox-fuel]')
50+
subgroup_and_order('used-up-MOX-fuel', 'ir-fuels', 'zz[mox-fuel-used]')
51+
subgroup_and_order('breeder-fuel-cell', 'ir-fuels', 'zz[breeder-fuel-cell]')
52+
subgroup_and_order('used-up-breeder-fuel-cell', 'ir-fuels', 'zz[breeder-fuel-cell-used]')
53+
subgroup_and_order('plutonium-238', 'ir-fuels', 'cc[plutonium-238]')
54+
subgroup_and_order('plutonium-239', 'ir-fuels', 'cc[plutonium-239]')
55+
56+
if settings.startup['enable-plutonium-ammo'].value then
57+
subgroup_and_order('plutonium-rounds-magazine', 'ir-ammo', 'c-q', 'ammo')
58+
end

compat/RealisticReactors.lua

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- big TODO
2+
-- Basically need a rewrite
3+
4+
log("Realistic Reactors no-op compat loaded")

compat/SchallRadioactiveWaste.lua

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
log("SchallRadioactiveWaste compat tweaks")
2+
3+
---@diagnostic disable: undefined-global
4+
SchallRadioactiveWaste_add_incineration_recipe('used-up-MOX-fuel', 22.3, 0.9)
5+
SchallRadioactiveWaste_add_incineration_recipe('used-up-breeder-fuel-cell', 45.0, 1.5)
6+
SchallRadioactiveWaste_add_incineration_recipe('plutonium-238', 3, 0.85)
7+
SchallRadioactiveWaste_add_incineration_recipe('plutonium-239', 700, 0.85)
8+
9+
SchallRadioactiveWaste_add_radioactive_effects('plutonium-atomic-rocket', 84, 2.8, 70)
10+
11+
if data.raw['artillery-projectile']['plutonium-atomic-artillery-projectile'] then
12+
SchallRadioactiveWaste_add_radioactive_effects('plutonium-atomic-artillery-projectile', 84, 2.8, 70)
13+
end

compat/attack-parameters.lua

Whitespace-only changes.

compat/nuclear-artillery.lua

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
log("Nuclear artillery tweaks")
2+
3+
-- Add nuclear artillery to artillery guns
4+
5+
local function contains(table_to_search, item)
6+
for _, v in pairs(table_to_search) do
7+
if v == item then
8+
return true
9+
end
10+
end
11+
return false
12+
end
13+
14+
for _, gun in pairs(data.raw['gun']) do
15+
if gun.attack_parameters.ammo_categories and not gun.attack_parameters.ammo_category then
16+
if contains(gun.attack_parameters.ammo_categories, 'artillery-shell') then
17+
table.insert(gun.attack_parameters.ammo_categories, 'artillery-shell')
18+
end
19+
end
20+
if gun.attack_parameters.ammo_category == 'artillery-shell' then
21+
gun.attack_parameters.ammo_categories = { 'artillery-shell', 'nuclear-artillery' }
22+
gun.attack_parameters.ammo_category = nil
23+
end
24+
end
25+
26+
-- Add nuclear artillery damage bonus
27+
28+
local function affects_ammotype(effects, ammotype)
29+
for _, effect in pairs(effects) do
30+
if effect.type == "ammo-damage" and effect.ammo_category == ammotype then
31+
return effect.modifier
32+
end
33+
end
34+
return nil
35+
end
36+
37+
for name, tech in pairs(data.raw['technology']) do
38+
if tech.effects ~= nil then
39+
local ammotype_effect = affects_ammotype(tech.effects, 'rocket')
40+
if ammotype_effect then
41+
table.insert(data.raw['technology'][name].effects,
42+
{ type = "ammo-damage", ammo_category = "nuclear-artillery", modifier = ammotype_effect })
43+
end
44+
end
45+
end

compat/productivity.lua

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
log("Tweaking productivity restrictions")
2+
3+
-- Add some recipes to productivty modules limitation (which is whitelist for some reason)
4+
local limitation_to_add = {
5+
'advanced-nuclear-fuel-reprocessing',
6+
'MOX-fuel-cell', 'MOX-fuel-cell-reprocessing',
7+
'plutonium-fuel',
8+
'breeder-fuel-cell-reprocessing',
9+
'used-up-uranium-fuel-cell-solution-centrifuging',
10+
'used-up-breeder-fuel-cell-solution-centrifuging',
11+
'breeder-fuel-cell',
12+
}
13+
for _, module in pairs(data.raw['module']) do
14+
if module.limitation and module.effect.productivity then
15+
for _, recipe in pairs(limitation_to_add) do
16+
table.insert(module.limitation, recipe)
17+
end
18+
end
19+
end

compat/prototype-subgroup.lua

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
log("Tweaking item and recipe subgroups")
2+
3+
4+
-- Lists of items and recipes to replace subgroups of
5+
6+
-- Recipes that need to have the subgroup of nuclear fuel recipe
7+
local nuclear_fuel_list_recipes = {
8+
'plutonium-fuel'
9+
}
10+
-- Recipes that need to have the subgroup of uranium fuel cell recipe
11+
local uranium_fuel_cell_list_recipes = {
12+
'MOX-fuel-cell',
13+
'breeder-fuel-cell',
14+
'breeder-fuel-cell-from-uranium-cell',
15+
'breeder-fuel-cell-from-MOX-fuel-cell',
16+
'breeder-fuel-cell-reprocessing',
17+
'used-up-uranium-fuel-cell-solution-centrifuging',
18+
'used-up-breeder-fuel-cell-solution-centrifuging',
19+
'advanced-nuclear-fuel-reprocessing',
20+
'advanced-nuclear-fuel-reprocessing-with-barrelling',
21+
'used-up-uranium-fuel-cell-solution-centrifuging',
22+
'MOX-fuel-reprocessing',
23+
'breeder-fuel-cell-reprocessing',
24+
'breeder-fuel-cell-reprocessing-with-barrelling',
25+
'used-up-breeder-fuel-cell-solution-centrifuging'
26+
}
27+
-- Items that need to have the subgroup of nuclear fuel item
28+
local nuclear_fuel_list_items = {
29+
'plutonium-fuel'
30+
}
31+
-- Items that need to have the subgroup of uranium fuel cell
32+
local uranium_fuel_cell_list_items = {
33+
'MOX-fuel',
34+
'breeder-fuel-cell'
35+
}
36+
37+
38+
-- Function definitions
39+
40+
-- Replace subgroup of a prototype
41+
local function replace_subgroup(prototype_type, replace_with, targets_list)
42+
for _, name in pairs(targets_list) do
43+
log("Replacing subgroup of " .. prototype_type .. " named `" .. name .. "` with `" .. replace_with .. "`")
44+
if data.raw[prototype_type][name] then
45+
data.raw[prototype_type][name].subgroup = replace_with
46+
else
47+
log("Warning: prototype does not exist in `data.raw`")
48+
end
49+
end
50+
end
51+
52+
-- Wrapper for recipes
53+
local function replace_recipe_subgroup(replace_with, targets_list)
54+
replace_subgroup('recipe', replace_with, targets_list)
55+
end
56+
57+
-- Wrapper for items
58+
local function replace_item_subgroup(replace_with, targets_list)
59+
replace_subgroup('item', replace_with, targets_list)
60+
end
61+
62+
63+
-- Replacing action
64+
65+
-- Subgroups to replace with
66+
local nuclear_fuel_recipe_subgroup = data.raw['recipe']['nuclear-fuel'].subgroup
67+
local uranium_fuel_cell_recipe_subgroup = data.raw['recipe']['nuclear-fuel-reprocessing'].subgroup
68+
69+
local nuclear_fuel_item_subgroup = data.raw['item']['nuclear-fuel'].subgroup
70+
local uranium_fuel_cell_item_subgroup = data.raw['item']['uranium-fuel-cell'].subgroup
71+
72+
-- And call the functions
73+
if nuclear_fuel_recipe_subgroup then
74+
replace_recipe_subgroup(nuclear_fuel_recipe_subgroup, nuclear_fuel_list_recipes)
75+
end
76+
if uranium_fuel_cell_recipe_subgroup then
77+
replace_recipe_subgroup(uranium_fuel_cell_recipe_subgroup, uranium_fuel_cell_list_recipes)
78+
end
79+
80+
if nuclear_fuel_item_subgroup then
81+
replace_item_subgroup(nuclear_fuel_item_subgroup, nuclear_fuel_list_items)
82+
end
83+
if uranium_fuel_cell_item_subgroup then
84+
replace_item_subgroup(uranium_fuel_cell_item_subgroup, uranium_fuel_cell_list_items)
85+
end

compat/space-exploration.lua

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
log("Space Exploration compatibility tweaks")
2+
3+
-- Space Exploration compatibility tweaks, originally by Polish DeathCare
4+
5+
local data_util = require('__space-exploration__.data_util')
6+
7+
if not se_delivery_cannon_recipes then se_delivery_cannon_recipes = {} end
8+
9+
se_delivery_cannon_recipes['plutonium-239'] = { name = 'plutonium-239' }
10+
se_delivery_cannon_recipes['plutonium-238'] = { name = 'plutonium-238' }
11+
12+
if not se_delivery_cannon_ammo_recipes then se_delivery_cannon_ammo_recipes = {} end
13+
14+
se_delivery_cannon_ammo_recipes['plutonium-atomic-bomb'] = {
15+
type = 'ammo',
16+
name = 'plutonium-atomic-bomb',
17+
amount = 1,
18+
ingredients = {
19+
{ 'plutonium-atomic-bomb', 1 },
20+
{ data_util.mod_prefix .. 'delivery-cannon-weapon-capsule', 1 }
21+
}
22+
}

data-final-fixes.lua

+2-84
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,2 @@
1-
-- Add some recipes to productivty modules limitation (which is whitelist for some reason)
2-
local limitation_to_add = {
3-
'advanced-nuclear-fuel-reprocessing',
4-
'MOX-fuel-cell', 'MOX-fuel-cell-reprocessing',
5-
'plutonium-fuel',
6-
'breeder-fuel-cell-reprocessing',
7-
'used-up-uranium-fuel-cell-solution-centrifuging',
8-
'used-up-breeder-fuel-cell-solution-centrifuging',
9-
'breeder-fuel-cell',
10-
}
11-
for _, module in pairs(data.raw['module']) do
12-
if module.limitation and module.effect.productivity then
13-
for _, recipe in pairs(limitation_to_add) do
14-
table.insert(module.limitation, recipe)
15-
end
16-
end
17-
end
18-
19-
local function replace_subgroup(prototype_type, replace_with, targets_list)
20-
for _, name in pairs(targets_list) do
21-
log("Replacing subgroup of " .. prototype_type .. " named `" .. name .. "` with `" .. replace_with .. "`")
22-
if data.raw[prototype_type][name] then
23-
data.raw[prototype_type][name].subgroup = replace_with
24-
else
25-
log("Warning: prototype does not exist in `data.raw`")
26-
end
27-
end
28-
end
29-
30-
local function replace_recipe_subgroup(replace_with, targets_list)
31-
replace_subgroup('recipe', replace_with, targets_list)
32-
end
33-
34-
local function replace_item_subgroup(replace_with, targets_list)
35-
replace_subgroup('item', replace_with, targets_list)
36-
end
37-
38-
local nuclear_fuel_recipe_subgroup = data.raw['recipe']['nuclear-fuel'].subgroup
39-
local uranium_fuel_cell_recipe_subgroup = data.raw['recipe']['nuclear-fuel-reprocessing'].subgroup
40-
41-
local nuclear_fuel_list_recipes = {
42-
'plutonium-fuel'
43-
}
44-
local uranium_fuel_cell_list_recipes = {
45-
'MOX-fuel-cell',
46-
'breeder-fuel-cell',
47-
'breeder-fuel-cell-from-uranium-cell',
48-
'breeder-fuel-cell-from-MOX-fuel-cell',
49-
'breeder-fuel-cell-reprocessing',
50-
'used-up-uranium-fuel-cell-solution-centrifuging',
51-
'used-up-breeder-fuel-cell-solution-centrifuging',
52-
'advanced-nuclear-fuel-reprocessing',
53-
'advanced-nuclear-fuel-reprocessing-with-barrelling',
54-
'used-up-uranium-fuel-cell-solution-centrifuging',
55-
'MOX-fuel-reprocessing',
56-
'breeder-fuel-cell-reprocessing',
57-
'breeder-fuel-cell-reprocessing-with-barrelling',
58-
'used-up-breeder-fuel-cell-solution-centrifuging'
59-
}
60-
61-
if nuclear_fuel_recipe_subgroup then
62-
replace_recipe_subgroup(nuclear_fuel_recipe_subgroup, nuclear_fuel_list_recipes)
63-
end
64-
if uranium_fuel_cell_recipe_subgroup then
65-
replace_recipe_subgroup(uranium_fuel_cell_recipe_subgroup, uranium_fuel_cell_list_recipes)
66-
end
67-
68-
local nuclear_fuel_item_subgroup = data.raw['item']['nuclear-fuel'].subgroup
69-
local uranium_fuel_cell_item_subgroup = data.raw['item']['uranium-fuel-cell'].subgroup
70-
71-
local nuclear_fuel_list_items = {
72-
'plutonium-fuel'
73-
}
74-
local uranium_fuel_cell_list_items = {
75-
'MOX-fuel',
76-
'breeder-fuel-cell'
77-
}
78-
79-
if nuclear_fuel_item_subgroup then
80-
replace_item_subgroup(nuclear_fuel_item_subgroup, nuclear_fuel_list_items)
81-
end
82-
if uranium_fuel_cell_item_subgroup then
83-
replace_item_subgroup(uranium_fuel_cell_item_subgroup, uranium_fuel_cell_list_items)
84-
end
1+
require('compat.productivity')
2+
require('compat.prototype-subgroup')

0 commit comments

Comments
 (0)