From 473158dc74ae475c25028c1677929f91b7a7d1b9 Mon Sep 17 00:00:00 2001 From: jp Date: Wed, 29 Jul 2015 16:51:41 +0200 Subject: [PATCH] Only allow put damaged tools in worktable --- worktable.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/worktable.lua b/worktable.lua index 32c50bd..b324d6d 100644 --- a/worktable.lua +++ b/worktable.lua @@ -119,6 +119,17 @@ local function xput(pos, listname, index, stack, player) return 0 end end + if listname == "src" then + local tname = stack:get_name() + local tdef = minetest.registered_tools[tname] + local twear = stack:get_wear() + + if tdef and twear > 0 then + return 1 + else + return 0 + end + end return stack:get_count() end @@ -205,14 +216,11 @@ minetest.register_abm({ -- Repair Tool's code by Krock, modified by kilbith. local wear = src:get_wear() local repair = -1400 - if (src:is_empty() or wear == 0 or wear == 65535) then - return - end + if (src:is_empty() or wear == 0 or wear == 65535) then return end local fuel = inv:get_stack("fuel", 1) if (fuel:is_empty() or fuel:get_name() ~= "xdecor:hammer") then - return - end + return end if (wear + repair < 0) then src:add_wear(repair + wear)