From ca056b9920bfec9232e45593e7e403602198082b Mon Sep 17 00:00:00 2001 From: Wouters Dorian Date: Fri, 31 Jul 2015 15:11:31 +0200 Subject: [PATCH] [ambience] Use minetest.after --- mods/ambience_modpack/ambience/init.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/mods/ambience_modpack/ambience/init.lua b/mods/ambience_modpack/ambience/init.lua index d086f31b..d5a950b1 100755 --- a/mods/ambience_modpack/ambience/init.lua +++ b/mods/ambience_modpack/ambience/init.lua @@ -738,14 +738,8 @@ local stop_sound = function(still_playing, player) end -local timer = 0 -minetest.register_globalstep(function(dtime) - timer = timer+dtime - if timer < 1 then - return - end - timer = 0 - +local function tick() + minetest.after(1, tick) for _,player in ipairs(minetest.get_connected_players()) do ambiences = get_ambience(player) stop_sound(ambiences, player) @@ -773,8 +767,9 @@ minetest.register_globalstep(function(dtime) end end end -end) +end +tick() minetest.register_on_joinplayer(function(player) local player_name = player:get_player_name()