Skip to content

Commit

Permalink
Convert minetest.sound_play uses to ephemeral
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Feb 5, 2020
1 parent 176ddba commit d3e26db
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion mods/carts/cart_entity.lua
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions mods/default/chests.lua
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion mods/default/functions.lua
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mods/default/item_entity.lua
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion mods/default/torch.lua
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions mods/doors/init.lua
Expand Up @@ -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, {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
5 changes: 3 additions & 2 deletions mods/farming/api.lua
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions mods/fire/init.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions mods/tnt/init.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
})
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d3e26db

Please sign in to comment.