Delete ABM, add global timer, and adjust gravity

This commit is contained in:
squiddible 2020-05-22 18:13:22 -04:00 committed by GitHub
parent 174aec7e0a
commit 6272f4f50a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,28 +1,34 @@
local func = function() --[[
Lowers gravity the higher (and lower) you get above (or below) sea
level, max gravity at sea level.
]]--
local update = function()
for _, players in ipairs(minetest.get_connected_players()) do
local player = minetest.get_player_by_name("singleplayer") local player = minetest.get_player_by_name("singleplayer")
local pos = player:get_pos() local pos = player:get_pos()
local grav = 1 local grav = 1
if pos.y > 10 then grav = 10/pos.y end 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}) player:set_physics_override({gravity=grav})
end
end end
minetest.register_abm({ local gravity_timer = 0
nodenames = { local action_timer = 0
"air",
"default:stone", local function gravity_globaltimer(dtime)
"default:dirt", gravity_timer = gravity_timer + dtime
"default:sand", action_timer = action_timer + dtime
"default:water_source"
}, if action_timer > 4 then
neighbors = { update()
"air", action_timer = 0
"default:stone", end
"default:dirt", end
"default:sand",
"default:water_source" minetest.register_globalstep(gravity_globaltimer)
},
interval = 1,
chance = 1,
action = func
})