diff options
| author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-14 19:29:33 +0100 | 
|---|---|---|
| committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-14 19:29:33 +0100 | 
| commit | eefcbc1e86409672037b77bb65afaed98721c202 (patch) | |
| tree | 741d12fbab1f841f8827ebb21674a1b008feb6d6 | |
| parent | 47ba12311362e467e9610d8e873b3581074f7b4f (diff) | |
wielder.lua: can_tool_dig_node(): try falling back to hand if inserted tool can't break node
| -rw-r--r-- | wielder.lua | 10 | 
1 files changed, 9 insertions, 1 deletions
| diff --git a/wielder.lua b/wielder.lua index 95be47c..8f2b2a2 100644 --- a/wielder.lua +++ b/wielder.lua @@ -29,7 +29,15 @@ local can_tool_dig_node = function(nodename, toolcaps, toolname)  	-- 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 +	local diggable = minetest.get_dig_params(nodegroups, toolcaps).diggable +	if not diggable then +		-- a pickaxe can't actually dig leaves based on it's groups alone, +		-- but a player holding one can - the game seems to fall back to the hand. +		-- fall back to checking the hand's properties if the tool isn't the correct one. +		local hand_caps = minetest.registered_items[""].tool_capabilities +		diggable = minetest.get_dig_params(nodegroups, hand_caps) +	end +	return diggable  end  local function wielder_on(data, wielder_pos, wielder_node) | 
