-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpollution-values.lua
131 lines (119 loc) · 4.9 KB
/
pollution-values.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
local function increasePollution(obj, f)
if obj.energy_source.emissions then
obj.energy_source.emissions = obj.energy_source.emissions*f
end
if obj.energy_source.emissions_per_second_per_watt then
obj.energy_source.emissions_per_second_per_watt = obj.energy_source.emissions_per_second_per_watt*f
end
if obj.energy_source.emissions_per_minute then
obj.energy_source.emissions_per_minute = obj.energy_source.emissions_per_minute*f
end
--log(serpent.block("Entity had no emissions parameter. Entity: "))
--log(serpent.block(obj))
end
local function increaseFuelEmissions(fuel, factor)
local obj = data.raw.item[fuel]
if not obj.fuel_emissions_multiplier then
obj.fuel_emissions_multiplier = 1
end
obj.fuel_emissions_multiplier = obj.fuel_emissions_multiplier*factor
end
local function increaseRecipeEmissions(recipe, factor)
local obj = data.raw.recipe[recipe]
if not obj.emissions_multiplier then
obj.emissions_multiplier = 1
end
obj.emissions_multiplier = obj.emissions_multiplier*factor
end
local function getExtraPollution(label, name)
if extraPollution[label] then
if extraPollution[label][name] then
return extraPollution[label][name]
end
if extraPollution[label]["*"] then
return extraPollution[label]["*"]
end
if extraPollution[label]["HAS_WILDCARD"] then
for card,value in pairs(extraPollution[label]) do
if string.find(card, "_*", 1, true) then
local look = string.sub(card, 1, -3)
--log("Looking for '" .. look .. "' in '" .. name .. "'")
if string.find(name, look, 1, true) then
return value
end
end
end
end
end
return nil
end
function increaseEmissionValues()
local repl = {}
for _,name in pairs(pollutionIncreaseExclusion) do
log("Excluding " .. name .. " from pollution increase")
repl[name] = 1
end
pollutionIncreaseExclusion = repl --turn into table for fast lookup
local coalBurners = {"boiler", "furnace", "mining-drill", "assembling-machine", "lab"}--, "inserter", "car", "locomotive"} these do not have emissions params; do they even pollute? (reddit says no)
for idx,label in pairs(coalBurners) do
for k,obj in pairs(data.raw[label]) do
if pollutionIncreaseExclusion[k] ~= 1 then
log(serpent.block("Checking candidate coal burner '" .. k .. "'"))
if obj.energy_source.type == "burner" and obj.energy_source.fuel_category == "chemical" then
--log(serpent.block("ID'ed coal burner '" .. k .. "', increasing emissions " .. coalPollutionScale .. "x"))
increasePollution(obj, coalPollutionScale)
end
end
end
end
for name,tree in pairs(data.raw["tree"]) do
if tree.emissions_per_second and not string.find(name, "dead") then
--log(serpent.block("Checking candidate coal burner '" .. k .. "'"))
--log(serpent.block("ID'ed coal burner '" .. k .. "', increasing emissions " .. pollutionScale*coalPollutionScale .. "x"))
tree.emissions_per_second = tree.emissions_per_second*treePollutionAbsorptionScale
end
end
local polluters = {"assembling-machine", "pump", "mining-drill", "furnace", "boiler"} --assembly also includes chem plant, refinery, centrifuge
for idx,label in pairs(polluters) do
for k,obj in pairs(data.raw[label]) do
if pollutionIncreaseExclusion[k] ~= 1 then
--log(serpent.block("Checking candidate polluter '" .. k .. "'"))
log(serpent.block("ID'ed polluter '" .. k .. "', increasing emissions " .. pollutionScale .. "x"))
increasePollution(obj, pollutionScale)
if label == "mining-drill" then
increasePollution(obj, miningPollutionScale)
log(serpent.block("ID'ed mining polluter '" .. k .. "', increasing emissions again " .. miningPollutionScale .. "x"))
end
local f = getExtraPollution(label, k)
if f then
increasePollution(obj, f)
log(serpent.block("ID'ed 'extra' polluter '" .. k .. "', increasing emissions again " .. f .. "x"))
end
end
end
end
for k,obj in pairs(data.raw.fire) do
--log(serpent.block("Checking candidate polluter '" .. k .. "'"))
--log(serpent.block("ID'ed polluter '" .. k .. "', increasing emissions " .. pollutionScale*firePollutionScale .. "x"))
if obj.emissions_per_tick then
obj.emissions_per_tick = obj.emissions_per_tick*pollutionScale*firePollutionScale
end
--log(serpent.block("Success"))
end
for k,obj in pairs(data.raw.recipe) do
if recipePollutionIncreases[k] then
if not obj.emissions_multiplier then obj.emissions_multiplier = 1 end
obj.emissions_multiplier = obj.emissions_multiplier*recipePollutionIncreases[k]
log("Increasing recipe '" .. k .. "' emissions by " .. recipePollutionIncreases[k] .. "x")
end
end
increaseFuelEmissions("coal", 1.2)
increaseFuelEmissions("solid-fuel", 0.8)
increaseFuelEmissions("wood", 0.7)
increaseFuelEmissions("nuclear-fuel", 3)
increaseRecipeEmissions("concrete", 5)
increaseRecipeEmissions("steel-plate", 6)
increaseRecipeEmissions("basic-oil-processing", 2)
increaseRecipeEmissions("coal-liquefaction", 3)
increaseRecipeEmissions("lubricant", 2)
end