aboutsummaryrefslogtreecommitdiff
path: root/builtin/client/cheats
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/client/cheats')
-rw-r--r--builtin/client/cheats/init.lua1
-rw-r--r--builtin/client/cheats/movement.lua27
2 files changed, 15 insertions, 13 deletions
diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua
index 2c67e0ebf..2307c7aec 100644
--- a/builtin/client/cheats/init.lua
+++ b/builtin/client/cheats/init.lua
@@ -18,6 +18,7 @@ core.cheats = {
["Jesus"] = "jesus",
["NoSlow"] = "no_slow",
["AutoSneak"] = "autosneak",
+ ["AutoSprint"] = "autosprint",
},
["Render"] = {
["Xray"] = "xray",
diff --git a/builtin/client/cheats/movement.lua b/builtin/client/cheats/movement.lua
index bd9b995ad..9737662b2 100644
--- a/builtin/client/cheats/movement.lua
+++ b/builtin/client/cheats/movement.lua
@@ -1,14 +1,15 @@
--- autosneak
+local function register_keypress_cheat(cheat, keyname)
+ local was_enabled = false
+ core.register_globalstep(function()
+ if core.settings:get_bool(cheat) then
+ was_enabled = true
+ core.set_keypress(keyname, true)
+ elseif was_enabled then
+ was_enabled = false
+ core.set_keypress(keyname, false)
+ end
+ end)
+end
-local autosneak_was_enabled = false
-
-core.register_globalstep(function()
- if core.settings:get_bool("autosneak") then
- core.set_keypress("sneak", true)
- autosneak_was_enabled = true
- elseif autosneak_was_enabled then
- autosneak_was_enabled = false
- core.set_keypress("sneak", false)
- end
-end)
-
+register_keypress_cheat("autosneak", "sneak")
+register_keypress_cheat("autosprint", "special1")