1
0
mirror of https://codeberg.org/minenux/minetest-mod-xdecor synced 2023-10-20 21:43:39 -07:00

Fix ench. table swapping tool causing unknown bugs

This commit is contained in:
Christian Wischenbart 2015-08-05 02:03:51 +02:00 committed by jp
parent 70f6e97706
commit 958b235d26

View File

@ -16,6 +16,16 @@ local function enchconstruct(pos)
inv:set_size("mese", 1)
end
local function is_allowed_tool(toolname)
local tdef = minetest.registered_tools[toolname]
if tdef and string.find(toolname, "default:") and not
string.find(toolname, "sword") and not
string.find(toolname, "stone") and not
string.find(toolname, "wood") then
return 1
else return 0 end
end
local function enchfields(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -26,7 +36,7 @@ local function enchfields(pos, formname, fields, sender)
local enchs = {"durable", "fast"}
for _, e in pairs(enchs) do
if string.find(toolname, "default:") and mese > 0 and fields[e] then
if is_allowed_tool(toolname) ~= 0 and mese > 0 and fields[e] then
toolstack:replace("xdecor:enchanted_"..string.sub(toolname, 9).."_"..e)
mesestack:take_item()
inv:set_stack("mese", 1, mesestack)
@ -54,13 +64,7 @@ local function enchput(pos, listname, index, stack, player)
else return 0 end
end
if listname == "tool" then
local tdef = minetest.registered_tools[toolname]
if tdef and string.find(toolname, "default:") and not
string.find(toolname, "sword") and not
string.find(toolname, "stone") and not
string.find(toolname, "wood") then
return 1
else return 0 end
return is_allowed_tool(toolname)
end
return count
end