diff --git a/common/Appstore.lua b/common/Appstore.lua index 67dfb36..7a5856f 100644 --- a/common/Appstore.lua +++ b/common/Appstore.lua @@ -38,7 +38,7 @@ local APP_DIR = 'usr/apps' local source = { text = "STD Default", event = 'source', - url = "http://pastebin.com/raw/zVws7eLq", + url = "https://github.com/LDDestroier/STD-GUI/raw/master/list.lua", } shell.setDir(APP_DIR) @@ -325,7 +325,7 @@ function categoryPage:setCategory(name, index) table.insert(self.grid.values, v) end end - self.statusBar:setStatus(string.format('%s: %s', self.source.text, name)) + self.statusBar:setStatus(string.format('%s: %s', self.source.text or '', name)) self.grid:update() self.grid:setIndex(1) end @@ -346,7 +346,7 @@ function categoryPage:eventHandler(event) UI:setPage(appPage, self.grid:getSelected()) elseif event.type == 'category' then - self:setCategory(self.source, event.button.text, event.button.index) + self:setCategory(event.button.text, event.button.index) self:setFocus(self.grid) self:draw() 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/milo/MiloRemote.lua b/milo/MiloRemote.lua index bf628cf..6644a5b 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, 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 76ce95c..5bf7cc9 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) 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', { 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. 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/shopTab.lua b/swshop/shopTab.lua index 63e3220..f731ebf 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, diff --git a/swshop/swshop.lua b/swshop/swshop.lua index 391b6a8..a90c20a 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) @@ -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('top', false) + rs.setOutput(rsSide, false) jua.stop() _G.printError("Terminated") end) @@ -44,7 +45,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 @@ -144,7 +145,7 @@ local function connect() assert(success, "Failed to get websocket URL") print("Connected to websocket.") - rs.setOutput('top', 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('top', false) +rs.setOutput(rsSide, false) if not s then error(m, 2) end 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