forked from Mirrorlandia_minetest/minetest
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
This commit is contained in:
parent
ee698770b9
commit
60ab2d94f0
@ -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 = {
|
||||
|
@ -6084,6 +6084,7 @@ Used by `minetest.register_node`.
|
||||
dug = <SimpleSoundSpec>,
|
||||
place = <SimpleSoundSpec>,
|
||||
place_failed = <SimpleSoundSpec>,
|
||||
fall = <SimpleSoundSpec>,
|
||||
},
|
||||
|
||||
drop = "",
|
||||
|
Loading…
Reference in New Issue
Block a user