cron f934733623 Merge Dragonfire
Replicate the following commit (with cherry-picked parents on left
side):

    commit be80a15bad718285fd2f24ff1fa88821e35f9388
    Merge: be8e8b906 33a69f694
    Author:     cron <example@example.local>
    AuthorDate: Wed Dec 9 20:36:09 2020 +0000
    Commit:     cron <example@example.local>
    CommitDate: Wed Dec 9 20:36:09 2020 +0000

	Merge Dragonfire
	Dragonfire commit: 56d536ea5e1f98c760d7c78a4584df043fb7f0f8
2021-08-28 23:21:04 -05:00

45 lines
1.4 KiB
Lua

local function register_keypress_cheat(cheat, keyname, condition)
local was_active = false
minetest.register_globalstep(function()
local is_active = minetest.settings:get_bool(cheat) and (not condition or condition())
if is_active then
minetest.set_keypress(keyname, true)
elseif was_active then
minetest.set_keypress(keyname, false)
end
was_active = is_active
end)
end
register_keypress_cheat("autosneak", "sneak", function()
return minetest.localplayer:is_touching_ground()
end)
register_keypress_cheat("autosprint", "special1")
local legit_override
local function get_override_factor(name)
if minetest.settings:get_bool("override_" .. name) then
return tonumber(minetest.settings:get("override_" .. name .. "_factor")) or 1
else
return 1.0
end
end
minetest.register_globalstep(function()
if not legit_override then return end
local override = table.copy(legit_override)
override.speed = override.speed * get_override_factor("speed")
override.jump = override.jump * get_override_factor("jump")
override.gravity = override.gravity * get_override_factor("gravity")
minetest.localplayer:set_physics_override(override)
end)
minetest.register_on_recieve_physics_override(function(override)
legit_override = override
return true
end)
minetest.register_cheat("AutoSneak", "Movement", "autosneak")
minetest.register_cheat("AutoSprint", "Movement", "autosprint")