From b77661ce9d02a9ba7eefe0193af2d36151d66d7e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 18 Jun 2020 13:52:21 +0200 Subject: [PATCH] typo for variable player(s); adding settingtypes --- init.lua | 15 ++++++++------- mod.conf | 2 ++ settingtypes.txt | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 mod.conf create mode 100644 settingtypes.txt 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