Ench. table : prevent putting tools which can't be enchanted

This commit is contained in:
jp 2015-11-25 12:29:23 +01:00
parent e0a0c607e4
commit 0246054ff8

View File

@ -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