From de9d430b2300ca6f33de6e457ca167f99f277e28 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 25 May 2022 10:43:51 +0200 Subject: [PATCH] Furnace: Clean fire sound IDs after a few seconds --- mods/default/furnace.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mods/default/furnace.lua b/mods/default/furnace.lua index 30d09440..f8b097c1 100644 --- a/mods/default/furnace.lua +++ b/mods/default/furnace.lua @@ -99,7 +99,7 @@ local function stop_furnace_sound(pos, fadeout_step) local sound_ids = furnace_fire_sounds[hash] if sound_ids then for _, sound_id in ipairs(sound_ids) do - minetest.sound_fade(sound_ids, -1, 0) + minetest.sound_fade(sound_id, -1, 0) end furnace_fire_sounds[hash] = nil end @@ -276,6 +276,21 @@ local function furnace_node_timer(pos, elapsed) if #furnace_fire_sounds[hash] > 3 then table.remove(furnace_fire_sounds[hash], 1) end + -- Remove the sound ID automatically from table after 11 seconds + minetest.after(11, function(t) + if not furnace_fire_sounds[t.hash] then + return + end + for f=#furnace_fire_sounds[t.hash], 1, -1 do + if furnace_fire_sounds[t.hash][f] == t.sound_id then + minetest.log("error", "remove_after:"..t.sound_id) + table.remove(furnace_fire_sounds[t.hash], f) + end + end + if #furnace_fire_sounds[t.hash] == 0 then + furnace_fire_sounds[t.hash] = nil + end + end, {sound_id=sound_id, hash=hash}) end else if fuellist and not fuellist[1]:is_empty() then