Add eat sound (#7956)
authorWuzzy <wuzzy2@mail.ru>
Mon, 10 Dec 2018 08:25:47 +0000 (09:25 +0100)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Mon, 10 Dec 2018 08:25:47 +0000 (09:25 +0100)
builtin/game/item.lua
doc/lua_api.txt

index 9b7569c774de1791d37abe62b8d124d633decb3f..ced28771e37b43c5d3ed137dcd4dfe0b88c7b370 100644 (file)
@@ -469,6 +469,11 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
        if itemstack:take_item() ~= nil then
                user:set_hp(user:get_hp() + hp_change)
 
+               local def = itemstack:get_definition()
+               if def and def.sound and def.sound.eat then
+                       minetest.sound_play(def.sound.eat, { pos = user:get_pos(), max_hear_distance = 16 })
+               end
+
                if replace_with_item then
                        if itemstack:is_empty() then
                                itemstack:add_item(replace_with_item)
index d48e50fde4386e853a014dce7ecf73ef494f9920..523bf8eb175e13f6d39ec55ef66ca6f077e70570 100644 (file)
@@ -5795,6 +5795,7 @@ Used by `minetest.register_node`, `minetest.register_craftitem`, and
         sound = {
             breaks = "default_tool_break",  -- tools only
             place = <SimpleSoundSpec>,
+            eat = <SimpleSoundSpec>,
         },
 
         on_place = func(itemstack, placer, pointed_thing),