Add support for craftguide mod recipe registration.

This commit is contained in:
SFENCE 2021-03-26 19:05:32 +01:00
parent 43acec2900
commit 5d4ead886c
3 changed files with 35 additions and 1 deletions

View File

@ -12,3 +12,4 @@ intllib?
unified_inventory?
vector_extras?
dye?
craftguide?

View File

@ -1,4 +1,5 @@
local have_ui = minetest.get_modpath("unified_inventory")
local have_cg = minetest.get_modpath("craftguide")
technic.recipes = { cooking = { input_size = 1, output_size = 1 } }
function technic.register_recipe_type(typename, origdata)
@ -13,6 +14,13 @@ function technic.register_recipe_type(typename, origdata)
height = 1,
})
end
if have_cg and craftguide.register_craft_type and data.output_size == 1 then
craftguide.register_craft_type(typename, {
description = data.description,
--width = data.input_size,
--height = 1,
})
end
data.recipes = {}
technic.recipes[typename] = data
end
@ -59,6 +67,31 @@ local function register_recipe(typename, data)
width = 0,
})
end
if have_cg and technic.recipes[typename].output_size == 1 then
if craftguide.register_craft then
local result = data.output;
if (type(result)=="table") then
result = result[1];
end
local items = "";
for index, input in pairs(data.input) do
if (items=="") then
items = items..input;
else
items = items..", "..input;
end
end
if (result=="default:bronze_ingot 8") then
minetest.log("warning", dump(data));
minetest.log("warning", items);
end
craftguide.register_craft({
type = typename,
result = result,
items = {items},
})
end
end
end
function technic.register_recipe(typename, data)

View File

@ -1,3 +1,3 @@
name = technic
depends = default, pipeworks, technic_worldgen, basic_materials
optional_depends = bucket, screwdriver, mesecons, mesecons_mvps, digilines, digiline_remote, intllib, unified_inventory, vector_extras, dye
optional_depends = bucket, screwdriver, mesecons, mesecons_mvps, digilines, digiline_remote, intllib, unified_inventory, vector_extras, dye, craftguide