diff --git a/init.lua b/init.lua index f1c7845..a307ce2 100644 --- a/init.lua +++ b/init.lua @@ -5,24 +5,25 @@ level, max gravity at sea level. ]]-- +local action_timer = 0 +local realgthres=minetest.settings:get('real_g_threshold') or 300 -local update = function() +local gravity_update = function() for _, players in ipairs(minetest.get_connected_players()) do - local pos = player:get_pos() + local pos = players:get_pos() local grav = 1 - if pos.y > 300 then grav = 300/pos.y end - if pos.y < -300 then grav = -300/pos.y end - player:set_physics_override({gravity=grav}) + if pos.y > realgthres then grav = realgthres/pos.y end + if pos.y < (-1)*realgthres then grav = -1*realgthres/pos.y end + players:set_physics_override({gravity=grav}) end end -local action_timer = 0 local function gravity_globaltimer(dtime) action_timer = action_timer + dtime if action_timer > 4 then - update() + gravity_update() action_timer = 0 end end diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..4779f3f --- /dev/null +++ b/mod.conf @@ -0,0 +1,2 @@ +name = real_g +depends = default diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..f79d137 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1 @@ +real_g_threshold (Threshold for activating real_g) int 300