From 25219c71023a916f116ca030ebd3d9d04cee4ace Mon Sep 17 00:00:00 2001 From: JoseDouglas26 Date: Wed, 8 May 2024 06:25:09 -0300 Subject: [PATCH] Copper buttons and some small changes --- mods/ITEMS/REDSTONE/mesecons_button/init.lua | 10 ++++++---- mods/ITEMS/mcl_copper/crafting.lua | 5 +++++ mods/ITEMS/mcl_copper/descriptions.lua | 7 +++++++ mods/ITEMS/mcl_copper/functions.lua | 14 ++++++++++++++ mods/ITEMS/mcl_copper/nodes.lua | 16 ++++++++++++++++ 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_button/init.lua b/mods/ITEMS/REDSTONE/mesecons_button/init.lua index 8e2159045..b0177a23c 100644 --- a/mods/ITEMS/REDSTONE/mesecons_button/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_button/init.lua @@ -207,10 +207,12 @@ function mesecon.register_button(basename, description, texture, recipeitem, sou _mcl_hardness = 0.5, }) - minetest.register_craft({ - output = "mesecons_button:button_"..basename.."_off", - recipe = {{ recipeitem }}, - }) + if recipeitem then + minetest.register_craft({ + output = "mesecons_button:button_"..basename.."_off", + recipe = {{ recipeitem }}, + }) + end if minetest.get_modpath("mesecons_mvps") then mesecon.register_mvps_unsticky("mesecons_button:button_"..basename.."_off") diff --git a/mods/ITEMS/mcl_copper/crafting.lua b/mods/ITEMS/mcl_copper/crafting.lua index cb1fe6eae..13b516389 100644 --- a/mods/ITEMS/mcl_copper/crafting.lua +++ b/mods/ITEMS/mcl_copper/crafting.lua @@ -220,3 +220,8 @@ minetest.register_craft({ {"mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot"} } }) + +minetest.register_craft({ + output = "mesecons_button:button_copper_off", + recipe = {{"mcl_copper:copper_ingot"}} +}) diff --git a/mods/ITEMS/mcl_copper/descriptions.lua b/mods/ITEMS/mcl_copper/descriptions.lua index 1face6507..29cd073bf 100644 --- a/mods/ITEMS/mcl_copper/descriptions.lua +++ b/mods/ITEMS/mcl_copper/descriptions.lua @@ -179,3 +179,10 @@ mcl_copper.doors_descs = { {S("Oxidized Copper Door"), S("Oxidized Copper Trapdoor")}, {S("Waxed Oxidized Copper Door"), S("Waxed Oxidized Copper Trapdoor")} } +-- Description for copper buttons, selected by its position on the table. +mcl_copper.button_descs = { + S("Copper Button"), S("Waxed Copper Button"), + S("Exposed Copper Button"), S("Waxed Exposed Copper Button"), + S("Weathered Copper Button"), S("Waxed Weathered Copper Button"), + S("Oxidized Copper Button"), S("Waxed Oxidized Copper Button") +} diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index bc3c43375..fd30ba9ca 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -12,6 +12,11 @@ local function register_oxidation_and_scraping(mod_name, subname, decay_chain) for i = 1, #decay_chain - 1 do item = mod_name..":"..subname..decay_chain[i] oxidized_item = mod_name..":"..subname..decay_chain[i + 1] + -- Copper buttons have a special treatment due to the format of your name. + if subname:find("button") then + item = item.."_off" + oxidized_item = oxidized_item.."_off" + end minetest.override_item(item, {_mcl_oxidized_variant = oxidized_item}) minetest.override_item(oxidized_item, {_mcl_stripped_variant = item}) @@ -64,6 +69,11 @@ local function register_waxing_and_scraping(mod_name, subname, decay_chain) for i = 1, #decay_chain do waxed_item = mod_name..":"..subname..decay_chain[i] unwaxed_item = mod_name..":"..subname:gsub("waxed_", "")..decay_chain[i] + -- Copper buttons have a special treatment due to the format of your name. + if subname:find("button") then + waxed_item = waxed_item.."_off" + unwaxed_item = unwaxed_item.."_off" + end minetest.override_item(waxed_item, {_mcl_stripped_variant = unwaxed_item}) minetest.override_item(unwaxed_item, {_mcl_waxed_variant = waxed_item}) @@ -116,9 +126,13 @@ register_oxidation_and_scraping("mcl_copper", "trapdoor", decay_chain) register_oxidation_and_scraping("mcl_copper", "door", decay_chain) +register_oxidation_and_scraping("mesecons_button", "button_copper", decay_chain) + register_waxing_and_scraping("mcl_copper", "waxed_trapdoor", decay_chain) register_waxing_and_scraping("mcl_copper", "waxed_door", decay_chain) + +register_waxing_and_scraping("mesecons_button", "button_waxed_copper", decay_chain) -- Redefining values and using decay chains for stairs and slabs. for i = 1, 4 do decay_chain[i] = decay_chain[i].."_cut" diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index 1d4394e5c..e2de7ea94 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -230,6 +230,21 @@ local function register_copper_variants(name, definitions) _mcl_hardness = 3 }) end + -- Registering buttons. + if definitions._mesecons_buttons then + mesecon.register_button( + names[i]:gsub("block", "copper"), + mcl_copper.button_descs[i], + set_tiles(tiles, i), + nil, + mcl_sounds.node_sound_metal_defaults(), + set_groups(names[i], {handy = 1, pickaxey = 1}), + math.ceil(i / 2) * 0.5, + true, + nil, + "mesecons_button_push" + ) + end end end -- Using the function above to register the copper blocks. @@ -238,6 +253,7 @@ register_copper_variants("block", { -- Copper blocks are no longer the manufacturing material for doors but this definition will be -- maintained here to avoid individual registration of 16 blocks. _mcl_doors = true, + _mesecons_buttons = true, }) -- Using the function above to register the cut copper blocks. register_copper_variants("cut", {