Skip to content

Commit

Permalink
Builtin/../item: Enable tool breaking sounds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sofar authored and paramat committed Nov 18, 2016
1 parent afc48c8 commit 4a0a672
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/game/item.lua
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions doc/lua_api.txt
Expand Up @@ -3606,6 +3606,7 @@ Definition tables
actual result to client in a short moment.
]]
sound = {
breaks = "default_tool_break", -- tools only
place = --[[<SimpleSoundSpec>]],
},

Expand Down

0 comments on commit 4a0a672

Please sign in to comment.