]> git.lizzy.rs Git - dragonfireclient.git/blob - builtin/client/cheats/movement.lua
Improved AutoSneak
[dragonfireclient.git] / builtin / client / cheats / movement.lua
1 local function register_keypress_cheat(cheat, keyname, condition)
2         local was_enabled = false
3         core.register_globalstep(function()
4                 local is_active = core.settings:get_bool(cheat)
5                 local condition_true = (not condition or condition())
6                 if is_active and condition_true then
7                         core.set_keypress(keyname, true)
8                 elseif was_enabled then
9                         core.set_keypress(keyname, false)
10                 end
11                 was_enabled = is_active and condition_true
12         end)
13 end
14
15 register_keypress_cheat("autosneak", "sneak", function()
16         return core.localplayer:is_touching_ground()
17 end)
18 register_keypress_cheat("autosprint", "special1")