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)
11 was_enabled = is_active and condition_true
15 register_keypress_cheat("autosneak", "sneak", function()
16 return core.localplayer:is_touching_ground()
18 register_keypress_cheat("autosprint", "special1")