From 2da8be9f78c3923297360d22e9b7307cb43d530f Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 16 Mar 2021 11:22:13 +0100 Subject: [PATCH] optimise walkover part2 --- mods/CORE/walkover/init.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/CORE/walkover/init.lua b/mods/CORE/walkover/init.lua index a4f657706..4ef164303 100644 --- a/mods/CORE/walkover/init.lua +++ b/mods/CORE/walkover/init.lua @@ -3,6 +3,7 @@ local get_connected_players = minetest.get_connected_players local get_node = minetest.get_node local vector_add = vector.add +local ceil = math.ceil walkover = {} walkover.registered_globals = {} @@ -31,7 +32,7 @@ minetest.register_globalstep(function(dtime) if timer >= 0.3 then for _,player in ipairs(get_connected_players()) do 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}) if loc ~= nil then @@ -41,8 +42,8 @@ minetest.register_globalstep(function(dtime) if on_walk[nodeiamon.name] then on_walk[nodeiamon.name](loc, nodeiamon, player) end - for _,func in ipairs(registered_globals) do - func(loc, nodeiamon, player) + for i = 1, #registered_globals do + registered_globals[i](loc, nodeiamon, player) end end end