diff --git a/QuickStackToBag/Lua/Autorun/init.lua b/QuickStackToBag/Lua/Autorun/init.lua index 4d6be28..1072505 100644 --- a/QuickStackToBag/Lua/Autorun/init.lua +++ b/QuickStackToBag/Lua/Autorun/init.lua @@ -215,26 +215,31 @@ end ---@return Barotrauma.Item[] local function getOpenContainers() debugPrint("Attempting to find open container...") - local containers = {} - for item in Item.ItemList do - ---@cast item Barotrauma.Item - local isok = true - isok = isok and item ~= nil - isok = isok and item.OwnInventory ~= nil - isok = isok and item.OwnInventory.visualSlots ~= nil - isok = isok and #item.OwnInventory.visualSlots > 0 - -- I don't know what rootContainer is - -- It seems to be the parent of the current item...? - -- Maybe the world object... - -- Either way - static objects that we may open have it - -- And our own inventory does not - -- So it's a good selector for now - isok = isok and item.rootContainer ~= nil - if isok then - containers[#containers + 1] = item - end - end - return containers + -- local containers = {} + -- for item in Item.ItemList do + -- ---@cast item Barotrauma.Item + -- local isok = true + -- isok = isok and item ~= nil + -- isok = isok and item.OwnInventory ~= nil + -- isok = isok and item.OwnInventory.visualSlots ~= nil + -- isok = isok and #item.OwnInventory.visualSlots > 0 + -- -- I don't know what rootContainer is + -- -- It seems to be the parent of the current item...? + -- -- Maybe the world object... + -- -- Either way - static objects that we may open have it + -- -- And our own inventory does not + -- -- So it's a good selector for now + -- isok = isok and item.rootContainer ~= nil + -- if isok then + -- containers[#containers + 1] = item + -- end + -- end + + local controlledCharacter = Character.Controlled + if not controlledCharacter then return {} end + local selectedItem = controlledCharacter.SelectedItem + if not selectedItem then return {} end + return { selectedItem } end -- We would like to fill larger stacks first