From 949c4855399cb035ca93157d296c351722c52315 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Fri, 17 Apr 2020 20:41:58 -0600 Subject: [PATCH] changes for deprecated ui methods - recolor milo - make turtle scripts run again - mob rancher improvements --- builder/builder.lua | 6 +- common/Appstore.lua | 4 +- common/Devices.lua | 4 +- common/DiskCopy.lua | 2 +- common/Events.lua | 2 +- common/Follow.lua | 2 +- common/SoundPlayer.lua | 2 +- common/Turtles.lua | 46 ++++++---- common/etc/scripts/moveTo | 29 ------ common/etc/scripts/moveTo.lua | 17 ++++ gps/gpsServer.lua | 2 +- milo/MiloLocal.lua | 2 +- milo/MiloRemote.lua | 8 +- milo/core/listing.lua | 8 +- milo/core/machines.lua | 11 +-- milo/plugins/activityView.lua | 1 - milo/plugins/backupView.lua | 2 - milo/plugins/brewingStandView.lua | 1 - milo/plugins/emitterView.lua | 2 - milo/plugins/inputChestView.lua | 2 - milo/plugins/item/infoTab.lua | 3 - milo/plugins/item/machinesTab.lua | 1 - milo/plugins/item/recipeTab.lua | 3 - milo/plugins/jobMonitor.lua | 1 - milo/plugins/remote/setup.lua | 3 +- milo/plugins/speakerView.lua | 1 - milo/plugins/statsView.lua | 6 +- milo/plugins/storageView.lua | 2 - milo/plugins/transferView.lua | 1 - milo/plugins/trashcanView.lua | 1 - neural/Equipment.lua | 142 ++++++++++++++++++++++++++++++ neural/Scanner.lua | 4 +- neural/Sensor.lua | 4 +- neural/etc/apps.db | 6 ++ neural/mobRancher.lua | 35 +++++--- recipeBook/recipeBook.lua | 4 +- secure/autorun/lock.lua | 4 +- swshop/Shoplogs.lua | 2 +- swshop/shopConfig.lua | 4 +- 39 files changed, 258 insertions(+), 122 deletions(-) delete mode 100644 common/etc/scripts/moveTo create mode 100644 common/etc/scripts/moveTo.lua create mode 100644 neural/Equipment.lua diff --git a/builder/builder.lua b/builder/builder.lua index 7e7638f..c021169 100644 --- a/builder/builder.lua +++ b/builder/builder.lua @@ -724,8 +724,7 @@ function startPage:eventHandler(event) Builder:begin() elseif event.type == 'quit' then - UI.term:reset() - Event.exitPullEvents() + UI:quit() end return UI.Page.eventHandler(self, event) @@ -769,5 +768,4 @@ UI:setPages({ }) UI:setPage('start') - -UI:pullEvents() +UI:start() diff --git a/common/Appstore.lua b/common/Appstore.lua index 2bbb521..7576f5f 100644 --- a/common/Appstore.lua +++ b/common/Appstore.lua @@ -354,7 +354,7 @@ function categoryPage:eventHandler(event) self:draw() elseif event.type == 'quit' then - UI:exitPullEvents() + UI:quit() else return UI.Page.eventHandler(self, event) @@ -366,4 +366,4 @@ print("Retrieving catalog list") categoryPage:setCategory(source.name, source.index) UI:setPage(categoryPage) -UI:pullEvents() +UI:start() diff --git a/common/Devices.lua b/common/Devices.lua index 0415291..22177b9 100644 --- a/common/Devices.lua +++ b/common/Devices.lua @@ -49,7 +49,7 @@ end function peripheralsPage:eventHandler(event) if event.type == 'quit' then - Event.exitPullEvents() + UI:quit() elseif event.type == 'grid_select' then UI:setPage('methods', event.selected) @@ -198,4 +198,4 @@ UI:setPages({ methods = methodsPage, }) -UI:pullEvents() +UI:start() diff --git a/common/DiskCopy.lua b/common/DiskCopy.lua index a0d41ef..ef1f4a6 100644 --- a/common/DiskCopy.lua +++ b/common/DiskCopy.lua @@ -269,4 +269,4 @@ Event.onTimeout(.2, function() end) UI:setPage(page) -UI:pullEvents() +UI:start() diff --git a/common/Events.lua b/common/Events.lua index 83f3fdd..783e38c 100644 --- a/common/Events.lua +++ b/common/Events.lua @@ -90,7 +90,7 @@ local page = UI.Page { self.grid:draw() elseif event.type == 'quit' then - UI:exitPullEvents() + UI:quit() else return UI.Page.eventHandler(self, event) diff --git a/common/Follow.lua b/common/Follow.lua index cd9afb2..6c2e84d 100644 --- a/common/Follow.lua +++ b/common/Follow.lua @@ -238,6 +238,6 @@ Event.addRoutine(function() end) UI:setPage(page) -UI:pullEvents() +UI:start() swarm:stop() diff --git a/common/SoundPlayer.lua b/common/SoundPlayer.lua index bcce449..bb36029 100644 --- a/common/SoundPlayer.lua +++ b/common/SoundPlayer.lua @@ -60,4 +60,4 @@ function page:eventHandler(event) end UI:setPage(page) -UI:pullEvents() +UI:start() diff --git a/common/Turtles.lua b/common/Turtles.lua index 947ec62..38bf888 100644 --- a/common/Turtles.lua +++ b/common/Turtles.lua @@ -292,30 +292,42 @@ function page:runScript(scriptName) print('Unable to read script file') end - local socket = Socket.connect(turtle.id, 161) - if not socket then - print('Unable to connect to ' .. turtle.id) - return - end - - local function processVariables(script) + local function processVariables() local variables = { - COMPUTER_ID = os.getComputerID(), + COMPUTER_ID = os.getComputerID, + GPS = function() + local pt = require('opus.gps').getPoint() + if not pt then + error('Unable to determine location') + end + return _G.textutils.serialize(pt) + end, } for k,v in pairs(variables) do local token = string.format('{%s}', k) - script = script:gsub(token, v) + if script:find(token, 1, true) then + local s, m = pcall(v) + if not s then + self.notification:error(m) + return + end + script = script:gsub(token, m) + end end - - return script + return true end - script = processVariables(script) + if processVariables(script) then + local socket = Socket.connect(turtle.id, 161) + if not socket then + self.notification:error('Unable to connect') + return + end + socket:write({ type = 'script', args = script }) + socket:close() - socket:write({ type = 'script', args = script }) - socket:close() - - self.notification:success('Sent') + self.notification:success('Sent') + end end end @@ -339,7 +351,7 @@ end function page:eventHandler(event) if event.type == 'quit' then - UI:exitPullEvents() + UI:quit() elseif event.type == 'tab_select' then config.tab = event.button.text diff --git a/common/etc/scripts/moveTo b/common/etc/scripts/moveTo deleted file mode 100644 index 11be075..0000000 --- a/common/etc/scripts/moveTo +++ /dev/null @@ -1,29 +0,0 @@ -turtle.run(function() - - _G.requireInjector(_ENV) - - local GPS = require('opus.gps') - local Socket = require('opus.socket') - - local id = {COMPUTER_ID} - - if not turtle.enableGPS() then - error('turtle: No GPS found') - end - - local socket = Socket.connect(id, 161) - if not socket then - error('turtle: Unable to connect to ' .. id) - end - - socket:write({ type = 'gps' }) - - local pt = socket:read(3) - if not pt then - error('turtle: No GPS response') - end - - if not turtle.pathfind(pt) then - error('Unable to go to location') - end -end) diff --git a/common/etc/scripts/moveTo.lua b/common/etc/scripts/moveTo.lua new file mode 100644 index 0000000..72d597a --- /dev/null +++ b/common/etc/scripts/moveTo.lua @@ -0,0 +1,17 @@ +local turtle = _G.turtle + +turtle.run(function() + _G.requireInjector(_ENV) + + local GPS = require('opus.gps') + + if not turtle.enableGPS() then + error('turtle: No GPS found') + end + + local pt = {GPS} + + if not turtle.pathfind(pt) then + error('Unable to go to location') + end +end) diff --git a/gps/gpsServer.lua b/gps/gpsServer.lua index 5c60926..7f6aaed 100644 --- a/gps/gpsServer.lua +++ b/gps/gpsServer.lua @@ -313,4 +313,4 @@ else end UI:setPage(page) -UI:pullEvents() +UI:start() diff --git a/milo/MiloLocal.lua b/milo/MiloLocal.lua index 68b409f..7ba699b 100644 --- a/milo/MiloLocal.lua +++ b/milo/MiloLocal.lua @@ -216,7 +216,7 @@ _G._syslog = function(...) end local s, m = pcall(function() - UI:pullEvents() + UI:start() end) turtle.setStatus('idle') diff --git a/milo/MiloRemote.lua b/milo/MiloRemote.lua index c2dc4f1..f9c6e8c 100644 --- a/milo/MiloRemote.lua +++ b/milo/MiloRemote.lua @@ -63,8 +63,8 @@ local page = UI.Page { x = 1, ex = -13, limit = 50, shadowText = 'filter', - backgroundColor = colors.cyan, - backgroundFocusColor = colors.cyan, + backgroundColor = UI.colors.primary, + backgroundFocusColor = UI.colors.primary, accelerators = { [ 'enter' ] = 'eject', [ 'up' ] = 'grid_up', @@ -169,7 +169,7 @@ end function page:eventHandler(event) if event.type == 'quit' then - UI:exitPullEvents() + UI:quit() elseif event.type == 'setup' then self.setup.form:setValues(context.state) @@ -524,7 +524,7 @@ local programDir = fs.getDir(shell.getRunningProgram()) loadDirectory(fs.combine(programDir, 'plugins/remote')) UI:setPage(page) -UI:pullEvents() +UI:start() if context.socket then context.socket:close() diff --git a/milo/core/listing.lua b/milo/core/listing.lua index 994ceba..aa23978 100644 --- a/milo/core/listing.lua +++ b/milo/core/listing.lua @@ -54,8 +54,8 @@ local page = UI.Page { limit = 50, shadowText = 'filter', shadowTextColor = colors.gray, - backgroundColor = colors.cyan, - backgroundFocusColor = colors.cyan, + backgroundColor = UI.colors.primary, + backgroundFocusColor = UI.colors.primary, accelerators = { [ 'enter' ] = 'eject', [ 'up' ] = 'grid_up', @@ -66,7 +66,7 @@ local page = UI.Page { storageStatus = UI.Text { x = -17, ex = -10, textColor = colors.lime, - backgroundColor = colors.cyan, + backgroundColor = UI.colors.primary, value = '', }, amount = UI.TextEntry { @@ -208,7 +208,7 @@ end function page:eventHandler(event) if event.type == 'quit' then - UI:exitPullEvents() + UI:quit() elseif event.type == 'eject' or event.type == 'grid_select' then self:eject(1) diff --git a/milo/core/machines.lua b/milo/core/machines.lua index 99c61b5..23cb9f1 100644 --- a/milo/core/machines.lua +++ b/milo/core/machines.lua @@ -7,7 +7,6 @@ local Util = require('opus.util') local colors = _G.colors local device = _G.device -local turtle = _G.turtle local context = Milo:getContext() @@ -22,8 +21,8 @@ local networkPage = UI.Page { y = -2, x = 1, ex = -9, limit = 50, shadowText = 'filter', - backgroundColor = colors.cyan, - backgroundFocusColor = colors.cyan, + backgroundColor = UI.colors.primary, + backgroundFocusColor = UI.colors.primary, }, grid = UI.ScrollingGrid { y = 2, ey = -3, @@ -195,7 +194,6 @@ nodeWizard = UI.Page { pages = { general = UI.WizardPage { index = 1, - backgroundColor = colors.cyan, form = UI.Form { x = 2, ex = -2, y = 1, ey = 3, manualControls = true, @@ -236,11 +234,10 @@ The settings will take effect immediately!]], }, }, statusBar = UI.StatusBar { - backgroundColor = colors.cyan, + backgroundColor = UI.colors.primary, }, notification = UI.Notification { }, filter = UI.SlideOut { - backgroundColor = colors.cyan, noFill = true, menuBar = UI.MenuBar { buttons = { @@ -292,7 +289,7 @@ The settings will take effect immediately!]], }, }, statusBar = UI.StatusBar { - backgroundColor = colors.cyan, + backgroundColor = UI.colors.primary, }, }, } diff --git a/milo/plugins/activityView.lua b/milo/plugins/activityView.lua index 723d313..1d8cffd 100644 --- a/milo/plugins/activityView.lua +++ b/milo/plugins/activityView.lua @@ -17,7 +17,6 @@ Right-clicking on the activity monitor will reset the totals.]] local wizardPage = UI.WizardPage { title = 'Activity Monitor', index = 2, - backgroundColor = colors.cyan, [1] = UI.TextArea { x = 2, ex = -2, y = 2, ey = 6, marginRight = 0, diff --git a/milo/plugins/backupView.lua b/milo/plugins/backupView.lua index f52a00e..f53516a 100644 --- a/milo/plugins/backupView.lua +++ b/milo/plugins/backupView.lua @@ -3,7 +3,6 @@ local Event = require('opus.event') local Milo = require('milo') local UI = require('opus.ui') -local colors = _G.colors local device = _G.device local fs = _G.fs local os = _G.os @@ -23,7 +22,6 @@ Backup configuration files each minecraft day. local wizardPage = UI.WizardPage { title = 'Backup Drive', index = 2, - backgroundColor = colors.cyan, [1] = UI.TextArea { x = 2, ex = -2, y = 2, ey = -2, value = string.format(template, Ansi.yellow, Ansi.reset), diff --git a/milo/plugins/brewingStandView.lua b/milo/plugins/brewingStandView.lua index 88b550a..c97004e 100644 --- a/milo/plugins/brewingStandView.lua +++ b/milo/plugins/brewingStandView.lua @@ -18,7 +18,6 @@ Note that you do not need to import items from the brewing stand or export blaze local wizardPage = UI.WizardPage { title = 'Brewing Stand', index = 2, - backgroundColor = colors.cyan, [1] = UI.TextArea { x = 2, ex = -2, y = 2, ey = -2, value = string.format(template, Ansi.yellow, Ansi.reset), diff --git a/milo/plugins/emitterView.lua b/milo/plugins/emitterView.lua index f3c51d3..6198a6a 100644 --- a/milo/plugins/emitterView.lua +++ b/milo/plugins/emitterView.lua @@ -4,12 +4,10 @@ local itemDB = require('core.itemDB') local colors = _G.colors local device = _G.device -local context = Milo:getContext() local wizardPage = UI.WizardPage { title = 'Level Emitter', index = 2, - backgroundColor = colors.cyan, [1] = UI.TextArea { x = 2, y = 1, height = 2, diff --git a/milo/plugins/inputChestView.lua b/milo/plugins/inputChestView.lua index fe0fd9a..5709f3b 100644 --- a/milo/plugins/inputChestView.lua +++ b/milo/plugins/inputChestView.lua @@ -1,7 +1,6 @@ local Ansi = require('opus.ansi') local UI = require('opus.ui') -local colors = _G.colors local device = _G.device --[[ Configuration Screen ]] @@ -14,7 +13,6 @@ Any items placed in this chest will be imported into storage. local inputChestWizardPage = UI.WizardPage { 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), diff --git a/milo/plugins/item/infoTab.lua b/milo/plugins/item/infoTab.lua index 5bf7cc9..fb96fc1 100644 --- a/milo/plugins/item/infoTab.lua +++ b/milo/plugins/item/infoTab.lua @@ -1,12 +1,9 @@ local Ansi = require('opus.ansi') local UI = require('opus.ui') -local colors = _G.colors - local infoTab = UI.Tab { tabTitle = 'Info', index = 4, - backgroundColor = colors.cyan, textArea = UI.TextArea { x = 2, ex = -2, y = 2, ey = -2, }, diff --git a/milo/plugins/item/machinesTab.lua b/milo/plugins/item/machinesTab.lua index 4ff7e04..8f52595 100644 --- a/milo/plugins/item/machinesTab.lua +++ b/milo/plugins/item/machinesTab.lua @@ -9,7 +9,6 @@ local context = Milo:getContext() local machinesTab = UI.Tab { tabTitle = 'Machine', index = 3, - backgroundColor = colors.cyan, grid = UI.ScrollingGrid { x = 2, ex = -2, y = 2, ey = -2, disableHeader = true, diff --git a/milo/plugins/item/recipeTab.lua b/milo/plugins/item/recipeTab.lua index 0a08fca..93e321f 100644 --- a/milo/plugins/item/recipeTab.lua +++ b/milo/plugins/item/recipeTab.lua @@ -3,12 +3,9 @@ local itemDB = require('core.itemDB') local Milo = require('milo') local UI = require('opus.ui') -local colors = _G.colors - local recipeTab = UI.Tab { tabTitle = 'Recipe', index = 2, - backgroundColor = colors.cyan, grid = UI.ScrollingGrid { x = 2, ex = -2, y = 2, ey = -4, disableHeader = true, diff --git a/milo/plugins/jobMonitor.lua b/milo/plugins/jobMonitor.lua index 846e279..a548fcf 100644 --- a/milo/plugins/jobMonitor.lua +++ b/milo/plugins/jobMonitor.lua @@ -15,7 +15,6 @@ local os = _G.os local wizardPage = UI.WizardPage { title = 'Crafting Monitor', index = 2, - backgroundColor = colors.cyan, [1] = UI.TextArea { x = 2, ex = -2, y = 2, ey = 3, marginRight = 0, diff --git a/milo/plugins/remote/setup.lua b/milo/plugins/remote/setup.lua index 1ea8de3..4688300 100644 --- a/milo/plugins/remote/setup.lua +++ b/milo/plugins/remote/setup.lua @@ -10,7 +10,6 @@ local STARTUP_FILE = 'usr/autorun/miloRemote.lua' local context = ({ ... })[1] local setup = UI.SlideOut { - backgroundColor = colors.cyan, titleBar = UI.TitleBar { title = 'Remote Setup', }, @@ -51,7 +50,7 @@ local setup = UI.SlideOut { [[also have an introspection module.]], }, statusBar = UI.StatusBar { - backgroundColor = colors.cyan, + backgroundColor = UI.colors.primary, }, } diff --git a/milo/plugins/speakerView.lua b/milo/plugins/speakerView.lua index c5668dc..1b5cd3c 100644 --- a/milo/plugins/speakerView.lua +++ b/milo/plugins/speakerView.lua @@ -14,7 +14,6 @@ end local wizardPage = UI.WizardPage { title = 'Speaker', index = 2, - backgroundColor = colors.cyan, [1] = UI.Text { x = 2, y = 2, textColor = colors.yellow, diff --git a/milo/plugins/statsView.lua b/milo/plugins/statsView.lua index 4f70601..b6ab90c 100644 --- a/milo/plugins/statsView.lua +++ b/milo/plugins/statsView.lua @@ -18,7 +18,6 @@ Right-clicking on the activity monitor will reset the totals.]] local wizardPage = UI.WizardPage { title = 'Status Monitor', index = 2, - backgroundColor = colors.cyan, [1] = UI.TextArea { x = 2, ex = -2, y = 2, ey = 6, marginRight = 0, @@ -137,12 +136,14 @@ local function createPage(node) }, [2] = UI.Tab { tabTitle = 'Stats', + noFill = true, textArea = UI.TextArea { y = 3, }, }, [3] = UI.Tab { tabTitle = 'Storage', + noFill = true, grid = UI.ScrollingGrid { y = 2, columns = { @@ -157,6 +158,7 @@ local function createPage(node) }, [4] = UI.Tab { tabTitle = 'Offline', + noFill = true, grid = UI.ScrollingGrid { y = 2, columns = { @@ -167,12 +169,14 @@ local function createPage(node) }, [5] = UI.Tab { tabTitle = 'Activity', + noFill = true, term = UI.Embedded { --visible = true, }, }, [6] = UI.Tab { tabTitle = 'Tasks', + noFill = true, grid = UI.ScrollingGrid { y = 2, values = context.tasks, diff --git a/milo/plugins/storageView.lua b/milo/plugins/storageView.lua index b1d51c2..18e2c0e 100644 --- a/milo/plugins/storageView.lua +++ b/milo/plugins/storageView.lua @@ -7,7 +7,6 @@ local device = _G.device local storageView = UI.WizardPage { title = 'Storage Options - General', index = 2, - backgroundColor = colors.cyan, form = UI.Form { x = 2, ex = -2, y = 1, ey = -2, manualControls = true, @@ -62,7 +61,6 @@ UI:getPage('nodeWizard').wizard:add({ storageGeneral = storageView }) local lockView = UI.WizardPage { title = 'Storage Options - Locking', index = 3, - backgroundColor = colors.cyan, form = UI.Form { x = 2, ex = -2, y = 1, ey = 3, manualControls = true, diff --git a/milo/plugins/transferView.lua b/milo/plugins/transferView.lua index 3fa70ff..df6079e 100644 --- a/milo/plugins/transferView.lua +++ b/milo/plugins/transferView.lua @@ -12,7 +12,6 @@ local context = Milo:getContext() local wizardPage = UI.WizardPage { title = 'Transfer Inventory', index = 2, - backgroundColor = colors.cyan, grid = UI.ScrollingGrid { y = 2, ey = -2, values = context.storage.nodes, diff --git a/milo/plugins/trashcanView.lua b/milo/plugins/trashcanView.lua index 2de4a4e..fc1e70f 100644 --- a/milo/plugins/trashcanView.lua +++ b/milo/plugins/trashcanView.lua @@ -9,7 +9,6 @@ local device = _G.device local wizardPage = UI.WizardPage { title = 'Trashcan', index = 2, - backgroundColor = colors.cyan, info = UI.TextArea { x = 1, ex = -1, y = 2, ey = 4, textColor = colors.yellow, diff --git a/neural/Equipment.lua b/neural/Equipment.lua new file mode 100644 index 0000000..32b849e --- /dev/null +++ b/neural/Equipment.lua @@ -0,0 +1,142 @@ +local Event = require('opus.event') +local itemDB = require('core.itemDB') +local neural = require('neural.interface') +local UI = require('opus.ui') +local Util = require('opus.util') + +local device = _G.device + +neural.assertModules({ + 'plethora:sensor', + 'plethora:kinetic', + 'plethora:introspection', +}) +UI:configure('Equipment', ...) + +local equipment = device.neuralInterface.getEquipment() + +local slots = { + 'primary', + 'offhand', + 'boots', + 'leggings', + 'chest', + 'helmet', +} + +local page = UI.Page { + menuBar = UI.MenuBar { + buttons = { + { text = 'Drop', event = 'drop' }, + { text = 'Suck', event = 'suck' }, + }, + }, + grid = UI.Grid { + y = 2, + columns = { + { heading = 'Slot', key = 'index', width = 7 }, + { heading = 'Name', key = 'displayName' }, + { heading = 'Count', key = 'count', width = 5, align = 'right' }, + }, + sortColumn = 'index', + accelerators = { + grid_select = 'show_detail', + }, + getDisplayValues = function(_, row) + row = Util.shallowCopy(row) + if row.name then + local item = itemDB:get( + table.concat({ row.name, row.damage, row.nbtHash }, ':'), + function() + return equipment.getItemMeta(row.index) + end) + row.displayName = item.displayName + else + row.displayName = 'empty' + end + row.index = slots[row.index] + return row + end, + }, + accelerators = { + [ 'control-q' ] = 'quit', + }, + detail = UI.SlideOut { + menuBar = UI.MenuBar { + buttons = { + { text = 'Back', event = 'slide_hide' }, + }, + }, + grid = UI.ScrollingGrid { + y = 2, + columns = { + { heading = 'Name', key = 'name' }, + { heading = 'Value', key = 'value' }, + }, + sortColumn = 'name', + accelerators = { + grid_select = 'inspect', + }, + }, + show = function(self, slot) + local detail = equipment.getItemMeta(slot.index) + local t = { } + for k,v in pairs(detail) do + table.insert(t, { + name = k, + value = v, + }) + end + self.grid:setValues(t) + self.grid:setIndex(1) + UI.SlideOut.show(self) + end, + }, + enable = function(self) + self:refresh() + UI.Page.enable(self) + end, + refresh = function(self) + local t = { } + local list = equipment.list() + for i = 1, equipment.size() do + local v = list[i] or { } + v.index = i + table.insert(t, v) + end + self.grid:setValues(t) + self.grid:draw() + end, + eventHandler = function(self, event) + if event.type == 'quit' then + UI:quit() + + elseif event.type == 'show_detail' then + if event.selected.name then + self.detail:show(event.selected) + end + + elseif event.type == 'drop' then + local selected = self.grid:getSelected() + equipment.drop(selected.index) + self:refresh() + + elseif event.type == 'suck' then + local selected = self.grid:getSelected() + equipment.suck(selected.index) + self:refresh() + end + + UI.Page.eventHandler(self, event) + end, +} + +Event.onInterval(1, function() + page:refresh() + page:sync() +end) + +UI:setPage(page) +UI:start() + +itemDB:flush() diff --git a/neural/Scanner.lua b/neural/Scanner.lua index 11edab2..4dd6be5 100644 --- a/neural/Scanner.lua +++ b/neural/Scanner.lua @@ -182,7 +182,7 @@ end function page:eventHandler(event) if event.type == 'quit' then - Event.exitPullEvents() + UI:quit() elseif event.type == 'scan' then self:scan() @@ -211,7 +211,7 @@ Event.onTimeout(0, function() page:sync() end) -UI:pullEvents() +UI:start() if canvas then canvas:clear() diff --git a/neural/Sensor.lua b/neural/Sensor.lua index d926c05..42d0b9a 100644 --- a/neural/Sensor.lua +++ b/neural/Sensor.lua @@ -253,7 +253,7 @@ end function page:eventHandler(event) if event.type == 'quit' then - Event.exitPullEvents() + UI:quit() elseif event.type == 'tab_activate' then config.activeTab = event.activated.tabTitle @@ -268,7 +268,7 @@ if config.activeTab then end UI:setPage(page) -UI:pullEvents() +UI:start() if canvas then canvas:clear() diff --git a/neural/etc/apps.db b/neural/etc/apps.db index 61040b2..31c01d7 100644 --- a/neural/etc/apps.db +++ b/neural/etc/apps.db @@ -29,4 +29,10 @@ run = "ores.lua", requires = "neuralInterface", }, + [ "7f2465ac7cefab2766e6ee0714647089df9364b0ff09858c84b21b8a436a845d" ] = { + title = "Equipment", + category = "Neural", + run = "Equipment", + requires = "neuralInterface", + } } diff --git a/neural/mobRancher.lua b/neural/mobRancher.lua index c09d7d3..51ce614 100644 --- a/neural/mobRancher.lua +++ b/neural/mobRancher.lua @@ -1,6 +1,15 @@ --[[ - Breed either cows or sheep. - Must be run on a mob with the same height. + Changed to use a 2-high mob (smaller mobs may work ?) + Updated due to entity.look working correctly now. + + The mob looks head-on to the lever. Make sure the + lever is accessible by the mob. + + Laser is now optional - if no laser, the mobs will be + punched (or provide a stick). Best mob may be a + skeleton (unlimited ammo). + + Feeding hand has been changed to off-hand. ]] local Array = require('opus.array') @@ -21,7 +30,7 @@ local WALK_SPEED = 1.5 neural.assertModules({ 'plethora:sensor', 'plethora:scanner', - 'plethora:laser', + --'plethora:laser', 'plethora:kinetic', 'plethora:introspection', }) @@ -29,27 +38,27 @@ neural.assertModules({ local fed = { } local function resupply() - local slot = neural.getEquipment().list()[1] + local slot = neural.getEquipment().list()[2] if slot and slot.count > 32 then return end print('resupplying') for _ = 1, 2 do - local dispenser = Map.find(neural.scan(), 'name', 'minecraft:dispenser') + local dispenser = Map.find(neural.scan(), 'name', 'minecraft:lever') if not dispenser then print('dispenser not found') break end if math.abs(dispenser.x) <= 1 and math.abs(dispenser.z) <= 1 then - neural.lookAt(dispenser) + neural.lookAt({ x = dispenser.x, y = dispenser.y, z = dispenser.z }) for _ = 1, 8 do neural.use(0, 'off') os.sleep(.2) - neural.getEquipment().suck(1, 64) + neural.getEquipment().suck(2, 64) end break else - neural.walkTo({ x = dispenser.x, y = 0, z = dispenser.z }, WALK_SPEED) + neural.walkTo({ x = dispenser.x, y = 0, z = dispenser.z }, WALK_SPEED, .5) end end end @@ -63,18 +72,22 @@ local function breed(entity) entity = neural.getMetaByID(entity.id) if entity then neural.lookAt(entity) - neural.use(1) + neural.use(1, 'off') os.sleep(.1) end end local function kill(entity) print('killing') - neural.walkTo(entity, WALK_SPEED, 2.5) + neural.walkTo(entity, WALK_SPEED, (neural.fire or neural.shoot) and 2.5 or .5) entity = neural.getMetaByID(entity.id) if entity then neural.lookAt(entity) - neural.fireAt({ x = entity.x, y = 0, z = entity.z }) + if neural.fire or neural.shoot then + neural.shootAt(entity) + else + neural.swing() + end Sound.play('entity.firework.launch') os.sleep(.2) end diff --git a/recipeBook/recipeBook.lua b/recipeBook/recipeBook.lua index 4df6acb..65d4fc7 100644 --- a/recipeBook/recipeBook.lua +++ b/recipeBook/recipeBook.lua @@ -172,11 +172,11 @@ function page:eventHandler(event) self.info:draw() elseif event.type == 'quit' then - UI:exitPullEvents() + UI:quit() end UI.Page.eventHandler(self, event) end UI:setPage(page) -UI:pullEvents() +UI:start() diff --git a/secure/autorun/lock.lua b/secure/autorun/lock.lua index f951dfc..a8965d7 100644 --- a/secure/autorun/lock.lua +++ b/secure/autorun/lock.lua @@ -49,7 +49,7 @@ local function buildLockScreen() #self.pass.value > 0 and Security.verifyPassword(SHA.compute(self.pass.value)) then - UI:exitPullEvents() -- valid + UI:quit() -- valid else self.notification:error('Invalid password', math.max(counter, 2)) self:sync() @@ -66,7 +66,7 @@ local function buildLockScreen() Event.onTerminate(function() return false end) UI:setPage(page) - UI:pullEvents() + UI:start() -- restart lock timer timer = os.startTimer(config.timeout) diff --git a/swshop/Shoplogs.lua b/swshop/Shoplogs.lua index 5766b08..5a478e3 100644 --- a/swshop/Shoplogs.lua +++ b/swshop/Shoplogs.lua @@ -189,4 +189,4 @@ end) page.grid:loadTransactions() UI:setPage(page) -UI:pullEvents() +UI:start() diff --git a/swshop/shopConfig.lua b/swshop/shopConfig.lua index 026ad16..761b587 100644 --- a/swshop/shopConfig.lua +++ b/swshop/shopConfig.lua @@ -9,7 +9,6 @@ local os = _G.os local wizardPage = UI.WizardPage { title = 'Store Front', index = 2, - backgroundColor = colors.cyan, form = UI.Form { x = 2, ex = -2, y = 1, ey = -2, manualControls = true, @@ -90,7 +89,6 @@ end local passwordPage = UI.WizardPage { title = 'Krist Settings', index = 3, - backgroundColor = colors.cyan, form = UI.Form { x = 2, ex = -2, y = 1, ey = -2, manualControls = true, @@ -112,7 +110,7 @@ local passwordPage = UI.WizardPage { preview = UI.TextEntry { formIndex = 4, formLabel = 'Using address', formKey = 'address', - backgroundColor = colors.cyan, + backgroundColor = UI.colors.primary, textColor = colors.yellow, inactive = true, },