diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-24 09:48:16 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-24 09:48:16 +0100 |
commit | 7d327def8219f74d51127a739c9cdf8100b82c6d (patch) | |
tree | 84016c96549722a1731528719924136056ef91ac /builtin/client/cheats/movement.lua | |
parent | 82216e1476dff509ba0c83bfabf5e4ec6e1075b2 (diff) | |
download | dragonfireclient-7d327def8219f74d51127a739c9cdf8100b82c6d.tar.xz |
Improved AutoSneak
Diffstat (limited to 'builtin/client/cheats/movement.lua')
-rw-r--r-- | builtin/client/cheats/movement.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/builtin/client/cheats/movement.lua b/builtin/client/cheats/movement.lua index 9737662b2..907990cce 100644 --- a/builtin/client/cheats/movement.lua +++ b/builtin/client/cheats/movement.lua @@ -1,15 +1,18 @@ -local function register_keypress_cheat(cheat, keyname) +local function register_keypress_cheat(cheat, keyname, condition) local was_enabled = false core.register_globalstep(function() - if core.settings:get_bool(cheat) then - was_enabled = true + local is_active = core.settings:get_bool(cheat) + local condition_true = (not condition or condition()) + if is_active and condition_true then core.set_keypress(keyname, true) elseif was_enabled then - was_enabled = false core.set_keypress(keyname, false) end + was_enabled = is_active and condition_true end) end -register_keypress_cheat("autosneak", "sneak") +register_keypress_cheat("autosneak", "sneak", function() + return core.localplayer:is_touching_ground() +end) register_keypress_cheat("autosprint", "special1") |