summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHybridDog <ovvv@web.de>2018-08-01 16:41:55 +0200
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-08-01 16:41:55 +0200
commit6492b8ec7650f4f76c9eded84418fe9e9fc6df71 (patch)
treee85a442a59bd08d75847a5e941ab49786ce6f449
parent8186f003beae42c9815b3c9c131e919f5b099035 (diff)
downloadpipeworks-6492b8ec7650f4f76c9eded84418fe9e9fc6df71.tar
pipeworks-6492b8ec7650f4f76c9eded84418fe9e9fc6df71.tar.gz
pipeworks-6492b8ec7650f4f76c9eded84418fe9e9fc6df71.tar.bz2
pipeworks-6492b8ec7650f4f76c9eded84418fe9e9fc6df71.tar.xz
pipeworks-6492b8ec7650f4f76c9eded84418fe9e9fc6df71.zip
Add node breaker sounds (#219)
Also, disallow node breakers to dig unknown nodes and a bit whitespace fix
-rw-r--r--wielder.lua23
1 files changed, 18 insertions, 5 deletions
diff --git a/wielder.lua b/wielder.lua
index 98f1ef0..4a80d3e 100644
--- a/wielder.lua
+++ b/wielder.lua
@@ -331,12 +331,25 @@ if pipeworks.enable_node_breaker then
virtplayer:set_wielded_item(wieldstack)
else
local under_node = minetest.get_node(pointed_thing.under)
- local on_dig = (minetest.registered_nodes[under_node.name] or {on_dig=minetest.node_dig}).on_dig
- -- check that the current tool is capable of destroying the target node.
+ local def = minetest.registered_nodes[under_node.name]
+ if not def then
+ -- do not dig an unknown node
+ return
+ end
+ -- check that the current tool is capable of destroying the
+ -- target node.
-- if we can't, don't dig, and leave the wield stack unchanged.
- -- note that wieldstack:get_tool_capabilities() returns hand properties if the item has none of it's own.
- if can_tool_dig_node(under_node.name, wieldstack:get_tool_capabilities(), wieldstack:get_name()) then
- on_dig(pointed_thing.under, under_node, virtplayer)
+ -- note that wieldstack:get_tool_capabilities() returns hand
+ -- properties if the item has none of it's own.
+ if can_tool_dig_node(under_node.name,
+ wieldstack:get_tool_capabilities(),
+ wieldstack:get_name()) then
+ def.on_dig(pointed_thing.under, under_node, virtplayer)
+ local sound = def.sounds and def.sounds.dug
+ if sound then
+ minetest.sound_play(sound.name,
+ {pos=pointed_thing.under, gain=sound.gain})
+ end
wieldstack = virtplayer:get_wielded_item()
else
--pipeworks.logger(dname.."couldn't dig node!")