diff --git a/QuickStackToBag/Lua/Autorun/init.lua b/QuickStackToBag/Lua/Autorun/init.lua index 1259ef6..94420f8 100644 --- a/QuickStackToBag/Lua/Autorun/init.lua +++ b/QuickStackToBag/Lua/Autorun/init.lua @@ -93,9 +93,15 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab quickbuy.tryBuy() end, Hook.HookMethodType.After) +local throttle = 0.1 +local throttleTimer = 0 Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable) - ---@cast PlayerInput Barotrauma.PlayerInput - if not PlayerInput.IsShiftDown() then return end - if not PlayerInput.PrimaryMouseButtonClicked() then return end + if Timer.GetTime() < throttleTimer then return end + throttleTimer = Timer.GetTime() + throttle + -- We can not use shift because holding shift means we're moving half a stack + -- Fuck me sideways + -- if not PlayerInput.IsShiftDown() then return end + if not PlayerInput.IsAltDown() then return end + -- if not PlayerInput.PrimaryMouseButtonClicked() then return end cursormacroer.tryStackCursorItem() end, Hook.HookMethodType.After) diff --git a/QuickStackToBag/Lua/Cyka/cursormacroer.lua b/QuickStackToBag/Lua/Cyka/cursormacroer.lua index c1d5819..05c8dd6 100644 --- a/QuickStackToBag/Lua/Cyka/cursormacroer.lua +++ b/QuickStackToBag/Lua/Cyka/cursormacroer.lua @@ -47,6 +47,8 @@ local function getInventorySlotUnderCursor() return nil, nil, nil end +-- TODO: Make shift right click mark target inventory +-- So that we can stack items to boxes and shit local function tryStackCursorItem() MyModGlobal.debugPrint("Shift + Left Click detected") @@ -65,6 +67,11 @@ local function tryStackCursorItem() return end + if not slot or not slot.items or not slot.items[1] then + MyModGlobal.debugPrint("No items in slot") + return + end + local itemTree, err = quickstack.tryBuildCharacterItemTree(controlledCharacter) if err then MyModGlobal.debugPrint(string.format("Error building item tree: %s", err)) @@ -78,7 +85,7 @@ local function tryStackCursorItem() end -- MyModGlobal.debugPrint(string.format("Enqueued %d items from the inventory slot", #itemsToMove)) - local errors = quickstack.tryMoveItems(itemsToMove, itemTree) + local errors = quickstack.tryMoveItems(itemsToMove, itemTree, true) for _, error in ipairs(errors) do MyModGlobal.debugPrint(string.format("Error moving item: %s", error)) end