From 5d4ead886c12b82ffc0a3cff2f010959cb5641b1 Mon Sep 17 00:00:00 2001 From: SFENCE Date: Fri, 26 Mar 2021 19:05:32 +0100 Subject: [PATCH] Add support for craftguide mod recipe registration. --- technic/depends.txt | 1 + technic/machines/register/recipes.lua | 33 +++++++++++++++++++++++++++ technic/mod.conf | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/technic/depends.txt b/technic/depends.txt index 1b76ab3..4657992 100644 --- a/technic/depends.txt +++ b/technic/depends.txt @@ -12,3 +12,4 @@ intllib? unified_inventory? vector_extras? dye? +craftguide? diff --git a/technic/machines/register/recipes.lua b/technic/machines/register/recipes.lua index 921d1c8..77eb039 100644 --- a/technic/machines/register/recipes.lua +++ b/technic/machines/register/recipes.lua @@ -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) diff --git a/technic/mod.conf b/technic/mod.conf index f2cefaa..e0df0aa 100644 --- a/technic/mod.conf +++ b/technic/mod.conf @@ -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