Add quick terminal hotkey
This commit is contained in:
@@ -28,6 +28,7 @@ else
|
||||
QICK_FABRICATOR = Keys.K,
|
||||
QICK_DECONSTRUCTOR = Keys.J,
|
||||
QICK_MEDICAL_FABRICATOR = Keys.M,
|
||||
QICK_TERMINAL = Keys.N,
|
||||
NESTED_CONTAINERS = true,
|
||||
DEBUG_MODE = true,
|
||||
},
|
||||
@@ -97,88 +98,93 @@ else
|
||||
LuaUserData.RegisterType("Barotrauma.Items.Components.Repairable")
|
||||
LuaUserData.RegisterType("Barotrauma.VisualSlot")
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QUICKSTACK_KEYS) then return end
|
||||
-- quickstack.quickStackItems(instance)
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QUICKSTACK_KEYS) then return end
|
||||
quickstack.quickStackItems(instance)
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.STACK_TO_CURSOR) then return end
|
||||
-- if not PlayerInput.IsShiftDown() then
|
||||
-- quickstack.stackToCursor()
|
||||
-- else
|
||||
-- quickstack.stackAllToCursor()
|
||||
-- end
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.STACK_TO_CURSOR) then return end
|
||||
if not PlayerInput.IsShiftDown() then
|
||||
quickstack.stackToCursor()
|
||||
else
|
||||
quickstack.stackAllToCursor()
|
||||
end
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.FABRICATOR_KEY) then return end
|
||||
-- fabricatorstack.tryStackFabricator(instance)
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.FABRICATOR_KEY) then return end
|
||||
fabricatorstack.tryStackFabricator(instance)
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.FIX) then return end
|
||||
-- hotkeyrepair.tryRepair()
|
||||
-- end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.MAX_BUY) then return end
|
||||
-- quickbuy.tryBuy()
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.MAX_BUY) then return end
|
||||
quickbuy.tryBuy()
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
local throttle = 0.1
|
||||
local throttleTimer = 0
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if PlayerInput.Mouse4ButtonClicked() then
|
||||
cursormacroer.setTargetInventory()
|
||||
end
|
||||
if not PlayerInput.IsAltDown() 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.PrimaryMouseButtonClicked() then return end
|
||||
cursormacroer.tryStackCursorItem()
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.UNLOAD) then return end
|
||||
quickunload.tryUnloadCursorItem()
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.RELOAD) then return end
|
||||
quickreload.tryReloadCursorItem(PlayerInput.IsShiftDown())
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)i
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.LOOT) then return end
|
||||
-- quickloot.tryLoot()
|
||||
-- end, Hook.HookMethodType.After)
|
||||
|
||||
-- local throttle = 0.1
|
||||
-- local throttleTimer = 0
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if PlayerInput.Mouse4ButtonClicked() then
|
||||
-- cursormacroer.setTargetInventory()
|
||||
-- end
|
||||
-- if not PlayerInput.IsAltDown() 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.PrimaryMouseButtonClicked() then return end
|
||||
-- cursormacroer.tryStackCursorItem()
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.SONAR) then return end
|
||||
sonarpinger.tryPing()
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.UNLOAD) then return end
|
||||
-- quickunload.tryUnloadCursorItem()
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.AOEPICKUP) then return end
|
||||
aoepickup.tryAoePickup()
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.RELOAD) then return end
|
||||
-- quickreload.tryReloadCursorItem(PlayerInput.IsShiftDown())
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_FABRICATOR) then return end
|
||||
quickaccess.tryAccessFabricator(PlayerInput.IsShiftDown())
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- -- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- -- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.LOOT) then return end
|
||||
-- -- quickloot.tryLoot()
|
||||
-- -- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_DECONSTRUCTOR) then return end
|
||||
quickaccess.tryAccessDeconstructor(PlayerInput.IsShiftDown())
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.SONAR) then return end
|
||||
-- sonarpinger.tryPing()
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_MEDICAL_FABRICATOR) then return end
|
||||
quickaccess.tryAccessMedicalFabricator(PlayerInput.IsShiftDown())
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.AOEPICKUP) then return end
|
||||
-- aoepickup.tryAoePickup()
|
||||
-- end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_FABRICATOR) then return end
|
||||
-- quickaccess.tryAccessFabricator(PlayerInput.IsShiftDown())
|
||||
-- end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_DECONSTRUCTOR) then return end
|
||||
-- quickaccess.tryAccessDeconstructor(PlayerInput.IsShiftDown())
|
||||
-- end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_MEDICAL_FABRICATOR) then return end
|
||||
-- quickaccess.tryAccessMedicalFabricator(PlayerInput.IsShiftDown())
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.QICK_TERMINAL) then return end
|
||||
quickaccess.tryAccessTerminal(PlayerInput.IsShiftDown())
|
||||
end, Hook.HookMethodType.After)
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ local dump = require "Cyka.dump"
|
||||
|
||||
-- TODO: Also cook terminal
|
||||
-- terminal d:28 t:logic,smallitem c:Terminal, Holdable, ConnectionPanel,
|
||||
local machines = "fabricator,deconstructor,medicalfabricator"
|
||||
local machines = "fabricator,deconstructor,medicalfabricator,navterminal"
|
||||
Hook.Patch("Cyka", "Barotrauma.Character", "CanInteractWith",
|
||||
{ "Barotrauma.Item", "System.Single&", "System.Boolean" },
|
||||
function(_, ptable)
|
||||
@@ -20,7 +20,7 @@ Hook.Patch("Cyka", "Barotrauma.Character", "CanInteractWith",
|
||||
local cachedFabricator = nil
|
||||
local cachedDeconstructor = nil
|
||||
local cachedMedicalFabricator = nil
|
||||
|
||||
local cachedTerminal = nil
|
||||
local function select(item)
|
||||
MyModGlobal.debugPrint("Selecting " .. tostring(item))
|
||||
item.Prefab.GrabWhenSelected = false
|
||||
@@ -109,8 +109,24 @@ local function tryAccessMedicalFabricator(force)
|
||||
select(medicalFabricator)
|
||||
end
|
||||
|
||||
local function tryAccessTerminal(force)
|
||||
local terminal = cachedTerminal
|
||||
if not terminal or force then
|
||||
terminal = findByComponent("navterminal", "Steering")
|
||||
if not terminal then
|
||||
MyModGlobal.debugPrint("No terminal found")
|
||||
return
|
||||
end
|
||||
cachedTerminal = terminal
|
||||
end
|
||||
|
||||
MyModGlobal.debugPrint("Selecting terminal")
|
||||
select(terminal)
|
||||
end
|
||||
|
||||
return {
|
||||
tryAccessFabricator = tryAccessFabricator,
|
||||
tryAccessDeconstructor = tryAccessDeconstructor,
|
||||
tryAccessMedicalFabricator = tryAccessMedicalFabricator,
|
||||
tryAccessTerminal = tryAccessTerminal,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user