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
|
|
|
|
2021-03-03 17:49:49 +01:00
|
|
|
if minetest.get_modpath("technic") then
|
|
|
|
for recipe_type, entry in pairs(technic.recipes) do
|
|
|
|
if entry.recipes then
|
2021-03-03 20:02:59 +01:00
|
|
|
for _, recipe in pairs(entry.recipes) do
|
|
|
|
local result_stack = ItemStack(recipe.output)
|
|
|
|
local outputname = result_stack:get_name()
|
|
|
|
|
|
|
|
local existing_recipes = data[outputname]
|
2021-03-03 17:49:49 +01:00
|
|
|
if not existing_recipes then
|
|
|
|
existing_recipes = {}
|
|
|
|
end
|
2021-03-03 17:47:02 +01:00
|
|
|
|
2021-03-03 17:49:49 +01:00
|
|
|
table.insert(existing_recipes, {
|
|
|
|
type = recipe_type,
|
|
|
|
method = recipe_type,
|
|
|
|
items = recipe.input,
|
|
|
|
output = recipe.output,
|
|
|
|
time = recipe.time
|
|
|
|
})
|
2021-03-03 17:47:02 +01:00
|
|
|
|
2021-03-03 20:02:59 +01:00
|
|
|
data[outputname] = existing_recipes
|
2021-03-03 17:49:49 +01:00
|
|
|
end
|
2021-03-03 17:47:02 +01:00
|
|
|
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
|