From 08acd126c85b2623de45dc3681dbd9ada8631561 Mon Sep 17 00:00:00 2001 From: kepler155c Date: Mon, 25 Sep 2017 22:49:25 -0400 Subject: [PATCH] better startup --- apis/configurator.lua | 16 ------------- apps/chestManager.lua | 1 - apps/mwm.lua | 41 ++++++++++++++++++++-------------- apps/shapes.lua | 2 +- apps/webapp.lua | 52 ------------------------------------------- etc/recipes.db | 20 +++++++++++++++++ 6 files changed, 45 insertions(+), 87 deletions(-) delete mode 100644 apis/configurator.lua delete mode 100644 apps/webapp.lua diff --git a/apis/configurator.lua b/apis/configurator.lua deleted file mode 100644 index 47acf45..0000000 --- a/apis/configurator.lua +++ /dev/null @@ -1,16 +0,0 @@ -requireInjector(getfenv(1)) - -local Util = require('util') - -local Configurator = { } - -function Configurator.get() - print('Select device') - for k,v in pairs(device) do - Util.print('%s [%s]', v.name, v.side) - end -end - -Configurator.get() - -return Configurator diff --git a/apps/chestManager.lua b/apps/chestManager.lua index 8e3a3fa..9796257 100644 --- a/apps/chestManager.lua +++ b/apps/chestManager.lua @@ -394,7 +394,6 @@ local function watchResources(items) for rsDevice, sides in pairs(outputs) do for side, enable in pairs(sides) do pcall(function() - debug({ rsDevice, side, enable }) device[rsDevice].setOutput(side, enable) end) end diff --git a/apps/mwm.lua b/apps/mwm.lua index bb6b770..8cab342 100644 --- a/apps/mwm.lua +++ b/apps/mwm.lua @@ -16,6 +16,7 @@ local parentTerm = term.current() local configFile = args[1] or syntax() local defaultEnv = Util.shallowCopy(getfenv(1)) local monitor +local exitSession if args[2] then monitor = peripheral.wrap(args[2]) or syntax() @@ -35,7 +36,7 @@ local function nextUID() return UID end -local function saveConfig() +local function saveSession() local t = { } for _,process in pairs(processes) do if process.path and not process.isShell then @@ -133,7 +134,7 @@ function Process:new(args) end end Util.removeByValue(processes, self) - saveConfig() + saveSession() redraw() end) @@ -239,7 +240,7 @@ function Process:resizeClick(x, y) self:reposition() self:resume('term_resize') self:drawSizers(true) - saveConfig() + saveSession() end function Process:resume(event, ...) @@ -316,10 +317,11 @@ end function defaultEnv.multishell.openTab(tabInfo) local process = Process:new(tabInfo) - saveConfig() + saveSession() return process.uid end +--[[ Special shell process for launching programs ]]-- local function addShell() local process = setmetatable({ @@ -357,9 +359,11 @@ local function addShell() process.terminal = process.window process.co = coroutine.create(function() - while true do - os.run(Util.shallowCopy(defaultEnv), shell.resolveProgram('shell')) - end + print('To run a program on the monitor, type "fg "') + print('To quit, type "exit"') + print('Press the [ shell ] button on the monitor to return to this shell') + os.run(Util.shallowCopy(defaultEnv), shell.resolveProgram('shell')) + exitSession = true end) table.insert(processes, process) @@ -370,23 +374,25 @@ local function addShell() term.redirect(previousTerm) end -addShell() - -if fs.exists(configFile) then - local config = Util.readTable(configFile) - if config then - for _,v in pairs(config) do - Process:new(v) +local function loadSession() + if fs.exists(configFile) then + local config = Util.readTable(configFile) + if config then + for _,v in pairs(config) do + Process:new(v) + end end end end -while true do +addShell() +loadSession() + +while not exitSession do local event = { os.pullEventRaw() } if event[1] == 'terminate' then - term.redirect(parentTerm) break elseif event[1] == "monitor_touch" then @@ -425,7 +431,7 @@ while true do process.y = y process:reposition() process:drawSizers(true) - saveConfig() + saveSession() end end @@ -449,5 +455,6 @@ while true do end end +term.redirect(parentTerm) parentTerm.clear() parentTerm.setCursorPos(1, 1) diff --git a/apps/shapes.lua b/apps/shapes.lua index 67cabe7..69d2245 100644 --- a/apps/shapes.lua +++ b/apps/shapes.lua @@ -327,7 +327,7 @@ function page:runFunction(id, script) local fn, msg = loadstring(script, 'script') if not fn then self.notification:error('Error in script') - debug(msg) +-- debug(msg) return end diff --git a/apps/webapp.lua b/apps/webapp.lua deleted file mode 100644 index 5a5c8ef..0000000 --- a/apps/webapp.lua +++ /dev/null @@ -1,52 +0,0 @@ -local args = { ... } -local GIT_REPO = 'kepler155c/opus/master' -local BASE = 'https://raw.githubusercontent.com/' .. GIT_REPO - -local function dourl(env, url) - local h = http.get(url) - if h then - local fn, m = load(h.readAll(), url, nil, env) - h.close() - if fn then - return fn() - end - end - error('Failed to download ' .. url) -end - -local s, m = pcall(function() - - _G.requireInjector = dourl(getfenv(1), BASE .. '/sys/apis/injector.lua') - - local function mkenv() - local env = { } - for k,v in pairs(getfenv(1)) do - env[k] = v - end - setmetatable(env, { __index = _G }) - return env - end - - -- install vfs - dourl(mkenv(), BASE .. '/sys/extensions/vfs.lua') - - -- install filesystem - fs.mount('', 'gitfs', GIT_REPO) - fs.mount('usr', 'gitfs', 'kepler155c/opus-apps/master') - - -- start program - local file = table.remove(args, 1) - - local s, m = os.run(mkenv(), file or 'startup', unpack(args)) - if not s and m then - error(m) - end -end) - -if not s and m then - printError(m) -end - -if fs.restore then - fs.restore() -end diff --git a/etc/recipes.db b/etc/recipes.db index 3019fdc..13e39d1 100644 --- a/etc/recipes.db +++ b/etc/recipes.db @@ -502,6 +502,15 @@ [ 6 ] = "minecraft:iron_ingot:0", }, }, + [ "minecraft:brewing_stand:0" ] = { + count = 1, + ingredients = { + [ 7 ] = "minecraft:cobblestone:0", + [ 2 ] = "minecraft:blaze_rod:0", + [ 5 ] = "minecraft:cobblestone:0", + [ 6 ] = "minecraft:cobblestone:0", + }, + }, [ "minecraft:stained_glass:0" ] = { count = 8, ingredients = { @@ -1758,6 +1767,17 @@ [ 7 ] = "minecraft:stained_glass:9", }, }, + [ "minecraft:iron_door:0" ] = { + count = 3, + ingredients = { + "minecraft:iron_ingot:0", + "minecraft:iron_ingot:0", + [ 9 ] = "minecraft:iron_ingot:0", + [ 10 ] = "minecraft:iron_ingot:0", + [ 5 ] = "minecraft:iron_ingot:0", + [ 6 ] = "minecraft:iron_ingot:0", + }, + }, [ "minecraft:stained_glass_pane:12" ] = { count = 16, ingredients = {