From b6ddbfdc80d0bc90b4778fa53c56fb01eee0f413 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sun, 10 Nov 2019 18:49:02 -0700 Subject: [PATCH 01/17] update to master --- packages.list | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/packages.list b/packages.list index 57b1ce5..ab68761 100644 --- a/packages.list +++ b/packages.list @@ -1,26 +1,26 @@ { - [ 'common' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/common/.package', - [ 'core' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/core/.package', - [ 'builder' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/builder/.package', - [ 'ccemux' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/ccemux/.package', - [ 'farms' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/farms/.package', --- [ 'forestry' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/forestry/.package', - [ 'games' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/games/.package', --- [ 'glasses' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/glasses/.package', - [ 'gps' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/gps/.package', - [ 'lzwfs' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/lzwfs/.package', - [ 'mbs' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/mbs/.package', - [ 'milo' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/milo/.package', - [ 'miloApps' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/miloApps/.package', - [ 'miners' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/miners/.package', - [ 'minify' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/minify/.package', - [ 'monitor' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/monitor/.package', - [ 'neural' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/neural/.package', --- [ 'pickup' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/pickup/.package', - [ 'recipeBook' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/recipeBook/.package', - [ 'screenSaver'] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/screenSaver/.package', - [ 'secure' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/secure/.package', - [ 'shellex' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/shellex/.package', - [ 'swshop' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/swshop/.package', - [ 'turtle' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/turtle/.package', -} \ No newline at end of file + [ 'common' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/common/.package', + [ 'core' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/core/.package', + [ 'builder' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/builder/.package', + [ 'ccemux' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/ccemux/.package', + [ 'farms' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/farms/.package', +-- [ 'forestry' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/forestry/.package', + [ 'games' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/games/.package', +-- [ 'glasses' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/glasses/.package', + [ 'gps' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/gps/.package', + [ 'lzwfs' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/lzwfs/.package', + [ 'mbs' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/mbs/.package', + [ 'milo' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/milo/.package', + [ 'miloApps' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/miloApps/.package', + [ 'miners' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/miners/.package', + [ 'minify' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/minify/.package', + [ 'monitor' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/monitor/.package', + [ 'neural' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/neural/.package', +-- [ 'pickup' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/pickup/.package', + [ 'recipeBook' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/recipeBook/.package', + [ 'screenSaver'] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/screenSaver/.package', + [ 'secure' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/secure/.package', + [ 'shellex' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/shellex/.package', + [ 'swshop' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/swshop/.package', + [ 'turtle' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master/turtle/.package', +} -- 2.49.1 From 64ec8c82d301639bc397aafe69dd74974b8161ca Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Wed, 13 Nov 2019 14:24:54 -0700 Subject: [PATCH 02/17] properly handle empty text entry fields (including transformations) --- builder/builder.lua | 2 +- ccemux/system/ccemux.lua | 33 +++++++++++++++++++-------------- common/SoundPlayer.lua | 32 ++++++++++++++++---------------- lzwfs/system/lzwfs.lua | 2 +- milo/MiloRemote.lua | 2 +- milo/core/listing.lua | 2 +- milo/plugins/item/manageTab.lua | 4 ++-- milo/plugins/remote/setup.lua | 4 ++-- milo/plugins/storageView.lua | 4 ++-- screenSaver/system/saver.lua | 12 ++++++++---- secure/system/secure.lua | 12 ++++++++---- swshop/shopConfig.lua | 4 ++-- swshop/shopTab.lua | 2 +- 13 files changed, 64 insertions(+), 51 deletions(-) diff --git a/builder/builder.lua b/builder/builder.lua index a2a5138..0c39cb8 100644 --- a/builder/builder.lua +++ b/builder/builder.lua @@ -276,7 +276,7 @@ function substitutionPage:eventHandler(event) self.info:draw() elseif event.type == 'text_change' then - local text = event.text + local text = event.text or '' if #text == 0 then self.grid.values = self.allItems else diff --git a/ccemux/system/ccemux.lua b/ccemux/system/ccemux.lua index c62dd0f..0948583 100644 --- a/ccemux/system/ccemux.lua +++ b/ccemux/system/ccemux.lua @@ -33,6 +33,7 @@ local tab = UI.Tab { shadowText = 'id', width = 5, limit = 3, + transform = 'number', }, add = UI.Button { x = 28, y = 3, @@ -78,23 +79,27 @@ end function tab:eventHandler(event) if event.type == 'form_complete' then - ccemux.detach(event.values.side) - ccemux.attach(event.values.side, event.values.type) + if event.values.type == 'disk_drive' and not event.values.drive_id then + self:emit({ type = 'error_message', message = 'Invalid drive ID' }) + else + ccemux.detach(event.values.side) + ccemux.attach(event.values.side, event.values.type) - local config = Config.load('ccemux') - config[event.values.side] = { - type = event.values.type - } - if event.values.type == 'disk_drive' and tonumber(event.values.drive_id) then - config[event.values.side].args = { - id = tonumber(event.values.drive_id) + local config = Config.load('ccemux') + config[event.values.side] = { + type = event.values.type } - end - Config.update('ccemux', config) - self:updatePeripherals(config) - self.grid:draw() + if event.values.type == 'disk_drive' then + config[event.values.side].args = { + id = event.values.drive_id + } + end + Config.update('ccemux', config) + self:updatePeripherals(config) + self.grid:draw() - self:emit({ type = 'success_message', message = 'Attached' }) + self:emit({ type = 'success_message', message = 'Attached' }) + end elseif event.type == 'choice_change' then if event.element == self.form.ptype then diff --git a/common/SoundPlayer.lua b/common/SoundPlayer.lua index 459259e..db69f40 100644 --- a/common/SoundPlayer.lua +++ b/common/SoundPlayer.lua @@ -5,13 +5,13 @@ local Util = require('opus.util') local peripheral = _G.peripheral if not peripheral.find('speaker') then - error('No speaker attached') + error('No speaker attached') end local rawSounds = Util.readLines('packages/games/etc/sounds.txt') or error('Unable to read sounds file') local sounds = { } for _, s in pairs(rawSounds) do - table.insert(sounds, { name = s }) + table.insert(sounds, { name = s }) end UI:configure('SoundPlayer', ...) @@ -25,21 +25,21 @@ local page = UI.Page { x = 10, y = 2, ex = -3, limit = 32, }, - grid = UI.ScrollingGrid { + grid = UI.ScrollingGrid { y = 4, - columns = { - { heading = 'Name', key = 'name' }, - }, - values = sounds, - }, + columns = { + { heading = 'Name', key = 'name' }, + }, + values = sounds, + }, } function page:eventHandler(event) - if event.type == 'grid_select' then - Sound.play(event.selected.name) + if event.type == 'grid_select' then + Sound.play(event.selected.name) elseif event.type == 'text_change' then - if #event.text == 0 then + if not event.text then self.grid.values = sounds else self.grid.values = { } @@ -51,12 +51,12 @@ function page:eventHandler(event) end self.grid:update() self.grid:setIndex(1) - self.grid:draw() + self.grid:draw() - else - return UI.Page.eventHandler(self, event) - end - return true + else + return UI.Page.eventHandler(self, event) + end + return true end UI:setPage(page) diff --git a/lzwfs/system/lzwfs.lua b/lzwfs/system/lzwfs.lua index edeff99..2c76f30 100644 --- a/lzwfs/system/lzwfs.lua +++ b/lzwfs/system/lzwfs.lua @@ -85,7 +85,7 @@ local function rewriteFiles(p) end function tab:eventHandler(event) - if event.type == 'add_path' then + if event.type == 'add_path' and self.entry.value then table.insert(self.grid.values, { value = self.entry.value, }) diff --git a/milo/MiloRemote.lua b/milo/MiloRemote.lua index 27aecd5..e85de5c 100644 --- a/milo/MiloRemote.lua +++ b/milo/MiloRemote.lua @@ -246,7 +246,7 @@ function page:eventHandler(event) Config.update('miloRemote', context.state) elseif event.type == 'text_change' and event.element == self.statusBar.filter then - self.filter = event.text + self.filter = event.text or '' if #self.filter == 0 then self.filter = nil end diff --git a/milo/core/listing.lua b/milo/core/listing.lua index 2a6eeea..6a2d9c4 100644 --- a/milo/core/listing.lua +++ b/milo/core/listing.lua @@ -272,7 +272,7 @@ function page:eventHandler(event) end elseif event.type == 'text_change' and event.element == self.statusBar.filter then - self.filter = event.text + self.filter = event.text or '' if #self.filter == 0 then self.filter = nil end diff --git a/milo/plugins/item/manageTab.lua b/milo/plugins/item/manageTab.lua index f7db7b5..2df0a13 100644 --- a/milo/plugins/item/manageTab.lua +++ b/milo/plugins/item/manageTab.lua @@ -21,12 +21,12 @@ local manageTab = UI.Tab { [2] = UI.TextEntry { width = 7, formLabel = 'Min', formKey = 'low', help = 'Craft if below min', - validate = 'numeric', + transform = 'number', }, [3] = UI.TextEntry { width = 7, formLabel = 'Max', formKey = 'limit', help = 'Send to trash if above max', - validate = 'numeric', + transform = 'number', }, [4] = UI.Checkbox { formLabel = 'Ignore Dmg', formKey = 'ignoreDamage', diff --git a/milo/plugins/remote/setup.lua b/milo/plugins/remote/setup.lua index 3ba5439..5d12d21 100644 --- a/milo/plugins/remote/setup.lua +++ b/milo/plugins/remote/setup.lua @@ -21,7 +21,7 @@ local setup = UI.SlideOut { help = 'ID for the server', shadowText = 'Milo server ID', limit = 6, - validate = 'numeric', + transform = 'number', required = true, }, [2] = UI.TextEntry { @@ -29,7 +29,7 @@ local setup = UI.SlideOut { help = 'Use a slot for sending to storage', shadowText = 'Inventory slot #', limit = 5, - validate = 'numeric', + transform = 'number', required = false, }, [3] = UI.Checkbox { diff --git a/milo/plugins/storageView.lua b/milo/plugins/storageView.lua index 50a6788..b1d51c2 100644 --- a/milo/plugins/storageView.lua +++ b/milo/plugins/storageView.lua @@ -15,14 +15,14 @@ local storageView = UI.WizardPage { formLabel = 'Priority', formKey = 'priority', help = 'Larger values get precedence', limit = 4, - validate = 'numeric', + transform = 'number', shadowText = 'Numeric priority', }, [2] = UI.TextEntry { formLabel = 'Refresh', formKey = 'refreshInterval', shadowText = 'seconds between refresh', limit = 4, - validate = 'numeric', + tranform = 'number', help = 'Refresh periodically', }, [3] = UI.TextArea { diff --git a/screenSaver/system/saver.lua b/screenSaver/system/saver.lua index 87e3b5d..b8fa7a3 100644 --- a/screenSaver/system/saver.lua +++ b/screenSaver/system/saver.lua @@ -42,11 +42,15 @@ function tab:eventHandler(event) config.enabled = not not event.checked elseif event.type == 'update' then - config.timeout = self.timeout.value - Config.update('saver', config) + if self.timeout.value then + config.timeout = self.timeout.value + Config.update('saver', config) - self:emit({ type = 'success_message', message = 'Settings updated' }) - os.queueEvent('config_update', 'saver', config) + self:emit({ type = 'success_message', message = 'Settings updated' }) + os.queueEvent('config_update', 'saver', config) + else + self:emit({ type = 'error_message', message = 'Invalid timeout' }) + end end return UI.Tab.eventHandler(self, event) end diff --git a/secure/system/secure.lua b/secure/system/secure.lua index d2d6ba9..113ad9b 100644 --- a/secure/system/secure.lua +++ b/secure/system/secure.lua @@ -42,11 +42,15 @@ function tab:eventHandler(event) config.enabled = not not event.checked elseif event.type == 'update' then - config.timeout = self.timeout.value - Config.update('secure', config) + if self.timeout.value then + config.timeout = self.timeout.value + Config.update('secure', config) - self:emit({ type = 'success_message', message = 'Settings updated' }) - os.queueEvent('config_update', 'secure', config) + self:emit({ type = 'success_message', message = 'Settings updated' }) + os.queueEvent('config_update', 'secure', config) + else + self:emit({ type = 'error_message', message = 'Invalid timeout' }) + end end return UI.Tab.eventHandler(self, event) end diff --git a/swshop/shopConfig.lua b/swshop/shopConfig.lua index 7d65fad..958a86d 100644 --- a/swshop/shopConfig.lua +++ b/swshop/shopConfig.lua @@ -106,7 +106,7 @@ local passwordPage = UI.WizardPage { } local function makeAddress(text, isPrivateKey) - local privKey = text + local privKey = text or '' if not isPrivateKey then privKey = Krist.toKristWalletFormat(privKey) end @@ -116,7 +116,7 @@ end function passwordPage.form:eventHandler(event) if (event.type == 'text_change' and event.element.pass) or (event.type == 'checkbox_change' and event.element.ispkey) then - self.passEntry.shadowText = self.pkeyCheck.value and 'Private key' or 'Password' + self.passEntry.shadowText = self.pkeyCheck.value and 'Private key' or 'Password' self.preview.value = makeAddress(self.passEntry.value, self.pkeyCheck.value) self:draw() end diff --git a/swshop/shopTab.lua b/swshop/shopTab.lua index 169d6ee..6bfabb5 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, - validate = 'numeric', + transform = 'number', }, [3] = UI.TextEntry { limit = 64, -- 2.49.1 From 922c391bf29cef0a05ded955c38cca9f1963a725 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sun, 17 Nov 2019 18:21:48 -0700 Subject: [PATCH 03/17] cleanup + example start --- common/Devices.lua | 8 +-- common/SoundPlayer.lua | 2 +- common/etc/apps.db | 6 +++ {games => common}/etc/sounds.txt | 0 examples/.package | 6 +++ examples/grid.lua | 44 ++++++++++++++++ games/etc/apps.db | 6 --- {common/etc => ignore}/scripts/abort | 0 {common/etc => ignore}/scripts/goHome | 0 {common/etc => ignore}/scripts/moveTo | 0 {common/etc => ignore}/scripts/reboot | 0 {common/etc => ignore}/scripts/setHome | 0 {common/etc => ignore}/scripts/shutdown | 0 {common/etc => ignore}/scripts/summon | 0 recipeBook/.package | 2 +- recipeBook/recipeBook.lua | 70 ++++++++++++------------- 16 files changed, 95 insertions(+), 49 deletions(-) rename {games => common}/etc/sounds.txt (100%) create mode 100644 examples/.package create mode 100644 examples/grid.lua rename {common/etc => ignore}/scripts/abort (100%) rename {common/etc => ignore}/scripts/goHome (100%) rename {common/etc => ignore}/scripts/moveTo (100%) rename {common/etc => ignore}/scripts/reboot (100%) rename {common/etc => ignore}/scripts/setHome (100%) rename {common/etc => ignore}/scripts/shutdown (100%) rename {common/etc => ignore}/scripts/summon (100%) diff --git a/common/Devices.lua b/common/Devices.lua index 57ac8fe..6ad2f08 100644 --- a/common/Devices.lua +++ b/common/Devices.lua @@ -1,5 +1,3 @@ -_G.requireInjector(_ENV) - local Ansi = require('opus.ansi') local Event = require('opus.event') local UI = require('opus.ui') @@ -27,7 +25,7 @@ local peripheralsPage = UI.Page { }, } -function peripheralsPage.grid:draw() +function peripheralsPage.grid:enable() local sides = peripheral.getNames() Util.clear(self.values) @@ -39,7 +37,7 @@ function peripheralsPage.grid:draw() end self:update() self:adjustWidth() - UI.Grid.draw(self) + UI.Grid.enable(self) end function peripheralsPage:updatePeripherals() @@ -84,7 +82,6 @@ local methodsPage = UI.Page { } function methodsPage:enable(p) - self.peripheral = p or self.peripheral p = peripheral.wrap(self.peripheral.side) @@ -136,7 +133,6 @@ function methodsPage:eventHandler(event) end function methodsPage:getDocumentation() - local method = self.grid:getSelected() if method.noext then -- computercraft docs diff --git a/common/SoundPlayer.lua b/common/SoundPlayer.lua index db69f40..bcce449 100644 --- a/common/SoundPlayer.lua +++ b/common/SoundPlayer.lua @@ -8,7 +8,7 @@ if not peripheral.find('speaker') then error('No speaker attached') end -local rawSounds = Util.readLines('packages/games/etc/sounds.txt') or error('Unable to read sounds file') +local rawSounds = Util.readLines('packages/common/etc/sounds.txt') or error('Unable to read sounds file') local sounds = { } for _, s in pairs(rawSounds) do table.insert(sounds, { name = s }) diff --git a/common/etc/apps.db b/common/etc/apps.db index 7e6a4ad..d12829c 100644 --- a/common/etc/apps.db +++ b/common/etc/apps.db @@ -59,4 +59,10 @@ iconExt = "\030 \031 \128\030d\159\030 \031d\140\030d\031 \155\030 \0315\140\0305\031 \155\030 \128\010\030 \031d\136\145\0315\136\145\031d\153\031 \128\0315\153\010\030 \031 \128\031d\130\140\134\0315\140\134\031 \128", run = "packages/common/hexedit.lua", }, + [ "fb1c39e9f4f3c2628ad173ab401a6e4e4baf783d" ] = { + title = "Sounds", + category = "System", + run = "SoundPlayer", + iconExt = "\030 \031 \128\0307\159\129\030 \0317\149\0310\144\0300\031 \155\030 \0310\137\144\010\0307\0317\128\128\128\030 \149\0300\031 \149\030 \128\0310\149\0300\031 \149\010\030 \031 \128\0317\130\0307\031 \144\030 \0317\149\0310\129\134\152\129", + }, } diff --git a/games/etc/sounds.txt b/common/etc/sounds.txt similarity index 100% rename from games/etc/sounds.txt rename to common/etc/sounds.txt diff --git a/examples/.package b/examples/.package new file mode 100644 index 0000000..da8c112 --- /dev/null +++ b/examples/.package @@ -0,0 +1,6 @@ +{ + title = 'Example programs for coding in Opus', + repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/examples', + description = [[Starter/example programs for creating Opus programs.]], + license = 'MIT', +} diff --git a/examples/grid.lua b/examples/grid.lua new file mode 100644 index 0000000..b979a87 --- /dev/null +++ b/examples/grid.lua @@ -0,0 +1,44 @@ +local UI = require('opus.ui') + +local page = UI.Page { + menuBar = UI.MenuBar { + buttons = { + { text = 'Shuffle', event = 'shuffle' }, + { text = 'Clear', event = 'clear', }, + } + }, + grid = UI.ScrollingGrid { + y = 2, ey = -2, + values = { + { col = 'column1', value = 'value1' }, + { col = 'column2', value = 'value2' }, + { col = 'column3', value = 'value3' }, + }, + columns = { + { heading = 'HDR1', key = 'col' }, + { heading = 'HDR2', key = 'value' }, + } + }, + statusBar = UI.StatusBar { }, +} + +function page:eventHandler(event) + if event.type == 'grid_select' then + self.statusBar:setStatus('Selected: ' .. event.selected.value) + + elseif event.type == 'shuffle' then + for _,v in pairs(self.grid.values) do + v.col = 'column' .. math.random(1,3) + end + self.grid:update() + self.grid:draw() + + elseif event.type == 'clear' then + self.grid:setValues({ }) + self.grid:draw() + end + return UI.Page.eventHandler(self, event) +end + +UI:setPage(page) +UI:pullEvents() diff --git a/games/etc/apps.db b/games/etc/apps.db index 11aaac5..f149739 100644 --- a/games/etc/apps.db +++ b/games/etc/apps.db @@ -17,12 +17,6 @@ run = "Pipes", iconExt = "\030 \031 \128\0300\0310\128\030 \031 \128\0310\143\0300\031 \130\030 \128\0300\0310\128\010\0300\031 \131\0310\128\031 \131\131\030 \0310\159\031 \128\0310\143\010\030 \031 \128\0315\143\031 \128\128\128\128\0300\131", }, - [ "fb1c39e9f4f3c2628ad173ab401a6e4e4baf783d" ] = { - title = "Sounds", - category = "System", - run = "SoundPlayer", - iconExt = "\030 \031 \128\0307\159\129\030 \0317\149\0310\144\0300\031 \155\030 \0310\137\144\010\0307\0317\128\128\128\030 \149\0300\031 \149\030 \128\0310\149\0300\031 \149\010\030 \031 \128\0317\130\0307\031 \144\030 \0317\149\0310\129\134\152\129", - }, [ "a2accffe95b2c8be30e8a05e0c6ab7e8f5966f43" ] = { title = "Strafe", category = "Games", diff --git a/common/etc/scripts/abort b/ignore/scripts/abort similarity index 100% rename from common/etc/scripts/abort rename to ignore/scripts/abort diff --git a/common/etc/scripts/goHome b/ignore/scripts/goHome similarity index 100% rename from common/etc/scripts/goHome rename to ignore/scripts/goHome diff --git a/common/etc/scripts/moveTo b/ignore/scripts/moveTo similarity index 100% rename from common/etc/scripts/moveTo rename to ignore/scripts/moveTo diff --git a/common/etc/scripts/reboot b/ignore/scripts/reboot similarity index 100% rename from common/etc/scripts/reboot rename to ignore/scripts/reboot diff --git a/common/etc/scripts/setHome b/ignore/scripts/setHome similarity index 100% rename from common/etc/scripts/setHome rename to ignore/scripts/setHome diff --git a/common/etc/scripts/shutdown b/ignore/scripts/shutdown similarity index 100% rename from common/etc/scripts/shutdown rename to ignore/scripts/shutdown diff --git a/common/etc/scripts/summon b/ignore/scripts/summon similarity index 100% rename from common/etc/scripts/summon rename to ignore/scripts/summon diff --git a/recipeBook/.package b/recipeBook/.package index 8b0f49b..12e145e 100644 --- a/recipeBook/.package +++ b/recipeBook/.package @@ -1,6 +1,6 @@ { title = 'Recipe books for crafting programs', repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/recipeBook', - description = [[ WIP ]], + description = [[Recipe book manager for Milo and programs that utilize crafting]], license = 'MIT', } diff --git a/recipeBook/recipeBook.lua b/recipeBook/recipeBook.lua index fc0b719..3aa67c3 100644 --- a/recipeBook/recipeBook.lua +++ b/recipeBook/recipeBook.lua @@ -60,37 +60,37 @@ local page = UI.Page { sortColumn = 'name', autospace = true, }, - add = UI.SlideOut { - backgroundColor = colors.cyan, - titleBar = UI.TitleBar { - title = 'Add a new book', - }, - form = UI.Form { - x = 2, ex = -2, y = 2, ey = -1, - [1] = UI.TextEntry { - formLabel = 'Name', formKey = 'name', - shadowText = 'Friendly name', - limit = 64, - required = true, - }, - [2] = UI.TextEntry { - formLabel = 'Version', formKey = 'version', - shadowText = 'Mod version', - limit = 10, - }, - [3] = UI.TextEntry { - formLabel = 'URL', formKey = 'url', - shadowText = 'URL for recipes', - limit = 128, - required = true, - }, - [4] = UI.TextEntry { - formLabel = 'File name', formKey = 'localName', - shadowText = 'Short name for saving file', - limit = 20, - required = true, - }, - }, + add = UI.SlideOut { + backgroundColor = colors.cyan, + titleBar = UI.TitleBar { + title = 'Add a new book', + }, + form = UI.Form { + x = 2, ex = -2, y = 2, ey = -1, + [1] = UI.TextEntry { + formLabel = 'Name', formKey = 'name', + shadowText = 'Friendly name', + limit = 64, + required = true, + }, + [2] = UI.TextEntry { + formLabel = 'Version', formKey = 'version', + shadowText = 'Mod version', + limit = 10, + }, + [3] = UI.TextEntry { + formLabel = 'URL', formKey = 'url', + shadowText = 'URL for recipes', + limit = 128, + required = true, + }, + [4] = UI.TextEntry { + formLabel = 'File name', formKey = 'localName', + shadowText = 'Short name for saving file', + limit = 20, + required = true, + }, + }, }, notification = UI.Notification { }, } @@ -156,8 +156,8 @@ function page:eventHandler(event) self.grid:draw() elseif event.type == 'add_book' then - self.add.form:setValues({ }) - self.add:show() + self.add.form:setValues({ }) + self.add:show() elseif event.type == 'form_complete' then self.add:hide() @@ -166,8 +166,8 @@ function page:eventHandler(event) self.grid:setValues(getRecipeBooks()) self.grid:draw() - elseif event.type == 'form_cancel' then - self.add:hide() + elseif event.type == 'form_cancel' then + self.add:hide() elseif event.type == 'grid_focus_row' then self.info:draw() -- 2.49.1 From d8f33b9cb760da8f83dcee02f827169d15bd1567 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Mon, 18 Nov 2019 15:03:02 -0500 Subject: [PATCH 04/17] multiMiner.lua Move abort button to avoid accidental clicking --- common/multiMiner.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/multiMiner.lua b/common/multiMiner.lua index 5b40286..d721461 100644 --- a/common/multiMiner.lua +++ b/common/multiMiner.lua @@ -351,8 +351,8 @@ local page = UI.Page { menuBar = UI.MenuBar { buttons = { { text = 'Scan', event = 'scan' }, - { text = 'Abort', event = 'abort' }, pauseResume[1], + { text = 'Abort', event = 'abort', x = -7 }, }, }, tabs = UI.Tabs { -- 2.49.1 From df8c80e4dbc092dcdd06f0cbc815dfff7789385a Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Mon, 25 Nov 2019 15:24:11 -0700 Subject: [PATCH 05/17] crafting fix --- milo/apis/craft2.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/milo/apis/craft2.lua b/milo/apis/craft2.lua index 2918300..57b7004 100644 --- a/milo/apis/craft2.lua +++ b/milo/apis/craft2.lua @@ -309,7 +309,7 @@ function Craft.craftRecipeInternal(recipe, count, storage, origItem, path) local function maxBatch() local max = 64 for _, i in Craft.ingredients(recipe) do - max = math.min(max, math.floor(64 / i.count)) + max = math.min(max, math.floor(itemDB:getMaxCount(i.key) / i.count)) end return max end -- 2.49.1 From aeec3c688e43390896becd4e6363d3ac1fc69edc Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Mon, 25 Nov 2019 15:29:25 -0700 Subject: [PATCH 06/17] move scripts back for turtles program --- {ignore => common/etc}/scripts/abort | 0 {ignore => common/etc}/scripts/goHome | 0 {ignore => common/etc}/scripts/moveTo | 0 {ignore => common/etc}/scripts/reboot | 0 {ignore => common/etc}/scripts/setHome | 0 {ignore => common/etc}/scripts/shutdown | 0 {ignore => common/etc}/scripts/summon | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {ignore => common/etc}/scripts/abort (100%) rename {ignore => common/etc}/scripts/goHome (100%) rename {ignore => common/etc}/scripts/moveTo (100%) rename {ignore => common/etc}/scripts/reboot (100%) rename {ignore => common/etc}/scripts/setHome (100%) rename {ignore => common/etc}/scripts/shutdown (100%) rename {ignore => common/etc}/scripts/summon (100%) diff --git a/ignore/scripts/abort b/common/etc/scripts/abort similarity index 100% rename from ignore/scripts/abort rename to common/etc/scripts/abort diff --git a/ignore/scripts/goHome b/common/etc/scripts/goHome similarity index 100% rename from ignore/scripts/goHome rename to common/etc/scripts/goHome diff --git a/ignore/scripts/moveTo b/common/etc/scripts/moveTo similarity index 100% rename from ignore/scripts/moveTo rename to common/etc/scripts/moveTo diff --git a/ignore/scripts/reboot b/common/etc/scripts/reboot similarity index 100% rename from ignore/scripts/reboot rename to common/etc/scripts/reboot diff --git a/ignore/scripts/setHome b/common/etc/scripts/setHome similarity index 100% rename from ignore/scripts/setHome rename to common/etc/scripts/setHome diff --git a/ignore/scripts/shutdown b/common/etc/scripts/shutdown similarity index 100% rename from ignore/scripts/shutdown rename to common/etc/scripts/shutdown diff --git a/ignore/scripts/summon b/common/etc/scripts/summon similarity index 100% rename from ignore/scripts/summon rename to common/etc/scripts/summon -- 2.49.1 From 824685fc074bc84ce5700ceac4f661ee80d689b8 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Thu, 5 Dec 2019 00:18:55 -0500 Subject: [PATCH 07/17] speakerView fix --- milo/plugins/speakerView.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/milo/plugins/speakerView.lua b/milo/plugins/speakerView.lua index 2d79952..c5668dc 100644 --- a/milo/plugins/speakerView.lua +++ b/milo/plugins/speakerView.lua @@ -39,7 +39,7 @@ local wizardPage = UI.WizardPage { function wizardPage:setNode(node) self.form:setValues(node) if not node.volume then - self.form.volume = 1 + self.form.volume.value = 1 end end -- 2.49.1 From a2c8f0c65509c154ae75be976297648267425b5b Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Thu, 5 Dec 2019 11:37:31 -0700 Subject: [PATCH 08/17] cash alternative shell added --- cash/.package | 30 ++++++++++++++++++++++++++++++ cash/etc/apps.db | 7 +++++++ cash/etc/fstab | 1 + common/etc/fstab | 4 +++- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 cash/.package create mode 100644 cash/etc/apps.db create mode 100644 cash/etc/fstab diff --git a/cash/.package b/cash/.package new file mode 100644 index 0000000..b7a2cec --- /dev/null +++ b/cash/.package @@ -0,0 +1,30 @@ +{ + title = 'ComputerCraft Advanced Shell', + repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/cash', + description = [[A Bourne-compatible shell for ComputerCraft. + +Features +Bash/sh-style command line +Tab completion (defaulting to file names where not supported) +Customizable prompts (including ANSI support) +Local & environment variables +Argument quoting +Multiple commands on one line with semicolons +Many built-in functions (including in-line Lua commands) +Arithmetic expansion +If, while, for statements +Function support +Shell scripting/shebangs +Background jobs +rc files +Restorable history +Partial CCKernel2 support +Full compatibility with CraftOS shell.lua]], + license = 'MIT', + install = [[ + require('opus.alternate').set('shell', 'packages/cash/cash.lua') + ]], + uninstall = [[ + require('opus.alternate').remove('shell', 'packages/cash/cash.lua') + ]], +} diff --git a/cash/etc/apps.db b/cash/etc/apps.db new file mode 100644 index 0000000..2b13ce3 --- /dev/null +++ b/cash/etc/apps.db @@ -0,0 +1,7 @@ +{ + [ "a3c2cb0e2228250d98c481128f6837ef93111d73" ] = { + title = "MBS", + category = "Apps", + run = ".mbs/bin/shell.lua", + }, +} diff --git a/cash/etc/fstab b/cash/etc/fstab new file mode 100644 index 0000000..37fb07c --- /dev/null +++ b/cash/etc/fstab @@ -0,0 +1 @@ +packages/cash/cash.lua urlfs https://raw.githubusercontent.com/MCJack123/cash/master/cash.lua \ No newline at end of file diff --git a/common/etc/fstab b/common/etc/fstab index eedfbf8..e636640 100644 --- a/common/etc/fstab +++ b/common/etc/fstab @@ -1,4 +1,6 @@ packages/common/ascii.lua urlfs http://pastebin.com/raw/u3kcnyjd packages/common/hexedit.lua urlfs https://pastebin.com/raw/Ds9ajsp4 packages/common/colors.lua urlfs https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/ignore/colors.lua -packages/common/cowsay.lua urlfs https://pastebin.com/raw/n00VQJsw \ No newline at end of file +packages/common/cowsay.lua urlfs https://pastebin.com/raw/n00VQJsw +packages/common/calc.lua urlfs https://pastebin.com/raw/nAinUn1h +packages/common/write.lua urlfs https://pastebin.com/raw/RSyhCjqv \ No newline at end of file -- 2.49.1 From e0960bd93073bbd9a53bcae9711429b008e0bc32 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Thu, 5 Dec 2019 11:39:55 -0700 Subject: [PATCH 09/17] cash alternative shell added --- packages.list | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.list b/packages.list index 57b1ce5..092785d 100644 --- a/packages.list +++ b/packages.list @@ -2,6 +2,7 @@ [ 'common' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/common/.package', [ 'core' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/core/.package', [ 'builder' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/builder/.package', + [ 'cash' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/cash/.package', [ 'ccemux' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/ccemux/.package', [ 'farms' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/farms/.package', -- [ 'forestry' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/forestry/.package', -- 2.49.1 From 6831de37a3f2e566380f6ffee99047219232919e Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Thu, 5 Dec 2019 13:27:14 -0700 Subject: [PATCH 10/17] compression read missing --- lzwfs/lzwfs.lua | 9 ++++++++- packages.list | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lzwfs/lzwfs.lua b/lzwfs/lzwfs.lua index 46aa869..382bd7a 100644 --- a/lzwfs/lzwfs.lua +++ b/lzwfs/lzwfs.lua @@ -180,7 +180,14 @@ function fs.open(fname, flags) local ctr = 0 local lines return { - readLine = function() + read = function() + if not lines then + lines = decompress(f.readAll()) + end + ctr = ctr + 1 + return lines:sub(ctr, ctr) + end, + readLine = function() if not lines then lines = split(decompress(f.readAll())) end diff --git a/packages.list b/packages.list index 092785d..eaee2b8 100644 --- a/packages.list +++ b/packages.list @@ -1,9 +1,9 @@ { - [ 'common' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/common/.package', - [ 'core' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/core/.package', [ 'builder' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/builder/.package', [ 'cash' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/cash/.package', [ 'ccemux' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/ccemux/.package', + [ 'common' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/common/.package', + [ 'core' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/core/.package', [ 'farms' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/farms/.package', -- [ 'forestry' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/forestry/.package', [ 'games' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/games/.package', -- 2.49.1 From 7b45348710fc77cdbd70034e7b6bc8e7bb802d47 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Thu, 5 Dec 2019 15:34:20 -0700 Subject: [PATCH 11/17] oops --- cash/etc/apps.db | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cash/etc/apps.db b/cash/etc/apps.db index 2b13ce3..00e39c0 100644 --- a/cash/etc/apps.db +++ b/cash/etc/apps.db @@ -1,7 +1,7 @@ { - [ "a3c2cb0e2228250d98c481128f6837ef93111d73" ] = { - title = "MBS", + [ "16323efd4cb1f1f639d67b94161c2ef37a905517e" ] = { + title = "cash", category = "Apps", - run = ".mbs/bin/shell.lua", + run = "packages/cash/cash.lua", }, } -- 2.49.1 From a85e14e94d653a28adfa77f48edda9d5dd5152a4 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Sat, 7 Dec 2019 22:32:40 -0500 Subject: [PATCH 12/17] ores.lua: Load ore lists from config file and damage value support --- neural/ores.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/neural/ores.lua b/neural/ores.lua index 373dd85..7c15018 100644 --- a/neural/ores.lua +++ b/neural/ores.lua @@ -5,6 +5,8 @@ -- Updated to use new(ish) canvas3d +local Config = require('opus.config') + local gps = _G.gps local keys = _G.keys local os = _G.os @@ -43,7 +45,7 @@ local function getPoint() end end -local targets = { +local targets = Config.load('ores', { ["minecraft:emerald_ore"] = { "minecraft:emerald_ore", 0 }, ["minecraft:diamond_ore"] = { "minecraft:diamond_ore", 0 }, ["minecraft:gold_ore"] = { "minecraft:gold_ore", 0 }, @@ -54,7 +56,8 @@ local targets = { ["minecraft:coal_ore"] = { "minecraft:coal_ore", 0 }, ["minecraft:quartz_ore"] = { "minecraft:quartz_ore", 0 }, ["minecraft:glowstone"] = { "minecraft:glowstone", 0 }, -} +}) + local projecting = { } local offset = getPoint() or showRequirements('GPS') local canvas = modules.canvas3d().create({ @@ -85,7 +88,7 @@ local function update() local blocks = { } for _, b in pairs(scanned) do - if targets[b.name] then + if targets[b.name..(b.metadata ~= 0 and ":"..b.metadata or "")] then -- track block's world position b.id = table.concat({ math.floor(pos.x + b.x), @@ -98,7 +101,8 @@ local function update() for _, b in pairs(blocks) do if not projecting[b.id] then projecting[b.id] = b - local target = targets[b.name] + + local target = targets[b.name..(b.metadata ~= 0 and ":"..b.metadata or "")] local x = b.x - math.floor(offset.x) + math.floor(pos.x) local y = b.y - math.floor(offset.y) + math.floor(pos.y) -- 2.49.1 From 14e6fd57a79945f9213a1889953df54b61f4f6ea Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sun, 8 Dec 2019 13:50:22 -0700 Subject: [PATCH 13/17] cash tweaks --- cash/.package | 1 + cash/etc/apps.db | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cash/.package b/cash/.package index b7a2cec..93cb0fb 100644 --- a/cash/.package +++ b/cash/.package @@ -23,6 +23,7 @@ Full compatibility with CraftOS shell.lua]], license = 'MIT', install = [[ require('opus.alternate').set('shell', 'packages/cash/cash.lua') + require('opus.util').writeFile('.cashrc', 'set TERMINATE_QUIT=yes') ]], uninstall = [[ require('opus.alternate').remove('shell', 'packages/cash/cash.lua') diff --git a/cash/etc/apps.db b/cash/etc/apps.db index 00e39c0..d58d870 100644 --- a/cash/etc/apps.db +++ b/cash/etc/apps.db @@ -1,6 +1,6 @@ { [ "16323efd4cb1f1f639d67b94161c2ef37a905517e" ] = { - title = "cash", + title = "Cash", category = "Apps", run = "packages/cash/cash.lua", }, -- 2.49.1 From 83452a2be0e4a2c0cb874fe94ec72b9f4f87a4b1 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sun, 15 Dec 2019 19:12:36 -0700 Subject: [PATCH 14/17] experimental terminal window manager --- ignore/twm.lua | 469 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 469 insertions(+) create mode 100644 ignore/twm.lua diff --git a/ignore/twm.lua b/ignore/twm.lua new file mode 100644 index 0000000..24f908a --- /dev/null +++ b/ignore/twm.lua @@ -0,0 +1,469 @@ +local Terminal = require('opus.terminal') +local trace = require('opus.trace') +local Util = require('opus.util') + +local colors = _G.colors +local os = _G.os +local peripheral = _G.peripheral +local printError = _G.printError +local shell = _ENV.shell +local term = _G.term +local window = _G.window + +local function syntax() + printError('Syntax:') + error('mwm [--config=filename] [monitor]') +end + +local args = Util.parse(...) +local UID = 0 +local multishell = { } +local processes = { } +local parentTerm = term.current() +local sessionFile = args.config or 'usr/config/mwm' +local monName = args[1] +local running +local parentMon + +local defaultEnv = Util.shallowCopy(_ENV) +defaultEnv.multishell = multishell + +if monName == 'terminal' then + parentMon = term.current() +elseif monName then + parentMon = peripheral.wrap(monName) or syntax() +else + parentMon = peripheral.find('monitor') or syntax() +end + +if parentMon.setTextScale then + parentMon.setTextScale(.5) +end + +local monDim, termDim = { }, { } +monDim.width, monDim.height = parentMon.getSize() +termDim.width, termDim.height = parentTerm.getSize() + +-- even though the monitor window is set to visible +-- the canvas is not (possibly change default in terminal.lua) + +-- canvas is not visible so that redraws +-- are done once in the event loop +local monitor = Terminal.window(parentMon, 1, 1, monDim.width, monDim.height, true) +monitor.setBackgroundColor(colors.gray) +monitor.clear() + +local function nextUID() + UID = UID + 1 + return UID +end + +local function xprun(env, path, ...) + setmetatable(env, { __index = _G }) + local fn, m = loadfile(path, env) + if fn then + return trace(fn, ...) + end + return fn, m +end + +local function write(win, x, y, text) + win.setCursorPos(x, y) + win.write(text) +end + +local function redraw() + --monitor.clear() + monitor.canvas:dirty() + --monitor.setBackgroundColor(colors.gray) + monitor.canvas:clear(colors.gray) + for k, process in ipairs(processes) do + process.container.canvas:dirty() + process:focus(k == #processes) + end +end + +local function getProcessAt(x, y) + for k = #processes, 1, -1 do + local process = processes[k] + if x >= process.x and + y >= process.y and + x <= process.x + process.width - 1 and + y <= process.y + process.height - 1 then + return k, process + end + end +end + +--[[ A runnable process ]]-- +local Process = { } + +function Process:new(args) + args.env = args.env or Util.shallowCopy(defaultEnv) + args.width = args.width or math.floor(termDim.width * .75) + args.height = args.height or math.floor(termDim.height * .75) + + -- TODO: randomize start position + local self = setmetatable({ + uid = nextUID(), + x = args.x or 1, + y = args.y or 1, + width = args.width, + height = args.height + 1, + path = args.path, + args = args.args or { }, + title = args.title or 'shell', + isMoving = false, + isResizing = false, + }, { __index = Process }) + + self:adjustDimensions() + if not args.x then + self.x = math.random(1, monDim.width - self.width + 1) + self.y = math.random(1, monDim.height - self.height + 1) + end + + self.container = Terminal.window(monitor, self.x, self.y, self.width, self.height, true) + self.window = window.create(self.container, 1, 2, args.width, args.height, true) + self.terminal = self.window + + self.container.canvas.parent = monitor.canvas + table.insert(monitor.canvas.layers, 1, self.container.canvas) + self.container.canvas:setVisible(true) + + --self.container.getSize = self.window.getSize + + self.co = coroutine.create(function() + local result, err + + if args.fn then + result, err = Util.runFunction(args.env, args.fn, table.unpack(self.args)) + elseif args.path then + result, err = xprun(args.env, args.path, table.unpack(self.args)) + end + + if not result and err and err ~= 'Terminated' then + printError('\n' .. tostring(err)) + os.pullEventRaw('terminate') + end + multishell.removeProcess(self) + end) + + self:focus(false) + + return self +end + +function Process:focus(focused) + if focused then + self.container.setBackgroundColor(colors.yellow) + else + self.container.setBackgroundColor(colors.lightGray) + end + self.container.setTextColor(colors.black) + write(self.container, 1, 1, string.rep(' ', self.width)) + write(self.container, 2, 1, self.title) + write(self.container, self.width - 1, 1, '*') + write(self.container, self.width - 3, 1, '\029') + + if focused then + self.window.restoreCursor() + end +end + +function Process:drawSizers() + self.container.setBackgroundColor(colors.black) + self.container.setTextColor(colors.yellow) + local str = string.format('%d x %d', self.width - 2, self.height - 3) + write(self.container, (self.width - #str) / 2, 1, str) +end + +function Process:adjustDimensions() + self.width = math.min(self.width, monDim.width) + self.height = math.min(self.height, monDim.height) + + self.x = math.max(1, self.x) + self.y = math.max(1, self.y) + self.x = math.min(self.x, monDim.width - self.width + 1) + self.y = math.min(self.y, monDim.height - self.height + 1) +end + +function Process:reposition() + self:adjustDimensions() + self.container.reposition(self.x, self.y, self.width, self.height) + self.container.setBackgroundColor(colors.black) + self.container.clear() + self.window.reposition(1, 2, self.width, self.height - 1) + if self.window ~= self.terminal then + if self.terminal.reposition then -- ?? + self.terminal.reposition(1, 1, self.width, self.height - 1) + end + end + redraw() +end + +function Process:click(x, y, rx, ry) + if y == 1 then -- title bar + if x == self.width - 1 then + self:resume('terminate') + elseif x == self.width - 3 then + self.isResizing = { x = rx, y = ry, h = self.height, w = self.width } + else + self.isMoving = { x = rx, y = ry, ox = self.x, oy = self.y } + end + + else + if self.isMoving then + self.isMoving = false + end + self:resume('mouse_click', 1, x, y - 1) + self:resume('mouse_up', 1, x, y - 1) + end +end + +function Process:resize(x, y) + self.height = y - self.isResizing.y + self.isResizing.h + self.width = x - self.isResizing.x + self.isResizing.w + + self:reposition() + self:resume('term_resize') + self:drawSizers() + multishell.saveSession(sessionFile) +end + +function Process:resume(event, ...) + if coroutine.status(self.co) == 'dead' then + return + end + + if not self.filter or self.filter == event or event == "terminate" then + --term.redirect(self.terminal) + local previousTerm = term.redirect(self.terminal) + + local previous = running + running = self -- stupid shell set title + local ok, result = coroutine.resume(self.co, event, ...) + running = previous + + self.terminal = term.current() + term.redirect(previousTerm) + + if ok then + self.filter = result + else + printError(result) + end + return ok, result + end +end + +--[[ Install a multishell manager for the monitor ]]-- +function multishell.getFocus() + return processes[#processes].uid +end + +function multishell.setFocus(uid) + local process = Util.find(processes, 'uid', uid) + + if process then + local lastFocused = processes[#processes] + if lastFocused ~= process then + + if lastFocused then + lastFocused:focus(false) + end + + Util.removeByValue(processes, process) + table.insert(processes, process) + + process.container.canvas:raise() + process:focus(true) + process.container.canvas:dirty() + end + return true + end + return false +end + +function multishell.getTitle(uid) + local process = Util.find(processes, 'uid', uid) + if process then + return process.title + end +end + +function multishell.setTitle(uid, title) + local process = Util.find(processes, 'uid', uid) + if process then + process.title = title or '' + process:focus(process == processes[#processes]) + end +end + +function multishell.getCurrent() + if running then + return running.uid + end +end + +function multishell.getCount() + return #processes +end + +function multishell.getTabs() + return processes +end + +function multishell.launch(env, file, ...) + return multishell.openTab({ + path = file, + env = env, + title = 'shell', + args = { ... }, + }) +end + +function multishell.openTab(tabInfo) + local process = Process:new(tabInfo) + + table.insert(processes, 1, process) + + --local previousTerm = term.current() + process:resume() + --term.redirect(previousTerm) + + multishell.saveSession(sessionFile) + + return process.uid +end + +function multishell.removeProcess(process) + Util.removeByValue(processes, process) + process.container.canvas:removeLayer() + + multishell.saveSession(sessionFile) + redraw() +end + +function multishell.saveSession(filename) + local t = { } + for _,process in ipairs(processes) do + if process.path then + table.insert(t, { + x = process.x, + y = process.y, + width = process.width, + height = process.height - 1, + path = process.path, + args = process.args, + }) + end + end + Util.writeTable(filename, t) +end + +function multishell.loadSession(filename) + local config = Util.readTable(filename) + if config then + for k = #config, 1, -1 do + multishell.openTab(config[k]) + end + end +end + +function multishell.stop() + multishell._stop = true +end + +function multishell.start() + while not multishell._stop do + + local event = { os.pullEventRaw() } + + if event[1] == 'terminate' then + local focused = processes[#processes] + if focused then + focused:resume('terminate') + if #processes == 0 then + break + end + end + + elseif event[1] == 'monitor_touch' or event[1] == 'mouse_click' then --or event[1] == 'mouse_up' then + local x, y = event[3], event[4] + + local key, process = getProcessAt(x, y) + if process then + if key ~= #processes then + multishell.setFocus(process.uid) + multishell.saveSession(sessionFile) + end + process:click(x - process.x + 1, y - process.y + 1, x, y) + end + + elseif event[1] == 'mouse_up' then + local focused = processes[#processes] + if focused and (focused.isResizing or focused.isMoving) then + multishell.saveSession(sessionFile) + if focused.isResizing then + focused:focus(true) + end + end + if focused then + focused.isResizing = nil + focused.isMoving = false + end + + elseif event[1] == 'mouse_drag' then + local focused = processes[#processes] + if focused then + if focused.isResizing then + focused:resize(event[3], event[4]) + + elseif focused.isMoving then + focused.x = event[3] - focused.isMoving.x + focused.isMoving.ox + focused.y = event[4] - focused.isMoving.y + focused.isMoving.oy + focused:reposition() + end + end + + elseif event[1] == 'char' or + event[1] == 'key' or + event[1] == 'key_up' or + event[1] == 'paste' then + + local focused = processes[#processes] + if focused then + focused:resume(table.unpack(event)) + end + + else + for _,process in pairs(Util.shallowCopy(processes)) do + process:resume(table.unpack(event)) + end + end + + monitor.canvas:render(parentMon) + + local focused = processes[#processes] + if focused then + focused.window.restoreCursor() + end + end +end + +multishell.loadSession(sessionFile) + +if #processes == 0 then + multishell.openTab({ + path = 'sys/apps/shell.lua', + title = 'shell', + }) +end + +processes[#processes]:focus(true) +multishell.start() + +term.redirect(parentTerm) +parentTerm.clear() +parentTerm.setCursorPos(1, 1) -- 2.49.1 From 79c8c4beaec6b35312795da0d31da3171a271af5 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Mon, 16 Dec 2019 18:02:25 -0700 Subject: [PATCH 15/17] builder help update --- builder/help/builder | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/builder/help/builder b/builder/help/builder index f668438..b105f97 100644 --- a/builder/help/builder +++ b/builder/help/builder @@ -27,7 +27,7 @@ Copy a schematic file to the turtle/command computer (see downloading instructio Building ======== Run: -> builder +> builder The first time you run the program, you must select a wrench. Place a wrench into the chest. Go to the supplies list and double-click the SelectAWrench item. Select the wrench and apply. @@ -47,9 +47,13 @@ Simply copy a schematic file into the computer's folder. Multiplayer ----------- -Option 1: Use wget if the schematic is available for download (unreliable). +Option 1: Pass the url of the schematic. -Option 2: Transferring via pastebin (reliable) +> builder + +Option 2: Use wget if the schematic is available for download (unreliable). + +Option 3: Transferring via pastebin (reliable) To create a base64 file from a command line, do: * linux / max: -- 2.49.1 From 3f19c94e0fa4c28dab162695c168171f7618d111 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Fri, 27 Dec 2019 01:18:09 -0500 Subject: [PATCH 16/17] 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', { -- 2.49.1 From f7a29fc6d469dcec1922b31db1cc1760742fd55d Mon Sep 17 00:00:00 2001 From: LDDestroier Date: Sun, 19 Jan 2020 13:26:26 -0500 Subject: [PATCH 17/17] Changed default list URL to updated one --- 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', -- 2.49.1