2020-05-22 18:13:22 -04:00
|
|
|
--[[
|
2020-06-21 13:28:17 -05:00
|
|
|
Copyright (C) 2020 squiddible and contributors
|
|
|
|
This project is licensed under the MIT license.
|
|
|
|
|
|
|
|
See https://mit-license.org/ for more information.
|
|
|
|
|
|
|
|
--------------------------------------------------
|
2020-05-02 16:32:54 -04:00
|
|
|
|
2020-05-22 18:13:22 -04:00
|
|
|
Lowers gravity the higher (and lower) you get above (or below) sea
|
|
|
|
level, max gravity at sea level.
|
|
|
|
]]--
|
|
|
|
|
2020-06-18 13:52:21 +02:00
|
|
|
local action_timer = 0
|
|
|
|
local realgthres=minetest.settings:get('real_g_threshold') or 300
|
2020-05-22 18:13:22 -04:00
|
|
|
|
2020-06-18 13:52:21 +02:00
|
|
|
local gravity_update = function()
|
2020-05-22 18:13:22 -04:00
|
|
|
for _, players in ipairs(minetest.get_connected_players()) do
|
2020-06-18 13:52:21 +02:00
|
|
|
local pos = players:get_pos()
|
2020-05-22 18:13:22 -04:00
|
|
|
local grav = 1
|
2020-06-18 16:56:55 +02:00
|
|
|
if abs(pos.y) > realgthres then grav = abs(realgthres/pos.y) end
|
2020-06-18 13:52:21 +02:00
|
|
|
players:set_physics_override({gravity=grav})
|
2020-05-22 18:13:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function gravity_globaltimer(dtime)
|
|
|
|
action_timer = action_timer + dtime
|
|
|
|
|
|
|
|
if action_timer > 4 then
|
2020-06-18 13:52:21 +02:00
|
|
|
gravity_update()
|
2020-05-22 18:13:22 -04:00
|
|
|
action_timer = 0
|
|
|
|
end
|
2020-05-02 16:32:54 -04:00
|
|
|
end
|
|
|
|
|
2020-05-22 18:13:22 -04:00
|
|
|
minetest.register_globalstep(gravity_globaltimer)
|