Fix queueing slots that aren't slots anymore
But are now tables, fuck me
This commit is contained in:
@@ -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/
|
||||
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user