1.7 fixes
This commit is contained in:
@@ -5,6 +5,7 @@ local Config = require('config')
|
||||
local Craft = require('turtle.craft')
|
||||
local Event = require('event')
|
||||
local itemDB = require('itemDB')
|
||||
local MEAdapater = require('meAdapter')
|
||||
local Peripheral = require('peripheral')
|
||||
local RefinedAdapter = require('refinedAdapter')
|
||||
local Terminal = require('terminal')
|
||||
@@ -21,20 +22,42 @@ multishell.setTitle(multishell.getCurrent(), 'Resource Manager')
|
||||
local config = {
|
||||
trashDirection = 'up', -- trash /chest in relation to chest
|
||||
inventoryDirection = { direction = 'north', wrapSide = 'back' },
|
||||
chestDirection = { direction = 'down', wrapSide = 'top' },
|
||||
chestDirection = { direction = 'down', wrapSide = 'top' },
|
||||
}
|
||||
|
||||
Config.load('chestManager', config)
|
||||
|
||||
local controller = RefinedAdapter()
|
||||
if not controller:isValid() then
|
||||
-- error('Refined storage controller not found')
|
||||
controller = nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------- FIX ME
|
||||
local inventoryAdapter = ChestAdapter(config.inventoryDirection)
|
||||
local turtleChestAdapter = ChestAdapter(config.chestDirection)
|
||||
local duckAntenna
|
||||
|
||||
local controller = RefinedAdapter()
|
||||
if not controller:isValid() then
|
||||
controller = MEAdapater(config.inventoryDirection)
|
||||
if not controller:isValid() then
|
||||
controller = nil
|
||||
else
|
||||
inventoryAdapter = controller -- ME functions as inventory and crafting
|
||||
end
|
||||
end
|
||||
|
||||
if device.workbench then
|
||||
|
||||
local oppositeSide = {
|
||||
[ 'left' ] = 'right',
|
||||
[ 'right' ] = 'left',
|
||||
}
|
||||
|
||||
local duckAntennaSide = oppositeSide[device.workbench.side]
|
||||
duckAntenna = peripheral.wrap(duckAntennaSide)
|
||||
if not duckAntenna or not duckAntenna.getAllStacks then
|
||||
duckAntenna = nil
|
||||
end
|
||||
end
|
||||
|
||||
local canCraft = not not duckAntenna or turtleChestAdapter:isValid()
|
||||
|
||||
---------------------------------------------------------------------- FIX ME
|
||||
|
||||
local RESOURCE_FILE = 'usr/config/resources.db'
|
||||
local RECIPES_FILE = 'usr/etc/recipes.db'
|
||||
@@ -194,7 +217,7 @@ end
|
||||
|
||||
local function craftItem(recipe, items, originalItem, craftList, count)
|
||||
|
||||
if craftingPaused or not device.workbench or not isGridClear() then
|
||||
if craftingPaused or not canCraft or not isGridClear() then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -315,7 +338,7 @@ local function getAutocraftItems()
|
||||
for _,res in pairs(resources) do
|
||||
|
||||
if res.auto then
|
||||
res.count = 4 -- this could be higher to increase autocrafting speed
|
||||
res.count = 64 -- this could be higher to increase autocrafting speed
|
||||
local key = uniqueKey(res)
|
||||
craftList[key] = res
|
||||
end
|
||||
@@ -361,7 +384,7 @@ local function watchResources(items)
|
||||
end
|
||||
|
||||
if res.limit and item.count > res.limit then
|
||||
inventoryAdapter:provide(
|
||||
local s, m = inventoryAdapter:provide(
|
||||
{ name = item.name, damage = item.damage },
|
||||
item.count - res.limit,
|
||||
nil,
|
||||
@@ -587,8 +610,6 @@ local listingPage = UI.Page {
|
||||
sortColumn = 'displayName',
|
||||
},
|
||||
statusBar = UI.StatusBar {
|
||||
--backgroundColor = colors.gray,
|
||||
width = UI.term.width,
|
||||
filterText = UI.Text {
|
||||
x = 2,
|
||||
value = 'Filter',
|
||||
@@ -720,6 +741,20 @@ function listingPage:applyFilter()
|
||||
end
|
||||
|
||||
local function getTurtleInventory()
|
||||
|
||||
if duckAntenna then
|
||||
local list = duckAntenna.getAllStacks(false)
|
||||
for k,v in pairs(list) do
|
||||
v.name = v.id
|
||||
v.damage = v.dmg
|
||||
v.displayName = v.display_name
|
||||
v.count = v.qty
|
||||
v.maxDamage = v.max_dmg
|
||||
v.maxCount = v.max_size
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
local inventory = { }
|
||||
for i = 1,16 do
|
||||
local qty = turtle.getItemCount(i)
|
||||
@@ -747,7 +782,7 @@ local function learnRecipe(page)
|
||||
local ingredients = getTurtleInventory()
|
||||
if ingredients then
|
||||
turtle.select(1)
|
||||
if device.workbench and turtle.craft() then
|
||||
if canCraft and turtle.craft() then
|
||||
recipe = getTurtleInventory()
|
||||
if recipe and recipe[1] then
|
||||
clearGrid()
|
||||
|
||||
29
apps/mwm.lua
29
apps/mwm.lua
@@ -14,6 +14,7 @@ local processes = { }
|
||||
local parentTerm = term.current()
|
||||
local configFile = args[1] or syntax()
|
||||
local defaultEnv = Util.shallowCopy(getfenv(1))
|
||||
local running
|
||||
local monitor
|
||||
local exitSession
|
||||
|
||||
@@ -170,16 +171,26 @@ end
|
||||
|
||||
function Process:drawSizers(showSizers)
|
||||
|
||||
local sizeChars = {
|
||||
'\135', '\139', '\141', '\142'
|
||||
}
|
||||
|
||||
if Util.getVersion() < 1.8 then
|
||||
sizeChars = {
|
||||
'#', '#', '#', '#'
|
||||
}
|
||||
end
|
||||
|
||||
self.showSizers = showSizers
|
||||
|
||||
self.container.setBackgroundColor(colors.black)
|
||||
self.container.setTextColor(colors.white)
|
||||
|
||||
if self.showSizers then
|
||||
write(self.container, 1, 1, '\135')
|
||||
write(self.container, self.width, 1, '\139')
|
||||
write(self.container, 1, self.height, '\141')
|
||||
write(self.container, self.width, self.height, '\142')
|
||||
write(self.container, 1, 1, sizeChars[1])
|
||||
write(self.container, self.width, 1, sizeChars[2])
|
||||
write(self.container, 1, self.height, sizeChars[3])
|
||||
write(self.container, self.width, self.height, sizeChars[4])
|
||||
|
||||
self.container.setTextColor(colors.yellow)
|
||||
write(self.container, 1, 3, '+')
|
||||
@@ -250,7 +261,11 @@ function Process:resume(event, ...)
|
||||
if not self.filter or self.filter == event or event == "terminate" then
|
||||
term.redirect(self.terminal)
|
||||
|
||||
local previous = running
|
||||
running = self -- stupid shell set title
|
||||
local ok, result = coroutine.resume(self.co, event, ...)
|
||||
running = previous
|
||||
|
||||
self.terminal = term.current()
|
||||
if ok then
|
||||
self.filter = result
|
||||
@@ -269,7 +284,7 @@ function defaultEnv.multishell.getFocus()
|
||||
end
|
||||
|
||||
function defaultEnv.multishell.setFocus(uid)
|
||||
local process, key = Util.find(processes, 'uid', uid)
|
||||
local process = Util.find(processes, 'uid', uid)
|
||||
|
||||
if process then
|
||||
if processes[#processes] ~= process then
|
||||
@@ -296,8 +311,8 @@ function defaultEnv.multishell.setTitle(uid, title)
|
||||
end
|
||||
|
||||
function defaultEnv.multishell.getCurrent()
|
||||
if #processes > 0 then
|
||||
return processes[#processes].uid
|
||||
if running then
|
||||
return running.uid
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ local Util = require('util')
|
||||
|
||||
local storage = RefinedAdapter()
|
||||
if not storage:isValid() then
|
||||
storage = MEAdapter()
|
||||
storage = MEAdapter({ auto = true })
|
||||
if not storage:isValid() then
|
||||
storage = ChestAdapter()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user