From 3f19c94e0fa4c28dab162695c168171f7618d111 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Fri, 27 Dec 2019 01:18:09 -0500 Subject: [PATCH 01/10] GPS overhaul --- gps/gpsServer.lua | 7 +++---- neural/ores.lua | 11 ++--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/gps/gpsServer.lua b/gps/gpsServer.lua index 15191e5..5c60926 100644 --- a/gps/gpsServer.lua +++ b/gps/gpsServer.lua @@ -6,7 +6,6 @@ local Event = require('opus.event') local colors = _G.colors local fs = _G.fs -local gps = _G.gps local os = _G.os local peripheral = _G.peripheral local read = _G.read @@ -200,7 +199,7 @@ local function server(mode) error('Modem is not activated or connected: ' .. k) end if mode == 'gps' then - modem.open(gps.CHANNEL_GPS) + modem.open(GPS.CHANNEL_GPS) elseif mode == 'snmp' then modem.open(999) end @@ -254,9 +253,9 @@ local function server(mode) Event.on('modem_message', function(_, side, channel, computerId, message, distance) if distance and modems[side] then - if mode == 'gps' and channel == gps.CHANNEL_GPS and message == "PING" then + if mode == 'gps' and channel == GPS.CHANNEL_GPS and message == "PING" then for _, modem in pairs(modems) do - modem.transmit(computerId, gps.CHANNEL_GPS, { modem.x, modem.y, modem.z }) + modem.transmit(computerId, GPS.CHANNEL_GPS, { modem.x, modem.y, modem.z }) end getPosition(computerId, modems[side], distance) end diff --git a/neural/ores.lua b/neural/ores.lua index 7c15018..9bbf2de 100644 --- a/neural/ores.lua +++ b/neural/ores.lua @@ -6,8 +6,8 @@ -- Updated to use new(ish) canvas3d local Config = require('opus.config') +local GPS = require("opus.gps") -local gps = _G.gps local keys = _G.keys local os = _G.os local parallel = _G.parallel @@ -35,14 +35,7 @@ end local BLOCK_SIZE = .5 local function getPoint() - local pt = { gps.locate() } - if pt[1] then - return { - x = pt[1], - y = pt[2], - z = pt[3], - } - end + return GPS.locate() end local targets = Config.load('ores', { From 62951067aeaf98036c0ec5c94225ccc74d362604 Mon Sep 17 00:00:00 2001 From: LDDestroier Date: Sun, 19 Jan 2020 20:48:41 -0500 Subject: [PATCH 02/10] Updated list URL --- common/Appstore.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/Appstore.lua b/common/Appstore.lua index a94c93f..c489696 100644 --- a/common/Appstore.lua +++ b/common/Appstore.lua @@ -40,7 +40,7 @@ local sources = { { text = "STD Default", event = 'source', - url = "http://pastebin.com/raw/zVws7eLq" }, --stock + url = "https://github.com/LDDestroier/STD-GUI/raw/master/list.lua" }, --stock --[[ { text = "Discover", event = 'source', From 48f142accc1ad233ebeee7152889ad772dd82285 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Wed, 29 Jan 2020 23:14:38 -0500 Subject: [PATCH 03/10] swshop helpfile and updates --- swshop/.package | 3 +++ swshop/Shoplogs.lua | 2 +- swshop/help/swshop | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 swshop/help/swshop diff --git a/swshop/.package b/swshop/.package index efb46ed..afeb083 100644 --- a/swshop/.package +++ b/swshop/.package @@ -1,4 +1,7 @@ { + required = { + 'milo', + }, title = 'Switchcraft basic shop', repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/swshop', description = 'Modification of the k store by Lemmmy\nRun installPlugin.lua after install', diff --git a/swshop/Shoplogs.lua b/swshop/Shoplogs.lua index 2eb605e..5766b08 100644 --- a/swshop/Shoplogs.lua +++ b/swshop/Shoplogs.lua @@ -141,7 +141,7 @@ end function page.grid:getDisplayValues(row) row = Util.shallowCopy(row) local x = row.recipient - row.from = x and x:match('(%w+)@') or row.from + row.from = x and x:match('(.+)@') or row.from return row end diff --git a/swshop/help/swshop b/swshop/help/swshop new file mode 100644 index 0000000..5fc1804 --- /dev/null +++ b/swshop/help/swshop @@ -0,0 +1,25 @@ +An item shop software using Krist as its currency. + +Requirements +============ + * Advanced Turtle + * Chests (any type) + * Milo system + +Installation +============ +> pastebin run uzghlbnc +> package install swshop +> reboot + +Setup +===== +From the shell, run the 'installPlugin.lua' once to install the shop component into your Milo installation. + +From Milo, open the setup page and find the monitor you wish to use in the list. + +Choose the monitor's type to be 'Store Front', and configure your domain and your wallet's key. + +Usage +===== +Setup prices by right-clicking on the desired item and going on the 'Shops' tab. From d971448c9a8c426df5713c04e5d8ef4ecd63e105 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Sat, 8 Feb 2020 00:01:36 -0500 Subject: [PATCH 04/10] Fix swshop Fixes a number transform issue which caused swshop to crash without giving the bought item. --- swshop/swshop.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swshop/swshop.lua b/swshop/swshop.lua index 391b6a8..0bb07ab 100644 --- a/swshop/swshop.lua +++ b/swshop/swshop.lua @@ -44,7 +44,7 @@ local function getItemDetails(item) t = textutils.unserialize(t) for key, v in pairs(t) do if v.name == item then - return key, v.price + return key, tonumber(v.price) end end end From 301f531a4a48ed528dede03957e7a4db5813688b Mon Sep 17 00:00:00 2001 From: Anavrins Date: Fri, 14 Feb 2020 01:13:43 -0500 Subject: [PATCH 05/10] Fix getFuelLimit and getFuelLevel --- turtle/autorun/6.tl3.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/turtle/autorun/6.tl3.lua b/turtle/autorun/6.tl3.lua index 51db8ec..d6a352b 100644 --- a/turtle/autorun/6.tl3.lua +++ b/turtle/autorun/6.tl3.lua @@ -391,8 +391,9 @@ end if type(turtle.getFuelLevel()) ~= 'number' then -- Support unlimited fuel function turtle.getFuelLevel() - return 100000 + return math.huge end + turtle.getFuelLimit = turtle.getFuelLevel end -- override to optionally specify a fuel From afcbfd1b0427d92debf6f2cf2b4be29a5607c397 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Mon, 24 Feb 2020 21:10:30 -0500 Subject: [PATCH 06/10] Added a "Level Emitter" to Milo --- milo/plugins/emitterTask.lua | 29 +++++++++ milo/plugins/emitterView.lua | 109 ++++++++++++++++++++++++++++++++++ milo/plugins/item/infoTab.lua | 3 + 3 files changed, 141 insertions(+) create mode 100644 milo/plugins/emitterTask.lua create mode 100644 milo/plugins/emitterView.lua diff --git a/milo/plugins/emitterTask.lua b/milo/plugins/emitterTask.lua new file mode 100644 index 0000000..b5088dd --- /dev/null +++ b/milo/plugins/emitterTask.lua @@ -0,0 +1,29 @@ +local itemDB = require('core.itemDB') +local Milo = require('milo') + +local device = _G.device + +local EmitterTask = { + name = 'emitter', + priority = 5, +} + +local function filter(a) + return a.emitter +end + +function EmitterTask:cycle(context) + for node in context.storage:filterActive('emitter', filter) do + local config = node.emitter + local item = Milo:getItem(itemDB:splitKey(config.item)) + + config.signal = not not config.signal + if item and item.count >= config.amount then + device[node.name].setOutput(config.side, config.signal) + else + device[node.name].setOutput(config.side, not config.signal) + end + end +end + +Milo:registerTask(EmitterTask) diff --git a/milo/plugins/emitterView.lua b/milo/plugins/emitterView.lua new file mode 100644 index 0000000..f3c51d3 --- /dev/null +++ b/milo/plugins/emitterView.lua @@ -0,0 +1,109 @@ +local Milo = require('milo') +local UI = require('opus.ui') +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, + textColor = colors.yellow, + value = 'Emit a redstone signal if an\nitem amount if over a threshold', + }, + form = UI.Form { + x = 1, ex = -1, y = 3, ey = -1, + manualControls = true, + + itemName = UI.TextEntry { + formLabel = 'Item', formKey = 'item', formIndex = 1, + help = 'Item to monitor', + required = true, + }, + side = UI.Chooser { + formLabel = 'Side', formKey = 'side', formIndex = 2, + width = 10, + choices = { + {name = 'Down', value = 'down'}, + {name = 'Up', value = 'up'}, + {name = 'North', value = 'north'}, + {name = 'South', value = 'south'}, + {name = 'West', value = 'west'}, + {name = 'East', value = 'east'}, + }, + required = true, + }, + amount = UI.TextEntry { + formLabel = 'Amount', formKey = 'amount', formIndex = 3, + width = 7, + transform = 'number', + help = 'Threshold value', + required = true, + }, + signal = UI.Checkbox { + formLabel = 'Signal', formKey = 'signal', formIndex = 4, + help = 'Enable redstone signal when over threshold', + }, + scanItem = UI.Button { + x = 15, y = 6, + text = 'Scan item', event = 'scan_turtle', + help = 'Scan an item from the turtle inventory', + }, + }, +} + +function wizardPage:setNode(node) + self.node = node + if not self.node.emitter then + self.node.emitter = { + signal = { value = true } + } + end + self.form:setValues(self.node.emitter) +end + +function wizardPage:validate() + return self.form:save() +end + +function wizardPage:isValidType(node) + local m = device[node.name] + return m and m.type == 'redstone_integrator' and { + name = 'Level Emitter', + value = 'emitter', + category = 'custom', + help = 'Emit redstone signals', + } +end + +function wizardPage:isValidFor(node) + return node.mtype == 'emitter' +end + +function wizardPage:enable() + Milo:pauseCrafting({ key = 'gridInUse', msg = 'Crafting paused' }) + UI.WizardPage.enable(self) +end +function wizardPage:disable() + Milo:resumeCrafting({ key = 'gridInUse' }) + UI.WizardPage.disable(self) +end + +function wizardPage:eventHandler(event) + if event.type == 'scan_turtle' then + local inventory = Milo:getTurtleInventory() + for _,item in pairs(inventory) do + self.form.itemName.value = itemDB:makeKey(item) + break + end + self:draw() + Milo:emptyInventory() + end +end + +UI:getPage('nodeWizard').wizard:add({ emiter = wizardPage }) diff --git a/milo/plugins/item/infoTab.lua b/milo/plugins/item/infoTab.lua index 7ae99c7..92bb37d 100644 --- a/milo/plugins/item/infoTab.lua +++ b/milo/plugins/item/infoTab.lua @@ -27,6 +27,9 @@ function infoTab:draw() value = value .. item.nbtHash .. '\n' end + value = value .. string.format('\n%sCount:%s %s', + Ansi.yellow, Ansi.reset, item.count) + value = value .. string.format('\n%sDamage:%s %s', Ansi.yellow, Ansi.reset, item.damage) From 2dc74d80ea7a1bb7b06639805890eef4114fa390 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Mon, 23 Mar 2020 23:41:16 -0400 Subject: [PATCH 07/10] Milo: Bump max request amount to 9999 --- milo/MiloRemote.lua | 6 +++--- milo/core/listing.lua | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/milo/MiloRemote.lua b/milo/MiloRemote.lua index e85de5c..32cbd06 100644 --- a/milo/MiloRemote.lua +++ b/milo/MiloRemote.lua @@ -60,7 +60,7 @@ local page = UI.Page { statusBar = UI.Window { y = -1, filter = UI.TextEntry { - x = 1, ex = -12, + x = 1, ex = -13, limit = 50, shadowText = 'filter', backgroundColor = colors.cyan, @@ -73,8 +73,8 @@ local page = UI.Page { }, }, amount = UI.TextEntry { - x = -11, ex = -7, - limit = 3, + x = -12, ex = -7, + limit = 4, shadowText = '1', shadowTextColor = colors.gray, backgroundColor = colors.black, diff --git a/milo/core/listing.lua b/milo/core/listing.lua index 6a2d9c4..b19b4d2 100644 --- a/milo/core/listing.lua +++ b/milo/core/listing.lua @@ -50,7 +50,7 @@ local page = UI.Page { }, statusBar = UI.StatusBar { filter = UI.TextEntry { - x = 1, ex = -17, + x = 1, ex = -18, limit = 50, shadowText = 'filter', shadowTextColor = colors.gray, @@ -64,14 +64,14 @@ local page = UI.Page { }, }, storageStatus = UI.Text { - x = -16, ex = -9, + x = -17, ex = -10, textColor = colors.lime, backgroundColor = colors.cyan, value = '', }, amount = UI.TextEntry { - x = -8, ex = -4, - limit = 3, + x = -9, ex = -4, + limit = 4, shadowText = '1', shadowTextColor = colors.gray, backgroundColor = colors.black, From 996b8c1cd378f4aa6e5bd115e685f88051f1a7f2 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Tue, 24 Mar 2020 00:09:51 -0400 Subject: [PATCH 08/10] Swshop: Configurable lamp side --- swshop/shopConfig.lua | 16 +++++++++++++++- swshop/swshop.lua | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/swshop/shopConfig.lua b/swshop/shopConfig.lua index 958a86d..026ad16 100644 --- a/swshop/shopConfig.lua +++ b/swshop/shopConfig.lua @@ -33,8 +33,22 @@ local wizardPage = UI.WizardPage { limit = 64, }, [4] = UI.Chooser { + formLabel = 'RS Signal', formKey = 'rsSide', formIndex = 5, + width = 10, + nochoice = 'Top', + choices = { + {name = 'Bottom', value = 'bottom'}, + {name = 'Top', value = 'top'}, + {name = 'Back', value = 'back'}, + {name = 'Front', value = 'front'}, + {name = 'Right', value = 'right'}, + {name = 'Left', value = 'left'}, + }, + required = true, + }, + [5] = UI.Chooser { width = 9, - formIndex = 5, + formIndex = 6, formLabel = 'Font Size', formKey = 'textScale', nochoice = 'Small', choices = { diff --git a/swshop/swshop.lua b/swshop/swshop.lua index 0bb07ab..499c8f9 100644 --- a/swshop/swshop.lua +++ b/swshop/swshop.lua @@ -19,7 +19,7 @@ local textutils = _G.textutils local chat = device['plethora:chat'] local storage = Config.load('storage') -rs.setOutput('top', false) +Util.each(rs.getSides(), function(side) rs.setOutput(side, false) end) r.init(jua) w.init(jua) @@ -31,7 +31,7 @@ local privatekey = config.isPrivateKey and config.password or Krist.toKristWalle local address = Krist.makev2address(privatekey) jua.on("terminate", function() - rs.setOutput('top', false) + rs.setOutput(config.rsSide, false) jua.stop() _G.printError("Terminated") end) @@ -144,7 +144,7 @@ local function connect() assert(success, "Failed to get websocket URL") print("Connected to websocket.") - rs.setOutput('top', true) + rs.setOutput(config.rsSide, true) success = await(ws.subscribe, "ownTransactions", function(data) local transaction = data.transaction @@ -160,7 +160,7 @@ local s, m = pcall(function() end) end) -rs.setOutput('top', false) +rs.setOutput(config.rsSide, false) if not s then error(m, 2) end From 408601f0d2f5cdccb5e5c34b531e19398e035e8f Mon Sep 17 00:00:00 2001 From: Anavrins Date: Tue, 24 Mar 2020 00:17:35 -0400 Subject: [PATCH 09/10] Swshop: whoops --- swshop/swshop.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/swshop/swshop.lua b/swshop/swshop.lua index 499c8f9..a90c20a 100644 --- a/swshop/swshop.lua +++ b/swshop/swshop.lua @@ -29,9 +29,10 @@ local node = ({ ... })[1] or error('Node name is required') local config = storage[node] local privatekey = config.isPrivateKey and config.password or Krist.toKristWalletFormat(config.password) local address = Krist.makev2address(privatekey) +local rsSide = config.rsSide or 'top' jua.on("terminate", function() - rs.setOutput(config.rsSide, false) + rs.setOutput(rsSide, false) jua.stop() _G.printError("Terminated") end) @@ -144,7 +145,7 @@ local function connect() assert(success, "Failed to get websocket URL") print("Connected to websocket.") - rs.setOutput(config.rsSide, true) + rs.setOutput(rsSide, true) success = await(ws.subscribe, "ownTransactions", function(data) local transaction = data.transaction @@ -160,7 +161,7 @@ local s, m = pcall(function() end) end) -rs.setOutput(config.rsSide, false) +rs.setOutput(rsSide, false) if not s then error(m, 2) end From b08a0f225e225374f758e43189f6d838bbb68584 Mon Sep 17 00:00:00 2001 From: Drew Lemmy Date: Fri, 27 Mar 2020 17:09:04 +0000 Subject: [PATCH 10/10] Temporary patch for #20 A more comprehensive fix should be found in the future --- swshop/shopTab.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swshop/shopTab.lua b/swshop/shopTab.lua index 6bfabb5..169d6ee 100644 --- a/swshop/shopTab.lua +++ b/swshop/shopTab.lua @@ -25,7 +25,7 @@ local shopTab = UI.Tab { formLabel = 'Price', formKey = 'price', help = 'Per item cost', required = true, - transform = 'number', + validate = 'numeric', }, [3] = UI.TextEntry { limit = 64,