From 89257d1cf2abc617e4f95954ac34e1403e3a976e Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sun, 30 Mar 2025 14:21:33 +0200 Subject: [PATCH] Slot under cursor maybe? --- QuickStackToBag/Lua/Autorun/init.lua | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/QuickStackToBag/Lua/Autorun/init.lua b/QuickStackToBag/Lua/Autorun/init.lua index 6c98f99..deb3b65 100644 --- a/QuickStackToBag/Lua/Autorun/init.lua +++ b/QuickStackToBag/Lua/Autorun/init.lua @@ -342,6 +342,67 @@ local function tryBuildItemTree(inventory) return itemTree, nil end +-- -- Register necessary type to access VisualSlot +-- LuaUserData.RegisterType("Barotrauma.VisualSlot") +-- +-- ---@return Barotrauma.VisualSlot|nil, Barotrauma.ItemInventory|nil, Barotrauma.Item|nil +-- local function getInventorySlotUnderCursor() +-- -- Make sure we have a controlled character +-- local controlledCharacter = Character.Controlled +-- if not controlledCharacter then return nil, nil, nil end +-- +-- -- Check player inventory first +-- local charInventory = controlledCharacter.Inventory +-- if charInventory and charInventory.visualSlots then +-- for i, visualSlot in ipairs(charInventory.visualSlots) do +-- -- Check if mouse is over this slot +-- if visualSlot:MouseOn() then +-- local slot = charInventory.slots[i] +-- local item = nil +-- if #slot.items > 0 then +-- item = slot.items[1] +-- end +-- return visualSlot, charInventory, item +-- end +-- end +-- end +-- +-- -- Check if selected item has inventory (containers, etc.) +-- local selectedItem = controlledCharacter.SelectedItem +-- if selectedItem and selectedItem.OwnInventory and selectedItem.OwnInventory.visualSlots then +-- local itemInv = selectedItem.OwnInventory +-- for i, visualSlot in ipairs(itemInv.visualSlots) do +-- if visualSlot:MouseOn() then +-- local slot = itemInv.slots[i] +-- local item = nil +-- if #slot.items > 0 then +-- item = slot.items[1] +-- end +-- return visualSlot, itemInv, item +-- end +-- end +-- end +-- +-- -- Check open containers or other items with visible inventories +-- for item in Item.ItemList do +-- if item and item.OwnInventory and item.OwnInventory.visualSlots then +-- local itemInv = item.OwnInventory +-- for i, visualSlot in ipairs(itemInv.visualSlots) do +-- if visualSlot:MouseOn() then +-- local slot = itemInv.slots[i] +-- local slotItem = nil +-- if #slot.items > 0 then +-- slotItem = slot.items[1] +-- end +-- return visualSlot, itemInv, slotItem +-- end +-- end +-- end +-- end +-- +-- return nil, nil, nil +-- end + -- Function to quickly stack items from inventory to containers -- 6 and 7 are hands -- 9..18 are main slots