Add quick access
Now we're telepathic
This commit is contained in:
		@@ -22,6 +22,8 @@ MyModGlobal = {
 | 
			
		||||
        LOOT = Keys.L,
 | 
			
		||||
        SONAR = Keys.X,
 | 
			
		||||
        AOEPICKUP = Keys.Y,
 | 
			
		||||
        QICK_FABRICATOR = Keys.K,
 | 
			
		||||
        QICK_DECONSTRUCTOR = Keys.J,
 | 
			
		||||
        NESTED_CONTAINERS = true,
 | 
			
		||||
        DEBUG_MODE = true,
 | 
			
		||||
    },
 | 
			
		||||
@@ -63,10 +65,11 @@ local quickbuy = require("Cyka.quickbuy")
 | 
			
		||||
local hotkeyrepair = require("Cyka.hotkeyrepair")
 | 
			
		||||
local cursormacroer = require("Cyka.cursormacroer")
 | 
			
		||||
local quickunload = require("Cyka.quickunload")
 | 
			
		||||
local quickreload= require("Cyka.quickreload")
 | 
			
		||||
local quickreload = require("Cyka.quickreload")
 | 
			
		||||
local quickloot = require("Cyka.quickloot")
 | 
			
		||||
local sonarpinger = require("Cyka.sonarpinger")
 | 
			
		||||
local aoepickup = require("Cyka.aoepickup")
 | 
			
		||||
local quickaccess = require("Cyka.quickaccess")
 | 
			
		||||
require("Cyka.xpticker")
 | 
			
		||||
require("Cyka.zoom")
 | 
			
		||||
 | 
			
		||||
@@ -160,3 +163,13 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab
 | 
			
		||||
    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()
 | 
			
		||||
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()
 | 
			
		||||
end, Hook.HookMethodType.After)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										80
									
								
								QuickStackToBag/Lua/Cyka/quickaccess.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								QuickStackToBag/Lua/Cyka/quickaccess.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,80 @@
 | 
			
		||||
-- luacheck: globals MyModGlobal Character
 | 
			
		||||
local utils = require "Cyka.utils"
 | 
			
		||||
local dump = require "Cyka.dump"
 | 
			
		||||
 | 
			
		||||
local function tryAccessFabricator()
 | 
			
		||||
	local items = utils.enqueueAllSubmarineItems({}, function(item)
 | 
			
		||||
		return item.Prefab.Identifier.Value == "fabricator", item.Prefab.Identifier.Value == "fabricator"
 | 
			
		||||
	end)
 | 
			
		||||
	if #items == 0 then
 | 
			
		||||
		MyModGlobal.debugPrint("No fabricator found")
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	if #items > 1 then
 | 
			
		||||
		MyModGlobal.debugPrint("Multiple fabricators found, using first one")
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	---@type Barotrauma.Item
 | 
			
		||||
	local fabricator = items[1]
 | 
			
		||||
	---@type Barotrauma.Items.Components.Fabricator
 | 
			
		||||
	local fabricatorComponent
 | 
			
		||||
	for component in fabricator.Components do
 | 
			
		||||
		if component.Name == "Fabricator" then
 | 
			
		||||
			fabricatorComponent = component
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if not fabricatorComponent then
 | 
			
		||||
		MyModGlobal.debugPrint("No fabricator component found")
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local me = Character.Controlled
 | 
			
		||||
	if not me then
 | 
			
		||||
		MyModGlobal.debugPrint("No controlled character found")
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	MyModGlobal.debugPrint("Selecting fabricator")
 | 
			
		||||
	-- fabricatorComponent.Select(me)
 | 
			
		||||
	me.SelectedItem = fabricator
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function tryAccessDeconstructor()
 | 
			
		||||
	local items = utils.enqueueAllSubmarineItems({}, function(item)
 | 
			
		||||
		return item.Prefab.Identifier.Value == "deconstructor", item.Prefab.Identifier.Value == "deconstructor"
 | 
			
		||||
	end)
 | 
			
		||||
	if #items == 0 then
 | 
			
		||||
		MyModGlobal.debugPrint("No deconstructor found")
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	if #items > 1 then
 | 
			
		||||
		MyModGlobal.debugPrint("Multiple deconstructors found, using first one")
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	---@type Barotrauma.Item
 | 
			
		||||
	local deconstructor = items[1]
 | 
			
		||||
	---@type Barotrauma.Items.Components.Deconstructor
 | 
			
		||||
	local deconstructorComponent
 | 
			
		||||
	for component in deconstructor.Components do
 | 
			
		||||
		if component.Name == "Deconstructor" then
 | 
			
		||||
			deconstructorComponent = component
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if not deconstructorComponent then
 | 
			
		||||
		MyModGlobal.debugPrint("No deconstructor component found")
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local me = Character.Controlled
 | 
			
		||||
	if not me then
 | 
			
		||||
		MyModGlobal.debugPrint("No controlled character found")
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	MyModGlobal.debugPrint("Selecting deconstructor")
 | 
			
		||||
	-- deconstructorComponent.Select(me)
 | 
			
		||||
	me.SelectedItem = deconstructor
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
	tryAccessFabricator = tryAccessFabricator,
 | 
			
		||||
	tryAccessDeconstructor = tryAccessDeconstructor,
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user