Delete ABM, add global timer, and adjust gravity
This commit is contained in:
parent
174aec7e0a
commit
6272f4f50a
50
init.lua
50
init.lua
@ -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 pos = player:get_pos()
|
||||
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})
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {
|
||||
"air",
|
||||
"default:stone",
|
||||
"default:dirt",
|
||||
"default:sand",
|
||||
"default:water_source"
|
||||
},
|
||||
neighbors = {
|
||||
"air",
|
||||
"default:stone",
|
||||
"default:dirt",
|
||||
"default:sand",
|
||||
"default:water_source"
|
||||
},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = func
|
||||
})
|
||||
local gravity_timer = 0
|
||||
local action_timer = 0
|
||||
|
||||
local function gravity_globaltimer(dtime)
|
||||
gravity_timer = gravity_timer + dtime
|
||||
action_timer = action_timer + dtime
|
||||
|
||||
if action_timer > 4 then
|
||||
update()
|
||||
action_timer = 0
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_globalstep(gravity_globaltimer)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user