Turn repairable tools to be a function

This commit is contained in:
Jean-Patrick Guerrero 2016-02-15 18:11:28 +01:00
parent e69cf4fcb7
commit 231caefc5a

View File

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