]> git.lizzy.rs Git - xdecor.git/commitdiff
Turn repairable tools to be a function
authorJean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com>
Mon, 15 Feb 2016 17:11:28 +0000 (18:11 +0100)
committerJean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com>
Mon, 15 Feb 2016 17:11:28 +0000 (18:11 +0100)
workbench.lua

index 53d4da52ac3a0fa22ed366746843d25e1495874e..781498855aa3db783aba80de8916f2a31b6f1b78 100644 (file)
@@ -38,9 +38,10 @@ workbench.defs = {
 }
 
 -- Tools allowed to be repaired.
-workbench.repairable_tools = [[
-       pick, axe, shovel, sword, hoe, armor, shield
-]]
+function workbench:repairable_tools(stack)
+       local tools = [[ pick, axe, shovel, sword, hoe, armor, shield ]]
+       return tools:find(stack:match(":(%w+)"))
+end
 
 function workbench:get_output(inv, input, name)
        if inv:is_empty("input") then
@@ -141,8 +142,7 @@ end
 
 function workbench.put(_, listname, _, stack)
        local stackname = stack:get_name()
-       if (listname == "tool" and stack:get_wear() > 0 and
-                       workbench.repairable_tools:find(stackname:match(":(%w+)"))) or
+       if (listname == "tool" and stack:get_wear() > 0 and workbench:repairable_tools(stackname)) or
                        (listname == "input" and minetest.registered_nodes[stackname.."_cube"]) or
                        (listname == "hammer" and stackname == "xdecor:hammer") or
                        listname == "storage" then