From 40ff5f730f2f6c4aae708a64d00a4377ffe13457 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sun, 30 Mar 2025 19:10:59 +0200 Subject: [PATCH] Throttle mouseover stack per slot --- QuickStackToBag/Lua/Cyka/cursormacroer.lua | 10 +++++++++- QuickStackToBag/Lua/Cyka/quickstack.lua | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/QuickStackToBag/Lua/Cyka/cursormacroer.lua b/QuickStackToBag/Lua/Cyka/cursormacroer.lua index 7f4a4eb..cb9d6fc 100644 --- a/QuickStackToBag/Lua/Cyka/cursormacroer.lua +++ b/QuickStackToBag/Lua/Cyka/cursormacroer.lua @@ -1,4 +1,4 @@ --- luacheck: globals Character MyModGlobal +-- luacheck: globals Character MyModGlobal Timer local quickstack = require("Cyka.quickstack") local utils = require("Cyka.utils") @@ -103,6 +103,7 @@ local function getInventorySlotsUnderCursor() end local targetInventory = nil +local slotThrottle = {} local function tryStackCursorItem() local slots, err = getInventorySlotsUnderCursor() if err then @@ -159,10 +160,17 @@ local function tryStackCursorItem() itemTree = quickstack.sortItemTree(itemTree) local itemsToMove = {} + local now = Timer.GetTime() for _, slot in ipairs(slots) do + local runAfter = slotThrottle[slot] or 0 + if now < runAfter then + goto continue + end -- 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)) + slotThrottle[slot] = now + 1 + ::continue:: end -- for _, item in ipairs(itemsToMove) do -- MyModGlobal.debugPrint(string.format("Enqueued item: %s", tostring(item))) diff --git a/QuickStackToBag/Lua/Cyka/quickstack.lua b/QuickStackToBag/Lua/Cyka/quickstack.lua index 0e99911..fb266a7 100644 --- a/QuickStackToBag/Lua/Cyka/quickstack.lua +++ b/QuickStackToBag/Lua/Cyka/quickstack.lua @@ -194,7 +194,7 @@ end -- Maybe it will be fine... ---@return Barotrauma.Item[] local function getOpenContainers() - MyModGlobal.debugPrint("Attempting to find open container...") + -- MyModGlobal.debugPrint("Attempting to find open container...") -- local containers = {} -- for item in Item.ItemList do -- ---@cast item Barotrauma.Item