From 109fcba8c210a8e05d6f3960698fbf7b01db0ce4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 6 Sep 2019 11:47:17 +0200 Subject: [PATCH] Check recipe validity --- mods/crafting/api.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mods/crafting/api.lua b/mods/crafting/api.lua index 0cc4111..66351c7 100644 --- a/mods/crafting/api.lua +++ b/mods/crafting/api.lua @@ -44,10 +44,9 @@ function crafting.register_craft(def) local itemstack = ItemStack(def.output) local itemkey = itemstack:to_string() - if crafting.registered_crafts[itemkey] ~= nil then - minetest.log("warning", - "Tried to register an existing craft " .. itemkey .. ", allowing") - end + -- Each output item may only be used once. There can't be 2 recipes with + -- the exact same output + assert(crafting.registered_crafts[itemkey] == nil, "Crafting recipe collision! itemkey="..itemkey.." def="..dump(def)) if not minetest.registered_items[itemstack:get_name()] then minetest.log("warning", @@ -61,7 +60,7 @@ function crafting.register_craft(def) groups = def.groups or crafting.default_craftdef.groups, } - if #craftdef.items > 4 then + if #craftdef.items > crafting.max_inputs then minetest.log("warning", "Attempting to register craft " .. itemkey .." with more than " .. crafting.max_inputs .. " inputs, allowing")