techage/recipe_checker.lua

40 lines
993 B
Lua
Raw Normal View History

2019-06-15 17:14:46 +03:00
--
-- Script to check recipe overlaps
--
local Recipes = {}
2022-08-03 23:19:46 +03:00
2019-06-15 17:14:46 +03:00
local function recipe_key(items)
local tbl = {}
for idx = 1,9 do
tbl[#tbl + 1] = items[idx] or "#"
end
return table.concat(tbl, "-")
end
minetest.after(1, function()
for name,_ in pairs(minetest.registered_items) do
local mod = string.split(name, ":")[1]
if mod == "techage" or mod == "signs_bot" or mod == "vm16" or mod == "beduino" then
2019-06-15 17:14:46 +03:00
local recipes = minetest.get_all_craft_recipes(name)
if recipes then
for _,recipe in ipairs(recipes) do
if recipe and recipe.items then
--print(dump(recipe.items))
local key = recipe_key(recipe.items)
if Recipes[key] then
2021-05-18 22:41:55 +03:00
if not string.find(name, "slab") and not string.find(name, "stair") then
local text = Recipes[key].." and "..name.." have the same incredients"
minetest.log("error", text)
end
2019-06-15 17:14:46 +03:00
end
Recipes[key] = name
end
2022-01-03 23:40:31 +03:00
end
2019-06-15 17:14:46 +03:00
end
end
end
end)
2022-08-03 23:19:46 +03:00
print ("[techage] Recipe checker loaded")