remove dependency on device global + milo backup config
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
_G.requireInjector(_ENV)
|
|
||||||
|
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
local os = _G.os
|
||||||
local os = _G.os
|
local peripheral = _G.peripheral
|
||||||
local term = _G.term
|
local term = _G.term
|
||||||
|
|
||||||
local args = { ... }
|
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.clear()
|
||||||
mon.setTextScale(.5)
|
mon.setTextScale(.5)
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ local Socket = require('socket')
|
|||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local network = _G.network
|
||||||
local network = _G.network
|
local os = _G.os
|
||||||
local os = _G.os
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
UI:configure('multiMiner', ...)
|
UI:configure('multiMiner', ...)
|
||||||
|
|
||||||
local scanner = device.neuralInterface
|
local scanner = peripheral.find('neuralInterface')
|
||||||
if not scanner or not scanner.scan then
|
if not scanner or not scanner.scan then
|
||||||
error('Plethora scanner must be equipped')
|
error('Plethora scanner must be equipped')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -7,10 +7,10 @@ local sync = require('sync').sync
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local fs = _G.fs
|
||||||
local fs = _G.fs
|
local peripheral = _G.peripheral
|
||||||
local shell = _ENV.shell
|
local shell = _ENV.shell
|
||||||
|
|
||||||
local context = {
|
local context = {
|
||||||
state = Config.load('miloRemote', { displayMode = 0, deposit = true }),
|
state = Config.load('miloRemote', { displayMode = 0, deposit = true }),
|
||||||
@@ -108,7 +108,7 @@ local page = UI.Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local function getPlayerName()
|
local function getPlayerName()
|
||||||
local neural = device.neuralInterface
|
local neural = peripheral.find('neuralInterface')
|
||||||
|
|
||||||
if neural and neural.getName then
|
if neural and neural.getName then
|
||||||
return neural.getName()
|
return neural.getName()
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ function Milo:eject(item, count)
|
|||||||
count = count - amount
|
count = count - amount
|
||||||
|
|
||||||
Sound.play('ui.button.click')
|
Sound.play('ui.button.click')
|
||||||
|
--Sound.play('entity.illusion_illager.death')
|
||||||
turtle.emptyInventory()
|
turtle.emptyInventory()
|
||||||
end
|
end
|
||||||
return total
|
return total
|
||||||
@@ -324,6 +325,7 @@ function Milo:updateRecipe(result, recipe)
|
|||||||
recipe.result = nil
|
recipe.result = nil
|
||||||
end
|
end
|
||||||
self.context.userRecipes[result] = recipe
|
self.context.userRecipes[result] = recipe
|
||||||
|
Util.backup(Craft.USER_RECIPES)
|
||||||
Util.writeTable(Craft.USER_RECIPES, self.context.userRecipes)
|
Util.writeTable(Craft.USER_RECIPES, self.context.userRecipes)
|
||||||
Craft.loadRecipes()
|
Craft.loadRecipes()
|
||||||
end
|
end
|
||||||
@@ -333,10 +335,12 @@ function Milo:saveMachineRecipe(recipe, result, machine)
|
|||||||
|
|
||||||
-- save the recipe
|
-- save the recipe
|
||||||
self.context.userRecipes[key] = recipe
|
self.context.userRecipes[key] = recipe
|
||||||
|
Util.backup(Craft.USER_RECIPES)
|
||||||
Util.writeTable(Craft.USER_RECIPES, self.context.userRecipes)
|
Util.writeTable(Craft.USER_RECIPES, self.context.userRecipes)
|
||||||
|
|
||||||
-- save the machine association
|
-- save the machine association
|
||||||
Craft.machineLookup[key] = machine
|
Craft.machineLookup[key] = machine
|
||||||
|
Util.backup(Craft.MACHINE_LOOKUP)
|
||||||
Util.writeTable(Craft.MACHINE_LOOKUP, Craft.machineLookup)
|
Util.writeTable(Craft.MACHINE_LOOKUP, Craft.machineLookup)
|
||||||
|
|
||||||
Craft.loadRecipes()
|
Craft.loadRecipes()
|
||||||
@@ -391,6 +395,7 @@ function Milo:mergeResources(t)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Milo:saveResources()
|
function Milo:saveResources()
|
||||||
|
Util.backup(self.RESOURCE_FILE)
|
||||||
Util.writeTable(self.RESOURCE_FILE, self.context.resources)
|
Util.writeTable(self.RESOURCE_FILE, self.context.resources)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ function Storage:saveConfiguration()
|
|||||||
v.adapter = nil
|
v.adapter = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Util.backup('usr/config/storage')
|
||||||
Config.update('storage', self.nodes)
|
Config.update('storage', self.nodes)
|
||||||
|
|
||||||
for k,v in pairs(t) do
|
for k,v in pairs(t) do
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local device = _G.device
|
local fs = _G.fs
|
||||||
local fs = _G.fs
|
local peripheral = _G.peripheral
|
||||||
local shell = _ENV.shell
|
local shell = _ENV.shell
|
||||||
|
|
||||||
if fs.exists('packages/milo/Milo.lua') then
|
if fs.exists('packages/milo/Milo.lua') then
|
||||||
fs.delete('packages/milo/Milo.lua')
|
fs.delete('packages/milo/Milo.lua')
|
||||||
@@ -9,6 +9,6 @@ end
|
|||||||
|
|
||||||
fs.delete('packages/milo/apis/milo.lua')
|
fs.delete('packages/milo/apis/milo.lua')
|
||||||
|
|
||||||
if device.workbench then
|
if peripheral.find('workbench') then
|
||||||
shell.openForegroundTab('MiloLocal')
|
shell.openForegroundTab('MiloLocal')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ local Event = require('event')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local peripheral = _G.peripheral
|
||||||
local ni = device.neuralInterface
|
|
||||||
|
|
||||||
local SHIELD_SLOT = 2
|
local ni = peripheral.find('neuralInterface')
|
||||||
local context = args[1]
|
local context = args[1]
|
||||||
|
|
||||||
if not context.state.autostore then
|
if not context.state.autostore then
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ local Config = require('config')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local itemDB = require('core.itemDB')
|
local itemDB = require('core.itemDB')
|
||||||
|
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local peripheral = _G.peripheral
|
||||||
local ni = device.neuralInterface
|
|
||||||
|
|
||||||
local context = args[1]
|
local context = args[1]
|
||||||
|
local ni = peripheral.find('neuralInterface')
|
||||||
|
|
||||||
if not context.state.depositAll then
|
if not context.state.depositAll then
|
||||||
context.state.depositAll = { }
|
context.state.depositAll = { }
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ local Milo = require('milo')
|
|||||||
local Sound = require('sound')
|
local Sound = require('sound')
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local context = Milo:getContext()
|
local context = Milo:getContext()
|
||||||
local device = _G.device
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
local speakerNode = context.storage:getSingleNode('speaker')
|
local speakerNode = context.storage:getSingleNode('speaker')
|
||||||
if speakerNode then
|
if speakerNode then
|
||||||
@@ -50,8 +50,7 @@ function wizardPage:validate()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function wizardPage:isValidType(node)
|
function wizardPage:isValidType(node)
|
||||||
local m = device[node.name]
|
return peripheral.getType(node.name) == 'speaker' and {
|
||||||
return m and m.type == 'speaker' and {
|
|
||||||
name = 'Speaker',
|
name = 'Speaker',
|
||||||
value = 'speaker',
|
value = 'speaker',
|
||||||
category = 'custom',
|
category = 'custom',
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ local Sound = require('sound')
|
|||||||
local Swarm = require('core.swarm')
|
local Swarm = require('core.swarm')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
local os = _G.os
|
||||||
local os = _G.os
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
local COLUMNS = 4
|
local COLUMNS = 4
|
||||||
|
|
||||||
local gpt = GPS.getPoint() or error('GPS not found')
|
local gpt = GPS.getPoint() or error('GPS not found')
|
||||||
local scanner = device.neuralInterface
|
local scanner = peripheral.find('neuralInterface')
|
||||||
if not scanner or not scanner.scan then
|
if not scanner or not scanner.scan then
|
||||||
error('Plethora scanner must be equipped')
|
error('Plethora scanner must be equipped')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ local parentMon
|
|||||||
|
|
||||||
local defaultEnv = Util.shallowCopy(_ENV)
|
local defaultEnv = Util.shallowCopy(_ENV)
|
||||||
defaultEnv.multishell = multishell
|
defaultEnv.multishell = multishell
|
||||||
if args[3] then
|
if args[2] then
|
||||||
parentMon = _G.device[args[3]]
|
|
||||||
elseif args[2] then
|
|
||||||
parentMon = peripheral.wrap(args[2]) or syntax()
|
parentMon = peripheral.wrap(args[2]) or syntax()
|
||||||
else
|
else
|
||||||
parentMon = peripheral.find('monitor') or syntax()
|
parentMon = peripheral.find('monitor') or syntax()
|
||||||
|
|||||||
@@ -4,11 +4,14 @@ local Project = require('neural.project')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
|
||||||
local peripheral = _G.peripheral
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
local scanner = device.neuralInterface or device['plethora:scanner'] or peripheral.find('manipulator')
|
local scanner =
|
||||||
if not scanner or not scanner.scan then
|
peripheral.find('neuralInterface') or
|
||||||
|
peripheral.find('plethora:scanner') or
|
||||||
|
peripheral.find('manipulator')
|
||||||
|
|
||||||
|
if not scanner or not scanner.scan then
|
||||||
error('Plethora scanner must be equipped')
|
error('Plethora scanner must be equipped')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ local Project = require('neural.project')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
|
||||||
local peripheral = _G.peripheral
|
local peripheral = _G.peripheral
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
|
|
||||||
@@ -13,9 +12,9 @@ local function equip(side, rawName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local target = nil
|
local target = nil
|
||||||
local ni = device.neuralInterface
|
local ni = peripheral.find('neuralInterface')
|
||||||
local sensor = ni or
|
local sensor = ni or
|
||||||
device['plethora:sensor'] or
|
peripheral.find('plethora:sensor') or
|
||||||
peripheral.find('manipulator') or
|
peripheral.find('manipulator') or
|
||||||
equip('left', 'plethora:module:3')
|
equip('left', 'plethora:module:3')
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
local Interface = { }
|
local Interface = { }
|
||||||
|
|
||||||
local Angle = require('neural.angle')
|
local Angle = require('neural.angle')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
local os = _G.os
|
||||||
local os = _G.os
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
local ni = device.neuralInterface or { }
|
local ni = peripheral.find('neuralInterface') or { }
|
||||||
for k,v in pairs(ni) do
|
for k,v in pairs(ni) do
|
||||||
Interface[k] = v
|
Interface[k] = v
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
local device = _G.device
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
if not device.neuralInterface then
|
local ni = peripheral.find('neuralInterface')
|
||||||
|
if not ni then
|
||||||
error('Missing neural interface')
|
error('Missing neural interface')
|
||||||
elseif not device.neuralInterface.disableAI then
|
elseif not ni.disableAI then
|
||||||
_G.printError('Unable to disable AI')
|
error('Missing kinetic augment')
|
||||||
else
|
else
|
||||||
device.neuralInterface.disableAI()
|
ni.disableAI()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
local device = _G.device
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
if not device.neuralInterface then
|
local ni = peripheral.find('neuralInterface')
|
||||||
|
if not ni then
|
||||||
error('Missing neural interface')
|
error('Missing neural interface')
|
||||||
elseif not device.neuralInterface.getEquipment then
|
elseif not ni.getEquipment then
|
||||||
error('Missing introspection module')
|
error('Missing introspection module')
|
||||||
else
|
else
|
||||||
device.neuralInterface.getEquipment().drop(6)
|
ni.getEquipment().drop(6)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
_G.requireInjector(_ENV)
|
|
||||||
|
|
||||||
local GPS = require('gps')
|
local GPS = require('gps')
|
||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local parallel = _G.parallel
|
local parallel = _G.parallel
|
||||||
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
local t = { }
|
local t = { }
|
||||||
local ni = _G.device.neuralInterface or error('Neural Interface not found')
|
local ni =
|
||||||
|
peripheral.find('neuralInterface') or
|
||||||
|
error('Neural Interface not found')
|
||||||
|
|
||||||
if not ni.getID then
|
if not ni.getID then
|
||||||
error('Missing Introspection Module')
|
error('Missing Introspection Module')
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
_G.requireInjector(_ENV)
|
|
||||||
|
|
||||||
local GPS = require('gps')
|
local GPS = require('gps')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local shell = _ENV.shell
|
local peripheral = _G.peripheral
|
||||||
|
local shell = _ENV.shell
|
||||||
|
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
local fileName = args[1] or 'neural.tbl'
|
local fileName = args[1] or 'neural.tbl'
|
||||||
|
|
||||||
local t = Util.readTable(shell.resolve(fileName)) or error('Unable to read ' .. fileName)
|
local t = Util.readTable(shell.resolve(fileName)) or error('Unable to read ' .. fileName)
|
||||||
local ni = _G.device.neuralInterface
|
local ni = peripheral.find('neuralInterface')
|
||||||
|
|
||||||
local function walkTo(x, y, z)
|
local function walkTo(x, y, z)
|
||||||
local pt = GPS.locate(2)
|
local pt = GPS.locate(2)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local device = _G.device
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
--[[ Configuration Page ]]--
|
--[[ Configuration Page ]]--
|
||||||
local wizardPage = UI.WizardPage {
|
local wizardPage = UI.WizardPage {
|
||||||
@@ -64,8 +64,8 @@ function wizardPage:saveNode(node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function wizardPage:isValidType(node)
|
function wizardPage:isValidType(node)
|
||||||
local m = device[node.name]
|
local m = peripheral.getType(node.name)
|
||||||
return m and m.type == 'monitor' and {
|
return m == 'monitor' and {
|
||||||
name = 'Store Front',
|
name = 'Store Front',
|
||||||
value = 'shop',
|
value = 'shop',
|
||||||
category = 'display',
|
category = 'display',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local Equipper = require('turtle.equipper')
|
local Equipper = require('turtle.equipper')
|
||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
|
|
||||||
local peripheral = _G.device
|
local peripheral = _G.peripheral
|
||||||
local turtle = _G.turtle
|
local turtle = _G.turtle
|
||||||
|
|
||||||
local MAX_FUEL = turtle.getFuelLimit()
|
local MAX_FUEL = turtle.getFuelLimit()
|
||||||
|
|||||||
Reference in New Issue
Block a user