From 60ab2d94f07953e74fc98a33d468328c2adac75b Mon Sep 17 00:00:00 2001 From: DS Date: Tue, 5 Mar 2019 08:17:48 +0100 Subject: [PATCH] Add sounds for falling and attached nodes (#7719) * Add sounds for falling and attached nodes The sound specified in `node_definition.sounds.fall` is used. When a falling node is spawned at a position or an attached node drops, the sound is played at this position. * allow all sorts of soundspecs --- builtin/game/falling.lua | 10 +++++++++- doc/lua_api.txt | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 62b6973a7..df213e304 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -116,7 +116,7 @@ core.register_entity(":__builtin:falling_node", { local meta = core.get_meta(np) meta:from_table(self.meta) end - if def.sounds and def.sounds.place and def.sounds.place.name then + if def.sounds and def.sounds.place then core.sound_play(def.sounds.place, {pos = np}) end end @@ -141,6 +141,11 @@ local function convert_to_falling_node(pos, node) local meta = core.get_meta(pos) local metatable = meta and meta:to_table() or {} + local def = core.registered_nodes[node.name] + if def and def.sounds and def.sounds.fall then + core.sound_play(def.sounds.fall, {pos = pos}) + end + obj:get_luaentity():set_node(node, metatable) core.remove_node(pos) return true @@ -170,6 +175,9 @@ local function drop_attached_node(p) drops = drop_stacks def.preserve_metadata(pos_copy, node_copy, oldmeta, drops) end + if def and def.sounds and def.sounds.fall then + core.sound_play(def.sounds.fall, {pos = p}) + end core.remove_node(p) for _, item in pairs(drops) do local pos = { diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 2edd0d9de..05ea6b4bc 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -6084,6 +6084,7 @@ Used by `minetest.register_node`. dug = , place = , place_failed = , + fall = , }, drop = "",