-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-updates.lua
More file actions
201 lines (188 loc) · 7.36 KB
/
Copy pathdata-updates.lua
File metadata and controls
201 lines (188 loc) · 7.36 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
function update_recipe(recipeVersion)
table.insert(recipeVersion.ingredients,{type = "item", name = "assembly-bot", amount=1})
if recipeVersion.results then
recipeVersion.main_product = recipeVersion.results[1].name
-- if not recipeVersion.icon and not recipeVersion.icons then
-- local product = recipeVersion.results[1]
-- local thing
-- if product.type == "item" then
-- thing = data.raw.item[product.name]
-- elseif product.type == "fluid" then
-- thing = data.raw.fluid[product.name]
-- end
-- if thing.icon then
-- recipeVersion.icon = thing.icon
-- log("No icon found for " .. product.name)
-- end
-- end
table.insert(recipeVersion.results,{type = "item", name = "used-assembly-bot", amount=1})
table.insert(recipeVersion.results,{type = "item", name = "assembly-bot", amount=1, probability=assemblybots.config.replication_factor})
elseif recipeVersion.result then
-- transition from one output to multiple
recipeVersion.main_product = recipeVersion.result
local amount = 1
if recipeVersion.result_count ~= nil then
amount = recipeVersion.result_count
end
recipeVersion.results = { { name = recipeVersion.result, type = "item", amount = amount } }
recipeVersion.result = nil
recipeVersion.result_count = nil
table.insert(recipeVersion.results,{type = "item", name = "used-assembly-bot", amount=1})
table.insert(recipeVersion.results,{type = "item", name = "assembly-bot", amount=1, probability=assemblybots.config.replication_factor})
end
end
function update_production_recipe(production_recipeVersion)
production_recipeVersion.enabled = false
for ok, output in pairs(production_recipeVersion.results) do
if output.name ~= "assembly-bot" and output.name ~= "used-assembly-bot" then
if output.amount then
output.amount_max = output.amount * 2
output.amount_min = output.amount
output.amount = nil
elseif output.amount_max then
output.amount_max = output.amount_max * 2
else
log("No amount or amount_max for output " .. output.name)
end
end
end
for ik, input in pairs(production_recipeVersion.ingredients) do
if input.name == "assembly-bot" then input.amount = 2 end
end
end
function update_replication_recipe(replication_recipe)
replication_recipe.enabled = false;
for ok, output in pairs(replication_recipe.results) do
if output.name == "assembly-bot" then
output.probability = assemblybots.config.replication_mode_factor
end
end
end
function update_overdrive_recipe(overdrive_recipe)
overdrive_recipe.enabled = false
for ok, output in pairs(overdrive_recipe.results) do
if output.name == "assembly-bot" then
output.probability = 1
elseif output.name == "used-assembly-bot" then
output.probability = assemblybots.config.overdrive_mode_factor
output.name = "broken-assembly-bot"
end
end
end
function update_suppression_recipe(suppression_recipe)
suppression_recipe.enabled = false
local usedKey
for ok, output in pairs(suppression_recipe.results) do
if output.name == "used-assembly-bot" then
output.probability = 1
elseif output.name ~= "assembly-bot" then
output.probability = assemblybots.config.suppression_mode_factor
elseif output.name == "assembly-bot" then
usedKey = ok
end
end
table.remove(suppression_recipe.results, ok)
end
-- Add extra input to all assemblers
for k, assm in pairs(data.raw["assembling-machine"]) do
assm.ingredient_count = assm.ingredient_count + 1
end
-- Unlock long-handed-filter-inserter with electronics
table.insert(data.raw.technology["electronics"].effects, {type="unlock-recipe", recipe="long-filter-inserter"})
-- Add Assembly bots as input and output to all recipies (except smelting)
local toAdd = {}
for k, recipe in pairs(data.raw.recipe) do
if recipe.category ~= "smelting" and not string.match(recipe.name,"assembly%-bot") then
if not recipe.name then
recipe.name = recipe[1]
recipe.amount = recipe[2]
recipe[1] = nil
recipe[2] = nil
end
if recipe.normal then
update_recipe(recipe.normal)
recipe.main_product = recipe.normal.main_product
else
update_recipe(recipe)
end
if recipe.expensive then
update_recipe(recipe.expensive)
recipe.main_product = recipe.expensive.main_product
end
if not recipe.main_product and not recipe.subgroup then
recipe.subgroup = "fluid-recipes"
end
local production_recipe = util.table.deepcopy(recipe)
production_recipe.name = recipe.name .. "-production"
production_recipe.localised_name = recipe.localised_name
if production_recipe.normal then
update_production_recipe(production_recipe.normal)
else
update_production_recipe(production_recipe)
end
if production_recipe.expensive then
update_production_recipe(production_recipe.expensive)
end
table.insert(toAdd,production_recipe)
local replication_recipe = util.table.deepcopy(recipe)
replication_recipe.name = recipe.name .. "-replication"
replication_recipe.localised_name = recipe.localised_name
if replication_recipe.normal then
update_replication_recipe(replication_recipe.normal)
else
update_replication_recipe(replication_recipe)
end
if replication_recipe.expensive then
update_replication_recipe(replication_recipe.expensive)
end
table.insert(toAdd,replication_recipe)
local overdrive_recipe = util.table.deepcopy(recipe)
overdrive_recipe.name = recipe.name .. "-overdrive"
overdrive_recipe.localised_name = recipe.localised_name
if overdrive_recipe.normal then
update_overdrive_recipe(overdrive_recipe.normal)
else
update_overdrive_recipe(overdrive_recipe)
end
if overdrive_recipe.expensive then
update_overdrive_recipe(overdrive_recipe.expensive)
end
table.insert(toAdd,overdrive_recipe)
local suppression_recipe = util.table.deepcopy(recipe)
suppression_recipe.name = recipe.name .. "-suppression"
suppression_recipe.localised_name = recipe.localised_name
if suppression_recipe.normal then
update_suppression_recipe(suppression_recipe.normal)
else
update_suppression_recipe(suppression_recipe)
end
if suppression_recipe.expensive then
update_suppression_recipe(suppression_recipe.expensive)
end
table.insert(toAdd,suppression_recipe)
end
end
for k = #toAdd, 1, -1 do
data:extend({toAdd[k]})
end
-- Create copies of BotMode technologies with increasing costs
local techs = {}
techs["assemblybots-bot-normal"] = data.raw.technology["assemblybots-bot-normal-1"]
techs["assemblybots-bot-production"] = data.raw.technology["assemblybots-bot-production-1"]
techs["assemblybots-bot-overdrive"] = data.raw.technology["assemblybots-bot-overdrive-1"]
techs["assemblybots-bot-replication"] = data.raw.technology["assemblybots-bot-replication-1"]
techs["assemblybots-bot-suppression"] = data.raw.technology["assemblybots-bot-suppression-1"]
techs["assemblybots-bot-recharge1"] = data.raw.technology["assemblybots-bot-recharge1-1"]
techs["assemblybots-bot-recharge2"] = data.raw.technology["assemblybots-bot-recharge2-1"]
techs["assemblybots-bot-recharge3"] = data.raw.technology["assemblybots-bot-recharge3-1"]
local packs = {"science-pack-2","science-pack-3","military-science-pack","production-science-pack","high-tech-science-pack","space-science-pack"}
for tk, tech in pairs(techs) do
local newTech = util.table.deepcopy(tech)
for idx,pack in pairs(packs) do
newTech.name = tk.."-"..(idx + 1)
newTech.enabled = false
table.insert(newTech.unit.ingredients, {pack, 1})
data:extend({newTech})
newTech = util.table.deepcopy(newTech)
end
end