fix fly upwards (#7)

This commit is contained in:
Niklp 2023-03-24 14:55:35 +01:00 committed by GitHub
parent 3c2618437a
commit fd357093e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,6 +120,10 @@ local has_player_monoids = minetest.get_modpath("player_monoids")
local physics_attrs = {"jump", "speed", "gravity"} local physics_attrs = {"jump", "speed", "gravity"}
local function apply_physics_override(player, overrides) local function apply_physics_override(player, overrides)
-- prevent flys to the world border
if overrides.gravity and overrides.gravity < 0 then
overrides.gravity = 0
end
if has_player_monoids then if has_player_monoids then
for _, attr in pairs(physics_attrs) do for _, attr in pairs(physics_attrs) do
if overrides[attr] then if overrides[attr] then
@ -174,7 +178,7 @@ minetest.register_entity("hangglider:glider", {
end end
if debug then if debug then
player:hud_change(hangglider.debug[pname].id, "text", step_v..', '.. player:hud_change(hangglider.debug[pname].id, "text", step_v..', '..
player:get_physics_override().gravity..', '..tostring(hangglider.airbreak[pname])) player:get_physics_override().gravity)
end end
apply_physics_override(player, {gravity = ((step_v + 3)/20)}) apply_physics_override(player, {gravity = ((step_v + 3)/20)})
end end