From 1087e0c6457fdb3e9f025b80c01eb7b9fef01bcc Mon Sep 17 00:00:00 2001 From: James David Clarke Date: Wed, 27 Dec 2023 02:43:48 +0000 Subject: [PATCH] Added MCL CraftGuide for Machine recipes --- technic/init.lua | 2 + .../machines/register/centrifuge_recipes.lua | 16 +- .../machines/register/compressor_recipes.lua | 15 +- .../machines/register/extractor_recipes.lua | 25 +-- technic/machines/register/freezer_recipes.lua | 9 +- technic/machines/register/grinder_recipes.lua | 49 ++---- technic/mcl_craftguide.lua | 154 ++++++++++++++++++ technic/mod.conf | 2 +- 8 files changed, 178 insertions(+), 94 deletions(-) create mode 100644 technic/mcl_craftguide.lua diff --git a/technic/init.lua b/technic/init.lua index 3a38b4f..816a15a 100644 --- a/technic/init.lua +++ b/technic/init.lua @@ -47,6 +47,8 @@ dofile(modpath.."/config.lua") -- MineClone2 Support dofile(modpath.."/mcl_support.lua") +dofile(modpath.."/mcl_craftguide.lua") + -- Helper functions dofile(modpath.."/helpers.lua") diff --git a/technic/machines/register/centrifuge_recipes.lua b/technic/machines/register/centrifuge_recipes.lua index e9dd265..f969c57 100644 --- a/technic/machines/register/centrifuge_recipes.lua +++ b/technic/machines/register/centrifuge_recipes.lua @@ -10,31 +10,23 @@ function technic.register_separating_recipe(data) technic.register_recipe("separating", data) end -local recipes = { - { "technic:bronze_dust 8", "technic:copper_dust 7", "technic:tin_dust" }, - { "technic:stainless_steel_dust 5", "technic:wrought_iron_dust 4", "technic:chromium_dust" }, - { "technic:brass_dust 3", "technic:copper_dust 2", "technic:zinc_dust" }, - { "technic:chernobylite_dust", sand_ingrediant, "technic:uranium3_dust" }, - { dirt_ingrediant.." 4", sand_ingrediant, gravel_ingrediant, "default:clay_lump 2" }, -} - local function uranium_dust(p) return "technic:uranium"..(p == 7 and "" or p).."_dust" end for p = 1, 34 do - table.insert(recipes, { uranium_dust(p).." 2", uranium_dust(p-1), uranium_dust(p+1) }) + table.insert(centrifuge_recipes, { uranium_dust(p).." 2", uranium_dust(p-1), uranium_dust(p+1) }) end if minetest.get_modpath("bushes_classic") then for _, berry in ipairs({ "blackberry", "blueberry", "gooseberry", "raspberry", "strawberry" }) do - table.insert(recipes, { "bushes:"..berry.."_bush", "default:stick 20", "bushes:"..berry.." 4" }) + table.insert(centrifuge_recipes, { "bushes:"..berry.."_bush", "default:stick 20", "bushes:"..berry.." 4" }) end end if minetest.get_modpath("farming") then - table.insert(recipes, { "farming:wheat 4", "farming:seed_wheat 3", "default:dry_shrub 1" }) + table.insert(centrifuge_recipes, { "farming:wheat 4", "farming:seed_wheat 3", "default:dry_shrub 1" }) end -for _, data in pairs(recipes) do +for _, data in pairs(centrifuge_recipes) do technic.register_separating_recipe({ input = { data[1] }, output = { data[2], data[3], data[4] } }) end diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 264abe2..3436983 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -8,19 +8,8 @@ function technic.register_compressor_recipe(data) technic.register_recipe("compressing", data) end -local recipes = { - {snow_block_ingrediant, ice_block_ingrediant}, - {sand_ingrediant.." 2", sandstone_ingrediant}, - {desert_sand_ingrediant.." 2", desert_stone_ingrediant}, - {desert_sand_ingrediant, desert_stone_ingrediant}, - {"technic:mixed_metal_ingot", "technic:composite_plate"}, - {copper_ingrediant.." 5", "technic:copper_plate"}, - {"technic:coal_dust 4", "technic:graphite"}, - {"technic:carbon_cloth", "technic:carbon_plate"}, - {"technic:uranium35_ingot 5", "technic:uranium_fuel"}, -} if minetest.get_modpath("default") then -table.insert(recipes, {"default:silver_sand 2", "default:silver_sandstone"}) +table.insert(compressor_recipes, {"default:silver_sand 2", "default:silver_sandstone"}) end -- defuse the default sandstone recipe, since we have the compressor to take over in a more realistic manner minetest.clear_craft({ @@ -42,7 +31,7 @@ minetest.clear_craft({ }, }) -for _, data in pairs(recipes) do +for _, data in pairs(compressor_recipes) do technic.register_compressor_recipe({input = {data[1]}, output = data[2]}) end diff --git a/technic/machines/register/extractor_recipes.lua b/technic/machines/register/extractor_recipes.lua index 6885750..cc95153 100644 --- a/technic/machines/register/extractor_recipes.lua +++ b/technic/machines/register/extractor_recipes.lua @@ -8,32 +8,11 @@ function technic.register_extractor_recipe(data) technic.register_recipe("extracting", data) end -if minetest.get_modpath("dye") then +if minetest.get_modpath("dye") or minetest.get_modpath("mcl_dye") then -- check if we are using dye or unifieddyes local unifieddyes = minetest.get_modpath("unifieddyes") - - -- register recipes with the same crafting ratios as `dye` provides - - local dye_recipes = { - {"technic:coal_dust", dye_black .. " 2"}, - {blueberries_ingredient, dye_violet .. " 2"}, - {grass_ingredient, dye_green .. " 1"}, - {dry_shrub_ingredient, dye_brown .. " 1"}, - {junglegrass_ingredient, dye_green .. " 2"}, - {cactus_ingredient, dye_green .. " 4"}, - {geranium_ingredient, dye_blue .. " 4"}, - {dandelion_white_ingredient, dye_white .. " 4"}, - {dandelion_yellow_ingredient, dye_yellow .. " 4"}, - {tulip_ingredient, dye_orange .. " 4"}, - {rose_ingredient, dye_red .. " 4"}, - {viola_ingredient, dye_violet .. " 4"}, - {blackberry_ingredient, unifieddyes and "unifieddyes:magenta_s50 4" or dye_violet .. " 4"}, - {blueberry_ingredient, unifieddyes and "unifieddyes:magenta_s50 4" or ""}, - } - - - for _, data in ipairs(dye_recipes) do + for _, data in ipairs(extractor_recipes) do technic.register_extractor_recipe({input = {data[1]}, output = data[2]}) end diff --git a/technic/machines/register/freezer_recipes.lua b/technic/machines/register/freezer_recipes.lua index 59d6166..9a10c65 100644 --- a/technic/machines/register/freezer_recipes.lua +++ b/technic/machines/register/freezer_recipes.lua @@ -8,14 +8,7 @@ function technic.register_freezer_recipe(data) technic.register_recipe("freezing", data) end -local recipes = { - {water_bucket_ingrediant, { ice_block_ingrediant, emtpy_bucket_ingrediant } }, - {bucket_river_water_ingrediant, { ice_block_ingrediant, emtpy_bucket_ingrediant } }, - {dirt_ingrediant , dirt_with_snow_ingrediant }, - {bucket_lava_ingrediant, { obsidian_ingrediant, emtpy_bucket_ingrediant } } -} - -for _, data in pairs(recipes) do +for _, data in pairs(freezer_recipes) do technic.register_freezer_recipe({input = {data[1]}, output = data[2]}) end diff --git a/technic/machines/register/grinder_recipes.lua b/technic/machines/register/grinder_recipes.lua index 8087cd7..a99ca37 100644 --- a/technic/machines/register/grinder_recipes.lua +++ b/technic/machines/register/grinder_recipes.lua @@ -8,35 +8,10 @@ function technic.register_grinder_recipe(data) technic.register_recipe("grinding", data) end -local recipes = { - -- Dusts - {coal_ingrediant, "technic:coal_dust 2"}, - {copper_lump_ingrediant, "technic:copper_dust 2"}, - {desert_stone_ingrediant, desert_sand_ingrediant}, - {gold_lump_ingrediant, "technic:gold_dust 2"}, - {iron_lump_ingrediant, "technic:wrought_iron_dust 2"}, - {"moreores:tin_lump", "technic:tin_dust 2"}, - {"technic:chromium_lump", "technic:chromium_dust 2"}, - {"technic:uranium_lump", "technic:uranium_dust 2"}, - {"technic:zinc_lump", "technic:zinc_dust 2"}, - {"technic:lead_lump", "technic:lead_dust 2"}, - {"technic:sulfur_lump", "technic:sulfur_dust 2"}, - {stone_ingrediant, "technic:stone_dust"}, - {sand_ingrediant, "technic:stone_dust"}, - {desert_sand_ingrediant, "technic:stone_dust"}, - - -- Other - {cobble_ingrediant, gravel_ingrediant}, - {gravel_ingrediant, sand_ingrediant}, - {sandstone_ingrediant, sand_ingrediant.." 2"}, -- reverse recipe can be found in the compressor - {desert_stone_ingrediant, desert_sand_ingrediant.." 2"}, -- reverse recipe can be found in the compressor - {ice_block_ingrediant, snow_block_ingrediant}, -} - if minetest.get_modpath("default") then - table.insert(recipes, {"default:silver_sandstone", "default:silver_sand 2"}) -- reverse recipe can be found in the compressor - table.insert(recipes, {"default:silver_sand", "technic:stone_dust"}) + table.insert(grinder_recipes, {"default:silver_sandstone", "default:silver_sand 2"}) -- reverse recipe can be found in the compressor + table.insert(grinder_recipes, {"default:silver_sand", "technic:stone_dust"}) end -- defuse the sandstone -> 4 sand recipe to avoid infinite sand bugs (also consult the inverse compressor recipe) @@ -57,27 +32,27 @@ minetest.clear_craft({ }) if minetest.get_modpath("farming") then - table.insert(recipes, {"farming:seed_wheat", "farming:flour 1"}) + table.insert(grinder_recipes, {"farming:seed_wheat", "farming:flour 1"}) end if minetest.get_modpath("moreores") then - table.insert(recipes, {"moreores:mithril_lump", "technic:mithril_dust 2"}) - table.insert(recipes, {"moreores:silver_lump", "technic:silver_dust 2"}) + table.insert(grinder_recipes, {"moreores:mithril_lump", "technic:mithril_dust 2"}) + table.insert(grinder_recipes, {"moreores:silver_lump", "technic:silver_dust 2"}) end if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then - table.insert(recipes, {"gloopores:alatro_lump", "technic:alatro_dust 2"}) - table.insert(recipes, {"gloopores:kalite_lump", "technic:kalite_dust 2"}) - table.insert(recipes, {"gloopores:arol_lump", "technic:arol_dust 2"}) - table.insert(recipes, {"gloopores:talinite_lump", "technic:talinite_dust 2"}) - table.insert(recipes, {"gloopores:akalin_lump", "technic:akalin_dust 2"}) + table.insert(grinder_recipes, {"gloopores:alatro_lump", "technic:alatro_dust 2"}) + table.insert(grinder_recipes, {"gloopores:kalite_lump", "technic:kalite_dust 2"}) + table.insert(grinder_recipes, {"gloopores:arol_lump", "technic:arol_dust 2"}) + table.insert(grinder_recipes, {"gloopores:talinite_lump", "technic:talinite_dust 2"}) + table.insert(grinder_recipes, {"gloopores:akalin_lump", "technic:akalin_dust 2"}) end if minetest.get_modpath("homedecor") then - table.insert(recipes, {"home_decor:brass_ingot", "technic:brass_dust 1"}) + table.insert(grinder_recipes, {"home_decor:brass_ingot", "technic:brass_dust 1"}) end -for _, data in pairs(recipes) do +for _, data in pairs(grinder_recipes) do technic.register_grinder_recipe({input = {data[1]}, output = data[2]}) end diff --git a/technic/mcl_craftguide.lua b/technic/mcl_craftguide.lua new file mode 100644 index 0000000..2c170b9 --- /dev/null +++ b/technic/mcl_craftguide.lua @@ -0,0 +1,154 @@ +-- Register craft types for each machine +mcl_craftguide.register_craft_type("centrifuge", { + description = "Centrifuge", + icon = "technic_mv_centrifuge_front_active.png", +}) + +mcl_craftguide.register_craft_type("compressor", { + description = "Compressor", + icon = "technic_lv_compressor_front_active.png", +}) + +mcl_craftguide.register_craft_type("extractor", { + description = "Extractor", + icon = "technic_lv_extractor_front_active.png", +}) + +mcl_craftguide.register_craft_type("freezer", { + description = "Freezer", + icon = "technic_mv_freezer_front_active.png", +}) + +mcl_craftguide.register_craft_type("grinder", { + description = "Grinder", + icon = "technic_lv_grinder_front_active.png", +}) + + +centrifuge_recipes = { + { "technic:bronze_dust 8", "technic:copper_dust 7", "technic:tin_dust" }, + { "technic:stainless_steel_dust 5", "technic:wrought_iron_dust 4", "technic:chromium_dust" }, + { "technic:brass_dust 3", "technic:copper_dust 2", "technic:zinc_dust" }, + { "technic:chernobylite_dust", sand_ingrediant, "technic:uranium3_dust" }, + { dirt_ingrediant.." 4", sand_ingrediant, gravel_ingrediant, "default:clay_lump 2" }, +} + +compressor_recipes = { + {snow_block_ingrediant, ice_block_ingrediant}, + {sand_ingrediant.." 2", sandstone_ingrediant}, + {desert_sand_ingrediant.." 2", desert_stone_ingrediant}, + {desert_sand_ingrediant, desert_stone_ingrediant}, + {"technic:mixed_metal_ingot", "technic:composite_plate"}, + {copper_ingrediant.." 5", "technic:copper_plate"}, + {"technic:coal_dust 4", "technic:graphite"}, + {"technic:carbon_cloth", "technic:carbon_plate"}, + {"technic:uranium35_ingot 5", "technic:uranium_fuel"}, +} + +extractor_recipes = { + {"technic:coal_dust", dye_black .. " 2"}, + {blueberries_ingredient, dye_violet .. " 2"}, + {grass_ingredient, dye_green .. " 1"}, + {dry_shrub_ingredient, dye_brown .. " 1"}, + {junglegrass_ingredient, dye_green .. " 2"}, + {cactus_ingredient, dye_green .. " 4"}, + {geranium_ingredient, dye_blue .. " 4"}, + {dandelion_white_ingredient, dye_white .. " 4"}, + {dandelion_yellow_ingredient, dye_yellow .. " 4"}, + {tulip_ingredient, dye_orange .. " 4"}, + {rose_ingredient, dye_red .. " 4"}, + {viola_ingredient, dye_violet .. " 4"}, + {blackberry_ingredient, unifieddyes and "unifieddyes:magenta_s50 4" or dye_violet .. " 4"}, + {blueberry_ingredient, unifieddyes and "unifieddyes:magenta_s50 4" or ""}, +} + +freezer_recipes = { + {water_bucket_ingrediant, { ice_block_ingrediant, emtpy_bucket_ingrediant } }, + {bucket_river_water_ingrediant, { ice_block_ingrediant, emtpy_bucket_ingrediant } }, + {dirt_ingrediant , dirt_with_snow_ingrediant }, + {bucket_lava_ingrediant, { obsidian_ingrediant, emtpy_bucket_ingrediant } } +} + +grinder_recipes = { + -- Dusts + {coal_ingrediant, "technic:coal_dust 2"}, + {copper_lump_ingrediant, "technic:copper_dust 2"}, + {desert_stone_ingrediant, desert_sand_ingrediant}, + {gold_lump_ingrediant, "technic:gold_dust 2"}, + {iron_lump_ingrediant, "technic:wrought_iron_dust 2"}, + {"moreores:tin_lump", "technic:tin_dust 2"}, + {"technic:chromium_lump", "technic:chromium_dust 2"}, + {"technic:uranium_lump", "technic:uranium_dust 2"}, + {"technic:zinc_lump", "technic:zinc_dust 2"}, + {"technic:lead_lump", "technic:lead_dust 2"}, + {"technic:sulfur_lump", "technic:sulfur_dust 2"}, + {stone_ingrediant, "technic:stone_dust"}, + {sand_ingrediant, "technic:stone_dust"}, + {desert_sand_ingrediant, "technic:stone_dust"}, + + -- Other + {cobble_ingrediant, gravel_ingrediant}, + {gravel_ingrediant, sand_ingrediant}, + {sandstone_ingrediant, sand_ingrediant.." 2"}, -- reverse recipe can be found in the compressor + {desert_stone_ingrediant, desert_sand_ingrediant.." 2"}, -- reverse recipe can be found in the compressor + {ice_block_ingrediant, snow_block_ingrediant}, +} + +-- Register Centrifuge Recipes +for _, data in pairs(centrifuge_recipes) do + mcl_craftguide.register_craft({ + type = "centrifuge", + width = 1, + output = table.concat({data[2], data[3], data[4]}, " "), + items = {data[1]}, + }) +end + +-- Register Compressor Recipes +for _, data in pairs(compressor_recipes) do + mcl_craftguide.register_craft({ + type = "compressor", + width = 1, + output = data[2], + items = {data[1]}, + }) +end + +-- Register Extractor Recipes +for _, data in ipairs(extractor_recipes) do + mcl_craftguide.register_craft({ + type = "extractor", + width = 1, + output = data[2], + items = {data[1]}, + }) +end + +-- Register Freezer Recipes +for _, data in pairs(freezer_recipes) do + local output_string + if type(data[2]) == "table" then + output_string = table.concat(data[2], ", ") + else + output_string = data[2] + end + + mcl_craftguide.register_craft({ + type = "freezer", + width = 1, + output = output_string, + items = {data[1]}, + }) +end + + +-- Register Grinder Recipes +for _, data in pairs(grinder_recipes) do + mcl_craftguide.register_craft({ + type = "grinder", + width = 1, + output = data[2], + items = {data[1]}, + }) +end + diff --git a/technic/mod.conf b/technic/mod.conf index c4347b0..480451a 100644 --- a/technic/mod.conf +++ b/technic/mod.conf @@ -1,4 +1,4 @@ name = technic depends = pipeworks, technic_worldgen, basic_materials -optional_depends = bucket, default, screwdriver, mesecons,mesecons_torch, mesecons_mvps, digilines, digiline_remote, intllib, unified_inventory, vector_extras, dye, craftguide,i3, mcl_core +optional_depends = bucket, default, screwdriver, mesecons,mesecons_torch, mesecons_mvps, digilines, digiline_remote, intllib, unified_inventory, vector_extras, dye, craftguide,i3, mcl_core, mcl_craftguide supported_games = minetest_game,mineclone2 \ No newline at end of file