From da7baa8d131e4466acbbf6bc65f9fe9b6a989f9a Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 29 Mar 2025 23:46:31 +0100 Subject: [PATCH] Don't move ammo out of tools and weapons from main bar --- QuickStackToBag/Lua/Autorun/init.lua | 36 ++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/QuickStackToBag/Lua/Autorun/init.lua b/QuickStackToBag/Lua/Autorun/init.lua index 3e07a62..3854b71 100644 --- a/QuickStackToBag/Lua/Autorun/init.lua +++ b/QuickStackToBag/Lua/Autorun/init.lua @@ -364,7 +364,9 @@ local function tryBuildItemTree(inventory) end -- Function to quickly stack items from inventory to containers -local inventorySlotsToStack = {} +-- 6 and 7 are hands +-- 9..18 are main slots +local inventorySlotsToStack = { 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 } local function quickStackItems(character) if not character then debugPrint("No character found") @@ -387,7 +389,37 @@ local function quickStackItems(character) itemTree = sortItemtreeBySlots(itemTree) local toMove = {} - -- toMove = enqueueInventory(inventory, toMove) + for i, slot in ipairs(inventory.slots) do + if #slot.items > 0 then + local item = slot.items[1] + local identifier = item.Prefab.Identifier.Value + print(string.format("Item at slot %d is %s", i, identifier)) + end + end + + for _, slotid in ipairs(inventorySlotsToStack) do + debugPrint("Processing inventory slot: " .. slotid) + local slot = inventory.slots[slotid] + if #slot.items > 0 then + local item = slot.items[1] + local tags = item.Prefab.Tags + local shouldSuss = true + for tag in tags do + if tag.value:find("tool") or tag.value:find("weapon") then + debugPrint("Item is a tool or weapon, skipping") + shouldSuss = false + break + end + end + + if shouldSuss then + local before = #toMove + toMove = enqueueSlot(slot, toMove) + local after = #toMove + debugPrint("Enqueued " .. after - before .. " items from the inventory slot " .. slotid) + end + end + end local openContainers = getOpenContainers() for _, container in ipairs(openContainers) do