Compare commits
2 Commits
98018e4a8c
...
8db86ee45c
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8db86ee45c | ||
![]() |
3d293d3e68 |
16
debugger.lua
16
debugger.lua
@ -43,4 +43,18 @@ local function debugREPL(onResult, debugArgs)
|
||||
return success, (not success and retval) or nil
|
||||
end
|
||||
|
||||
return { debugREPL = debugREPL, execDebug = execDebug }
|
||||
local function hookDebugger(context, Logger)
|
||||
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,23 +2,10 @@ local Inventory = require("storage.inventory")
|
||||
local Sentinel = require("storage.sentinel")
|
||||
local Logging = require("logging")
|
||||
local Logger = Logging.getGlobalLogger()
|
||||
local Debugger = require("debugger")
|
||||
|
||||
local ItemStack = Sentinel:tag({}, Sentinel.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)
|
||||
local obj = {
|
||||
slot = slot,
|
||||
@ -204,10 +191,6 @@ function ItemStack:_modify(countDelta, stack)
|
||||
end
|
||||
|
||||
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())
|
||||
|
||||
-- If we can't transfer any data, then
|
||||
@ -226,20 +209,6 @@ function ItemStack:transferTo(target, count)
|
||||
return false, result[2]
|
||||
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)
|
||||
self:_modify(-result[2], self)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user