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
|
if SERVER then return end
|
||||||
-- Docs: https://evilfactory.github.io/LuaCsForBarotrauma/lua-docs/manual/common-questions/
|
-- Docs: https://evilfactory.github.io/LuaCsForBarotrauma/lua-docs/manual/common-questions/
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,9 @@ local function tryStackCursorItem()
|
|||||||
|
|
||||||
local itemsToMove = {}
|
local itemsToMove = {}
|
||||||
for _, slot in ipairs(slots) do
|
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
|
end
|
||||||
-- for _, item in ipairs(itemsToMove) do
|
-- for _, item in ipairs(itemsToMove) do
|
||||||
-- MyModGlobal.debugPrint(string.format("Enqueued item: %s", tostring(item)))
|
-- MyModGlobal.debugPrint(string.format("Enqueued item: %s", tostring(item)))
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ local function buildItemTree(inventory, itemTree, depth)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- MyModGlobal.debugPrint("Completed building item tree")
|
-- MyModGlobal.debugPrint("Completed building item tree")
|
||||||
MyModGlobal.debugPrint("Completed building item tree")
|
|
||||||
return itemTree
|
return itemTree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ enqueueItem = function(item, queue, predicate)
|
|||||||
-- local err
|
-- local err
|
||||||
-- This should make it breadth first, right...?
|
-- This should make it breadth first, right...?
|
||||||
-- No, not yet...
|
-- No, not yet...
|
||||||
|
if not item then return queue, "No item" end
|
||||||
|
|
||||||
local ok, stop = predicate(item)
|
local ok, stop = predicate(item)
|
||||||
if ok then
|
if ok then
|
||||||
queue[#queue + 1] = item
|
queue[#queue + 1] = item
|
||||||
@@ -49,6 +51,9 @@ enqueueSlot = function(slot, queue, predicate)
|
|||||||
local err
|
local err
|
||||||
-- If the slot is empty there's nothing to iterate
|
-- If the slot is empty there's nothing to iterate
|
||||||
-- And we will naturally return queue as is
|
-- 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
|
for _, item in ipairs(slot.items) do
|
||||||
-- Only the final leaf nodes decide upon the predicate
|
-- Only the final leaf nodes decide upon the predicate
|
||||||
queue, err = enqueueItem(item, queue, predicate)
|
queue, err = enqueueItem(item, queue, predicate)
|
||||||
@@ -69,6 +74,9 @@ enqueueInventory = function(inventory, queue, predicate)
|
|||||||
predicate = predicate or function() return true end
|
predicate = predicate or function() return true end
|
||||||
-- debugPrint(string.format("Enqueuing inventory with %d slots.", #inventory.slots))
|
-- debugPrint(string.format("Enqueuing inventory with %d slots.", #inventory.slots))
|
||||||
local err
|
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
|
for _, slot in ipairs(inventory.slots) do
|
||||||
-- Only the final leaf nodes decide upon the predicate
|
-- Only the final leaf nodes decide upon the predicate
|
||||||
queue, err = enqueueSlot(slot, queue, predicate)
|
queue, err = enqueueSlot(slot, queue, predicate)
|
||||||
|
|||||||
Reference in New Issue
Block a user