Small clean-up on ench./work table
This commit is contained in:
parent
1ba92e60b1
commit
860f520169
@ -21,13 +21,13 @@ local function enchfields(pos, formname, fields, sender)
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local toolstack = inv:get_stack("tool", 1)
|
local toolstack = inv:get_stack("tool", 1)
|
||||||
local mesestack = inv:get_stack("mese", 1)
|
local mesestack = inv:get_stack("mese", 1)
|
||||||
|
local toolname = toolstack:get_name()
|
||||||
|
local mese = mesestack:get_count()
|
||||||
local enchs = {"durable", "fast"}
|
local enchs = {"durable", "fast"}
|
||||||
|
|
||||||
for _, e in pairs(enchs) do
|
for _, e in pairs(enchs) do
|
||||||
if string.find(toolstack:get_name(), "default:") and
|
if string.find(toolname, "default:") and mese > 0 and fields[e] then
|
||||||
mesestack:get_count() > 0 and fields[e] then
|
toolstack:replace("xdecor:enchanted_"..string.sub(toolname, 9).."_"..e)
|
||||||
|
|
||||||
toolstack:replace("xdecor:enchanted_"..string.sub(toolstack:get_name(), 9).."_"..e)
|
|
||||||
mesestack:take_item()
|
mesestack:take_item()
|
||||||
inv:set_stack("mese", 1, mesestack)
|
inv:set_stack("mese", 1, mesestack)
|
||||||
inv:set_stack("tool", 1, toolstack)
|
inv:set_stack("tool", 1, toolstack)
|
||||||
@ -46,28 +46,21 @@ local function enchdig(pos, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function enchput(pos, listname, index, stack, player)
|
local function enchput(pos, listname, index, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local toolname = stack:get_name()
|
||||||
local inv = meta:get_inventory()
|
local count = stack:get_count()
|
||||||
|
|
||||||
if listname == "mese" then
|
if listname == "mese" then
|
||||||
if stack:get_name() == "default:mese_crystal" then
|
if toolname == "default:mese_crystal" then return count
|
||||||
return stack:get_count()
|
else return 0 end
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if listname == "tool" then
|
if listname == "tool" then
|
||||||
local tname = stack:get_name()
|
local tdef = minetest.registered_tools[toolname]
|
||||||
local tdef = minetest.registered_tools[tname]
|
if tdef and not string.find(toolname, "sword") and not
|
||||||
|
string.find(toolname, "stone") and not
|
||||||
if tdef and not string.find(stack:get_name(), "sword") and not
|
string.find(toolname, "wood") then
|
||||||
string.find(stack:get_name(), "stone") and not
|
|
||||||
string.find(stack:get_name(), "wood") then
|
|
||||||
return 1
|
return 1
|
||||||
else return 0 end
|
else return 0 end
|
||||||
end
|
end
|
||||||
|
|
||||||
return stack:get_count()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
xdecor.register("enchantment_table", {
|
xdecor.register("enchantment_table", {
|
||||||
|
@ -89,15 +89,13 @@ local function xdig(pos, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function xput(pos, listname, index, stack, player)
|
local function xput(pos, listname, index, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
local stackname = stack:get_name()
|
local stackname = stack:get_name()
|
||||||
|
local count = stack:get_count()
|
||||||
|
|
||||||
if listname == "output" then return 0 end
|
if listname == "output" then return 0 end
|
||||||
if listname == "input" then
|
if listname == "input" then
|
||||||
if string.find(stack:get_name(), "default:") then
|
if string.find(stackname, "default:") then return count
|
||||||
return stack:get_count()
|
else return 0 end
|
||||||
else return 0 end
|
|
||||||
end
|
end
|
||||||
if listname == "hammer" then
|
if listname == "hammer" then
|
||||||
if not (stackname == "xdecor:hammer") then return 0 end
|
if not (stackname == "xdecor:hammer") then return 0 end
|
||||||
|
Loading…
Reference in New Issue
Block a user