From bb76b466b33c573628cc53ef959f6ccd5ff17ec8 Mon Sep 17 00:00:00 2001 From: JoseDouglas26 Date: Tue, 21 May 2024 17:40:59 -0300 Subject: [PATCH] Fix code errors --- mods/ITEMS/mcl_copper/functions.lua | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index e138a63f4..95128ccf6 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -60,12 +60,6 @@ end ---@param decay_chain table local function register_oxidation_and_scraping(mod_name, subname, decay_chain) local item, oxidized_item - -- Handling special decay chain names. - if mod_name == "mcl_stairs" then - for i = 1, 4 do - decay_chain[i] = decay_chain[i].."_cut" - end - end for i = 1, #decay_chain - 1 do item = mod_name..":"..subname..decay_chain[i] @@ -124,18 +118,12 @@ end --- containing the list of subnames of the block oxidation chain (without the waxed variants subnames). local function register_waxing_and_scraping(mod_name, subname, decay_chain) local waxed_item, unwaxed_item - -- Handling special decay chain names. - if mod_name == "mcl_stairs" then - for i = 1, 4 do - decay_chain[i] = decay_chain[i].."_cut" - end - end for i = 1, #decay_chain do waxed_item = mod_name..":"..subname..decay_chain[i] unwaxed_item = mod_name..":"..subname:gsub("waxed_", "")..decay_chain[i] - for _, subnode in pairs(mcl_copper.subnodes[subname]) do + for _, subnode in pairs(mcl_copper.subnodes[subname:gsub("waxed_", "")]) do if subnode == "" then minetest.override_item(waxed_item, {_mcl_stripped_variant = unwaxed_item}) minetest.override_item(unwaxed_item, {_mcl_waxed_variant = waxed_item}) @@ -193,8 +181,6 @@ local mods_and_blocks = { {"mesecons_button", "button_copper", "button_waxed_copper"}, {"mcl_copper", "door", "waxed_door"}, {"mcl_copper", "pressure_plate_copper", "pressure_plate_waxed_copper"}, - {"mcl_stairs", "slab_copper", "slab_waxed_copper"}, - {"mcl_stairs", "stair_copper", "stair_waxed_copper"}, {"mcl_copper", "trapdoor", "waxed_trapdoor"} } -- Defining variants for all blocks registered by other API's. @@ -206,3 +192,21 @@ for _, mod_and_blocks in pairs(mods_and_blocks) do register_oxidation_and_scraping(mod, oxidize_and_scrap, decay_chain) register_waxing_and_scraping(mod, wax_and_scrap, decay_chain) end + +for i = 1, 4 do + decay_chain[i] = decay_chain[i].."_cut" +end + +mods_and_blocks = { + {"mcl_stairs", "slab_copper", "slab_waxed_copper"}, + {"mcl_stairs", "stair_copper", "stair_waxed_copper"} +} + +for _, mod_and_blocks in pairs(mods_and_blocks) do + local mod = mod_and_blocks[1] + local oxidize_and_scrap = mod_and_blocks[2] + local wax_and_scrap = mod_and_blocks[3] + + register_oxidation_and_scraping(mod, oxidize_and_scrap, decay_chain) + register_waxing_and_scraping(mod, wax_and_scrap, decay_chain) +end