diff options
Diffstat (limited to 'builtin/client/cheats/movement.lua')
-rw-r--r-- | builtin/client/cheats/movement.lua | 27 |
1 files changed, 14 insertions, 13 deletions
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") |