peripheral overhaul + 1.7 fixes
This commit is contained in:
@@ -32,7 +32,7 @@ function ChestAdapter:isValid()
|
||||
end
|
||||
|
||||
function ChestAdapter:getCachedItemDetails(item, k)
|
||||
local cached = itemDB:get(item, true)
|
||||
local cached = itemDB:get(item)
|
||||
if cached then
|
||||
return cached
|
||||
end
|
||||
@@ -44,7 +44,7 @@ function ChestAdapter:getCachedItemDetails(item, k)
|
||||
return
|
||||
end
|
||||
|
||||
return itemDB:add(item, detail)
|
||||
return itemDB:add(detail)
|
||||
end
|
||||
|
||||
function ChestAdapter:refresh(throttle)
|
||||
@@ -163,8 +163,8 @@ function ChestAdapter:extract(slot, qty, toSlot)
|
||||
self.pushItems(self.direction, slot, qty, toSlot)
|
||||
end
|
||||
|
||||
function ChestAdapter:insert(slot, qty)
|
||||
self.pullItems(self.direction, slot, qty)
|
||||
function ChestAdapter:insert(slot, qty, toSlot)
|
||||
self.pullItems(self.direction, slot, qty, toSlot)
|
||||
end
|
||||
|
||||
return ChestAdapter
|
||||
|
||||
@@ -5,8 +5,9 @@ local Adapter = { }
|
||||
function Adapter.wrap(args)
|
||||
local adapters = {
|
||||
--'refinedAdapter',
|
||||
--'meAdapter',
|
||||
'chestAdapter18',
|
||||
|
||||
'meAdapter',
|
||||
'chestAdapter',
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ function itemDB:splitKey(key, item)
|
||||
return item
|
||||
end
|
||||
|
||||
function itemDB:get(key, enforceNBT)
|
||||
function itemDB:get(key)
|
||||
if type(key) == 'string' then
|
||||
key = self:splitKey(key)
|
||||
end
|
||||
@@ -89,7 +89,7 @@ end
|
||||
If the base item contains an NBT hash, then the NBT hash uniquely
|
||||
identifies this item.
|
||||
]]--
|
||||
function itemDB:add(baseItem, detail)
|
||||
function itemDB:add(baseItem)
|
||||
local nItem = {
|
||||
name = baseItem.name,
|
||||
damage = baseItem.damage,
|
||||
@@ -101,9 +101,9 @@ function itemDB:add(baseItem, detail)
|
||||
debug('--')
|
||||
debug('adding ' .. makeKey(nItem))
|
||||
|
||||
nItem.displayName = safeString(detail.displayName)
|
||||
nItem.maxCount = detail.maxCount
|
||||
nItem.maxDamage = detail.maxDamage
|
||||
nItem.displayName = safeString(baseItem.displayName)
|
||||
nItem.maxCount = baseItem.maxCount
|
||||
nItem.maxDamage = baseItem.maxDamage
|
||||
|
||||
for k,item in pairs(self.data) do
|
||||
if nItem.name == item.name and
|
||||
|
||||
@@ -56,23 +56,24 @@ function MEAdapter:init(args)
|
||||
items = { },
|
||||
name = 'ME',
|
||||
jobList = { },
|
||||
direction = 'up',
|
||||
wrapSide = 'bottom',
|
||||
}
|
||||
Util.merge(self, defaults)
|
||||
Util.merge(self, args)
|
||||
|
||||
if self.autoDetect then
|
||||
local mep = Peripheral.getByMethod('getAvailableItems')
|
||||
if mep then
|
||||
Util.merge(self, mep)
|
||||
end
|
||||
local chest
|
||||
|
||||
if not self.side then
|
||||
chest = Peripheral.getByMethod('getAvailableItems')
|
||||
else
|
||||
local mep = peripheral.wrap(self.wrapSide)
|
||||
if mep then
|
||||
Util.merge(self, mep)
|
||||
chest = Peripheral.getBySide(self.side)
|
||||
if chest and not chest.getAvailableItems then
|
||||
chest = nil
|
||||
end
|
||||
end
|
||||
|
||||
if chest then
|
||||
Util.merge(self, chest)
|
||||
end
|
||||
end
|
||||
|
||||
function MEAdapter:isValid()
|
||||
@@ -87,11 +88,7 @@ function MEAdapter:refresh()
|
||||
convertItem(v)
|
||||
|
||||
if not itemDB:get(v) then
|
||||
local t = { }
|
||||
for _,k in pairs(keys) do
|
||||
t[k] = v[k]
|
||||
end
|
||||
itemDB:add(t)
|
||||
itemDB:add(v, v)
|
||||
end
|
||||
end
|
||||
itemDB:flush()
|
||||
|
||||
@@ -70,7 +70,7 @@ local function turtleCraft(recipe, qty, inventoryAdapter)
|
||||
inventoryAdapter:provide(item, provideQty, k)
|
||||
if turtle.getItemCount(k) == 0 then -- ~= qty then
|
||||
-- FIX: ingredients cannot be stacked
|
||||
debug('failed ' .. v .. ' - ' .. provideQty)
|
||||
--debug('failed ' .. v .. ' - ' .. provideQty)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user