diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-24 13:20:30 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-24 13:20:30 +0100 |
commit | 843239c0bab3dd55c7fb4f52556b5548d28b3c09 (patch) | |
tree | 16d8c566e7d56b33275ae1ab30c792fc1a5525a0 /builtin/client | |
parent | 598e9bdbce675289b00ad3cd544d74f7ad8659cc (diff) | |
download | dragonfireclient-843239c0bab3dd55c7fb4f52556b5548d28b3c09.tar.xz |
Added Speed/Jump/Gravity Override
Diffstat (limited to 'builtin/client')
-rw-r--r-- | builtin/client/cheats/init.lua | 3 | ||||
-rw-r--r-- | builtin/client/cheats/movement.lua | 35 |
2 files changed, 32 insertions, 6 deletions
diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 2307c7aec..69dbac02a 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -19,6 +19,9 @@ core.cheats = { ["NoSlow"] = "no_slow", ["AutoSneak"] = "autosneak", ["AutoSprint"] = "autosprint", + ["SpeedOverride"] = "override_speed", + ["JumpOverride"] = "override_jump", + ["GravityOverride"] = "override_gravity", }, ["Render"] = { ["Xray"] = "xray", diff --git a/builtin/client/cheats/movement.lua b/builtin/client/cheats/movement.lua index 907990cce..33a46fca0 100644 --- a/builtin/client/cheats/movement.lua +++ b/builtin/client/cheats/movement.lua @@ -1,14 +1,13 @@ local function register_keypress_cheat(cheat, keyname, condition) - local was_enabled = false + local was_active = false core.register_globalstep(function() - local is_active = core.settings:get_bool(cheat) - local condition_true = (not condition or condition()) - if is_active and condition_true then + local is_active = core.settings:get_bool(cheat) and (not condition or condition()) + if is_active then core.set_keypress(keyname, true) - elseif was_enabled then + elseif was_active then core.set_keypress(keyname, false) end - was_enabled = is_active and condition_true + was_active = is_active end) end @@ -16,3 +15,27 @@ register_keypress_cheat("autosneak", "sneak", function() return core.localplayer:is_touching_ground() end) register_keypress_cheat("autosprint", "special1") + +local legit_override + +local function get_override_factor(name) + if core.settings:get_bool("override_" .. name) then + return tonumber(core.settings:get("override_" .. name .. "_factor")) or 1 + else + return 1.0 + end +end + +core.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") + core.localplayer:set_physics_override(override) +end) + +core.register_on_recieve_physics_override(function(override) + legit_override = override + return true +end) |