mtinfo/recipes.lua

59 lines
1.4 KiB
Lua
Raw Normal View History

2020-01-06 13:31:18 +01:00
2021-02-10 07:54:51 +01:00
function mtinfo.export_recipes()
2021-02-11 11:25:18 +01:00
local data = {}
2020-01-06 13:31:18 +01:00
2021-02-11 11:25:18 +01:00
for name in pairs(minetest.registered_items) do
local recipes = minetest.get_all_craft_recipes(name)
local export_recipes = {}
if recipes then
for _, recipe in ipairs(recipes) do
local export_recipe = true
for _, item in ipairs(recipe.items) do
local is_group = item and string.sub(item, 6) == "group:"
if not is_group then
-- check not_in_creative_inventory group of item def
local itemdef = minetest.registered_items[item]
if itemdef and itemdef.groups and itemdef.groups.not_in_creative_inventory then
export_recipe = false
end
end
end
if export_recipe then
-- filter out moreblocks/stairs recipes (if the ingredient is not exported)
table.insert(export_recipes, recipe)
end
data[name] = export_recipes
end
end
end
2021-03-03 17:47:02 +01:00
for recipe_type, entry in pairs(technic.recipes) do
if entry.recipes then
for name, recipe in pairs(entry.recipes) do
local existing_recipes = data[name]
if not existing_recipes then
existing_recipes = {}
end
table.insert(existing_recipes, {
type = recipe_type,
method = recipe_type,
items = recipe.input,
output = recipe.output,
time = recipe.time
})
data[name] = existing_recipes
end
end
end
2021-02-11 11:25:18 +01:00
mtinfo.export_json(mtinfo.basepath.."/data/recipes.js", data, "mtinfo.recipes")
2020-01-06 13:31:18 +01:00
2021-01-16 21:03:43 +01:00
end