From 4a0a6723afc5c5a14acd7cd833aea33cb53ac618 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 22 Jan 2016 21:52:50 -0800 Subject: 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. --- builtin/game/item.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin/game') diff --git a/builtin/game/item.lua b/builtin/game/item.lua index ec996292f..a2fdbc1f4 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -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) -- cgit v1.2.3