-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.lua
40 lines (34 loc) · 1.08 KB
/
control.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
require("globals")
local recipes_providers = { -- an array of function(consumer_function(recipe_info))
require("process-logistic-chests"),
require("process-aai-containers"),
require("process-space-pipes"),
require("process-underground-pipe-pack"),
require("process-intermediate-bulk-containers"),
require("process-memory-storage"),
require("process-krastorio2"),
}
local function sync_recipe_with_research(recipe_info)
for _, force in pairs(game.forces) do
local tech = force.technologies[recipe_info.technology_name]
if tech and tech.researched then
local recipe = force.recipes[recipe_info.recipe_name]
if recipe then
recipe.enabled = true
end
end
end
end
local function sync_recipes_with_research()
for _, recipes in pairs(recipes_providers) do
recipes(sync_recipe_with_research)
end
end
local function on_init()
sync_recipes_with_research()
end
local function on_configuration_changed(change)
sync_recipes_with_research()
end
script.on_init(on_init)
script.on_configuration_changed(on_configuration_changed)