Make tools without toolcaps do damage as hand

If the tool_capabilities defaults to {} if unspecified the tool, then
users will not be able to attack with the tool at all.  This solves that
by including the damage_group and full_punch_interval from the hand into
the tool_capabilities when it is nil.
master
Elias Åström 2021-03-17 17:09:19 +01:00
parent 6fb56b074f
commit 54563262f6
1 changed files with 8 additions and 1 deletions

View File

@ -249,7 +249,14 @@ local function get_tool_capabilities(tdef)
if tdef.tool_capabilities then
return tdef.tool_capabilities
end
return {}
-- If the damage group and punch interval from hand is not included,
-- then the user will not be able to attack with the tool.
local hand_toolcaps = minetest.registered_tools[""].tool_capabilities
return {
full_punch_interval = hand_toolcaps.full_punch_interval,
damage_groups = hand_toolcaps.damage_groups
}
end
-- Get the groupcaps for a tool. This function returns "groupcaps" table of