From fe93603af95c2fd29b4516e39ffb4f867d97f01e Mon Sep 17 00:00:00 2001 From: tommy Date: Fri, 12 Jul 2024 08:34:24 -0400 Subject: [PATCH] Source commands added vsensmul sub command (this is a reimplementation that is better than what we had before as it was already present before but the code was never pushed to origin and got deleted) --- src/SlashCommands/SourceGames.lua | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/SlashCommands/SourceGames.lua diff --git a/src/SlashCommands/SourceGames.lua b/src/SlashCommands/SourceGames.lua new file mode 100644 index 0000000..0128847 --- /dev/null +++ b/src/SlashCommands/SourceGames.lua @@ -0,0 +1,55 @@ +local SlashCommandTools = require('discordia-slash').util.tools() + +local SubCommandHandler = require('../Modules/SubCommandHandler.lua') + +local SOURCE_DEFAULT_M_YAW = 0.022 + +local SourceSubCommandHandler = SubCommandHandler.new() +local SourceMainCommand = SlashCommandTools.slashCommand('source', 'Utility commands for source games (CS:S specifically)') + +local VSensMultiplierSubCommand = SlashCommandTools.subCommand('vsensmul', 'Apply a vertical multiplier to your sensitivity (roblox "myaw" equivalent)') +local VSensMultiplierSensitivityOption = SlashCommandTools.string('sensitivity', 'Your current sensitivity'):setRequired(true) +local VSensMultiplierMultiplierOption = SlashCommandTools.string('multiplier', 'The desired vertical sensitivity multiplier'):setRequired(true) +local VSensMultiplierMYawOption = SlashCommandTools.string('m_yaw', 'Your current m_yaw') +VSensMultiplierSubCommand:addOption(VSensMultiplierSensitivityOption) +VSensMultiplierSubCommand:addOption(VSensMultiplierMultiplierOption) +VSensMultiplierSubCommand:addOption(VSensMultiplierMYawOption) + +SourceMainCommand:addOption(VSensMultiplierSubCommand) + +SourceSubCommandHandler:AddSubCommand(VSensMultiplierSubCommand.name, function(Interaction, Command, Args) + local Sensitivity = tonumber(Args.sensitivity) + local VSensMultiplier = tonumber(Args.multiplier) + local MYaw = Args.m_yaw and tonumber(Args.m_yaw) or SOURCE_DEFAULT_M_YAW + + if type(Sensitivity) ~= 'number' then + error('"sensitivity" argument was not a valid number') + end + + if type(VSensMultiplier) ~= 'number' then + error('"multiplier" argument was not a valid number') + end + + if type(MYaw) ~= 'number' then + error('"m_yaw" argument was not a valid number') + end + + local OldVSensMultiplier = SOURCE_DEFAULT_M_YAW / MYaw + local SensitivityWithDefaultMYaw = Sensitivity / OldVSensMultiplier + local NewSensitivity = SensitivityWithDefaultMYaw * VSensMultiplier + local NewMYaw = SOURCE_DEFAULT_M_YAW / VSensMultiplier + + local Message = 'OldVSensMultiplier = '..OldVSensMultiplier..'\n'.. + 'SensitivityWithDefaultMYaw = '..SensitivityWithDefaultMYaw..'\n'.. + '```'..'\n'.. + 'sensitivity '..NewSensitivity..'; \n'.. + 'm_yaw '..NewMYaw..'\n'.. + '```' + + Interaction:reply(Message) +end) + +return { + Command = SourceMainCommand, + Callback = SourceSubCommandHandler:GetMainCommandCallback() +} \ No newline at end of file