-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontrol.lua
More file actions
43 lines (38 loc) · 1.3 KB
/
control.lua
File metadata and controls
43 lines (38 loc) · 1.3 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
local Items = require("migrations.items").items
local function contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
local function starts_with(str, start)
return str:sub(1, #start) == start
end
local function reenable_tech(force, tech)
local recipes = force.recipes
local force_tech = force.technologies[tech]
for _, effect in pairs(force_tech.prototype.effects) do
if effect.type == "unlock-recipe" and starts_with(effect.recipe, "deadlock") then
recipes[effect.recipe].enabled = true
recipes[effect.recipe].reload()
end
end
end
local function OnConfigurationChanged(e)
-- e.mod_changes
-- e.mod_startup_settings_changed
-- e.migration_applied
log("on_configuration_changed")
if e.mod_startup_settings_changed or e.mod_changes["DeadlockStackingForKrastorio2"] then
for index, force in pairs(game.forces) do
for _, item in pairs(Items) do
if item.tier and force.technologies[item.tier] and force.technologies[item.tier].researched then
reenable_tech(force, item.tier)
end
end
end
end
end
script.on_configuration_changed(OnConfigurationChanged)