forked from hkc/cc-stuff
37 lines
844 B
Lua
37 lines
844 B
Lua
|
|
||
|
local config = {
|
||
|
{ filter = ".*charged.*", from = "ae2:charger", to = "create:basin" },
|
||
|
{ filter = "!.*charged.*", from = "create:basin", to = "ae2:charger", limit = 1 }
|
||
|
}
|
||
|
|
||
|
local function is_matching(pattern, value)
|
||
|
if pattern:sub(1, 1) == "!" then
|
||
|
return not is_matching(pattern:sub(2))
|
||
|
end
|
||
|
return value:match(pattern) ~= nil
|
||
|
end
|
||
|
|
||
|
|
||
|
local items = {}
|
||
|
|
||
|
parallel.waitForAll(function() -- Inventory listener
|
||
|
while true do
|
||
|
local new_items = {}
|
||
|
peripheral.find("inventory", function(inv)
|
||
|
local inv_items = peripheral.call(inv, "list")
|
||
|
for slot, item in pairs(inv_items) do
|
||
|
new_items[string.format("%s#%d", inv, slot)] = item
|
||
|
end
|
||
|
end)
|
||
|
items = new_items
|
||
|
os.sleep(0)
|
||
|
end
|
||
|
end, function() -- Executor
|
||
|
while true do
|
||
|
for i, rule in ipairs(config) do
|
||
|
|
||
|
end
|
||
|
os.sleep(0)
|
||
|
end
|
||
|
end)
|