milo node rework
This commit is contained in:
@@ -65,6 +65,9 @@ function Storage:initStorage()
|
|||||||
v.adapter = InventoryAdapter.wrap({ side = k })
|
v.adapter = InventoryAdapter.wrap({ side = k })
|
||||||
v.adapter.online = true
|
v.adapter.online = true
|
||||||
v.adapter.dirty = true
|
v.adapter.dirty = true
|
||||||
|
elseif device[k] then
|
||||||
|
v.adapter = device[k]
|
||||||
|
v.adapter.online = true
|
||||||
end
|
end
|
||||||
if v.mtype == 'storage' then
|
if v.mtype == 'storage' then
|
||||||
online = online and not not (v.adapter and v.adapter.online)
|
online = online and not not (v.adapter and v.adapter.online)
|
||||||
@@ -73,15 +76,23 @@ function Storage:initStorage()
|
|||||||
|
|
||||||
if online ~= self.storageOnline then
|
if online ~= self.storageOnline then
|
||||||
self.storageOnline = online
|
self.storageOnline = online
|
||||||
|
-- TODO: if online, then list items
|
||||||
os.queueEvent(self.storageOnline and 'storage_online' or 'storage_offline', online)
|
os.queueEvent(self.storageOnline and 'storage_online' or 'storage_offline', online)
|
||||||
_G._debug('Storage: %s', self.storageOnline and 'online' or 'offline')
|
_G._debug('Storage: %s', self.storageOnline and 'online' or 'offline')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Storage:filterActive(mtype, filter)
|
function Storage:getSingleNode(mtype)
|
||||||
|
local node = Util.find(self.nodes, 'mtype', mtype)
|
||||||
|
if node and node.adapter and node.adapter.online then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Storage:filterNodes(mtype, filter)
|
||||||
local iter = { }
|
local iter = { }
|
||||||
for _, v in pairs(self.nodes) do
|
for _, v in pairs(self.nodes) do
|
||||||
if v.adapter and v.adapter.online and v.mtype == mtype then
|
if v.mtype == mtype then
|
||||||
if not filter or filter(v) then
|
if not filter or filter(v) then
|
||||||
table.insert(iter, v)
|
table.insert(iter, v)
|
||||||
end
|
end
|
||||||
@@ -95,6 +106,14 @@ function Storage:filterActive(mtype, filter)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Storage:filterActive(mtype, filter)
|
||||||
|
return self:filterNodes(mtype, function(v)
|
||||||
|
if v.adapter and v.adapter.online then
|
||||||
|
return not filter and true or filter(v)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function Storage:onlineAdapters(reversed)
|
function Storage:onlineAdapters(reversed)
|
||||||
local iter = { }
|
local iter = { }
|
||||||
for _, v in pairs(self.nodes) do
|
for _, v in pairs(self.nodes) do
|
||||||
@@ -184,6 +203,12 @@ _G._debug('STORAGE: refresh in ' .. timer())
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Storage:updateCache(adapter, key, count)
|
function Storage:updateCache(adapter, key, count)
|
||||||
|
if not adapter.cache then
|
||||||
|
adapter.dirty = true
|
||||||
|
self.dirty = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local entry = adapter.cache[key]
|
local entry = adapter.cache[key]
|
||||||
|
|
||||||
if not entry then
|
if not entry then
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ local turtle = _G.turtle
|
|||||||
|
|
||||||
local context = Milo:getContext()
|
local context = Milo:getContext()
|
||||||
|
|
||||||
|
local nodeWizard
|
||||||
|
|
||||||
local function saveConfig()
|
local function saveConfig()
|
||||||
local t = { }
|
local t = { }
|
||||||
for k,v in pairs(context.config.nodes) do
|
for k,v in pairs(context.config.nodes) do
|
||||||
@@ -38,9 +40,6 @@ local networkPage = UI.Page {
|
|||||||
shadowText = 'filter',
|
shadowText = 'filter',
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
backgroundFocusColor = colors.cyan,
|
backgroundFocusColor = colors.cyan,
|
||||||
accelerators = {
|
|
||||||
[ 'enter' ] = 'eject',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2, ey = -3,
|
y = 2, ey = -3,
|
||||||
@@ -91,12 +90,16 @@ end
|
|||||||
|
|
||||||
function networkPage:getList()
|
function networkPage:getList()
|
||||||
for _, v in pairs(device) do
|
for _, v in pairs(device) do
|
||||||
if v.pullItems then
|
if not context.config.nodes[v.name] then
|
||||||
if not context.config.nodes[v.name] then
|
local node = {
|
||||||
context.config.nodes[v.name] = {
|
name = v.name,
|
||||||
name = v.name,
|
mtype = 'ignore',
|
||||||
mtype = 'ignore',
|
}
|
||||||
}
|
for _, page in pairs(nodeWizard.wizard.pages) do
|
||||||
|
if page.isValidType and page:isValidType(node) then
|
||||||
|
context.config.nodes[v.name] = node
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -168,7 +171,7 @@ function networkPage:eventHandler(event)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local nodeWizard = UI.Page {
|
nodeWizard = UI.Page {
|
||||||
titleBar = UI.TitleBar { title = 'Configure' },
|
titleBar = UI.TitleBar { title = 'Configure' },
|
||||||
wizard = UI.Wizard {
|
wizard = UI.Wizard {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
@@ -185,16 +188,9 @@ local nodeWizard = UI.Page {
|
|||||||
limit = 64, pruneEmpty = true,
|
limit = 64, pruneEmpty = true,
|
||||||
},
|
},
|
||||||
[2] = UI.Chooser {
|
[2] = UI.Chooser {
|
||||||
width = 15,
|
width = 25,
|
||||||
formLabel = 'Type', formKey = 'mtype',
|
formLabel = 'Type', formKey = 'mtype',
|
||||||
nochoice = 'Storage',
|
--nochoice = 'Storage',
|
||||||
choices = {
|
|
||||||
{ name = 'Storage', value = 'storage' },
|
|
||||||
{ name = 'Trashcan', value = 'trashcan' },
|
|
||||||
{ name = 'Input chest', value = 'input' },
|
|
||||||
{ name = 'Ignore', value = 'ignore' },
|
|
||||||
{ name = 'Machine', value = 'machine' },
|
|
||||||
},
|
|
||||||
help = 'Select type',
|
help = 'Select type',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -401,36 +397,30 @@ function nodeWizard.wizard.pages.general.grid:getDisplayValues(row)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function nodeWizard.wizard.pages.general:validate()
|
function nodeWizard.wizard.pages.general:validate()
|
||||||
return self.form:save()
|
if self.form:save() then
|
||||||
end
|
for _, page in pairs(nodeWizard.wizard.pages) do
|
||||||
|
page.index = nil
|
||||||
--[[ Wizard ]] --
|
end
|
||||||
function nodeWizard.wizard:eventHandler(event)
|
local index = 2
|
||||||
if event.type == 'nextView' and
|
nodeWizard.wizard.pages.general.index = 1
|
||||||
Util.find(self.pages, 'enabled', true) == self.pages.general then
|
nodeWizard.wizard.pages.confirmation.index = 2
|
||||||
|
for _, page in pairs(nodeWizard.wizard.pages) do
|
||||||
if self.pages.general.form:save() then
|
if not page.index then
|
||||||
local index = 2
|
if not page.isValidFor or page:isValidFor(nodeWizard.node) then
|
||||||
for _, page in pairs(self.pages) do
|
|
||||||
page.index = nil
|
|
||||||
end
|
|
||||||
self.pages.general.index = 1
|
|
||||||
self.pages.confirmation.index = 2
|
|
||||||
|
|
||||||
for _, page in pairs(self.pages) do
|
|
||||||
if not page.index and page:isValidFor(self.parent.node) then
|
|
||||||
page.index = index
|
page.index = index
|
||||||
index = index + 1
|
index = index + 1
|
||||||
|
if page.setNode then
|
||||||
|
page:setNode(nodeWizard.node)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.pages.confirmation.index = index
|
|
||||||
return UI.Wizard.eventHandler(self, event)
|
|
||||||
end
|
end
|
||||||
else
|
nodeWizard.wizard.pages.confirmation.index = index
|
||||||
return UI.Wizard.eventHandler(self, event)
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[ Wizard ]] --
|
||||||
function nodeWizard:enable(node)
|
function nodeWizard:enable(node)
|
||||||
local adapter = node.adapter
|
local adapter = node.adapter
|
||||||
node.adapter = nil -- don't deep copy the adapter
|
node.adapter = nil -- don't deep copy the adapter
|
||||||
@@ -439,8 +429,21 @@ function nodeWizard:enable(node)
|
|||||||
node.adapter = adapter
|
node.adapter = adapter
|
||||||
|
|
||||||
_G._p2 = self.node
|
_G._p2 = self.node
|
||||||
self.wizard.pages.general.form:setValues(self.node)
|
|
||||||
|
local choices = {
|
||||||
|
{ name = 'Ignore', value = 'ignore' },
|
||||||
|
}
|
||||||
|
for _, page in pairs(self.wizard.pages) do
|
||||||
|
if page.isValidType then
|
||||||
|
local choice = page:isValidType(self.node)
|
||||||
|
if choice then
|
||||||
|
table.insert(choices, choice)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
self.wizard.pages.general.form[1].shadowText = self.node.name
|
self.wizard.pages.general.form[1].shadowText = self.node.name
|
||||||
|
self.wizard.pages.general.form[2].choices = choices
|
||||||
|
self.wizard.pages.general.form:setValues(self.node)
|
||||||
|
|
||||||
-- restore indices
|
-- restore indices
|
||||||
for _, page in pairs(self.wizard.pages) do
|
for _, page in pairs(self.wizard.pages) do
|
||||||
@@ -451,12 +454,6 @@ _G._p2 = self.node
|
|||||||
end
|
end
|
||||||
|
|
||||||
UI.Page.enable(self)
|
UI.Page.enable(self)
|
||||||
|
|
||||||
for _, v in pairs(self.wizard.pages) do
|
|
||||||
if v.setNode then
|
|
||||||
v:setNode(self.node)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function nodeWizard:eventHandler(event)
|
function nodeWizard:eventHandler(event)
|
||||||
|
|||||||
@@ -1,25 +1,47 @@
|
|||||||
|
local Ansi = require('ansi')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local Milo = require('milo')
|
local Milo = require('milo')
|
||||||
local Peripheral = require('peripheral')
|
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local context = Milo:getContext()
|
local context = Milo:getContext()
|
||||||
local mon = Peripheral.lookup(context.config.activityMonitor)
|
local device = _G.device
|
||||||
|
local monitor = context.storage:getSingleNode('activity')
|
||||||
|
|
||||||
local ActivityTask = {
|
--[[ Configuration Page ]]--
|
||||||
name = 'activity',
|
local template =
|
||||||
priority = 30,
|
[[%sDisplays the amount of items entering or leaving storage%s
|
||||||
|
|
||||||
|
Right-clicking on the activity monitor will reset the totals.
|
||||||
|
|
||||||
|
%sMilo must be restarted to activate diplay.
|
||||||
|
]]
|
||||||
|
|
||||||
|
local activityWizardPage = UI.Window {
|
||||||
|
title = 'Activity Monitor',
|
||||||
|
index = 2,
|
||||||
|
backgroundColor = colors.cyan,
|
||||||
|
[1] = UI.TextArea {
|
||||||
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if not mon then
|
function activityWizardPage:isValidType(node)
|
||||||
return
|
local m = device[node.name]
|
||||||
|
return m and m.type == 'monitor' and { name = 'Activity Monitor', value = 'activity' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function activityWizardPage:isValidFor(node)
|
||||||
|
return node.mtype == 'activity'
|
||||||
|
end
|
||||||
|
|
||||||
|
UI:getPage('nodeWizard').wizard:add({ activity = activityWizardPage })
|
||||||
|
|
||||||
local page = UI.Window {
|
local page = UI.Window {
|
||||||
parent = UI.Device {
|
parent = UI.Device {
|
||||||
device = mon,
|
device = monitor.adapter,
|
||||||
textScale = .5,
|
textScale = .5,
|
||||||
},
|
},
|
||||||
grid = UI.Grid {
|
grid = UI.Grid {
|
||||||
@@ -130,17 +152,23 @@ Event.on({ 'storage_offline', 'storage_online' }, function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
Event.on('monitor_touch', function(_, side)
|
Event.on('monitor_touch', function(_, side)
|
||||||
if side == mon.side then
|
if side == monitor.adapter.side then
|
||||||
page:reset()
|
page:reset()
|
||||||
page:sync()
|
page:sync()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
page:draw()
|
||||||
|
page:sync()
|
||||||
|
|
||||||
|
--[[ Task ]]--
|
||||||
|
local ActivityTask = {
|
||||||
|
name = 'activity',
|
||||||
|
priority = 30,
|
||||||
|
}
|
||||||
|
|
||||||
function ActivityTask:cycle()
|
function ActivityTask:cycle()
|
||||||
page:update()
|
page:update()
|
||||||
end
|
end
|
||||||
|
|
||||||
Milo:registerTask(ActivityTask)
|
Milo:registerTask(ActivityTask)
|
||||||
|
|
||||||
page:draw()
|
|
||||||
page:sync()
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ When finished brewing, the recipe will be available upon refreshing.
|
|||||||
Note that you do not need to import items from the brewing stand, this will be done automatically.]]
|
Note that you do not need to import items from the brewing stand, this will be done automatically.]]
|
||||||
|
|
||||||
local brewingStandView = UI.Window {
|
local brewingStandView = UI.Window {
|
||||||
title = 'Storage Options',
|
title = 'Brewing Stand',
|
||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
@@ -25,11 +25,13 @@ local brewingStandView = UI.Window {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function brewingStandView:isValidType(node)
|
||||||
|
local m = device[node.name]
|
||||||
|
return m and m.type == 'minecraft:brewing_stand'and { name = 'Brewing Stand', value = 'brewingStand' }
|
||||||
|
end
|
||||||
|
|
||||||
function brewingStandView:isValidFor(node)
|
function brewingStandView:isValidFor(node)
|
||||||
if node.mtype == 'machine' then
|
return node.mtype == 'brewingStand'
|
||||||
local m = device[node.name]
|
|
||||||
return m and m.type == 'minecraft:brewing_stand'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
UI:getPage('nodeWizard').wizard:add({ brewingStand = brewingStandView })
|
UI:getPage('nodeWizard').wizard:add({ brewingStand = brewingStandView })
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ local exportView = UI.Window {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function exportView:isValidType(node)
|
||||||
|
local m = device[node.name]
|
||||||
|
return m and m.pullItems and { name = 'Generic Inventory', value = 'machine' }
|
||||||
|
end
|
||||||
|
|
||||||
function exportView:isValidFor(node)
|
function exportView:isValidFor(node)
|
||||||
return node.mtype == 'machine'
|
return node.mtype == 'machine'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ local importView = UI.Window {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function importView:isValidType(node)
|
||||||
|
local m = device[node.name]
|
||||||
|
return m and m.pullItems and { name = 'Generic Inventory', value = 'machine' }
|
||||||
|
end
|
||||||
|
|
||||||
function importView:isValidFor(node)
|
function importView:isValidFor(node)
|
||||||
return node.mtype == 'machine'
|
return node.mtype == 'machine'
|
||||||
end
|
end
|
||||||
|
|||||||
33
milo/plugins/inputChestView.lua
Normal file
33
milo/plugins/inputChestView.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
local Ansi = require('ansi')
|
||||||
|
local UI = require('ui')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local device = _G.device
|
||||||
|
|
||||||
|
--[[ Configuration Screen ]]
|
||||||
|
local template =
|
||||||
|
[[%sInput Chest%s
|
||||||
|
|
||||||
|
Any items placed in this chest will be imported into storage.
|
||||||
|
]]
|
||||||
|
|
||||||
|
local inputChestWizardPage = UI.Window {
|
||||||
|
title = 'Input Chest',
|
||||||
|
index = 2,
|
||||||
|
backgroundColor = colors.cyan,
|
||||||
|
[1] = UI.TextArea {
|
||||||
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function inputChestWizardPage:isValidType(node)
|
||||||
|
local m = device[node.name]
|
||||||
|
return m and m.pullItems and { name = 'Input Chest', value = 'input' }
|
||||||
|
end
|
||||||
|
|
||||||
|
function inputChestWizardPage:isValidFor(node)
|
||||||
|
return node.mtype == 'input'
|
||||||
|
end
|
||||||
|
|
||||||
|
UI:getPage('nodeWizard').wizard:add({ inputChest = inputChestWizardPage })
|
||||||
@@ -1,21 +1,53 @@
|
|||||||
|
local Ansi = require('ansi')
|
||||||
local Craft = require('turtle.craft')
|
local Craft = require('turtle.craft')
|
||||||
local itemDB = require('itemDB')
|
local itemDB = require('itemDB')
|
||||||
local Milo = require('milo')
|
local Milo = require('milo')
|
||||||
local Peripheral = require('peripheral')
|
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
|
local context = Milo:getContext()
|
||||||
|
local device = _G.device
|
||||||
|
local monNode = context.storage:getSingleNode('jobs')
|
||||||
|
|
||||||
local context = Milo:getContext()
|
--[[ Configuration Screen ]]
|
||||||
local mon = Peripheral.lookup(context.config.monitor) or
|
local template =
|
||||||
error('Monitor is not attached')
|
[[%sDisplays the crafting progress%s
|
||||||
|
|
||||||
|
%sMilo must be restarted to activate diplay.
|
||||||
|
]]
|
||||||
|
|
||||||
|
local jobsWizardPage = UI.Window {
|
||||||
|
title = 'Crafting Monitor',
|
||||||
|
index = 2,
|
||||||
|
backgroundColor = colors.cyan,
|
||||||
|
[1] = UI.TextArea {
|
||||||
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function jobsWizardPage:isValidType(node)
|
||||||
|
local m = device[node.name]
|
||||||
|
return m and m.type == 'monitor' and { name = 'Crafting Monitor', value = 'jobs' }
|
||||||
|
end
|
||||||
|
|
||||||
|
function jobsWizardPage:isValidFor(node)
|
||||||
|
return node.mtype == 'jobs'
|
||||||
|
end
|
||||||
|
|
||||||
|
UI:getPage('nodeWizard').wizard:add({ jobs = jobsWizardPage })
|
||||||
|
|
||||||
|
--[[ Display ]]
|
||||||
|
if not monNode then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: some way to cancel a job
|
-- TODO: some way to cancel a job
|
||||||
|
|
||||||
local jobMonitor = UI.Page {
|
local jobMonitor = UI.Page {
|
||||||
parent = UI.Device {
|
parent = UI.Device {
|
||||||
device = mon,
|
device = monNode.adapter,
|
||||||
textScale = .5,
|
textScale = .5,
|
||||||
},
|
},
|
||||||
grid = UI.Grid {
|
grid = UI.Grid {
|
||||||
@@ -90,6 +122,7 @@ jobMonitor:enable()
|
|||||||
jobMonitor:draw()
|
jobMonitor:draw()
|
||||||
jobMonitor:sync()
|
jobMonitor:sync()
|
||||||
|
|
||||||
|
--[[ Task ]]
|
||||||
local jobMonitorTask = {
|
local jobMonitorTask = {
|
||||||
name = 'job status',
|
name = 'job status',
|
||||||
priority = 80,
|
priority = 80,
|
||||||
|
|||||||
64
milo/plugins/manipulatorView.lua
Normal file
64
milo/plugins/manipulatorView.lua
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
local Ansi = require('ansi')
|
||||||
|
local Milo = require('milo')
|
||||||
|
local Sync = require('sync')
|
||||||
|
local UI = require('ui')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local device = _G.device
|
||||||
|
local turtle = _G.turtle
|
||||||
|
|
||||||
|
--[[ Configuration Screen ]]
|
||||||
|
local template =
|
||||||
|
[[%sBound Manipulator%s
|
||||||
|
|
||||||
|
Automatically import items into storage from your ender chest.
|
||||||
|
]]
|
||||||
|
|
||||||
|
local wizardPage = UI.Window {
|
||||||
|
title = 'Manipulator',
|
||||||
|
index = 2,
|
||||||
|
backgroundColor = colors.cyan,
|
||||||
|
[1] = UI.TextArea {
|
||||||
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function wizardPage:isValidType(node)
|
||||||
|
local m = device[node.name]
|
||||||
|
return m and
|
||||||
|
m.type == 'manipulator' and
|
||||||
|
m.getEnder and
|
||||||
|
{ name = 'Manipulator', value = 'manipulator' }
|
||||||
|
end
|
||||||
|
|
||||||
|
function wizardPage:isValidFor(node)
|
||||||
|
return node.mtype == 'manipulator'
|
||||||
|
end
|
||||||
|
|
||||||
|
UI:getPage('nodeWizard').wizard:add({ manipulator = wizardPage })
|
||||||
|
|
||||||
|
local task = {
|
||||||
|
name = 'manipulator',
|
||||||
|
priority = 15,
|
||||||
|
}
|
||||||
|
|
||||||
|
function task:cycle(context)
|
||||||
|
local function filter(v)
|
||||||
|
return v.adapter.getEnder
|
||||||
|
end
|
||||||
|
|
||||||
|
for manipulator in context.storage:filterActive('manipulator', filter) do
|
||||||
|
for slot, item in pairs(manipulator.adapter.getEnder().list()) do
|
||||||
|
Sync.sync(turtle, function()
|
||||||
|
manipulator.adapter.getEnder().pushItems(
|
||||||
|
context.localName,
|
||||||
|
slot,
|
||||||
|
item.count)
|
||||||
|
Milo:clearGrid()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Milo:registerTask(task)
|
||||||
@@ -70,4 +70,4 @@ function dispenserView:setNode(node)
|
|||||||
self.form:setValues(node.redstone)
|
self.form:setValues(node.redstone)
|
||||||
end
|
end
|
||||||
|
|
||||||
UI:getPage('nodeWizard').wizard:add({ dispenser = dispenserView })
|
--UI:getPage('nodeWizard').wizard:add({ dispenser = dispenserView })
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ local function client(socket)
|
|||||||
|
|
||||||
local manipulator = getManipulatorForUser(user)
|
local manipulator = getManipulatorForUser(user)
|
||||||
if not manipulator then
|
if not manipulator then
|
||||||
_debug('REMOTE: Manipulator with introspection module bound with user not found. Closing connection.')
|
_G._debug('REMOTE: Manipulator with introspection module bound with user not found. Closing connection.')
|
||||||
socket:write({
|
socket:write({
|
||||||
msg = 'Manipulator not found'
|
msg = 'Manipulator not found'
|
||||||
})
|
})
|
||||||
@@ -37,7 +37,7 @@ local function client(socket)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
_debug('REMOTE: all good')
|
_G._debug('REMOTE: all good')
|
||||||
socket:write({
|
socket:write({
|
||||||
data = 'ok',
|
data = 'ok',
|
||||||
})
|
})
|
||||||
@@ -98,12 +98,14 @@ local function client(socket)
|
|||||||
request.requested,
|
request.requested,
|
||||||
data.item)
|
data.item)
|
||||||
|
|
||||||
turtle.eachFilledSlot(function(slot)
|
if transferred > 0 then
|
||||||
manipulator.getInventory().pullItems(
|
turtle.eachFilledSlot(function(slot)
|
||||||
context.localName,
|
manipulator.getInventory().pullItems(
|
||||||
slot.index,
|
context.localName,
|
||||||
transferred)
|
slot.index,
|
||||||
end)
|
slot.count)
|
||||||
|
end)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ function storageView:validate()
|
|||||||
return self.form:save()
|
return self.form:save()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function storageView:isValidType(node)
|
||||||
|
local m = device[node.name]
|
||||||
|
return m and m.pullItems and { name = 'Storage', value = 'storage' }
|
||||||
|
end
|
||||||
|
|
||||||
function storageView:isValidFor(node)
|
function storageView:isValidFor(node)
|
||||||
return node.mtype == 'storage'
|
return node.mtype == 'storage'
|
||||||
end
|
end
|
||||||
|
|||||||
35
milo/plugins/trashcanView.lua
Normal file
35
milo/plugins/trashcanView.lua
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
local Ansi = require('ansi')
|
||||||
|
local UI = require('ui')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local device = _G.device
|
||||||
|
|
||||||
|
--[[ Configuration Screen ]]
|
||||||
|
local template =
|
||||||
|
[[%sUse this inventory as a trashcan%s
|
||||||
|
|
||||||
|
If the number of items exceed the maximum value will be sent to this inventory.
|
||||||
|
|
||||||
|
Any items that cannot fit into a locked chest will automatically be sent to this inventory.
|
||||||
|
]]
|
||||||
|
|
||||||
|
local trashcanWizardPage = UI.Window {
|
||||||
|
title = 'Trashcan',
|
||||||
|
index = 2,
|
||||||
|
backgroundColor = colors.cyan,
|
||||||
|
[1] = UI.TextArea {
|
||||||
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function trashcanWizardPage:isValidType(node)
|
||||||
|
local m = device[node.name]
|
||||||
|
return m and m.pullItems and { name = 'Trashcan', value = 'trashcan' }
|
||||||
|
end
|
||||||
|
|
||||||
|
function trashcanWizardPage:isValidFor(node)
|
||||||
|
return node.mtype == 'trashcan'
|
||||||
|
end
|
||||||
|
|
||||||
|
UI:getPage('nodeWizard').wizard:add({ trashcan = trashcanWizardPage })
|
||||||
Reference in New Issue
Block a user