Use abstractions in ItemStack
This commit is contained in:
parent
1482437161
commit
55ec42bffb
@ -154,14 +154,14 @@ function ItemStack:_modify(countDelta, stack)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ItemStack:transferTo(target, count)
|
function ItemStack:transferTo(target, count)
|
||||||
local cap = math.min(count, target.maxCount - target.getCount(), self:getCount())
|
local cap = math.min(count or self:getCount(), target:getMaxCount() - target:getCount(), self:getCount())
|
||||||
|
|
||||||
-- If we can't transfer any data, then
|
-- If we can't transfer any data, then
|
||||||
if cap == 0 then
|
if cap == 0 then
|
||||||
return count == 0, 0
|
return count == 0, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local result, xfer = pcall(self.inv.pushItems, peripheral.getName(target.inv), self.slot, cap, target.slot)
|
local result, xfer = pcall(self:getInventory().pushItems, peripheral.getName(target:getInventory()), self:getSlot(), cap, target:getSlot())
|
||||||
|
|
||||||
if not result then
|
if not result then
|
||||||
return false, xfer
|
return false, xfer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user