peripheral overhaul + 1.7 fixes

This commit is contained in:
kepler155c
2018-01-06 22:26:21 -05:00
parent f2b9efc80f
commit 44932ac515
12 changed files with 536 additions and 113 deletions

View File

@@ -650,7 +650,6 @@ local itemPage = UI.Page {
function itemPage:enable(item)
self.item = item
debug(self.item)
self.form:setValues(item)
self.titleBar.title = item.displayName or item.name
@@ -778,7 +777,7 @@ local listingPage = UI.Page {
},
},
grid = UI.Grid {
y = 2, height = UI.term.height - 2,
y = 2, ey = -2,
columns = {
{ heading = 'Name', key = 'displayName' , width = 22 },
{ heading = 'Qty', key = 'count' , width = 5 },
@@ -806,6 +805,7 @@ local listingPage = UI.Page {
accelerators = {
r = 'refresh',
q = 'quit',
grid_select_right = 'craft',
},
displayMode = 0,
}
@@ -866,7 +866,7 @@ function listingPage:eventHandler(event)
elseif event.type == 'learn' then
UI:setPage('learn')
elseif event.type == 'craft' then
elseif event.type == 'craft' or event.type == 'grid_select_right' then
UI:setPage('craft', self.grid:getSelected())
elseif event.type == 'forget' then
@@ -923,7 +923,6 @@ function listingPage:applyFilter()
end
local function getTurtleInventory()
if duckAntenna then
local list = duckAntenna.getAllStacks(false)
for _,v in pairs(list) do
@@ -933,7 +932,11 @@ local function getTurtleInventory()
v.count = v.qty
v.maxDamage = v.max_dmg
v.maxCount = v.max_size
if not itemDB:get(v) then
itemDB:add(v)
end
end
itemDB:flush()
return list
end
@@ -1011,8 +1014,7 @@ local function learnRecipe(page)
if recipe.maxCount ~= 64 then
newRecipe.maxCount = recipe.maxCount
end
for k,ingredient in pairs(ingredients) do
for k,ingredient in pairs(Util.shallowCopy(ingredients)) do
if ingredient.maxDamage > 0 then
ingredient.damage = '*' -- I don't think this is right
end
@@ -1256,7 +1258,7 @@ Event.onInterval(5, function()
if item.count <= 0 then
demandCrafting[key] = nil
item.statusCode = 'success'
if item.eject then
if inventoryAdapter.eject and item.eject then
inventoryAdapter:eject(item, item.ocount, inventoryAdapter.getMetadata().state.facing)
end
end

View File

@@ -241,7 +241,6 @@ local function craftItem(ikey, item, items, machineStatus)
if turtle.getItemCount(slot) ~= maxCount * qty then -- ~= maxCount then FIXXX !!!
item.status = 'Extract failed: ' .. (ingredient.displayName or itemDB:getName(ingredient))
item.statusCode = STATUS_ERROR
debug({ key, maxCount })
return
end
-- c = c - maxCount
@@ -268,7 +267,6 @@ debug({ key, maxCount })
l = { true }
end
end
debug { s, l }
if not s then
item.statusCode = STATUS_ERROR
item.status = l
@@ -376,7 +374,7 @@ local function craftItems()
clearGrid()
elseif item.need > 0 then
item.status = 'no recipe'
item.statusCode = STATUS_WARNING
item.statusCode = STATUS_ERROR
end
jobListGrid:update()
jobListGrid:draw()

View File

@@ -39,13 +39,6 @@ while true do
end
end)
-- ensure socket is connected
Event.onInterval(3, function(h)
if not socket:ping() then
Event.off(h)
end
end)
while true do
Event.pullEvent()
if not socket.connected then

View File

@@ -150,7 +150,6 @@ function changedPage:refresh()
end
self.grid:setValues(changedItems)
debug(storage:getPercentUsed())
end
self.grid:draw()
end

View File

@@ -11,9 +11,12 @@ local name = args[1] or error('Syntax: termShare [device name] <title>')
local title = args[2]
device[name] = term.current()
device[name].name = name
device[name].side = name
device[name].type = 'terminal'
if title then
multishell.setTitle(multishell.getCurrent(), title)
end
os.pullEvent('char')
device[name] = nil
os.pullEvent('terminate')
os.queueEvent('peripheral_detach', name)