From 54122f90713fe7e8425ab59b93a64dccefd03650 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Mon, 8 Apr 2024 09:44:20 +0200 Subject: [PATCH 01/11] Add compressor recipes for nether brick and lump --- .../machines/register/compressor_recipes.lua | 33 ++++++++++++++++++- technic/mod.conf | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index ad098685..580b1171 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -38,7 +38,18 @@ if minetest.get_modpath("everness") then end end --- defuse the default sandstone recipe, since we have the compressor to take over in a more realistic manner +if minetest.get_modpath("nether") then + local nether_brick_and_lump_recipes = { + {"nether:brick 9", "nether:brick_compressed"}, + {"nether:brick_compressed 9", "nether:nether_lump"}, + } + + for _, data in ipairs(nether_brick_and_lump_recipes) do + table.insert(recipes, {data[1], data[2]}) + end +end + +-- Defuse the default sandstone recipes, since we have the compressor to take over in a more realistic manner. local crafts_to_clear = { "default:desert_sand", "default:sand", @@ -72,6 +83,26 @@ for _, sand_name in ipairs(crafts_to_clear) do }) end +if minetest.get_modpath("nether") then + -- Defuse the default compressed nether brick and nether lump recipes, + -- since we have the compressor to take over in a more realistic manner. + local nether_crafts_to_clear = { + "nether:brick", + "nether:brick_compressed", + } + + for _, nether_brick_name in ipairs(nether_crafts_to_clear) do + minetest.clear_craft({ + type = "shaped", + recipe = { + {nether_brick_name, nether_brick_name, nether_brick_name}, + {nether_brick_name, nether_brick_name, nether_brick_name}, + {nether_brick_name, nether_brick_name, nether_brick_name}, + }, + }) + end +end + for _, data in pairs(recipes) do technic.register_compressor_recipe({input = {data[1]}, output = data[2]}) end diff --git a/technic/mod.conf b/technic/mod.conf index 71062abe..97ca806e 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, craftguide, i3, everness +optional_depends = bucket, screwdriver, mesecons, mesecons_mvps, digilines, digiline_remote, intllib, unified_inventory, vector_extras, dye, craftguide, i3, everness, nether From 8ab2a6e0476cfe1f370590a3fb8bce9b5ae45c70 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Mon, 8 Apr 2024 09:57:50 +0200 Subject: [PATCH 02/11] Refactor recipes collection --- .../machines/register/compressor_recipes.lua | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 580b1171..8e3fc084 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -21,8 +21,8 @@ local recipes = { {"technic:uranium35_ingot 5", "technic:uranium_fuel"}, } -if minetest.get_modpath("everness") then - local everness_sand_to_sandstone_recipes = { +local dependent_recipes = { + everness = { {"everness:coral_deep_ocean_sand 2", "everness:coral_deep_ocean_sandstone_block"}, {"everness:coral_sand 2", "everness:coral_sandstone"}, {"everness:coral_white_sand 2", "everness:coral_white_sandstone"}, @@ -31,29 +31,27 @@ if minetest.get_modpath("everness") then {"everness:cursed_lands_deep_ocean_sand 2", "everness:cursed_lands_deep_ocean_sandstone_block"}, {"everness:cursed_sand 2", "everness:cursed_sandstone_block"}, {"everness:mineral_sand 2", "everness:mineral_sandstone"}, - } - - for _, data in ipairs(everness_sand_to_sandstone_recipes) do - table.insert(recipes, {data[1], data[2]}) - end -end - -if minetest.get_modpath("nether") then - local nether_brick_and_lump_recipes = { + }, + nether = { {"nether:brick 9", "nether:brick_compressed"}, {"nether:brick_compressed 9", "nether:nether_lump"}, - } + }, +} - for _, data in ipairs(nether_brick_and_lump_recipes) do - table.insert(recipes, {data[1], data[2]}) +for dependency, recipes_to_add in pairs(dependent_recipes) do + if minetest.get_modpath(dependency) then + for _, recipe_entry in ipairs(recipes_to_add) do + table.insert(recipes, recipe_entry) + end end end --- Defuse the default sandstone recipes, since we have the compressor to take over in a more realistic manner. +-- Defuse the default sandstone recipes, since we have +-- the compressor to take over in a more realistic manner. local crafts_to_clear = { "default:desert_sand", "default:sand", - "default:silver_sand" + "default:silver_sand", } if minetest.get_modpath("everness") then From 06ca0371eab087db4e3718aa15ac27d2d448e99f Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Mon, 8 Apr 2024 10:53:49 +0200 Subject: [PATCH 03/11] Refactor default recipe clearing --- .../machines/register/compressor_recipes.lua | 64 ++++++++++--------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 8e3fc084..f45aaa0a 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -38,6 +38,8 @@ local dependent_recipes = { }, } +-- Add dependent recipes to main recipe collection +-- if their mods are used. for dependency, recipes_to_add in pairs(dependent_recipes) do if minetest.get_modpath(dependency) then for _, recipe_entry in ipairs(recipes_to_add) do @@ -54,8 +56,8 @@ local crafts_to_clear = { "default:silver_sand", } -if minetest.get_modpath("everness") then - local everness_crafts_to_clear = { +local dependent_crafts_to_clear = { + everness = { "everness:coral_sand", "everness:coral_forest_deep_ocean_sand", "everness:coral_white_sand", @@ -64,43 +66,45 @@ if minetest.get_modpath("everness") then "everness:cursed_lands_deep_ocean_sand", "everness:crystal_forest_deep_ocean_sand", "everness:mineral_sand", - } + }, + nether = { + "nether:brick", + "nether:brick_compressed", + }, +} - for _, sand_name in ipairs(everness_crafts_to_clear) do - table.insert(crafts_to_clear, sand_name) +for dependency, crafts in pairs(dependent_crafts_to_clear) do + if minetest.get_modpath(dependency) then + for _, craft_entry in ipairs(crafts) do + table.insert(crafts_to_clear, craft_entry) + end end end -for _, sand_name in ipairs(crafts_to_clear) do +for _, craft_name in ipairs(crafts_to_clear) do + is_regular = string.sub(craft_name, 1, 7) ~= "nether:" + + if is_regular then + -- Regular compression recipes use 2x2 shape. + shaped_recipe = { + {craft_name, craft_name}, + {craft_name, craft_name}, + } + else + -- Nether's compression recipes use 3x3 shape. + shaped_recipe = { + {craft_name, craft_name, craft_name}, + {craft_name, craft_name, craft_name}, + {craft_name, craft_name, craft_name}, + } + end + minetest.clear_craft({ type = "shaped", - recipe = { - {sand_name, sand_name}, - {sand_name, sand_name}, - }, + recipe = shaped_recipe, }) end -if minetest.get_modpath("nether") then - -- Defuse the default compressed nether brick and nether lump recipes, - -- since we have the compressor to take over in a more realistic manner. - local nether_crafts_to_clear = { - "nether:brick", - "nether:brick_compressed", - } - - for _, nether_brick_name in ipairs(nether_crafts_to_clear) do - minetest.clear_craft({ - type = "shaped", - recipe = { - {nether_brick_name, nether_brick_name, nether_brick_name}, - {nether_brick_name, nether_brick_name, nether_brick_name}, - {nether_brick_name, nether_brick_name, nether_brick_name}, - }, - }) - end -end - for _, data in pairs(recipes) do technic.register_compressor_recipe({input = {data[1]}, output = data[2]}) end From 03d62da9c9c1ae62275ea69a2fc8ff819da1c671 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Mon, 8 Apr 2024 11:01:31 +0200 Subject: [PATCH 04/11] Refactor default recipe clearing part 2 --- .../machines/register/compressor_recipes.lua | 89 ++++++++++--------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index f45aaa0a..2c405dd3 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -8,47 +8,7 @@ function technic.register_compressor_recipe(data) technic.register_recipe("compressing", data) end -local recipes = { - {"default:snowblock", "default:ice"}, - {"default:sand 2", "default:sandstone"}, - {"default:desert_sand 2", "default:desert_sandstone"}, - {"default:silver_sand 2", "default:silver_sandstone"}, - {"default:desert_sand", "default:desert_stone"}, - {"technic:mixed_metal_ingot", "technic:composite_plate"}, - {"default:copper_ingot 5", "technic:copper_plate"}, - {"technic:coal_dust 4", "technic:graphite"}, - {"technic:carbon_cloth", "technic:carbon_plate"}, - {"technic:uranium35_ingot 5", "technic:uranium_fuel"}, -} - -local dependent_recipes = { - everness = { - {"everness:coral_deep_ocean_sand 2", "everness:coral_deep_ocean_sandstone_block"}, - {"everness:coral_sand 2", "everness:coral_sandstone"}, - {"everness:coral_white_sand 2", "everness:coral_white_sandstone"}, - {"everness:crystal_forest_deep_ocean_sand 2", "everness:crystal_forest_deep_ocean_sandstone_block"}, - {"everness:crystal_sand 2", "everness:crystal_sandstone"}, - {"everness:cursed_lands_deep_ocean_sand 2", "everness:cursed_lands_deep_ocean_sandstone_block"}, - {"everness:cursed_sand 2", "everness:cursed_sandstone_block"}, - {"everness:mineral_sand 2", "everness:mineral_sandstone"}, - }, - nether = { - {"nether:brick 9", "nether:brick_compressed"}, - {"nether:brick_compressed 9", "nether:nether_lump"}, - }, -} - --- Add dependent recipes to main recipe collection --- if their mods are used. -for dependency, recipes_to_add in pairs(dependent_recipes) do - if minetest.get_modpath(dependency) then - for _, recipe_entry in ipairs(recipes_to_add) do - table.insert(recipes, recipe_entry) - end - end -end - --- Defuse the default sandstone recipes, since we have +-- Defuse the default recipes, since we have -- the compressor to take over in a more realistic manner. local crafts_to_clear = { "default:desert_sand", @@ -73,6 +33,8 @@ local dependent_crafts_to_clear = { }, } +-- Add dependent recipes to main collection of +-- recipes to be cleared if their mods are used. for dependency, crafts in pairs(dependent_crafts_to_clear) do if minetest.get_modpath(dependency) then for _, craft_entry in ipairs(crafts) do @@ -81,6 +43,7 @@ for dependency, crafts in pairs(dependent_crafts_to_clear) do end end +-- Clear recipes for _, craft_name in ipairs(crafts_to_clear) do is_regular = string.sub(craft_name, 1, 7) ~= "nether:" @@ -105,6 +68,50 @@ for _, craft_name in ipairs(crafts_to_clear) do }) end +-- +-- Compile compressor recipes +-- +local recipes = { + {"default:snowblock", "default:ice"}, + {"default:sand 2", "default:sandstone"}, + {"default:desert_sand 2", "default:desert_sandstone"}, + {"default:silver_sand 2", "default:silver_sandstone"}, + {"default:desert_sand", "default:desert_stone"}, + {"technic:mixed_metal_ingot", "technic:composite_plate"}, + {"default:copper_ingot 5", "technic:copper_plate"}, + {"technic:coal_dust 4", "technic:graphite"}, + {"technic:carbon_cloth", "technic:carbon_plate"}, + {"technic:uranium35_ingot 5", "technic:uranium_fuel"}, +} + +local dependent_recipes = { + everness = { + {"everness:coral_deep_ocean_sand 2", "everness:coral_deep_ocean_sandstone_block"}, + {"everness:coral_sand 2", "everness:coral_sandstone"}, + {"everness:coral_white_sand 2", "everness:coral_white_sandstone"}, + {"everness:crystal_forest_deep_ocean_sand 2", "everness:crystal_forest_deep_ocean_sandstone_block"}, + {"everness:crystal_sand 2", "everness:crystal_sandstone"}, + {"everness:cursed_lands_deep_ocean_sand 2", "everness:cursed_lands_deep_ocean_sandstone_block"}, + {"everness:cursed_sand 2", "everness:cursed_sandstone_block"}, + {"everness:mineral_sand 2", "everness:mineral_sandstone"}, + }, + nether = { + {"nether:brick 9", "nether:brick_compressed"}, + {"nether:brick_compressed 9", "nether:nether_lump"}, + }, +} + +-- Add dependent recipes to main recipe collection +-- if their mods are used. +for dependency, recipes_to_add in pairs(dependent_recipes) do + if minetest.get_modpath(dependency) then + for _, recipe_entry in ipairs(recipes_to_add) do + table.insert(recipes, recipe_entry) + end + end +end + +-- Register compressor recipes for _, data in pairs(recipes) do technic.register_compressor_recipe({input = {data[1]}, output = data[2]}) end From ec646b2059d5eb11f0a996073a4cbe5dec83e51f Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Sat, 13 Apr 2024 21:15:11 +0200 Subject: [PATCH 05/11] Add additional check for nether (to make sure that we have the right one) --- technic/machines/register/compressor_recipes.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 2c405dd3..ae40703a 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -8,6 +8,18 @@ function technic.register_compressor_recipe(data) technic.register_recipe("compressing", data) end +-- Function for cases where multiple mods exist with the same name, +-- to check if we have the right one. +local function is_right_mod(dependency) + is_right = true + + if dependency == "nether" then + is_right = minetest.registered_nodes["nether:brick_compressed"] ~= nil + end + + return is_right +end + -- Defuse the default recipes, since we have -- the compressor to take over in a more realistic manner. local crafts_to_clear = { @@ -36,7 +48,7 @@ local dependent_crafts_to_clear = { -- Add dependent recipes to main collection of -- recipes to be cleared if their mods are used. for dependency, crafts in pairs(dependent_crafts_to_clear) do - if minetest.get_modpath(dependency) then + if minetest.get_modpath(dependency) and is_right_mod(dependency) then for _, craft_entry in ipairs(crafts) do table.insert(crafts_to_clear, craft_entry) end @@ -104,7 +116,7 @@ local dependent_recipes = { -- Add dependent recipes to main recipe collection -- if their mods are used. for dependency, recipes_to_add in pairs(dependent_recipes) do - if minetest.get_modpath(dependency) then + if minetest.get_modpath(dependency) and is_right_mod(dependency) then for _, recipe_entry in ipairs(recipes_to_add) do table.insert(recipes, recipe_entry) end From c92e8f796abbd261ef4e97c210c182665ac5b5ba Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Sat, 13 Apr 2024 21:17:57 +0200 Subject: [PATCH 06/11] Add local keyword to check function's local variable in compressor recipes --- technic/machines/register/compressor_recipes.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index ae40703a..89dd4374 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -11,7 +11,7 @@ end -- Function for cases where multiple mods exist with the same name, -- to check if we have the right one. local function is_right_mod(dependency) - is_right = true + local is_right = true if dependency == "nether" then is_right = minetest.registered_nodes["nether:brick_compressed"] ~= nil From 72c32fa13e76d0af69bb02dd256b704f62d42420 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 19 Apr 2024 07:05:44 +0200 Subject: [PATCH 07/11] Revert "Add local keyword to check function's local variable in compressor recipes" This reverts commit c92e8f796abbd261ef4e97c210c182665ac5b5ba. --- technic/machines/register/compressor_recipes.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 89dd4374..ae40703a 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -11,7 +11,7 @@ end -- Function for cases where multiple mods exist with the same name, -- to check if we have the right one. local function is_right_mod(dependency) - local is_right = true + is_right = true if dependency == "nether" then is_right = minetest.registered_nodes["nether:brick_compressed"] ~= nil From f68a3f060f7fdf54bf7da9d35ef42c8ba2760ee9 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 19 Apr 2024 07:06:22 +0200 Subject: [PATCH 08/11] Revert "Add additional check for nether (to make sure that we have the right one)" This reverts commit ec646b2059d5eb11f0a996073a4cbe5dec83e51f. --- technic/machines/register/compressor_recipes.lua | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index ae40703a..2c405dd3 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -8,18 +8,6 @@ function technic.register_compressor_recipe(data) technic.register_recipe("compressing", data) end --- Function for cases where multiple mods exist with the same name, --- to check if we have the right one. -local function is_right_mod(dependency) - is_right = true - - if dependency == "nether" then - is_right = minetest.registered_nodes["nether:brick_compressed"] ~= nil - end - - return is_right -end - -- Defuse the default recipes, since we have -- the compressor to take over in a more realistic manner. local crafts_to_clear = { @@ -48,7 +36,7 @@ local dependent_crafts_to_clear = { -- Add dependent recipes to main collection of -- recipes to be cleared if their mods are used. for dependency, crafts in pairs(dependent_crafts_to_clear) do - if minetest.get_modpath(dependency) and is_right_mod(dependency) then + if minetest.get_modpath(dependency) then for _, craft_entry in ipairs(crafts) do table.insert(crafts_to_clear, craft_entry) end @@ -116,7 +104,7 @@ local dependent_recipes = { -- Add dependent recipes to main recipe collection -- if their mods are used. for dependency, recipes_to_add in pairs(dependent_recipes) do - if minetest.get_modpath(dependency) and is_right_mod(dependency) then + if minetest.get_modpath(dependency) then for _, recipe_entry in ipairs(recipes_to_add) do table.insert(recipes, recipe_entry) end From b1364dd921e15653700f4c434b45f70279a6f59c Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 19 Apr 2024 07:16:15 +0200 Subject: [PATCH 09/11] Make variables local --- technic/machines/register/compressor_recipes.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 2c405dd3..777499f0 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -45,17 +45,17 @@ end -- Clear recipes for _, craft_name in ipairs(crafts_to_clear) do - is_regular = string.sub(craft_name, 1, 7) ~= "nether:" + local is_regular = string.sub(craft_name, 1, 7) ~= "nether:" if is_regular then -- Regular compression recipes use 2x2 shape. - shaped_recipe = { + local shaped_recipe = { {craft_name, craft_name}, {craft_name, craft_name}, } else -- Nether's compression recipes use 3x3 shape. - shaped_recipe = { + local shaped_recipe = { {craft_name, craft_name, craft_name}, {craft_name, craft_name, craft_name}, {craft_name, craft_name, craft_name}, From 7b46a699f9af18ebd3d54f04eba27858853bca87 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 19 Apr 2024 07:19:50 +0200 Subject: [PATCH 10/11] Fix local variable definition and access --- technic/machines/register/compressor_recipes.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 777499f0..9ed5718a 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -46,16 +46,17 @@ end -- Clear recipes for _, craft_name in ipairs(crafts_to_clear) do local is_regular = string.sub(craft_name, 1, 7) ~= "nether:" + local shaped_recipe = {} if is_regular then -- Regular compression recipes use 2x2 shape. - local shaped_recipe = { + shaped_recipe = { {craft_name, craft_name}, {craft_name, craft_name}, } else -- Nether's compression recipes use 3x3 shape. - local shaped_recipe = { + shaped_recipe = { {craft_name, craft_name, craft_name}, {craft_name, craft_name, craft_name}, {craft_name, craft_name, craft_name}, From 2d8716d70a5e5a1c5ad0ebd10c11b2f7420471e4 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 19 Apr 2024 07:22:44 +0200 Subject: [PATCH 11/11] Fix again --- technic/machines/register/compressor_recipes.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/technic/machines/register/compressor_recipes.lua b/technic/machines/register/compressor_recipes.lua index 9ed5718a..6acee20c 100644 --- a/technic/machines/register/compressor_recipes.lua +++ b/technic/machines/register/compressor_recipes.lua @@ -46,7 +46,7 @@ end -- Clear recipes for _, craft_name in ipairs(crafts_to_clear) do local is_regular = string.sub(craft_name, 1, 7) ~= "nether:" - local shaped_recipe = {} + local shaped_recipe if is_regular then -- Regular compression recipes use 2x2 shape.