aboutsummaryrefslogtreecommitdiff
path: root/builtin/game
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2019-09-22 22:12:21 +0200
committerGitHub <noreply@github.com>2019-09-22 22:12:21 +0200
commit70f9e1aafa6cd7a2b2d204609cab6cc26539cdb9 (patch)
tree7ae4b3532d6f7aee52b3c2c16628fe82c88775fa /builtin/game
parentfec30e37ac1d160a942777b05a7717b5395c4d99 (diff)
downloadminetest-70f9e1aafa6cd7a2b2d204609cab6cc26539cdb9.tar.gz
minetest-70f9e1aafa6cd7a2b2d204609cab6cc26539cdb9.tar.bz2
minetest-70f9e1aafa6cd7a2b2d204609cab6cc26539cdb9.zip
Punchwear (improved) (#8959)
Diffstat (limited to 'builtin/game')
-rw-r--r--builtin/game/register.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index bed269dbb..bfad6845c 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -256,6 +256,18 @@ function core.register_tool(name, tooldef)
end
-- END Legacy stuff
+ -- This isn't just legacy, but more of a convenience feature
+ local toolcaps = tooldef.tool_capabilities
+ if toolcaps and toolcaps.punch_attack_uses == nil then
+ for _, cap in pairs(toolcaps.groupcaps or {}) do
+ local level = (cap.maxlevel or 0) - 1
+ if (cap.uses or 0) ~= 0 and level >= 0 then
+ toolcaps.punch_attack_uses = cap.uses * (3 ^ level)
+ break
+ end
+ end
+ end
+
core.register_item(name, tooldef)
end