Make alt drag quick stack items
This commit is contained in:
@@ -93,9 +93,15 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab
|
|||||||
quickbuy.tryBuy()
|
quickbuy.tryBuy()
|
||||||
end, Hook.HookMethodType.After)
|
end, Hook.HookMethodType.After)
|
||||||
|
|
||||||
|
local throttle = 0.1
|
||||||
|
local throttleTimer = 0
|
||||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||||
---@cast PlayerInput Barotrauma.PlayerInput
|
if Timer.GetTime() < throttleTimer then return end
|
||||||
if not PlayerInput.IsShiftDown() then return end
|
throttleTimer = Timer.GetTime() + throttle
|
||||||
if not PlayerInput.PrimaryMouseButtonClicked() then return end
|
-- 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()
|
cursormacroer.tryStackCursorItem()
|
||||||
end, Hook.HookMethodType.After)
|
end, Hook.HookMethodType.After)
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ local function getInventorySlotUnderCursor()
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: Make shift right click mark target inventory
|
||||||
|
-- So that we can stack items to boxes and shit
|
||||||
local function tryStackCursorItem()
|
local function tryStackCursorItem()
|
||||||
MyModGlobal.debugPrint("Shift + Left Click detected")
|
MyModGlobal.debugPrint("Shift + Left Click detected")
|
||||||
|
|
||||||
@@ -65,6 +67,11 @@ local function tryStackCursorItem()
|
|||||||
return
|
return
|
||||||
end
|
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)
|
local itemTree, err = quickstack.tryBuildCharacterItemTree(controlledCharacter)
|
||||||
if err then
|
if err then
|
||||||
MyModGlobal.debugPrint(string.format("Error building item tree: %s", err))
|
MyModGlobal.debugPrint(string.format("Error building item tree: %s", err))
|
||||||
@@ -78,7 +85,7 @@ local function tryStackCursorItem()
|
|||||||
end
|
end
|
||||||
-- MyModGlobal.debugPrint(string.format("Enqueued %d items from the inventory slot", #itemsToMove))
|
-- 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
|
for _, error in ipairs(errors) do
|
||||||
MyModGlobal.debugPrint(string.format("Error moving item: %s", error))
|
MyModGlobal.debugPrint(string.format("Error moving item: %s", error))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user