Throttle mouseover stack per slot

This commit is contained in:
2025-03-30 19:10:59 +02:00
parent c40c5d5b21
commit 40ff5f730f
2 changed files with 10 additions and 2 deletions

View File

@@ -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)))

View File

@@ -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