lint
This commit is contained in:
@@ -575,7 +575,8 @@ function Blocks:init(args)
|
|||||||
placementDB:load2(blockDB, blockTypeDB)
|
placementDB:load2(blockDB, blockTypeDB)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- for an ID / dmg (with placement info) - return the correct block (without the placment info embedded in the dmg)
|
-- for an ID / dmg (with placement info)
|
||||||
|
-- return the correct block (without the placment info embedded in the dmg)
|
||||||
function Blocks:getPlaceableBlock(id, dmg)
|
function Blocks:getPlaceableBlock(id, dmg)
|
||||||
|
|
||||||
local p = placementDB:get({id, dmg})
|
local p = placementDB:get({id, dmg})
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ local function safeString(text)
|
|||||||
|
|
||||||
local newText = {}
|
local newText = {}
|
||||||
for i = 4, #text do
|
for i = 4, #text do
|
||||||
local val = text:byte(i)
|
val = text:byte(i)
|
||||||
newText[i - 3] = (val > 31 and val < 127) and val or 63
|
newText[i - 3] = (val > 31 and val < 127) and val or 63
|
||||||
end
|
end
|
||||||
return string.char(unpack(newText))
|
return string.char(unpack(newText))
|
||||||
@@ -110,11 +110,10 @@ function ChestAdapter:getItemInfo(item)
|
|||||||
return self.cache[key]
|
return self.cache[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:craft(id, dmg, qty)
|
function ChestAdapter:craft()
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:craftItems(items)
|
function ChestAdapter:craftItems()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:provide(item, qty, slot, direction)
|
function ChestAdapter:provide(item, qty, slot, direction)
|
||||||
@@ -144,7 +143,7 @@ end
|
|||||||
function ChestAdapter:insert(slot, qty)
|
function ChestAdapter:insert(slot, qty)
|
||||||
local s, m = pcall(function() self.pullItem(self.direction, slot, qty) end)
|
local s, m = pcall(function() self.pullItem(self.direction, slot, qty) end)
|
||||||
if not s and m then
|
if not s and m then
|
||||||
sleep(1)
|
os.sleep(1)
|
||||||
pcall(function() self.pullItem(self.direction, slot, qty) end)
|
pcall(function() self.pullItem(self.direction, slot, qty) end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -106,10 +106,10 @@ function ChestAdapter:getItemInfo(item)
|
|||||||
return self.cache[key]
|
return self.cache[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:craft(name, damage, qty)
|
function ChestAdapter:craft()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:craftItems(items)
|
function ChestAdapter:craftItems()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:provide(item, qty, slot, direction)
|
function ChestAdapter:provide(item, qty, slot, direction)
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ local itemDB = require('itemDB')
|
|||||||
local Peripheral = require('peripheral')
|
local Peripheral = require('peripheral')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local MEAdapter = class()
|
local os = _G.os
|
||||||
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
local convertNames = {
|
local convertNames = {
|
||||||
name = 'id',
|
name = 'id',
|
||||||
@@ -31,7 +32,7 @@ local function safeString(text)
|
|||||||
|
|
||||||
local newText = {}
|
local newText = {}
|
||||||
for i = 4, #text do
|
for i = 4, #text do
|
||||||
local val = text:byte(i)
|
val = text:byte(i)
|
||||||
newText[i - 3] = (val > 31 and val < 127) and val or 63
|
newText[i - 3] = (val > 31 and val < 127) and val or 63
|
||||||
end
|
end
|
||||||
return string.char(unpack(newText))
|
return string.char(unpack(newText))
|
||||||
@@ -48,6 +49,8 @@ local function convertItem(item)
|
|||||||
item.displayName = safeString(item.displayName)
|
item.displayName = safeString(item.displayName)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local MEAdapter = class()
|
||||||
|
|
||||||
function MEAdapter:init(args)
|
function MEAdapter:init(args)
|
||||||
local defaults = {
|
local defaults = {
|
||||||
items = { },
|
items = { },
|
||||||
@@ -104,7 +107,7 @@ function MEAdapter:listItems()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MEAdapter:getItemInfo(item)
|
function MEAdapter:getItemInfo(item)
|
||||||
for key,i in pairs(self.items) do
|
for _,i in pairs(self.items) do
|
||||||
if item.name == i.name and item.damage == i.damage and item.nbtHash == i.nbtHash then
|
if item.name == i.name and item.damage == i.damage and item.nbtHash == i.nbtHash then
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
@@ -133,7 +136,7 @@ function MEAdapter:craft(item, count)
|
|||||||
|
|
||||||
self:refresh()
|
self:refresh()
|
||||||
|
|
||||||
local item = self:getItemInfo(item)
|
item = self:getItemInfo(item)
|
||||||
if item and item.is_craftable then
|
if item and item.is_craftable then
|
||||||
|
|
||||||
local cpus = self.getCraftingCPUs() or { }
|
local cpus = self.getCraftingCPUs() or { }
|
||||||
@@ -220,7 +223,7 @@ function MEAdapter:provide(item, count, slot, direction)
|
|||||||
return pcall(function()
|
return pcall(function()
|
||||||
while count > 0 do
|
while count > 0 do
|
||||||
local qty = math.min(count, 64)
|
local qty = math.min(count, 64)
|
||||||
local s, m = self.exportItem({
|
local s = self.exportItem({
|
||||||
id = item.name,
|
id = item.name,
|
||||||
dmg = item.damage
|
dmg = item.damage
|
||||||
}, direction or self.direction, qty, slot)
|
}, direction or self.direction, qty, slot)
|
||||||
@@ -236,14 +239,10 @@ end
|
|||||||
function MEAdapter:insert(slot, count)
|
function MEAdapter:insert(slot, count)
|
||||||
local s, m = pcall(function() self.pullItem(self.direction, slot, count) end)
|
local s, m = pcall(function() self.pullItem(self.direction, slot, count) end)
|
||||||
if not s and m then
|
if not s and m then
|
||||||
print('MEAdapter:pullItem')
|
os.sleep(1)
|
||||||
print(m)
|
|
||||||
sleep(1)
|
|
||||||
s, m = pcall(function() self.pullItem(self.direction, slot, count) end)
|
s, m = pcall(function() self.pullItem(self.direction, slot, count) end)
|
||||||
if not s and m then
|
if not s and m then
|
||||||
print('MEAdapter:pullItem')
|
error(m)
|
||||||
print(m)
|
|
||||||
read()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function nameDB:load()
|
|||||||
end
|
end
|
||||||
|
|
||||||
for strId, block in pairs(blocks) do
|
for strId, block in pairs(blocks) do
|
||||||
local strId = 'minecraft:' .. strId
|
strId = 'minecraft:' .. strId
|
||||||
if type(block.name) == 'string' then
|
if type(block.name) == 'string' then
|
||||||
self.data[strId .. ':0'] = block.name
|
self.data[strId .. ':0'] = block.name
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -125,18 +125,18 @@ function RefinedAdapter:craft(item, qty)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function RefinedAdapter:craftItems(items)
|
function RefinedAdapter:craftItems()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function RefinedAdapter:provide(item, qty, slot)
|
function RefinedAdapter:provide()
|
||||||
end
|
end
|
||||||
|
|
||||||
function RefinedAdapter:extract(slot, qty)
|
function RefinedAdapter:extract()
|
||||||
-- self.pushItems(self.direction, slot, qty)
|
-- self.pushItems(self.direction, slot, qty)
|
||||||
end
|
end
|
||||||
|
|
||||||
function RefinedAdapter:insert(slot, qty)
|
function RefinedAdapter:insert()
|
||||||
-- self.pullItems(self.direction, slot, qty)
|
-- self.pullItems(self.direction, slot, qty)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ local DEFLATE = require('deflatelua')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
|
|
||||||
|
local bit = _G.bit
|
||||||
|
local fs = _G.fs
|
||||||
|
local term = _G.term
|
||||||
|
local turtle = _G.turtle
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Loading and manipulating a schematic
|
Loading and manipulating a schematic
|
||||||
--]]
|
--]]
|
||||||
@@ -218,11 +223,11 @@ function DiskFile:close()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local MemoryFile = class()
|
local MemoryFile = class()
|
||||||
function MemoryFile:init(args)
|
function MemoryFile:init()
|
||||||
self.s = { }
|
self.s = { }
|
||||||
self.i = 1
|
self.i = 1
|
||||||
end
|
end
|
||||||
function MemoryFile:open(filename)
|
function MemoryFile:open()
|
||||||
self.i = 1
|
self.i = 1
|
||||||
end
|
end
|
||||||
function MemoryFile:close() end
|
function MemoryFile:close() end
|
||||||
@@ -247,7 +252,7 @@ function Schematic:decompress(ifname, spinner)
|
|||||||
local mh = MemoryFile()
|
local mh = MemoryFile()
|
||||||
|
|
||||||
DEFLATE.gunzip({
|
DEFLATE.gunzip({
|
||||||
input=function(...) spinner:spin() return ifh.read() end,
|
input=function() spinner:spin() return ifh.read() end,
|
||||||
output=function(b) mh:write(b) end,
|
output=function(b) mh:write(b) end,
|
||||||
disable_crc=true
|
disable_crc=true
|
||||||
})
|
})
|
||||||
@@ -310,7 +315,7 @@ end
|
|||||||
|
|
||||||
function Schematic:load(filename)
|
function Schematic:load(filename)
|
||||||
|
|
||||||
local cursorX, cursorY = term.getCursorPos()
|
local _, cursorY = term.getCursorPos()
|
||||||
local spinner = UI.Spinner({
|
local spinner = UI.Spinner({
|
||||||
x = UI.term.width,
|
x = UI.term.width,
|
||||||
y = cursorY - 1
|
y = cursorY - 1
|
||||||
@@ -843,8 +848,6 @@ end
|
|||||||
-- set the order for block dependencies
|
-- set the order for block dependencies
|
||||||
function Schematic:setPlacementOrder(spinner, placementChains)
|
function Schematic:setPlacementOrder(spinner, placementChains)
|
||||||
|
|
||||||
local cursorX, cursorY = term.getCursorPos()
|
|
||||||
|
|
||||||
-- optimize for overlapping check
|
-- optimize for overlapping check
|
||||||
for _,chain in pairs(placementChains) do
|
for _,chain in pairs(placementChains) do
|
||||||
for index,_ in pairs(chain.keys) do
|
for index,_ in pairs(chain.keys) do
|
||||||
@@ -1040,8 +1043,6 @@ v.info = 'Unplaceable'
|
|||||||
end
|
end
|
||||||
|
|
||||||
term.clearLine()
|
term.clearLine()
|
||||||
|
|
||||||
return t
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Schematic:optimizeRoute(spinner, y)
|
function Schematic:optimizeRoute(spinner, y)
|
||||||
@@ -1146,7 +1147,6 @@ function Schematic:optimizeRoute(spinner, y)
|
|||||||
|
|
||||||
local maxDistance = self.width*self.length
|
local maxDistance = self.width*self.length
|
||||||
local plane, doors = extractPlane(y)
|
local plane, doors = extractPlane(y)
|
||||||
spinner:spin(percent)
|
|
||||||
pt.index = 0
|
pt.index = 0
|
||||||
for i = 1, #plane do
|
for i = 1, #plane do
|
||||||
local b = getNearestNeighbor(plane, pt, maxDistance)
|
local b = getNearestNeighbor(plane, pt, maxDistance)
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Ansi = require('ansi')
|
local Ansi = require('ansi')
|
||||||
local Config = require('config')
|
|
||||||
local SHA1 = require('sha1')
|
local SHA1 = require('sha1')
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
-- scrap this entire file. don't muck with standard apis
|
local fs = _G.fs
|
||||||
|
local http = _G.http
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
local os = _G.os
|
||||||
|
local shell = _ENV.shell
|
||||||
|
|
||||||
local REGISTRY_DIR = 'usr/.registry'
|
local REGISTRY_DIR = 'usr/.registry'
|
||||||
|
|
||||||
|
|
||||||
-- FIX SOMEDAY
|
-- FIX SOMEDAY
|
||||||
function os.registerApp(app, key)
|
local function registerApp(app, key)
|
||||||
|
|
||||||
app.key = SHA1.sha1(key)
|
app.key = SHA1.sha1(key)
|
||||||
Util.writeTable(fs.combine(REGISTRY_DIR, app.key), app)
|
Util.writeTable(fs.combine(REGISTRY_DIR, app.key), app)
|
||||||
os.queueEvent('os_register_app')
|
os.queueEvent('os_register_app')
|
||||||
end
|
end
|
||||||
|
|
||||||
function os.unregisterApp(key)
|
local function unregisterApp(key)
|
||||||
|
|
||||||
local filename = fs.combine(REGISTRY_DIR, SHA1.sha1(key))
|
local filename = fs.combine(REGISTRY_DIR, SHA1.sha1(key))
|
||||||
if fs.exists(filename) then
|
if fs.exists(filename) then
|
||||||
@@ -29,7 +32,7 @@ function os.unregisterApp(key)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local sandboxEnv = Util.shallowCopy(getfenv(1))
|
local sandboxEnv = Util.shallowCopy(_ENV)
|
||||||
setmetatable(sandboxEnv, { __index = _G })
|
setmetatable(sandboxEnv, { __index = _G })
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'App Store')
|
multishell.setTitle(multishell.getCurrent(), 'App Store')
|
||||||
@@ -243,7 +246,7 @@ function appPage:eventHandler(event)
|
|||||||
|
|
||||||
elseif event.type == 'uninstall' then
|
elseif event.type == 'uninstall' then
|
||||||
if self.app.runOnly then
|
if self.app.runOnly then
|
||||||
s,m = runApp(self.app, false, 'uninstall')
|
runApp(self.app, false, 'uninstall')
|
||||||
else
|
else
|
||||||
fs.delete(fs.combine(APP_DIR, self.app.name))
|
fs.delete(fs.combine(APP_DIR, self.app.name))
|
||||||
self.notification:success("Uninstalled " .. self.app.name, 3)
|
self.notification:success("Uninstalled " .. self.app.name, 3)
|
||||||
@@ -251,7 +254,7 @@ function appPage:eventHandler(event)
|
|||||||
self.menuBar.removeButton:disable('Remove')
|
self.menuBar.removeButton:disable('Remove')
|
||||||
self.menuBar:draw()
|
self.menuBar:draw()
|
||||||
|
|
||||||
os.unregisterApp(self.app.creator .. '.' .. self.app.name)
|
unregisterApp(self.app.creator .. '.' .. self.app.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif event.type == 'install' then
|
elseif event.type == 'install' then
|
||||||
@@ -275,7 +278,7 @@ function appPage:eventHandler(event)
|
|||||||
category = 'Games'
|
category = 'Games'
|
||||||
end
|
end
|
||||||
|
|
||||||
os.registerApp({
|
registerApp({
|
||||||
run = fs.combine(APP_DIR, self.app.name),
|
run = fs.combine(APP_DIR, self.app.name),
|
||||||
title = self.app.title,
|
title = self.app.title,
|
||||||
category = category,
|
category = category,
|
||||||
@@ -314,7 +317,7 @@ local categoryPage = UI.Page {
|
|||||||
|
|
||||||
function categoryPage:setCategory(source, name, index)
|
function categoryPage:setCategory(source, name, index)
|
||||||
self.grid.values = { }
|
self.grid.values = { }
|
||||||
for k,v in pairs(source.storeURLs) do
|
for _,v in pairs(source.storeURLs) do
|
||||||
if index == 0 or index == v.catagory then
|
if index == 0 or index == v.catagory then
|
||||||
table.insert(self.grid.values, v)
|
table.insert(self.grid.values, v)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
local os = _G.os
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Events')
|
multishell.setTitle(multishell.getCurrent(), 'Events')
|
||||||
UI:configure('Events', ...)
|
UI:configure('Events', ...)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Ansi = require('ansi')
|
local Ansi = require('ansi')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
@@ -6,6 +6,7 @@ local UI = require('ui')
|
|||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
|
local multishell = _ENV.multishell
|
||||||
local peripheral = _G.peripheral
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Devices')
|
multishell.setTitle(multishell.getCurrent(), 'Devices')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Config = require('config')
|
local Config = require('config')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
@@ -6,6 +6,12 @@ local Socket = require('socket')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local fs = _G.fs
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
local os = _G.os
|
||||||
|
local shell = _ENV.shell
|
||||||
|
|
||||||
local GROUPS_PATH = 'usr/groups'
|
local GROUPS_PATH = 'usr/groups'
|
||||||
local SCRIPTS_PATH = 'usr/etc/scripts'
|
local SCRIPTS_PATH = 'usr/etc/scripts'
|
||||||
|
|
||||||
@@ -26,7 +32,7 @@ if UI.term.width % 2 ~= 0 then
|
|||||||
width = width + 1
|
width = width + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function processVariables(script)
|
local function processVariables(script)
|
||||||
|
|
||||||
local fn = loadstring('return ' .. config.variables)
|
local fn = loadstring('return ' .. config.variables)
|
||||||
if fn then
|
if fn then
|
||||||
@@ -40,7 +46,7 @@ function processVariables(script)
|
|||||||
return script
|
return script
|
||||||
end
|
end
|
||||||
|
|
||||||
function invokeScript(computer, scriptName)
|
local function invokeScript(computer, scriptName)
|
||||||
|
|
||||||
local script = Util.readFile(scriptName)
|
local script = Util.readFile(scriptName)
|
||||||
if not script then
|
if not script then
|
||||||
@@ -74,7 +80,7 @@ function invokeScript(computer, scriptName)
|
|||||||
socket:close()
|
socket:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
function runScript(computerOrGroup, scriptName)
|
local function runScript(computerOrGroup, scriptName)
|
||||||
if computerOrGroup.id then
|
if computerOrGroup.id then
|
||||||
invokeScript(computerOrGroup, scriptName)
|
invokeScript(computerOrGroup, scriptName)
|
||||||
else
|
else
|
||||||
@@ -459,11 +465,6 @@ function mainPage:eventHandler(event)
|
|||||||
|
|
||||||
elseif event.type == 'toggle' then
|
elseif event.type == 'toggle' then
|
||||||
config.showGroups = not config.showGroups
|
config.showGroups = not config.showGroups
|
||||||
local text = 'Computers'
|
|
||||||
if config.showGroups then
|
|
||||||
text = 'Groups'
|
|
||||||
end
|
|
||||||
-- self.statusBar.toggleButton.text = text
|
|
||||||
self:draw()
|
self:draw()
|
||||||
|
|
||||||
Config.update('script', config)
|
Config.update('script', config)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Config = require('config')
|
local Config = require('config')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
@@ -8,6 +8,14 @@ local Terminal = require('terminal')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local fs = _G.fs
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
local network = _G.network
|
||||||
|
local os = _G.os
|
||||||
|
local shell = _ENV.shell
|
||||||
|
local term = _G.term
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Turtles')
|
multishell.setTitle(multishell.getCurrent(), 'Turtles')
|
||||||
UI.Button.defaults.focusIndicator = ' '
|
UI.Button.defaults.focusIndicator = ' '
|
||||||
UI:configure('Turtles', ...)
|
UI:configure('Turtles', ...)
|
||||||
@@ -27,15 +35,7 @@ local options = {
|
|||||||
local SCRIPTS_PATH = 'usr/etc/scripts'
|
local SCRIPTS_PATH = 'usr/etc/scripts'
|
||||||
|
|
||||||
local nullTerm = Terminal.getNullTerm(term.current())
|
local nullTerm = Terminal.getNullTerm(term.current())
|
||||||
local turtles = { }
|
|
||||||
local socket
|
local socket
|
||||||
local policies = {
|
|
||||||
{ label = 'none' },
|
|
||||||
{ label = 'digOnly' },
|
|
||||||
{ label = 'attackOnly' },
|
|
||||||
{ label = 'digAttack' },
|
|
||||||
{ label = 'turtleSafe' },
|
|
||||||
}
|
|
||||||
|
|
||||||
local page = UI.Page {
|
local page = UI.Page {
|
||||||
coords = UI.Window {
|
coords = UI.Window {
|
||||||
@@ -142,7 +142,7 @@ function page:enable(turtle)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function page:runFunction(script, nowrap)
|
function page:runFunction(script, nowrap)
|
||||||
for i = 1, 2 do
|
for _ = 1, 2 do
|
||||||
if not socket then
|
if not socket then
|
||||||
socket = Socket.connect(self.turtle.id, 161)
|
socket = Socket.connect(self.turtle.id, 161)
|
||||||
end
|
end
|
||||||
@@ -210,12 +210,6 @@ function page.tabs.inventory:draw()
|
|||||||
v.selected = true
|
v.selected = true
|
||||||
end
|
end
|
||||||
if v.id then
|
if v.id then
|
||||||
-- local item = itemDB:get({ v.id, v.dmg })
|
|
||||||
-- if item then
|
|
||||||
-- v.id = item.displayName
|
|
||||||
-- else
|
|
||||||
-- v.id = v.id:gsub('.*:(.*)', '%1')
|
|
||||||
-- end
|
|
||||||
v.id = itemDB:getName(v)
|
v.id = itemDB:getName(v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -356,7 +350,7 @@ if not Util.getOptions(options, { ... }, true) then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if options.turtle.value >= 0 then
|
if options.turtle.value >= 0 then
|
||||||
for i = 1, 10 do
|
for _ = 1, 10 do
|
||||||
page.turtle = _G.network[options.turtle.value]
|
page.turtle = _G.network[options.turtle.value]
|
||||||
if page.turtle then
|
if page.turtle then
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
Base64 = require('base64')
|
local Base64 = require('base64')
|
||||||
|
|
||||||
|
local http = _G.http
|
||||||
|
local os = _G.os
|
||||||
|
local shell = _ENV.shell
|
||||||
|
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local ChestAdapter = require('chestAdapter18')
|
local ChestAdapter = require('chestAdapter18')
|
||||||
local Config = require('config')
|
local Config = require('config')
|
||||||
@@ -12,6 +12,11 @@ local Terminal = require('terminal')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local device = _G.device
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
local peripheral = _G.peripheral
|
||||||
|
local term = _G.term
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Resource Manager')
|
multishell.setTitle(multishell.getCurrent(), 'Resource Manager')
|
||||||
|
|
||||||
-- 3 wide monitor (any side of turtle)
|
-- 3 wide monitor (any side of turtle)
|
||||||
@@ -58,6 +63,9 @@ end
|
|||||||
local RESOURCE_FILE = 'usr/config/resources.db'
|
local RESOURCE_FILE = 'usr/config/resources.db'
|
||||||
local RECIPES_FILE = 'usr/etc/recipes.db'
|
local RECIPES_FILE = 'usr/etc/recipes.db'
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local turtle = _G.turtle
|
||||||
|
|
||||||
local craftingPaused = false
|
local craftingPaused = false
|
||||||
local canCraft = not not duckAntenna or turtleChestAdapter:isValid()
|
local canCraft = not not duckAntenna or turtleChestAdapter:isValid()
|
||||||
local recipes = Util.readTable(RECIPES_FILE) or { }
|
local recipes = Util.readTable(RECIPES_FILE) or { }
|
||||||
@@ -97,18 +105,6 @@ local function getItemQuantity(items, item)
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getItemDetails(items, item)
|
|
||||||
local cItem = getItem(items, item)
|
|
||||||
if cItem then
|
|
||||||
return cItem
|
|
||||||
end
|
|
||||||
cItem = itemDB:get(itemDB:makeKey(item))
|
|
||||||
if cItem then
|
|
||||||
return { count = 0, maxCount = cItem.maxCount }
|
|
||||||
end
|
|
||||||
return { count = 0, maxCount = 64 }
|
|
||||||
end
|
|
||||||
|
|
||||||
local function uniqueKey(item)
|
local function uniqueKey(item)
|
||||||
return table.concat({ item.name, item.damage, item.nbtHash }, ':')
|
return table.concat({ item.name, item.damage, item.nbtHash }, ':')
|
||||||
end
|
end
|
||||||
@@ -148,7 +144,7 @@ local function filterItems(t, filter)
|
|||||||
if filter then
|
if filter then
|
||||||
local r = {}
|
local r = {}
|
||||||
filter = filter:lower()
|
filter = filter:lower()
|
||||||
for k,v in pairs(t) do
|
for _,v in pairs(t) do
|
||||||
if string.find(v.lname, filter) then
|
if string.find(v.lname, filter) then
|
||||||
table.insert(r, v)
|
table.insert(r, v)
|
||||||
end
|
end
|
||||||
@@ -160,7 +156,6 @@ end
|
|||||||
|
|
||||||
local function sumItems3(ingredients, items, summedItems, count)
|
local function sumItems3(ingredients, items, summedItems, count)
|
||||||
|
|
||||||
local canCraft = 0
|
|
||||||
for _,key in pairs(ingredients) do
|
for _,key in pairs(ingredients) do
|
||||||
local item = splitKey(key)
|
local item = splitKey(key)
|
||||||
local summedItem = summedItems[key]
|
local summedItem = summedItems[key]
|
||||||
@@ -205,7 +200,7 @@ local function addCraftingRequest(item, craftList, count)
|
|||||||
local key = uniqueKey(item)
|
local key = uniqueKey(item)
|
||||||
local request = craftList[key]
|
local request = craftList[key]
|
||||||
if not craftList[key] then
|
if not craftList[key] then
|
||||||
request = { name = item.name, damage = item.damage, nbtHash = nbtHash, count = 0 }
|
request = { name = item.name, damage = item.damage, nbtHash = item.nbtHash, count = 0 }
|
||||||
request.displayName = itemDB:getName(request)
|
request.displayName = itemDB:getName(request)
|
||||||
craftList[key] = request
|
craftList[key] = request
|
||||||
end
|
end
|
||||||
@@ -238,7 +233,7 @@ local function craftItem(recipe, items, originalItem, craftList, count)
|
|||||||
local summedItems = { }
|
local summedItems = { }
|
||||||
sumItems3(recipe.ingredients, items, summedItems, math.ceil(count / recipe.count))
|
sumItems3(recipe.ingredients, items, summedItems, math.ceil(count / recipe.count))
|
||||||
|
|
||||||
for key,ingredient in pairs(summedItems) do
|
for _,ingredient in pairs(summedItems) do
|
||||||
if not ingredient.recipe and ingredient.count < 0 then
|
if not ingredient.recipe and ingredient.count < 0 then
|
||||||
addCraftingRequest(ingredient, craftList, -ingredient.count)
|
addCraftingRequest(ingredient, craftList, -ingredient.count)
|
||||||
end
|
end
|
||||||
@@ -270,7 +265,7 @@ local function craftItems(craftList, allItems)
|
|||||||
else
|
else
|
||||||
local count = item.count
|
local count = item.count
|
||||||
while count >= 1 do -- try to request smaller quantities until successful
|
while count >= 1 do -- try to request smaller quantities until successful
|
||||||
local s, m = pcall(function()
|
local s = pcall(function()
|
||||||
item.status = '(no recipe)'
|
item.status = '(no recipe)'
|
||||||
if not controller:craft(item, count) then
|
if not controller:craft(item, count) then
|
||||||
item.status = '(missing ingredients)'
|
item.status = '(missing ingredients)'
|
||||||
@@ -289,7 +284,7 @@ local function craftItems(craftList, allItems)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function jobMonitor(jobList)
|
local function jobMonitor()
|
||||||
|
|
||||||
local mon = Peripheral.getByType('monitor')
|
local mon = Peripheral.getByType('monitor')
|
||||||
|
|
||||||
@@ -368,7 +363,7 @@ local function watchResources(items)
|
|||||||
local craftList = { }
|
local craftList = { }
|
||||||
local outputs = { }
|
local outputs = { }
|
||||||
|
|
||||||
for k, res in pairs(resources) do
|
for _,res in pairs(resources) do
|
||||||
local item = getItemWithQty(items, res, res.ignoreDamage)
|
local item = getItemWithQty(items, res, res.ignoreDamage)
|
||||||
if not item then
|
if not item then
|
||||||
item = {
|
item = {
|
||||||
@@ -381,7 +376,7 @@ local function watchResources(items)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if res.limit and item.count > res.limit then
|
if res.limit and item.count > res.limit then
|
||||||
local s, m = inventoryAdapter:provide(
|
inventoryAdapter:provide(
|
||||||
{ name = item.name, damage = item.damage },
|
{ name = item.name, damage = item.damage },
|
||||||
item.count - res.limit,
|
item.count - res.limit,
|
||||||
nil,
|
nil,
|
||||||
@@ -522,9 +517,9 @@ function itemPage:enable(item)
|
|||||||
|
|
||||||
local devices = self.form[6].choices
|
local devices = self.form[6].choices
|
||||||
Util.clear(devices)
|
Util.clear(devices)
|
||||||
for _,device in pairs(device) do
|
for _,dev in pairs(device) do
|
||||||
if device.setOutput then
|
if dev.setOutput then
|
||||||
table.insert(devices, { name = device.name, value = device.name })
|
table.insert(devices, { name = dev.name, value = dev.name })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -629,9 +624,6 @@ function listingPage.grid:getRowTextColor(row, selected)
|
|||||||
return colors.yellow
|
return colors.yellow
|
||||||
end
|
end
|
||||||
if row.has_recipe then
|
if row.has_recipe then
|
||||||
if selected then
|
|
||||||
return colors.cyan
|
|
||||||
end
|
|
||||||
return colors.cyan
|
return colors.cyan
|
||||||
end
|
end
|
||||||
return UI.Grid:getRowTextColor(row, selected)
|
return UI.Grid:getRowTextColor(row, selected)
|
||||||
@@ -741,7 +733,7 @@ local function getTurtleInventory()
|
|||||||
|
|
||||||
if duckAntenna then
|
if duckAntenna then
|
||||||
local list = duckAntenna.getAllStacks(false)
|
local list = duckAntenna.getAllStacks(false)
|
||||||
for k,v in pairs(list) do
|
for _,v in pairs(list) do
|
||||||
v.name = v.id
|
v.name = v.id
|
||||||
v.damage = v.dmg
|
v.damage = v.dmg
|
||||||
v.displayName = v.display_name
|
v.displayName = v.display_name
|
||||||
@@ -765,22 +757,12 @@ local function getTurtleInventory()
|
|||||||
return inventory
|
return inventory
|
||||||
end
|
end
|
||||||
|
|
||||||
local function filter(t, filter)
|
|
||||||
local keys = Util.keys(t)
|
|
||||||
for _,key in pairs(keys) do
|
|
||||||
if not Util.key(filter, key) then
|
|
||||||
t[key] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function learnRecipe(page)
|
local function learnRecipe(page)
|
||||||
local recipe = { }
|
|
||||||
local ingredients = getTurtleInventory()
|
local ingredients = getTurtleInventory()
|
||||||
if ingredients then
|
if ingredients then
|
||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
if canCraft and turtle.craft() then
|
if canCraft and turtle.craft() then
|
||||||
recipe = getTurtleInventory()
|
local recipe = getTurtleInventory()
|
||||||
if recipe and recipe[1] then
|
if recipe and recipe[1] then
|
||||||
clearGrid()
|
clearGrid()
|
||||||
|
|
||||||
@@ -906,8 +888,7 @@ end
|
|||||||
function craftPage:eventHandler(event)
|
function craftPage:eventHandler(event)
|
||||||
if event.type == 'cancel' then
|
if event.type == 'cancel' then
|
||||||
UI:setPreviousPage()
|
UI:setPreviousPage()
|
||||||
elseif event.type == 'accept' then
|
--elseif event.type == 'accept' then
|
||||||
|
|
||||||
else
|
else
|
||||||
return UI.Dialog.eventHandler(self, event)
|
return UI.Dialog.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Terminal = require('terminal')
|
local Terminal = require('terminal')
|
||||||
|
|
||||||
|
local shell = _ENV.shell
|
||||||
|
local term = _G.term
|
||||||
|
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
local mon = device[table.remove(args, 1) or 'monitor']
|
local mon = _G.device[table.remove(args, 1) or 'monitor']
|
||||||
if not mon then
|
if not mon then
|
||||||
error('mirror: Invalid device')
|
error('mirror: Invalid device')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local Logger = require('logger')
|
local Logger = require('logger')
|
||||||
local Socket = require('socket')
|
local Socket = require('socket')
|
||||||
local Terminal = require('terminal')
|
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
local os = _G.os
|
||||||
|
|
||||||
Logger.setScreenLogging()
|
Logger.setScreenLogging()
|
||||||
|
|
||||||
local remoteId
|
local remoteId
|
||||||
@@ -14,7 +16,7 @@ if #args == 1 then
|
|||||||
remoteId = tonumber(args[1])
|
remoteId = tonumber(args[1])
|
||||||
else
|
else
|
||||||
print('Enter host ID')
|
print('Enter host ID')
|
||||||
remoteId = tonumber(read())
|
remoteId = tonumber(_G.read())
|
||||||
end
|
end
|
||||||
|
|
||||||
if not remoteId then
|
if not remoteId then
|
||||||
@@ -70,7 +72,7 @@ while true do
|
|||||||
while true do
|
while true do
|
||||||
local e = Event.pullEvent()
|
local e = Event.pullEvent()
|
||||||
if e[1] == 'terminate' then
|
if e[1] == 'terminate' then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if not socket.connected then
|
if not socket.connected then
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local Logger = require('logger')
|
local Logger = require('logger')
|
||||||
local Socket = require('socket')
|
local Socket = require('socket')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local term = _G.term
|
||||||
|
|
||||||
Logger.setScreenLogging()
|
Logger.setScreenLogging()
|
||||||
|
|
||||||
local mon = term.current()
|
local mon = term.current()
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
if args[1] then
|
if args[1] then
|
||||||
mon = device[args[1]]
|
mon = _G.device[args[1]]
|
||||||
end
|
end
|
||||||
|
|
||||||
if not mon then
|
if not mon then
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
require = requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local device = _G.device
|
||||||
|
local turtle = _G.turtle
|
||||||
|
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Music')
|
multishell.setTitle(multishell.getCurrent(), 'Music')
|
||||||
|
|
||||||
local radio = device.drive or error('No drive attached')
|
local radio = device.drive or error('No drive attached')
|
||||||
@@ -16,8 +22,6 @@ end
|
|||||||
|
|
||||||
UI:configure('Music', ...)
|
UI:configure('Music', ...)
|
||||||
|
|
||||||
local monitor = UI.term
|
|
||||||
|
|
||||||
UI.Button.defaults.backgroundFocusColor = colors.gray
|
UI.Button.defaults.backgroundFocusColor = colors.gray
|
||||||
|
|
||||||
local page = UI.Page({
|
local page = UI.Page({
|
||||||
@@ -146,7 +150,7 @@ function page:eventHandler(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function page:setVolume(volume, displayOnly)
|
function page:setVolume(volume)
|
||||||
volume = math.min(volume, 15)
|
volume = math.min(volume, 15)
|
||||||
volume = math.max(volume, 1)
|
volume = math.max(volume, 1)
|
||||||
self.volume = volume
|
self.volume = volume
|
||||||
|
|||||||
19
apps/mwm.lua
19
apps/mwm.lua
@@ -1,9 +1,16 @@
|
|||||||
local injector = requireInjector or load(http.get('https://raw.githubusercontent.com/kepler155c/opus/master/sys/apis/injector.lua').readAll())()
|
local injector = requireInjector or load(http.get('https://raw.githubusercontent.com/kepler155c/opus/master/sys/apis/injector.lua').readAll())()
|
||||||
injector(getfenv(1))
|
injector()
|
||||||
|
|
||||||
local Canvas = require('ui.canvas')
|
local Canvas = require('ui.canvas')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local os = _G.os
|
||||||
|
local peripheral = _G.peripheral
|
||||||
|
local shell = _ENV.shell
|
||||||
|
local term = _G.term
|
||||||
|
local window = _G.window
|
||||||
|
|
||||||
local function syntax()
|
local function syntax()
|
||||||
printError('Syntax:')
|
printError('Syntax:')
|
||||||
error('mwm sessionName [monitor]')
|
error('mwm sessionName [monitor]')
|
||||||
@@ -18,7 +25,7 @@ local sessionFile = args[1] or syntax()
|
|||||||
local running
|
local running
|
||||||
local monitor
|
local monitor
|
||||||
|
|
||||||
local defaultEnv = Util.shallowCopy(getfenv(1))
|
local defaultEnv = Util.shallowCopy(_ENV)
|
||||||
defaultEnv.multishell = multishell
|
defaultEnv.multishell = multishell
|
||||||
|
|
||||||
if args[2] then
|
if args[2] then
|
||||||
@@ -356,7 +363,7 @@ function multishell.removeProcess(process)
|
|||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function multishell.saveSession(sessionFile)
|
function multishell.saveSession(filename)
|
||||||
local t = { }
|
local t = { }
|
||||||
for _,process in pairs(processes) do
|
for _,process in pairs(processes) do
|
||||||
if process.path and not process.isShell then
|
if process.path and not process.isShell then
|
||||||
@@ -370,11 +377,11 @@ function multishell.saveSession(sessionFile)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Util.writeTable(sessionFile, t)
|
Util.writeTable(filename, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
function multishell.loadSession(sessionFile)
|
function multishell.loadSession(filename)
|
||||||
local config = Util.readTable(sessionFile)
|
local config = Util.readTable(filename)
|
||||||
if config then
|
if config then
|
||||||
for _,v in pairs(config) do
|
for _,v in pairs(config) do
|
||||||
multishell.openTab(v)
|
multishell.openTab(v)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
local ChestAdapter = require('chestAdapter18')
|
local ChestAdapter = require('chestAdapter18')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
@@ -7,6 +7,9 @@ local RefinedAdapter = require('refinedAdapter')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
local multishell = _ENV.multishell
|
||||||
|
|
||||||
local storage = RefinedAdapter()
|
local storage = RefinedAdapter()
|
||||||
if not storage:isValid() then
|
if not storage:isValid() then
|
||||||
storage = MEAdapter({ auto = true })
|
storage = MEAdapter({ auto = true })
|
||||||
@@ -117,7 +120,8 @@ function changedPage:refresh()
|
|||||||
self.lastItems = t
|
self.lastItems = t
|
||||||
self.grid:setValues({ })
|
self.grid:setValues({ })
|
||||||
else
|
else
|
||||||
local changedItems = {}
|
local changedItems = { }
|
||||||
|
local found
|
||||||
for _,v in pairs(self.lastItems) do
|
for _,v in pairs(self.lastItems) do
|
||||||
found = false
|
found = false
|
||||||
for k2,v2 in pairs(t) do
|
for k2,v2 in pairs(t) do
|
||||||
@@ -141,12 +145,12 @@ function changedPage:refresh()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- No items left
|
-- No items left
|
||||||
for k,v in pairs(t) do
|
for _,v in pairs(t) do
|
||||||
v.lastCount = 0
|
v.lastCount = 0
|
||||||
table.insert(changedItems, v)
|
table.insert(changedItems, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k,v in pairs(changedItems) do
|
for _,v in pairs(changedItems) do
|
||||||
v.change = v.count - v.lastCount
|
v.change = v.count - v.lastCount
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
requireInjector(getfenv(1))
|
_G.requireInjector()
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Requirements:
|
Requirements:
|
||||||
@@ -27,6 +27,10 @@ local Pathing = require('turtle.pathfind')
|
|||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local os = _G.os
|
||||||
|
local read = _G.read
|
||||||
|
local turtle = _G.turtle
|
||||||
|
|
||||||
local FUEL_BASE = 0
|
local FUEL_BASE = 0
|
||||||
local FUEL_DIRE = FUEL_BASE + 10
|
local FUEL_DIRE = FUEL_BASE + 10
|
||||||
local FUEL_GOOD = FUEL_BASE + 2000
|
local FUEL_GOOD = FUEL_BASE + 2000
|
||||||
@@ -201,7 +205,7 @@ local function makeCharcoal()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getLogSlot(slots)
|
local function getLogSlot()
|
||||||
local maxslot = { count = 0 }
|
local maxslot = { count = 0 }
|
||||||
for k,slot in pairs(slots) do
|
for k,slot in pairs(slots) do
|
||||||
if string.match(k, 'minecraft:log') then
|
if string.match(k, 'minecraft:log') then
|
||||||
@@ -214,7 +218,8 @@ local function makeCharcoal()
|
|||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
local slots = turtle.getSummedInventory()
|
slots = turtle.getSummedInventory()
|
||||||
|
|
||||||
local charcoal = slots[CHARCOAL].count
|
local charcoal = slots[CHARCOAL].count
|
||||||
local slot = getLogSlot(slots)
|
local slot = getLogSlot(slots)
|
||||||
|
|
||||||
@@ -266,7 +271,7 @@ local function getCobblestone(count)
|
|||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
turtle.digDown()
|
turtle.digDown()
|
||||||
turtle.down()
|
turtle.down()
|
||||||
for i = 1, 4 do
|
for _ = 1, 4 do
|
||||||
if inspect(turtle.inspect) == STONE then
|
if inspect(turtle.inspect) == STONE then
|
||||||
turtle.dig()
|
turtle.dig()
|
||||||
end
|
end
|
||||||
@@ -510,10 +515,10 @@ local function fell()
|
|||||||
|
|
||||||
local pts = Util.shallowCopy(state.trees)
|
local pts = Util.shallowCopy(state.trees)
|
||||||
|
|
||||||
local pt = table.remove(pts, math.random(1, #pts))
|
local rpt = table.remove(pts, math.random(1, #pts))
|
||||||
|
|
||||||
-- give the pathfinder hints about what to avoid (state.trees)
|
-- give the pathfinder hints about what to avoid (state.trees)
|
||||||
if not turtle.faceAgainst(pt, { blocks = Util.shallowCopy(state.trees) }) or
|
if not turtle.faceAgainst(rpt, { blocks = Util.shallowCopy(state.trees) }) or
|
||||||
not string.match(inspect(turtle.inspect), 'minecraft:log') then
|
not string.match(inspect(turtle.inspect), 'minecraft:log') then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -523,7 +528,7 @@ local function fell()
|
|||||||
local fuel = turtle.getFuelLevel()
|
local fuel = turtle.getFuelLevel()
|
||||||
|
|
||||||
-- push this point to the start of this list
|
-- push this point to the start of this list
|
||||||
table.insert(pts, 1, pt)
|
table.insert(pts, 1, rpt)
|
||||||
|
|
||||||
Point.eachClosest(turtle.point, pts, function(pt)
|
Point.eachClosest(turtle.point, pts, function(pt)
|
||||||
if turtle.faceAgainst(pt, { blocks = Util.shallowCopy(state.trees) }) and
|
if turtle.faceAgainst(pt, { blocks = Util.shallowCopy(state.trees) }) and
|
||||||
@@ -570,7 +575,7 @@ local function moreTrees()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function getTurtleFacing(block)
|
local function getTurtleFacing(block)
|
||||||
local directions = {
|
local directions = {
|
||||||
[5] = 2,
|
[5] = 2,
|
||||||
[3] = 3,
|
[3] = 3,
|
||||||
@@ -586,7 +591,7 @@ function getTurtleFacing(block)
|
|||||||
return directions[bi.metadata]
|
return directions[bi.metadata]
|
||||||
end
|
end
|
||||||
|
|
||||||
function saveTurtleFacing()
|
local function saveTurtleFacing()
|
||||||
if not state.facing then
|
if not state.facing then
|
||||||
setState('facing', getTurtleFacing(CHEST))
|
setState('facing', getTurtleFacing(CHEST))
|
||||||
end
|
end
|
||||||
@@ -600,7 +605,7 @@ local function findGround()
|
|||||||
local s, block = turtle.inspectDown()
|
local s, block = turtle.inspectDown()
|
||||||
|
|
||||||
if not s then block = { name = 'minecraft:air', metadata = 0 } end
|
if not s then block = { name = 'minecraft:air', metadata = 0 } end
|
||||||
b = block.name .. ':' .. block.metadata
|
local b = block.name .. ':' .. block.metadata
|
||||||
|
|
||||||
if b == 'minecraft:dirt:0' or
|
if b == 'minecraft:dirt:0' or
|
||||||
b == 'minecraft:grass:0' or
|
b == 'minecraft:grass:0' or
|
||||||
@@ -741,5 +746,5 @@ local s, m = turtle.run(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
if not s then
|
if not s then
|
||||||
error('Failed')
|
error(m or 'Failed')
|
||||||
end
|
end
|
||||||
|
|||||||
1
etc/fstab.ignore
Normal file
1
etc/fstab.ignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
forced fstab overwrite
|
||||||
Reference in New Issue
Block a user