From 01452ced726544cb012fe8c19362c4b17885e88e Mon Sep 17 00:00:00 2001 From: kepler155c Date: Tue, 6 Nov 2018 16:21:31 -0500 Subject: [PATCH] package manager + tweaks to milo --- core/etc/apps/opus-apps.db | 71 ++++++++------------------------- farms/cows.lua | 6 ++- farms/etc/apps/apps.db | 11 +++++ farms/farm.lua | 6 ++- milo/.package | 6 ++- milo/Milo.lua | 5 +-- milo/apps/furni.lua | 54 +++++++++++++++++++++++++ milo/core/machines.lua | 2 +- storageManager/etc/apps/apps.db | 19 +++++++++ 9 files changed, 117 insertions(+), 63 deletions(-) create mode 100644 farms/etc/apps/apps.db create mode 100644 milo/apps/furni.lua create mode 100644 storageManager/etc/apps/apps.db diff --git a/core/etc/apps/opus-apps.db b/core/etc/apps/opus-apps.db index e2a8d90..443d9a8 100644 --- a/core/etc/apps/opus-apps.db +++ b/core/etc/apps/opus-apps.db @@ -32,15 +32,6 @@ \030 \031 \030f\0317\130\030 \031 \030f\0317\130", run = "Appstore.lua", }, - [ "4486006f811b88cacd5f211fd579717e29b600cd" ] = { - title = "Miner", - category = "Apps", - icon = " \0315\\\030 \031 \ - \0304\031f _ \030 \031c/\0315\\\ - \0304 ", - run = "simpleMiner.lua", - requires = 'turtle', - }, [ "131260cbfbb0c821f8eae5e7c3c296c7aa4d50b9" ] = { title = "Music", category = "Apps", @@ -52,13 +43,14 @@ requires = 'turtle', }, --[[ - [ "81c0d915fa6d82fd30661c5e66e204cea52bb2b5" ] = { - title = "Activity", + [ "4486006f811b88cacd5f211fd579717e29b600cd" ] = { + title = "Miner", category = "Apps", - icon = "\0318/\030f\031 \030 \0318\\\ -\030f \0308\0319o\030f\031 \ -\0318\\\030f\031 \030 \0318/", - run = "storageActivity.lua", + icon = " \0315\\\030 \031 \ + \0304\031f _ \030 \031c/\0315\\\ + \0304 ", + run = "simpleMiner.lua", + requires = 'turtle', }, [ "89307d419a2fe4fbb69af92b3d3af27b6ec14d3e" ] = { title = "Telnet", @@ -76,6 +68,15 @@ \031e\\/\031 \0319c", run = "vnc.lua", }, + [ "131f0b008f44298812221d120d982940609be781" ] = { + title = "Builder", + category = "Apps", + icon = "\0317_____\ +\030e\031c###\0308\0317=\030e\031c#\ +\030e\031c#\0307\031f.\030e\031c###", + run = "usr/apps/builder.lua", + requires = "turtle", + }, --]] [ "a0365977708b7387ee9ce2c13e5820e6e11732cb" ] = { title = "Pain", @@ -85,15 +86,6 @@ \030 \031f\030f\0318\143\133\0312\136\0302\031f\159\159\143\131\030f\0312\132", run = "http://pastebin.com/raw/wJQ7jav0", }, - [ "9e092dda4f0e27d0c7686ddd00272079e678b6e6" ] = { - title = "Storage", - category = "Apps", - icon = "\0307 \ -\0307 \0308\0311 \0305 \0308\031 \0307 \0308 \0301 \ -\0307 ", - run = "chestManager.lua", - requires = 'turtle', - }, [ "114edfc04a1ab03541bdc80ce064f66a7cfcedbb" ] = { title = "Recorder", category = "Apps", @@ -105,15 +97,6 @@ \030 \031f\030f\031e\139\030e\128\030f\159\129\0314\130\131\131\129", run = "recorder.lua", }, - [ "131f0b008f44298812221d120d982940609be781" ] = { - title = "Builder", - category = "Apps", - icon = "\0317_____\ -\030e\031c###\0308\0317=\030e\031c#\ -\030e\031c#\0307\031f.\030e\031c###", - run = "usr/apps/builder.lua", - requires = "turtle", - }, [ "d8c298dd41e4a4ec20e8307901797b64688b3b77" ] = { title = "GPS Deploy", category = "Apps", @@ -150,19 +133,6 @@ \030 \031f\030f\0310\136\140\140\030 ", run = "https://gist.github.com/LDDestroier/c7528d95bc0103545c2a/raw", }, ---[[ - [ "d78f28759f255a0db76604ee560b87c4715a0da5" ] = { - title = "Sketch", - category = "Apps", - icon = " \031bskch\ -\0303\031f \030d \ -\030d\031f ", - iconExt = "\030 \031f\0308\031f\151\0313\140\140\140\030f\0318\148\ -\030 \031f\030b\031f\149\0318\130\131\129\030f\031b\149\ -\030 \031f\030f\0318\138\0308\031b\130\131\129\030f\0318\133", - run = "http://pastebin.com/raw/Mm5hd97E", - }, -]] [ "58ec8d6e36e346d9f42eb43935652e3e58e2c829" ] = { title = "Mwm", category = "Apps", @@ -174,15 +144,6 @@ \030 \031f\0304\031f\131\131\131\131\131\131\131\030e\0314\131", run = "mwm.lua usr/config/mwm", }, - [ "8d1b0a73bedc0dc492377c2f6ab880940b97ec6e" ] = { - title = "Treefarm", - icon = "\030 \031f \0305 \030 \030d \030 \ -\0305\031f \030d \030 \030d \0305 \030d \ -\030 \031f \030c \030 \0304 \030 \030c \030 ", - category = "Apps", - run = "treefarm.lua", - requires = "turtle", - }, [ "01c933b2a36ad8ed2d54089cb2903039046c1216" ] = { title = "Enchat", icon = "\030e\031f\151\030f\031e\156\0311\140\0314\140\0315\140\031d\140\031b\140\031a\132\ diff --git a/farms/cows.lua b/farms/cows.lua index 43f3711..b5efaf0 100644 --- a/farms/cows.lua +++ b/farms/cows.lua @@ -93,7 +93,7 @@ end local chest = InventoryAdapter({ side = 'top', direction = 'down' }) or error('missing chest above') -turtle.run(function() +local s, m = turtle.run(function() turnOffWater() repeat @@ -117,3 +117,7 @@ turtle.run(function() os.sleep(5) until turtle.isAborted() end) + +if not s and m then + error(m) +end diff --git a/farms/etc/apps/apps.db b/farms/etc/apps/apps.db new file mode 100644 index 0000000..c9f8d4b --- /dev/null +++ b/farms/etc/apps/apps.db @@ -0,0 +1,11 @@ +{ + [ "8d1b0a73bedc0dc492377c2f6ab880940b97ec6e" ] = { + title = "Treefarm", + icon = "\030 \031f \0305 \030 \030d \030 \ +\0305\031f \030d \030 \030d \0305 \030d \ +\030 \031f \030c \030 \0304 \030 \030c \030 ", + category = "Apps", + run = "treefarm.lua", + requires = "turtle", + }, +} \ No newline at end of file diff --git a/farms/farm.lua b/farms/farm.lua index 297e54e..a68a41c 100644 --- a/farms/farm.lua +++ b/farms/farm.lua @@ -106,7 +106,7 @@ local function harvest(blocks) turtle.equip('right', 'plethora:module:2') end -turtle.run(function() +local s, m = turtle.run(function() local facing = scanner.getBlockMeta(0, 0, 0).state.facing turtle.point.heading = Point.facings[facing].heading @@ -125,3 +125,7 @@ turtle.run(function() end until turtle.isAborted() end) + +if not s and m then + error(m) +end diff --git a/milo/.package b/milo/.package index 3479fc3..b9690c4 100644 --- a/milo/.package +++ b/milo/.package @@ -2,8 +2,10 @@ required = { 'opus-develop-1.8', }, - title = 'Inventory manager for Opus OS', + title = 'Milo: Advanced inventory management', repository = 'kepler155c/opus-apps/develop-1.8/milo', - description = [[ ... ]], + description = [[Provides AE style crafting in computercraft. + Includes Importing, exporting, autocrafting, replenish and limits, and much more. + Includes over 200 standard Minecraft recipes.]], licence = 'MIT', } diff --git a/milo/Milo.lua b/milo/Milo.lua index f78c468..df1cbe9 100644 --- a/milo/Milo.lua +++ b/milo/Milo.lua @@ -69,7 +69,7 @@ local context = { _G._p = context --debug Event.on('storage_offline', function() - Milo:showError('A storage chest has gone offline, ctrl-l to continue') + Milo:showError('A storage chest has gone offline - See configuration screen') end) Milo:init(context) @@ -99,8 +99,7 @@ end Milo:clearGrid() -local page = UI:getPage('listing') -UI:setPage(page) +UI:setPage(UI:getPage('listing')) Event.on('milo_cycle', function() if not context.turtleBusy then diff --git a/milo/apps/furni.lua b/milo/apps/furni.lua new file mode 100644 index 0000000..8eb5294 --- /dev/null +++ b/milo/apps/furni.lua @@ -0,0 +1,54 @@ +--[[ +Use 4 furnaces at once to smelt items. + +Set up a turtle with a hopper on top and surrounded by furnaces. + +Set the hopper as a machine used for crafting. +Export coal to slot 2 of each furnace and import from slot 3. +--]] + +_G.requireInjector(_ENV) + +local Event = require('event') +local Util = require('util') + +local device = _G.device +local os = _G.os +local turtle = _G.turtle + +local intro = + device['plethora:introspection'] +local inv = intro.getInventory() + +Event.on('turtle_inventory', function() + while true do + local list = inv.list() + local sleepTime = 10 + if Util.empty(list) then + break + end + for k,slot in pairs(list) do + for _ = 1, 4 do + local count = 0 + local s, m = pcall(function() + count = inv.pushItems('front', k, 8, 1) + end) + if not s then + _G.printError(m) + end + if count > 0 then + sleepTime = 0 + end + turtle.turnRight() + slot.count = slot.count - count + if slot.count <= 0 then + break + end + end + end + os.sleep(sleepTime) + end +end) + +os.queueEvent('turtle_inventory') +Event.pullEvents() \ No newline at end of file diff --git a/milo/core/machines.lua b/milo/core/machines.lua index 144cf31..bc7b621 100644 --- a/milo/core/machines.lua +++ b/milo/core/machines.lua @@ -58,7 +58,7 @@ local machinesPage = UI.Page { function machinesPage.grid:getDisplayValues(row) row = Util.shallowCopy(row) - local t = { row.name:match(':(.+)_(%d+)') } + local t = { row.name:match(':(.+)_(%d+)$') } if t and #t == 2 then row.name, row.suffix = table.unpack(t) row.name = row.name .. '_' .. row.suffix diff --git a/storageManager/etc/apps/apps.db b/storageManager/etc/apps/apps.db new file mode 100644 index 0000000..603a26b --- /dev/null +++ b/storageManager/etc/apps/apps.db @@ -0,0 +1,19 @@ +{ + [ "81c0d915fa6d82fd30661c5e66e204cea52bb2b5" ] = { + title = "Activity", + category = "Apps", + icon = "\0318/\030f\031 \030 \0318\\\ +\030f \0308\0319o\030f\031 \ +\0318\\\030f\031 \030 \0318/", + run = "storageActivity.lua", + }, + [ "9e092dda4f0e27d0c7686ddd00272079e678b6e6" ] = { + title = "Storage", + category = "Apps", + icon = "\0307 \ +\0307 \0308\0311 \0305 \0308\031 \0307 \0308 \0301 \ +\0307 ", + run = "chestManager.lua", + requires = 'turtle', + }, +}