From 598a344d977562e5f2d34c6f4600f956c41fd984 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 22 Sep 2019 22:12:21 +0200 Subject: [PATCH] Punchwear (improved) (#8959) --- builtin/game/register.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/builtin/game/register.lua b/builtin/game/register.lua index bed269d..bfad684 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