Improved AutoSneak

pull/20/head
Elias Fleckenstein 2020-11-24 09:48:16 +01:00
parent 82216e1476
commit 7d327def82
1 changed files with 8 additions and 5 deletions

View File

@ -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")