summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-14 19:04:51 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-14 19:04:51 +0100
commit4915b2564f948c45e3fa994e80cf11c5a609a878 (patch)
tree6633742309a4fec8f1ba3d0b674f593f3fd0bc2e
parentf8cb55a60eada4e521954e0dab4177854ee7e389 (diff)
downloadpipeworks-4915b2564f948c45e3fa994e80cf11c5a609a878.tar
pipeworks-4915b2564f948c45e3fa994e80cf11c5a609a878.tar.gz
pipeworks-4915b2564f948c45e3fa994e80cf11c5a609a878.tar.bz2
pipeworks-4915b2564f948c45e3fa994e80cf11c5a609a878.tar.xz
pipeworks-4915b2564f948c45e3fa994e80cf11c5a609a878.zip
wielder.lua: properly implement can_tool_dig_node()
-rw-r--r--wielder.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/wielder.lua b/wielder.lua
index d1a1822..ed1ee42 100644
--- a/wielder.lua
+++ b/wielder.lua
@@ -20,8 +20,16 @@ local function set_wielder_formspec(data, meta)
end
local can_tool_dig_node = function(nodename, toolcaps, toolname)
- pipeworks.logger("can_tool_dig_node() STUB nodename="..tostring(nodename).." toolname="..tostring(toolname).." toolcaps: "..dump(toolcaps))
- return true
+ --pipeworks.logger("can_tool_dig_node() STUB nodename="..tostring(nodename).." toolname="..tostring(toolname).." toolcaps: "..dump(toolcaps))
+ -- brief documentation of minetest.get_dig_params() as it's not yet documented in lua_api.txt:
+ -- takes two arguments, a node's block groups and a tool's capabilities,
+ -- both as they appear in their respective definitions.
+ -- returns a table with the following fields:
+ -- diggable: boolean, can this tool dig this node at all
+ -- time: float, time needed to dig with this tool
+ -- wear: int, number of wear points to inflict on the item
+ local nodegroups = minetest.registered_nodes[nodename].groups
+ return minetest.get_dig_params(nodegroups, toolcaps).diggable
end
local function wielder_on(data, wielder_pos, wielder_node)
@@ -368,6 +376,8 @@ if pipeworks.enable_node_breaker then
if can_tool_dig_node(under_node.name, wieldstack:get_tool_capabilities(), wieldstack:get_name()) then
on_dig(pointed_thing.under, under_node, virtplayer)
wieldstack = virtplayer:get_wielded_item()
+ else
+ --pipeworks.logger(dname.."couldn't dig node!")
end
end
local wieldname = wieldstack:get_name()