forked from Void-Works/Void-Works
-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.lua
68 lines (61 loc) · 1.81 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
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
local function processPipes()
if global.pipes ~= nil then
for k,pipe in pairs(global.pipes) do
if pipe.valid then
pipe.fluidbox[1] = nil
else
table.remove(global.pipes, k)
if #global.pipes == 0 then
global.pipes = nil
end
end
end
end
end
script.on_nth_tick(120, function ()
processPipes()
end)
local function createEntity(entity)
if entity.name == "void-chest" then
entity.infinity_container_filters = {}
entity.remove_unfiltered_items = true
end
if entity.name == "void-pipe" then
if global.pipes == nil then
global.pipes = {}
end
table.insert(global.pipes, entity)
end
end
script.on_event({defines.events.on_built_entity}, function (event)
createEntity(event.created_entity)
end)
script.on_event({defines.events.on_robot_built_entity}, function (event)
createEntity(event.created_entity)
end)
script.on_event({defines.events.script_raised_built}, function (event)
createEntity(event.entity or event.created_entity)
end)
script.on_event({defines.events.script_raised_revive}, function (event)
createEntity(event.entity or event.created_entity)
end)
do
local function init_chests()
global.VoidChests = nil
for _, surface in pairs(game.surfaces) do
local chests = surface.find_entities_filtered {
name = "void-chest",
}
for _, chest in pairs(chests) do
chest.infinity_container_filters = {}
chest.remove_unfiltered_items = true
end
end
end
script.on_init(function()
init_chests()
end)
script.on_configuration_changed(function()
init_chests()
end)
end