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 quickstack = require("Cyka.quickstack")
|
||||||
local utils = require("Cyka.utils")
|
local utils = require("Cyka.utils")
|
||||||
|
|
||||||
@@ -103,6 +103,7 @@ local function getInventorySlotsUnderCursor()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local targetInventory = nil
|
local targetInventory = nil
|
||||||
|
local slotThrottle = {}
|
||||||
local function tryStackCursorItem()
|
local function tryStackCursorItem()
|
||||||
local slots, err = getInventorySlotsUnderCursor()
|
local slots, err = getInventorySlotsUnderCursor()
|
||||||
if err then
|
if err then
|
||||||
@@ -159,10 +160,17 @@ local function tryStackCursorItem()
|
|||||||
itemTree = quickstack.sortItemTree(itemTree)
|
itemTree = quickstack.sortItemTree(itemTree)
|
||||||
|
|
||||||
local itemsToMove = {}
|
local itemsToMove = {}
|
||||||
|
local now = Timer.GetTime()
|
||||||
for _, slot in ipairs(slots) do
|
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))
|
-- MyModGlobal.debugPrint(string.format("Enqueuing slot: %s, before: %d", tostring(slot), #itemsToMove))
|
||||||
utils.enqueueSlot(slot.slot, itemsToMove)
|
utils.enqueueSlot(slot.slot, itemsToMove)
|
||||||
-- MyModGlobal.debugPrint(string.format("Enqueuing slot: %s, after: %d", tostring(slot), #itemsToMove))
|
-- MyModGlobal.debugPrint(string.format("Enqueuing slot: %s, after: %d", tostring(slot), #itemsToMove))
|
||||||
|
slotThrottle[slot] = now + 1
|
||||||
|
::continue::
|
||||||
end
|
end
|
||||||
-- for _, item in ipairs(itemsToMove) do
|
-- for _, item in ipairs(itemsToMove) do
|
||||||
-- MyModGlobal.debugPrint(string.format("Enqueued item: %s", tostring(item)))
|
-- MyModGlobal.debugPrint(string.format("Enqueued item: %s", tostring(item)))
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ end
|
|||||||
-- Maybe it will be fine...
|
-- Maybe it will be fine...
|
||||||
---@return Barotrauma.Item[]
|
---@return Barotrauma.Item[]
|
||||||
local function getOpenContainers()
|
local function getOpenContainers()
|
||||||
MyModGlobal.debugPrint("Attempting to find open container...")
|
-- MyModGlobal.debugPrint("Attempting to find open container...")
|
||||||
-- local containers = {}
|
-- local containers = {}
|
||||||
-- for item in Item.ItemList do
|
-- for item in Item.ItemList do
|
||||||
-- ---@cast item Barotrauma.Item
|
-- ---@cast item Barotrauma.Item
|
||||||
|
|||||||
Reference in New Issue
Block a user