Last active
December 14, 2019 10:39
-
-
Save technix/3862c9eeb54cfb822d71fda5d091b269 to your computer and use it in GitHub Desktop.
Minetest jumpdrive mod patch to avoid falling through floor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 4e9c6e5822f884c0d113a06fee5507b274fddc8e Mon Sep 17 00:00:00 2001 | |
From: techniX <[email protected]> | |
Date: Sat, 14 Dec 2019 12:21:55 +0200 | |
Subject: [PATCH] No fall through while jumping: - temporary disable gravity | |
and player movement - re-enable gravity and player movement 3 sec after jump | |
- sometimes player still falls through, so place player into right position 3 | |
sec after jump - disallow jump if gravity is not enabled yet - i.e. | |
immediately after jump | |
--- | |
common.lua | 5 +++++ | |
move.lua | 6 ++++++ | |
2 files changed, 11 insertions(+) | |
diff --git a/common.lua b/common.lua | |
index 924cfec..1946e38 100644 | |
--- a/common.lua | |
+++ b/common.lua | |
@@ -36,6 +36,11 @@ jumpdrive.simulate_jump = function(pos, player, show_marker) | |
return false, "Error: mapgen was active in this area, please try again later for your own safety!" | |
end | |
+ | |
+ if player ~= nil and player:get_physics_override().gravity == 0 then | |
+ return false, "Error: jump is not finished!" | |
+ end | |
+ | |
local meta = minetest.get_meta(pos) | |
local radius = jumpdrive.get_radius(pos) | |
local distance = vector.distance(pos, targetPos) | |
diff --git a/move.lua b/move.lua | |
index be51f36..f773133 100644 | |
--- a/move.lua | |
+++ b/move.lua | |
@@ -107,7 +107,13 @@ jumpdrive.move = function(source_pos1, source_pos2, target_pos1, target_pos2) | |
if xMatch and yMatch and zMatch and player:is_player() then | |
minetest.log("action", "[jumpdrive] moving player: " .. player:get_player_name()) | |
local new_player_pos = vector.add(playerPos, delta_vector) | |
+ local op = player:get_physics_override() | |
+ player:set_physics_override({speed = 0, gravity = 0, jump = 0}) | |
player:set_pos( new_player_pos ); | |
+ minetest.after(3, function(o, pos) | |
+ player:set_physics_override({gravity = o.gravity, jump = o.jump, speed = o.speed}) | |
+ player:set_pos( pos ); | |
+ end, op, new_player_pos) | |
end | |
end | |
-- | |
2.17.1.windows.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment