Compare commits
No commits in common. "8db86ee45c1e876914a54d2d690733cbd53a851a" and "98018e4a8c36d3aa56eb8dc6d500aad9705dbd58" have entirely different histories.
8db86ee45c
...
98018e4a8c
16
debugger.lua
16
debugger.lua
@ -43,18 +43,4 @@ local function debugREPL(onResult, debugArgs)
|
|||||||
return success, (not success and retval) or nil
|
return success, (not success and retval) or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hookDebugger(context, Logger)
|
return { debugREPL = debugREPL, execDebug = execDebug }
|
||||||
Logger = Logger or require("logging").getGlobalLogger()
|
|
||||||
|
|
||||||
local result, retval
|
|
||||||
repeat
|
|
||||||
result, retval = debugREPL(function(r)
|
|
||||||
Logger:error("->", r)
|
|
||||||
end, context)
|
|
||||||
if not result then
|
|
||||||
Logger:error("x>", retval)
|
|
||||||
end
|
|
||||||
until result
|
|
||||||
end
|
|
||||||
|
|
||||||
return { debugREPL = debugREPL, execDebug = execDebug, hookDebugger = hookDebugger }
|
|
@ -2,10 +2,23 @@ local Inventory = require("storage.inventory")
|
|||||||
local Sentinel = require("storage.sentinel")
|
local Sentinel = require("storage.sentinel")
|
||||||
local Logging = require("logging")
|
local Logging = require("logging")
|
||||||
local Logger = Logging.getGlobalLogger()
|
local Logger = Logging.getGlobalLogger()
|
||||||
|
local Debugger = require("debugger")
|
||||||
|
|
||||||
local ItemStack = Sentinel:tag({}, Sentinel.ITEMSTACK)
|
local ItemStack = Sentinel:tag({}, Sentinel.ITEMSTACK)
|
||||||
ItemStack.__index = ItemStack
|
ItemStack.__index = ItemStack
|
||||||
|
|
||||||
|
local function hookDebugger(context)
|
||||||
|
local result, retval
|
||||||
|
repeat
|
||||||
|
result, retval = Debugger.debugREPL(function(r)
|
||||||
|
Logger:error("->", r)
|
||||||
|
end, context)
|
||||||
|
if not result then
|
||||||
|
Logger:error("x>", retval)
|
||||||
|
end
|
||||||
|
until result
|
||||||
|
end
|
||||||
|
|
||||||
function ItemStack:fromDetail(inv, detail, slot)
|
function ItemStack:fromDetail(inv, detail, slot)
|
||||||
local obj = {
|
local obj = {
|
||||||
slot = slot,
|
slot = slot,
|
||||||
@ -191,6 +204,10 @@ function ItemStack:_modify(countDelta, stack)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ItemStack:transferTo(target, count)
|
function ItemStack:transferTo(target, count)
|
||||||
|
if target:getMaxCount() == nil then
|
||||||
|
Logger:error("Max count is nil?", target, "\n", self, "\n", count)
|
||||||
|
hookDebugger({ target = target, count = count, self = self })
|
||||||
|
end
|
||||||
local cap = math.min(count or self:getCount(), target:getMaxCount() - 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
|
||||||
@ -209,6 +226,20 @@ function ItemStack:transferTo(target, count)
|
|||||||
return false, result[2]
|
return false, result[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if result[2] == nil then
|
||||||
|
Logger:error(
|
||||||
|
"Error transferring item", self:getInventory().pushItems, "\n",
|
||||||
|
peripheral.getName(target:getInventory()), "\n",
|
||||||
|
errC, "\n",
|
||||||
|
cap, "\n",
|
||||||
|
self, "\n",
|
||||||
|
target, "\n",
|
||||||
|
target:getInventory().getItemLimit(target:getSlot()), "\n",
|
||||||
|
result
|
||||||
|
)
|
||||||
|
hookDebugger({ target = target, count = count, self = self, result = result, errC = errC, cap = cap })
|
||||||
|
end
|
||||||
|
|
||||||
target:_modify(result[2], self)
|
target:_modify(result[2], self)
|
||||||
self:_modify(-result[2], self)
|
self:_modify(-result[2], self)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user