From d3e26dba18bd311e9989cf0cfe06fc41ca4c9b69 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 25 Jan 2020 23:45:09 +0100 Subject: [PATCH] Convert minetest.sound_play uses to ephemeral --- mods/carts/cart_entity.lua | 2 +- mods/default/chests.lua | 7 ++++--- mods/default/functions.lua | 2 +- mods/default/item_entity.lua | 2 +- mods/default/torch.lua | 3 ++- mods/doors/init.lua | 12 ++++++------ mods/farming/api.lua | 5 +++-- mods/fire/init.lua | 8 +++++--- mods/tnt/init.lua | 9 +++++---- 9 files changed, 28 insertions(+), 22 deletions(-) diff --git a/mods/carts/cart_entity.lua b/mods/carts/cart_entity.lua index 3c131a66..02ff6cde 100644 --- a/mods/carts/cart_entity.lua +++ b/mods/carts/cart_entity.lua @@ -414,7 +414,7 @@ minetest.register_craftitem("carts:cart", { end minetest.sound_play({name = "default_place_node_metal", gain = 0.5}, - {pos = pointed_thing.above}) + {pos = pointed_thing.above}, true) if not (creative and creative.is_enabled_for and creative.is_enabled_for(placer:get_player_name())) then diff --git a/mods/default/chests.lua b/mods/default/chests.lua index b401d916..3fe9c1a0 100644 --- a/mods/default/chests.lua +++ b/mods/default/chests.lua @@ -46,7 +46,8 @@ function default.chest.chest_lid_close(pn) local node = minetest.get_node(pos) minetest.after(0.2, minetest.swap_node, pos, { name = "default:" .. swap, param2 = node.param2 }) - minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10}) + minetest.sound_play(sound, {gain = 0.3, pos = pos, + max_hear_distance = 10}, true) end default.chest.open_chests = {} @@ -128,7 +129,7 @@ function default.chest.register_chest(name, d) end minetest.sound_play(def.sound_open, {gain = 0.3, - pos = pos, max_hear_distance = 10}) + pos = pos, max_hear_distance = 10}, true) if not default.chest.chest_lid_obstructed(pos) then minetest.swap_node(pos, { name = "default:" .. name .. "_open", @@ -199,7 +200,7 @@ function default.chest.register_chest(name, d) end def.on_rightclick = function(pos, node, clicker) minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos, - max_hear_distance = 10}) + max_hear_distance = 10}, true) if not default.chest.chest_lid_obstructed(pos) then minetest.swap_node(pos, { name = "default:" .. name .. "_open", diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 18ba561b..f67eadff 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -141,7 +141,7 @@ default.cool_lava = function(pos, node) minetest.set_node(pos, {name = "default:stone"}) end minetest.sound_play("default_cool_lava", - {pos = pos, max_hear_distance = 16, gain = 0.25}) + {pos = pos, max_hear_distance = 16, gain = 0.25}, true) end if minetest.settings:get_bool("enable_lavacooling") ~= false then diff --git a/mods/default/item_entity.lua b/mods/default/item_entity.lua index 2a61f08e..85454365 100644 --- a/mods/default/item_entity.lua +++ b/mods/default/item_entity.lua @@ -20,7 +20,7 @@ local item = { minetest.sound_play("default_item_smoke", { pos = p, max_hear_distance = 8, - }) + }, true) minetest.add_particlespawner({ amount = 3, time = 0.1, diff --git a/mods/default/torch.lua b/mods/default/torch.lua index 85035a5e..bf020148 100644 --- a/mods/default/torch.lua +++ b/mods/default/torch.lua @@ -11,7 +11,8 @@ local function on_flood(pos, oldnode, newnode) nodedef.groups.igniter and nodedef.groups.igniter > 0) then minetest.sound_play( "default_cool_lava", - {pos = pos, max_hear_distance = 16, gain = 0.1} + {pos = pos, max_hear_distance = 16, gain = 0.1}, + true ) end -- Remove the torch node diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 85af0ef8..ee4a188c 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -176,10 +176,10 @@ function doors.door_toggle(pos, node, clicker) if state % 2 == 0 then minetest.sound_play(def.door.sounds[1], - {pos = pos, gain = 0.3, max_hear_distance = 10}) + {pos = pos, gain = 0.3, max_hear_distance = 10}, true) else minetest.sound_play(def.door.sounds[2], - {pos = pos, gain = 0.3, max_hear_distance = 10}) + {pos = pos, gain = 0.3, max_hear_distance = 10}, true) end minetest.swap_node(pos, { @@ -340,7 +340,7 @@ function doors.register(name, def) itemstack:take_item() end - minetest.sound_play(def.sounds.place, {pos = pos}) + minetest.sound_play(def.sounds.place, {pos = pos}, true) on_place_node(pos, minetest.get_node(pos), placer, node, itemstack, pointed_thing) @@ -550,12 +550,12 @@ function doors.trapdoor_toggle(pos, node, clicker) if string.sub(node.name, -5) == "_open" then minetest.sound_play(def.sound_close, - {pos = pos, gain = 0.3, max_hear_distance = 10}) + {pos = pos, gain = 0.3, max_hear_distance = 10}, true) minetest.swap_node(pos, {name = string.sub(node.name, 1, string.len(node.name) - 5), param1 = node.param1, param2 = node.param2}) else minetest.sound_play(def.sound_open, - {pos = pos, gain = 0.3, max_hear_distance = 10}) + {pos = pos, gain = 0.3, max_hear_distance = 10}, true) minetest.swap_node(pos, {name = node.name .. "_open", param1 = node.param1, param2 = node.param2}) end @@ -744,7 +744,7 @@ function doors.register_fencegate(name, def) local node_def = minetest.registered_nodes[node.name] minetest.swap_node(pos, {name = node_def.gate, param2 = node.param2}) minetest.sound_play(node_def.sound, {pos = pos, gain = 0.3, - max_hear_distance = 8}) + max_hear_distance = 8}, true) return itemstack end, selection_box = { diff --git a/mods/farming/api.lua b/mods/farming/api.lua index c2c549e4..4a482fac 100644 --- a/mods/farming/api.lua +++ b/mods/farming/api.lua @@ -59,7 +59,7 @@ farming.hoe_on_use = function(itemstack, user, pointed_thing, uses) minetest.sound_play("default_dig_crumbly", { pos = pt.under, gain = 0.5, - }) + }, true) if not (creative and creative.is_enabled_for and creative.is_enabled_for(user:get_player_name())) then @@ -68,7 +68,8 @@ farming.hoe_on_use = function(itemstack, user, pointed_thing, uses) itemstack:add_wear(65535/(uses-1)) -- tool break sound if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then - minetest.sound_play(wdef.sound.breaks, {pos = pt.above, gain = 0.5}) + minetest.sound_play(wdef.sound.breaks, {pos = pt.above, + gain = 0.5}, true) end end return itemstack diff --git a/mods/fire/init.lua b/mods/fire/init.lua index 3c8a8fcf..c35207e2 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -34,7 +34,7 @@ local function flood_flame(pos, oldnode, newnode) if not (nodedef and nodedef.groups and nodedef.groups.igniter and nodedef.groups.igniter > 0) then minetest.sound_play("fire_extinguish_flame", - {pos = pos, max_hear_distance = 16, gain = 0.15}) + {pos = pos, max_hear_distance = 16, gain = 0.15}, true) end -- Remove the flame return false @@ -127,7 +127,8 @@ minetest.register_tool("fire:flint_and_steel", { local sound_pos = pointed_thing.above or user:get_pos() minetest.sound_play( "fire_flint_and_steel", - {pos = sound_pos, gain = 0.5, max_hear_distance = 8} + {pos = sound_pos, gain = 0.5, max_hear_distance = 8}, + true ) local player_name = user:get_player_name() if pointed_thing.type == "node" then @@ -154,7 +155,8 @@ minetest.register_tool("fire:flint_and_steel", { itemstack:add_wear(1000) -- Tool break sound if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then - minetest.sound_play(wdef.sound.breaks, {pos = sound_pos, gain = 0.5}) + minetest.sound_play(wdef.sound.breaks, {pos = sound_pos, + gain = 0.5}, true) end return itemstack end diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index 0e061fa6..82f0b9be 100644 --- a/mods/tnt/init.lua +++ b/mods/tnt/init.lua @@ -274,7 +274,7 @@ function tnt.burn(pos, nodename) def.on_ignite(pos) elseif minetest.get_item_group(name, "tnt") > 0 then minetest.swap_node(pos, {name = name .. "_burning"}) - minetest.sound_play("tnt_ignite", {pos = pos}) + minetest.sound_play("tnt_ignite", {pos = pos}, true) minetest.get_node_timer(pos):start(1) end end @@ -403,7 +403,7 @@ function tnt.boom(pos, def) end local sound = def.sound or "tnt_explode" minetest.sound_play(sound, {pos = pos, gain = 2.5, - max_hear_distance = math.min(def.radius * 20, 128)}) + max_hear_distance = math.min(def.radius * 20, 128)}, true) local drops, radius = tnt_explode(pos, def.radius, def.ignore_protection, def.ignore_on_blast, owner, def.explode_center) -- append entity drops @@ -541,7 +541,8 @@ minetest.register_node("tnt:gunpowder_burning", { -- unaffected by explosions on_blast = function() end, on_construct = function(pos) - minetest.sound_play("tnt_gunpowder_burning", {pos = pos, gain = 2}) + minetest.sound_play("tnt_gunpowder_burning", {pos = pos, + gain = 2}, true) minetest.get_node_timer(pos):start(1) end, }) @@ -672,7 +673,7 @@ function tnt.register_tnt(def) -- unaffected by explosions on_blast = function() end, on_construct = function(pos) - minetest.sound_play("tnt_ignite", {pos = pos}) + minetest.sound_play("tnt_ignite", {pos = pos}, true) minetest.get_node_timer(pos):start(4) minetest.check_for_falling(pos) end, -- 2.25.1