mirror of
https://github.com/minetest/minetest.git
synced 2024-12-24 23:22:24 +01:00
Add eat sound (#7956)
This commit is contained in:
parent
98a72b9d45
commit
5560ec8178
@ -469,6 +469,11 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
|
|||||||
if itemstack:take_item() ~= nil then
|
if itemstack:take_item() ~= nil then
|
||||||
user:set_hp(user:get_hp() + hp_change)
|
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 replace_with_item then
|
||||||
if itemstack:is_empty() then
|
if itemstack:is_empty() then
|
||||||
itemstack:add_item(replace_with_item)
|
itemstack:add_item(replace_with_item)
|
||||||
|
@ -5795,6 +5795,7 @@ Used by `minetest.register_node`, `minetest.register_craftitem`, and
|
|||||||
sound = {
|
sound = {
|
||||||
breaks = "default_tool_break", -- tools only
|
breaks = "default_tool_break", -- tools only
|
||||||
place = <SimpleSoundSpec>,
|
place = <SimpleSoundSpec>,
|
||||||
|
eat = <SimpleSoundSpec>,
|
||||||
},
|
},
|
||||||
|
|
||||||
on_place = func(itemstack, placer, pointed_thing),
|
on_place = func(itemstack, placer, pointed_thing),
|
||||||
|
Loading…
Reference in New Issue
Block a user