1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-22 07:38:48 -05:00

Builtin/../item: Enable tool breaking sounds

If a tool wears out and is destroyed, it's itemstack count
goes to 0, and we can optionally play a breaking sound.

This patch implements playing a breaking sound when this
occurs. Sounds need to be added to the tool itemdef
registration as the sound name string in the .sound.breaks
member.
This commit is contained in:
Auke Kok 2016-01-22 21:52:50 -08:00 committed by paramat
parent afc48c802a
commit 4a0a6723af
2 changed files with 4 additions and 0 deletions

View File

@ -474,6 +474,9 @@ function core.node_dig(pos, node, digger)
-- Wear out tool
if not core.setting_getbool("creative_mode") then
wielded:add_wear(dp.wear)
if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
core.sound_play(wdef.sound.breaks, {pos = pos, gain = 1.0})
end
end
end
digger:set_wielded_item(wielded)

View File

@ -3606,6 +3606,7 @@ Definition tables
actual result to client in a short moment.
]]
sound = {
breaks = "default_tool_break", -- tools only
place = --[[<SimpleSoundSpec>]],
},