Throttle mouseover stack per slot
This commit is contained in:
@@ -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)))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user