diff --git a/milo/Milo.lua b/milo/Milo.lua index 351c626..b9f0273 100644 --- a/milo/Milo.lua +++ b/milo/Milo.lua @@ -49,13 +49,30 @@ for _, node in pairs(config.nodes) do end end +local function Syntax(msg) + print([[ +Turtle must be equipped with: + * Introspection module + * Workbench + +Turtle must be connected to: + * Wired modem +]]) + + error(msg) +end + local modem = Peripheral.get('wired_modem') if not modem or not modem.getNameLocal then - error('Wired modem is not connected') + Syntax('Wired modem missing') end local introspection = Peripheral.get('plethora:introspection') or - error('Introspection module not found') + Syntax('Introspection module missing') + +if not device.workbench then + Syntax('Workbench missing') +end local context = { config = config, diff --git a/milo/MiloRemote.lua b/milo/MiloRemote.lua index 2ae9ffa..7c3c68f 100644 --- a/milo/MiloRemote.lua +++ b/milo/MiloRemote.lua @@ -114,11 +114,24 @@ local page = UI.Page { shadowText = 'Inventory slot #', limit = 5, validate = 'numeric', - required = true, + required = false, }, [4] = UI.Checkbox { formLabel = 'Shield Slot', formKey = 'useShield', - help = 'or use the shield slot for sending' + help = 'Or, use the shield slot for sending' + }, + info = UI.TextArea { + x = 1, ex = -1, y = 7, ey = -3, + textColor = colors.yellow, + marginLeft = 0, + marginRight = 0, + value = [[The Milo turtle must connect to a manipulator with a ]] .. + [[bound introspection module. The neural interface must ]] .. + [[also have an introspection module.]], + }, + [5] = UI.Button { + x = 1, y = -2, + text = 'Force scan', event = 'rescan', help = 'Force a scan of all inventories', }, }, statusBar = UI.StatusBar { @@ -252,12 +265,13 @@ function page:eventHandler(event) UI:exitPullEvents() elseif event.type == 'setup' then + self.setup.form:setValues(config) self.setup:show() elseif event.type == 'form_complete' then Config.update('miloRemote', config) self.setup:hide() - self:refresh() + self:refresh('list') self.grid:draw() elseif event.type == 'form_cancel' then @@ -299,10 +313,16 @@ function page:eventHandler(event) self:setStatus('nope ...') end + elseif event.type == 'rescan' then + self:setFocus(self.statusBar.filter) + self:setStatus('rescanning ...') + self:refresh('scan') + self.grid:draw() + elseif event.type == 'refresh' then self:setFocus(self.statusBar.filter) self:setStatus('updating ...') - self:refresh() + self:refresh('list') self.grid:draw() elseif event.type == 'toggle_display' then @@ -339,14 +359,14 @@ function page:enable() self.setup:show() end Event.onTimeout(.1, function() - self:refresh() + self:refresh('list') self.grid:draw() self:sync() end) end -function page:refresh() - local items = self:sendRequest({ request = 'list' }) +function page:refresh(requestType) + local items = self:sendRequest({ request = requestType }) if items then self.items = items @@ -366,7 +386,7 @@ Event.addRoutine(function() local inv = config.useShield and 'getEquipment' or 'getInventory' if not neural or not neural[inv] then _G._debug('missing Introspection module') - elseif config.server then + elseif config.server and (config.useShield or config.slot) then local method = neural[inv] local item = method and method().getItemMeta(config.useShield and SHIELD_SLOT or config.slot) if item then diff --git a/milo/core/machines.lua b/milo/core/machines.lua index 734e578..34f931c 100644 --- a/milo/core/machines.lua +++ b/milo/core/machines.lua @@ -183,7 +183,7 @@ nodeWizard = UI.Page { index = 1, backgroundColor = colors.cyan, form = UI.Form { - x = 1, y = 1, ex = -1, ey = 3, + x = 2, ex = -2, y = 1, ey = 3, manualControls = true, [1] = UI.TextEntry { formLabel = 'Name', formKey = 'displayName', diff --git a/milo/plugins/activityView.lua b/milo/plugins/activityView.lua index 1a15748..222cd04 100644 --- a/milo/plugins/activityView.lua +++ b/milo/plugins/activityView.lua @@ -11,12 +11,11 @@ local monitor = context.storage:getSingleNode('activity') --[[ Configuration Page ]]-- local template = -[[%sDisplays the amount of items entering or leaving storage%s +[[%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. -]] +%sMilo must be restarted to activate diplay.]] local activityWizardPage = UI.Window { title = 'Activity Monitor', @@ -24,6 +23,7 @@ local activityWizardPage = UI.Window { backgroundColor = colors.cyan, [1] = UI.TextArea { x = 2, ex = -2, y = 2, ey = -2, + marginRight = 0, value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange), }, } diff --git a/milo/plugins/exportView.lua b/milo/plugins/exportView.lua index 8bfcbf6..80821a0 100644 --- a/milo/plugins/exportView.lua +++ b/milo/plugins/exportView.lua @@ -2,6 +2,7 @@ local itemDB = require('itemDB') local UI = require('ui') local Util = require('util') +local colors = _G.colors local device = _G.device local exportView = UI.Window { @@ -20,17 +21,18 @@ local exportView = UI.Window { }, }, text = UI.Text { - x = 2, y = -2, + x = 3, y = -2, value = 'Slot', + textColor = colors.black, }, slots = UI.Chooser { - x = 7, y = -2, + x = 8, y = -2, width = 7, nochoice = 'All', help = 'Export to this slot', }, add = UI.Button { - x = 15, y = -2, + x = 16, y = -2, text = '+', event = 'add_entry', help = 'Add', }, remove = UI.Button { diff --git a/milo/plugins/importView.lua b/milo/plugins/importView.lua index 96e3db6..b27e8e4 100644 --- a/milo/plugins/importView.lua +++ b/milo/plugins/importView.lua @@ -2,6 +2,7 @@ local itemDB = require('itemDB') local UI = require('ui') local Util = require('util') +local colors = _G.colors local device = _G.device local importView = UI.Window { @@ -20,17 +21,18 @@ local importView = UI.Window { }, }, text = UI.Text { - x = 2, y = -2, + x = 3, y = -2, value = 'Slot', + textColor = colors.black, }, slots = UI.Chooser { - x = 7, y = -2, + x = 8, y = -2, width = 7, nochoice = 'All', help = 'Import from this slot', }, add = UI.Button { - x = 15, y = -2, + x = 16, y = -2, text = '+', event = 'add_entry', help = 'Add', }, remove = UI.Button { diff --git a/milo/plugins/jobMonitor.lua b/milo/plugins/jobMonitor.lua index 33d811a..3f5b217 100644 --- a/milo/plugins/jobMonitor.lua +++ b/milo/plugins/jobMonitor.lua @@ -14,8 +14,7 @@ local monitor = context.storage:getSingleNode('jobs') local template = [[%sDisplays the crafting progress%s -%sMilo must be restarted to activate diplay. -]] +%sMilo must be restarted to activate diplay.]] local jobsWizardPage = UI.Window { title = 'Crafting Monitor', @@ -23,6 +22,7 @@ local jobsWizardPage = UI.Window { backgroundColor = colors.cyan, [1] = UI.TextArea { x = 2, ex = -2, y = 2, ey = -2, + marginRight = 0, value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange), }, } diff --git a/milo/plugins/manipulatorView.lua b/milo/plugins/manipulatorView.lua index 5c2feb4..84d9107 100644 --- a/milo/plugins/manipulatorView.lua +++ b/milo/plugins/manipulatorView.lua @@ -13,7 +13,7 @@ local wizardPage = UI.Window { index = 2, backgroundColor = colors.cyan, form = UI.Form { - x = 1, y = 3, ex = -1, ey = -2, + x = 2, ex = -2, y = 3, ey = -2, manualControls = true, [1] = UI.Checkbox { formLabel = 'Import', formKey = 'importEnder', @@ -26,7 +26,7 @@ local wizardPage = UI.Window { }, }, userInfo = UI.TextArea { - x = 2, ex = -2, y = 2, height = 1, + x = 3, ex = -2, y = 2, height = 2, }, } diff --git a/milo/plugins/remote.lua b/milo/plugins/remote.lua index 0f522f8..a9e52ff 100644 --- a/milo/plugins/remote.lua +++ b/milo/plugins/remote.lua @@ -48,7 +48,11 @@ local function client(socket) break end - if data.request == 'list' then + if data.request == 'scan' then -- full scan of all inventories + local items = Milo:mergeResources(Milo:listItems(true)) + socket:write(items) + + elseif data.request == 'list' then local items = Milo:mergeResources(Milo:listItems()) socket:write(items) diff --git a/milo/plugins/storageView.lua b/milo/plugins/storageView.lua index 56bc72c..acacc0f 100644 --- a/milo/plugins/storageView.lua +++ b/milo/plugins/storageView.lua @@ -9,7 +9,7 @@ local storageView = UI.Window { index = 2, backgroundColor = colors.cyan, form = UI.Form { - x = 1, y = 1, ex = -1, ey = -2, + x = 2, ex = -2, y = 1, ey = -2, manualControls = true, [1] = UI.TextEntry { formLabel = 'Priority', formKey = 'priority', @@ -28,6 +28,7 @@ local storageView = UI.Window { [3] = UI.TextArea { x = 12, ex = -2, y = 4, textColor = colors.yellow, + marginRight = 0, value = 'Only specify if you are manually taking items out of this inventory. Value should be > 10', }, }, @@ -67,7 +68,7 @@ local lockView = UI.Window { index = 3, backgroundColor = colors.cyan, form = UI.Form { - x = 1, y = 1, ex = -1, ey = 3, + x = 2, ex = -2, y = 1, ey = 3, manualControls = true, [1] = UI.Checkbox { formLabel = 'Locked', formKey = 'lockWith', @@ -79,11 +80,12 @@ local lockView = UI.Window { }, }, grid = UI.ScrollingGrid { - x = 2, ex = -2, y = 4, ey = -2, + x = 2, ex = -2, y = 5, ey = -2, columns = { { heading = 'Name', key = 'displayName' }, }, sortColumn = 'displayName', + disableHeader = true, }, } diff --git a/milo/plugins/trashcanView.lua b/milo/plugins/trashcanView.lua index a6e1836..e305251 100644 --- a/milo/plugins/trashcanView.lua +++ b/milo/plugins/trashcanView.lua @@ -17,7 +17,7 @@ local wizardPage = UI.Window { value = [[ Items can be automatically dropped from this storage.]], }, form = UI.Form { - x = 1, y = 4, ex = -1, ey = -2, + x = 2, ex = -2, y = 4, ey = -2, manualControls = true, [1] = UI.Checkbox { formLabel = 'Drop', formKey = 'drop', @@ -25,7 +25,7 @@ local wizardPage = UI.Window { }, [2] = UI.Chooser { width = 9, - formLabel = 'Drop direction', formKey = 'dropDirection', + formLabel = 'Direction', formKey = 'dropDirection', nochoice = 'Down', choices = { { name = 'Down', value = 'down' },