milo: smart transfer

This commit is contained in:
kepler155c@gmail.com
2018-12-01 19:08:57 -05:00
parent 0853a16b59
commit 4a844eebfe
19 changed files with 177 additions and 121 deletions

View File

@@ -47,7 +47,7 @@ if nodes.nodes then
input = 'custom',
trashcan = 'custom',
machine = 'machine',
brewingStand = 'custom',
brewingStand = 'machine',
activity = 'display',
jobs = 'display',
ignore = 'ignore',
@@ -105,6 +105,8 @@ if not device.workbench then
end
end
local localName = modem.getNameLocal()
local context = {
nodes = nodes,
resources = Util.readTable(Milo.RESOURCE_FILE) or { },
@@ -115,20 +117,28 @@ local context = {
tasks = { },
queue = { },
localName = modem.getNameLocal(),
storage = Storage(nodes),
turtleInventory = introspection.getInventory(),
turtleInventory = {
name = localName,
mtype = 'hidden',
adapter = introspection.getInventory(),
}
}
device[context.localName] = introspection.getInventory()
nodes[localName] = context.turtleInventory
nodes[localName].adapter.name = localName
_G._p = context --debug
Milo:init(context)
context.storage:initStorage()
-- TODO: fix
context.storage.turtleInventory = context.turtleInventory
local function loadDirectory(dir)
for _, file in pairs(fs.list(dir)) do
_debug('loading: ' .. file)
local s, m = Util.run(_ENV, fs.combine(dir, file))
if not s and m then
error(m or 'Unknown error')
@@ -190,6 +200,12 @@ Event.on('milo_queue', function()
end
end)
Event.on('turtle_inventory', function()
if not processing and not Milo:isCraftingPaused() then
Milo:clearGrid()
end
end)
Event.onInterval(5, function()
if not Milo:isCraftingPaused() then
os.queueEvent('milo_cycle')