Fix up getopencontainer
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user