From 7d327def8219f74d51127a739c9cdf8100b82c6d Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 24 Nov 2020 09:48:16 +0100 Subject: Improved AutoSneak --- builtin/client/cheats/movement.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'builtin/client') 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") -- cgit v1.2.3