Hook debugger on error condition

This commit is contained in:
Gabriel Tofvesson 2024-11-28 22:50:58 +01:00
parent 0ff986a4f2
commit 686c1e5808

View File

@ -7,6 +7,13 @@ 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()
local errorCond = Debugger.debugREPL(function(retval)
Logger:error("->", retval)
end)
Logger:error("x>", errorCond)
end
function ItemStack:fromDetail(inv, detail, slot) function ItemStack:fromDetail(inv, detail, slot)
local obj = { local obj = {
slot = slot, slot = slot,
@ -193,6 +200,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()
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
@ -222,10 +233,7 @@ function ItemStack:transferTo(target, count)
target:getInventory().getItemLimit(target:getSlot()), "\n", target:getInventory().getItemLimit(target:getSlot()), "\n",
result result
) )
local errorCond = Debugger.debugREPL(function(retval) hookDebugger()
Logger:error("->", retval)
end)
Logger:error("x>", errorCond)
end end
target:_modify(result[2], self) target:_modify(result[2], self)