Sounds: Add falling node sounds
authorAuke Kok <sofar@foo-projects.org>
Thu, 9 Nov 2017 06:40:59 +0000 (22:40 -0800)
committerparamat <mat.gregory@virginmedia.com>
Tue, 14 Nov 2017 00:37:31 +0000 (00:37 +0000)
Falling nodes should make a sound. This can only be done here,
so for simplicity we just call the sound_play() here with the node
place sound. We ignore any gain value in the sound spec since a
falling node should be loud, so the 1.0 default gain makes sense
here.

builtin/game/falling.lua

index a553400f0a0c550e50f42eb0de375f83287d5ad1..1876cf2a89c49af3cc71183b65bb03c5eaa8257f 100644 (file)
@@ -104,12 +104,16 @@ core.register_entity(":__builtin:falling_node", {
                                end
                        end
                        -- Create node and remove entity
-                       if core.registered_nodes[self.node.name] then
+                       local def = core.registered_nodes[self.node.name]
+                       if def then
                                core.add_node(np, self.node)
                                if self.meta then
                                        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
+                                       core.sound_play(def.sounds.place, {pos = np})
+                               end
                        end
                        self.object:remove()
                        core.check_for_falling(np)