remove dependency on device global + milo backup config

This commit is contained in:
kepler155c@gmail.com
2019-03-11 23:48:53 -04:00
parent f2a8a7e639
commit b43761faf1
21 changed files with 79 additions and 125 deletions

View File

@@ -1,13 +1,13 @@
_G.requireInjector(_ENV)
local Util = require('util')
local device = _G.device
local os = _G.os
local term = _G.term
local os = _G.os
local peripheral = _G.peripheral
local term = _G.term
local args = { ... }
local mon = device[args[1] or 'monitor'] or error('Syntax: debug <monitor>')
local mon = args[1] and peripheral.wrap(args[1]) or
peripheral.find('monitor') or
error('Syntax: debug <monitor>')
mon.clear()
mon.setTextScale(.5)

View File

@@ -6,14 +6,14 @@ local Socket = require('socket')
local Util = require('util')
local UI = require('ui')
local colors = _G.colors
local device = _G.device
local network = _G.network
local os = _G.os
local colors = _G.colors
local network = _G.network
local os = _G.os
local peripheral = _G.peripheral
UI:configure('multiMiner', ...)
local scanner = device.neuralInterface
local scanner = peripheral.find('neuralInterface')
if not scanner or not scanner.scan then
error('Plethora scanner must be equipped')
end

View File

@@ -1,52 +0,0 @@
local args = {...}
if not args[1] then
print("Usage:")
print(shell.getRunningProgram() .. " <program> [program arguments, ...]")
return
end
local path = shell.resolveProgram(args[1]) or shell.resolve(args[1])
-- here be dragons
if fs.exists(path) then
local eshell = setmetatable({getRunningProgram=function() return path end}, {__index = shell})
local env = setmetatable({shell=eshell}, {__index=_ENV})
local f = fs.open(path, "r")
local d = f.readAll()
f.close()
local func, e = load(d, fs.getName(path), nil, env)
if not func then
printError("Syntax error:")
printError(" " .. e)
else
table.remove(args, 1)
xpcall(function() func(unpack(args)) end, function(err)
local trace = {}
local i, hitEnd, _, e = 4, false
repeat
_, e = pcall(function() error("<tracemarker>", i) end)
i = i + 1
if e == "xpcall: <tracemarker>" then
hitEnd = true
break
end
table.insert(trace, e)
until i > 10
table.remove(trace)
if err:match("^" .. trace[1]:match("^(.-:%d+)")) then table.remove(trace, 1) end
printError("\nProgram has crashed! Stack trace:")
printError(err)
for i, v in ipairs(trace) do
printError(" at " .. v:match("^(.-:%d+)"))
end
if not hitEnd then
printError(" ...")
end
end)
end
else
printError("program not found")
end