From 9c98105f13e0c93e97c187b8a03c9afd71af4879 Mon Sep 17 00:00:00 2001 From: kaadmy Date: Thu, 17 Dec 2015 14:40:30 -0800 Subject: [PATCH] check ambient sounds every second instead of every frame --- mods/ambiance/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mods/ambiance/init.lua b/mods/ambiance/init.lua index 6d35ff8..c630f12 100644 --- a/mods/ambiance/init.lua +++ b/mods/ambiance/init.lua @@ -54,6 +54,8 @@ local ambiance_volume = tonumber(minetest.setting_get("ambiance_volume")) or 1.0 local soundspec = {} local lastsound = {} +local timer = 0 + local function ambient_node_near(sound, pos) local nodepos = minetest.find_node_near(pos, sound.dist, sound.nodename) if nodepos ~= nil and math.random(1, sound.chance) == 1 then @@ -64,6 +66,12 @@ local function ambient_node_near(sound, pos) local nodepos = minetest.find_nod end local function step(dtime) + timer = timer + dtime + + if timer < 1 then return end + + timer = 0 + local player_positions = {} for _, player in ipairs(minetest.get_connected_players()) do