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.
This commit is contained in:
Elias Åström 2021-03-17 17:09:19 +01:00
parent fe770c19a5
commit 4c46eb2b4b

View file

@ -249,7 +249,14 @@ local function get_tool_capabilities(tdef)
if tdef.tool_capabilities then if tdef.tool_capabilities then
return tdef.tool_capabilities return tdef.tool_capabilities
end 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 end
-- Get the groupcaps for a tool. This function returns "groupcaps" table of -- Get the groupcaps for a tool. This function returns "groupcaps" table of