From 0246054ff8213f569ff8a23476c98493409931c9 Mon Sep 17 00:00:00 2001 From: jp Date: Wed, 25 Nov 2015 12:29:23 +0100 Subject: [PATCH] Ench. table : prevent putting tools which can't be enchanted --- enchanting.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/enchanting.lua b/enchanting.lua index 3cef5b3..de88caa 100644 --- a/enchanting.lua +++ b/enchanting.lua @@ -69,12 +69,14 @@ end function enchanting.put(_, listname, _, stack, _) local toolstack = stack:get_name() + local toolname = toolstack:match("[%w_]+:([%w_]+)") local count = stack:get_count() + local enchanted_tool = minetest.serialize(minetest.registered_tools):match("enchanted_"..toolname) - if listname == "mese" and - toolstack ~= "default:mese_crystal" then return 0 - elseif listname == "tool" and not - minetest.registered_tools[toolstack] then return 0 + if listname == "mese" and toolstack ~= "default:mese_crystal" then + return 0 + elseif listname == "tool" and not enchanted_tool then + return 0 end return count end