
local mod = get_mod("AutoSwing")

mod.attack_delay = 0
mod.auto_swing = false

mod.auto_swing_keybind_pressed = function(self)
	mod.auto_swing = self
end

local InputService_get = function(func, self, action_name)
	if (action_name == "action_one_hold" and mod.auto_swing and self.type == "Ingame") then
		if (mod.attack_delay > 0) then
			mod.attack_delay = mod.attack_delay - 1
		else
			mod.attack_delay = 1

			return true
		end
	end

	return func(self, action_name)
end

mod:hook("InputService", "_get", InputService_get)
mod:hook("InputService", "_get_simulate", InputService_get)