diff --git a/QuickStackToBag/Lua/Autorun/init.lua b/QuickStackToBag/Lua/Autorun/init.lua index 1cc000d..4556fe1 100644 --- a/QuickStackToBag/Lua/Autorun/init.lua +++ b/QuickStackToBag/Lua/Autorun/init.lua @@ -1,4 +1,6 @@ --- luacheck: globals MyModGlobal Character SERVER Keys LuaUserData Hook Descriptors +-- luacheck: globals MyModGlobal +-- luacheck: read_globals Character SERVER Keys LuaUserData Hook Descriptors PlayerInput Timer +-- luacheck: max line length 420 if SERVER then return end -- Docs: https://evilfactory.github.io/LuaCsForBarotrauma/lua-docs/manual/common-questions/ diff --git a/QuickStackToBag/Lua/Cyka/cursormacroer.lua b/QuickStackToBag/Lua/Cyka/cursormacroer.lua index 1456516..7f4a4eb 100644 --- a/QuickStackToBag/Lua/Cyka/cursormacroer.lua +++ b/QuickStackToBag/Lua/Cyka/cursormacroer.lua @@ -160,7 +160,9 @@ local function tryStackCursorItem() local itemsToMove = {} for _, slot in ipairs(slots) do - utils.enqueueSlot(slot, itemsToMove) + -- MyModGlobal.debugPrint(string.format("Enqueuing slot: %s, before: %d", tostring(slot), #itemsToMove)) + utils.enqueueSlot(slot.slot, itemsToMove) + -- MyModGlobal.debugPrint(string.format("Enqueuing slot: %s, after: %d", tostring(slot), #itemsToMove)) end -- for _, item in ipairs(itemsToMove) do -- MyModGlobal.debugPrint(string.format("Enqueued item: %s", tostring(item))) diff --git a/QuickStackToBag/Lua/Cyka/quickstack.lua b/QuickStackToBag/Lua/Cyka/quickstack.lua index 8419bf0..0e99911 100644 --- a/QuickStackToBag/Lua/Cyka/quickstack.lua +++ b/QuickStackToBag/Lua/Cyka/quickstack.lua @@ -73,7 +73,6 @@ local function buildItemTree(inventory, itemTree, depth) end -- MyModGlobal.debugPrint("Completed building item tree") - MyModGlobal.debugPrint("Completed building item tree") return itemTree end diff --git a/QuickStackToBag/Lua/Cyka/utils.lua b/QuickStackToBag/Lua/Cyka/utils.lua index 30c525a..2153fea 100644 --- a/QuickStackToBag/Lua/Cyka/utils.lua +++ b/QuickStackToBag/Lua/Cyka/utils.lua @@ -18,6 +18,8 @@ enqueueItem = function(item, queue, predicate) -- local err -- This should make it breadth first, right...? -- No, not yet... + if not item then return queue, "No item" end + local ok, stop = predicate(item) if ok then queue[#queue + 1] = item @@ -49,6 +51,9 @@ enqueueSlot = function(slot, queue, predicate) local err -- If the slot is empty there's nothing to iterate -- And we will naturally return queue as is + if not slot then return queue, "No slot" end + if not slot.items then return queue, "No items" end + for _, item in ipairs(slot.items) do -- Only the final leaf nodes decide upon the predicate queue, err = enqueueItem(item, queue, predicate) @@ -69,6 +74,9 @@ enqueueInventory = function(inventory, queue, predicate) predicate = predicate or function() return true end -- debugPrint(string.format("Enqueuing inventory with %d slots.", #inventory.slots)) local err + if not inventory then return queue, "No inventory" end + if not inventory.slots then return queue, "No slots" end + for _, slot in ipairs(inventory.slots) do -- Only the final leaf nodes decide upon the predicate queue, err = enqueueSlot(slot, queue, predicate)