1
0
Fork 0

optimise walkover part2

objects
AFCMS 2021-03-16 11:22:13 +01:00
parent 71bb18cd76
commit 2da8be9f78
1 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@
local get_connected_players = minetest.get_connected_players local get_connected_players = minetest.get_connected_players
local get_node = minetest.get_node local get_node = minetest.get_node
local vector_add = vector.add local vector_add = vector.add
local ceil = math.ceil
walkover = {} walkover = {}
walkover.registered_globals = {} walkover.registered_globals = {}
@ -31,7 +32,7 @@ minetest.register_globalstep(function(dtime)
if timer >= 0.3 then if timer >= 0.3 then
for _,player in ipairs(get_connected_players()) do for _,player in ipairs(get_connected_players()) do
local pp = player:get_pos() local pp = player:get_pos()
pp.y = math.ceil(pp.y) pp.y = ceil(pp.y)
local loc = vector_add(pp, {x=0,y=-1,z=0}) local loc = vector_add(pp, {x=0,y=-1,z=0})
if loc ~= nil then if loc ~= nil then
@ -41,8 +42,8 @@ minetest.register_globalstep(function(dtime)
if on_walk[nodeiamon.name] then if on_walk[nodeiamon.name] then
on_walk[nodeiamon.name](loc, nodeiamon, player) on_walk[nodeiamon.name](loc, nodeiamon, player)
end end
for _,func in ipairs(registered_globals) do for i = 1, #registered_globals do
func(loc, nodeiamon, player) registered_globals[i](loc, nodeiamon, player)
end end
end end
end end