various tweaks

This commit is contained in:
kepler155c@gmail.com
2018-12-16 14:53:54 -05:00
parent bf3983a7e2
commit ecd3d52797
5 changed files with 58 additions and 49 deletions

View File

@@ -15,6 +15,10 @@ if not turtle.select('minecraft:bucket') then
error('bucket required')
end
if turtle.getFuelLevel() == 0 then
error('Need some fuel to begin')
end
local s, m = turtle.run(function()
turtle.setMovementStrategy('goto')

View File

@@ -8,7 +8,6 @@
_G.requireInjector(_ENV)
local Config = require('config')
local Event = require('event')
local Milo = require('milo')
local Sound = require('sound')
@@ -27,49 +26,10 @@ if multishell then
multishell.setTitle(multishell.getCurrent(), 'Milo')
end
local nodes = Config.load('milo', { })
-- TODO: remove - temporary
if nodes.remoteDefaults then
nodes.nodes = nodes.remoteDefaults
nodes.remoteDefaults = nil
end
-- TODO: remove - temporary
if nodes.nodes then
local categories = {
input = 'custom',
trashcan = 'custom',
machine = 'machine',
brewingStand = 'machine',
activity = 'display',
jobs = 'display',
ignore = 'ignore',
hidden = 'ignore',
manipulator = 'custom',
storage = 'storage',
}
for _, node in pairs(nodes.nodes) do
if node.lock and type(node.lock) == 'string' then
node.lock = {
[ node.lock ] = true,
}
end
if not node.category then
node.category = categories[node.mtype]
if not node.category then
Util.print(node)
error('invalid node')
end
end
end
nodes = nodes.nodes
end
local function Syntax(msg)
print([[
Turtle must be equipped with:
* Introspection module
* Introspection module (unbound)
* Workbench
Turtle must be connected to:
@@ -118,7 +78,7 @@ local context = {
tasks = { },
queue = { },
storage = Storage(nodes),
storage = Storage(),
turtleInventory = {
name = localName,
mtype = 'hidden',
@@ -126,8 +86,8 @@ local context = {
}
}
nodes[localName] = context.turtleInventory
nodes[localName].adapter.name = localName
context.storage.nodes[localName] = context.turtleInventory
context.storage.nodes[localName].adapter.name = localName
_G._p = context --debug

View File

@@ -1,6 +1,6 @@
local Adapter = require('miniAdapter')
local class = require('class')
local Config = require('config')
local Config = require('config')
local Event = require('event')
local itemDB = require('itemDB')
local sync = require('sync').sync
@@ -12,14 +12,59 @@ local parallel = _G.parallel
local Storage = class()
function Storage:init(nodes)
local function loadOld(storage)
storage.nodes = Config.load('milo', { })
-- TODO: remove - temporary
if storage.nodes.remoteDefaults then
storage.nodes.nodes = storage.nodes.remoteDefaults
storage.nodes.remoteDefaults = nil
end
-- TODO: remove - temporary
if storage.nodes.nodes then
local categories = {
input = 'custom',
trashcan = 'custom',
machine = 'machine',
brewingStand = 'machine',
activity = 'display',
jobs = 'display',
ignore = 'ignore',
hidden = 'ignore',
manipulator = 'custom',
storage = 'storage',
}
for _, node in pairs(storage.nodes.nodes) do
if node.lock and type(node.lock) == 'string' then
node.lock = {
[ node.lock ] = true,
}
end
if not node.category then
node.category = categories[node.mtype]
if not node.category then
Util.print(node)
error('invalid node')
end
end
end
storage.nodes = storage.nodes.nodes
end
end
function Storage:init()
local defaults = {
nodes = nodes or { },
dirty = true,
activity = { },
storageOnline = true,
}
Util.merge(self, defaults)
self.nodes = Config.load('storage', { })
if not self.nodes then -- TODO: temporary
loadOld(self)
end
Event.on({ 'device_attach', 'device_detach' }, function(e, dev)
_G._debug('%s: %s', e, tostring(dev))
@@ -93,7 +138,7 @@ function Storage:saveConfiguration()
end
-- TODO: Should be named 'storage'
Config.update('milo', self.nodes)
Config.update('storage', self.nodes)
for k,v in pairs(t) do
self.nodes[k].adapter = v

View File

@@ -196,7 +196,7 @@ end)
Event.on('monitor_touch', function(_, side)
local function filter(node)
return node.adapter.name == side and pages[node.name]
return node.adapter.side == side and pages[node.name]
end
for node in context.storage:filterActive('activity', filter) do
pages[node.name]:reset()