Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eat sound #7956

Merged
merged 1 commit into from Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions builtin/game/item.lua
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions doc/lua_api.txt
Expand Up @@ -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),
Expand Down