From 7012175b3502169f3fefb7f1256b84bcadff3224 Mon Sep 17 00:00:00 2001 From: Michieal Date: Wed, 15 Feb 2023 13:41:43 -0500 Subject: [PATCH] Rebased; Changed the way that the abm handles being called. Still have to make the scraped variants of the stairs & slabs. --- mods/CORE/mcl_oxidization/init.lua | 4 +- mods/ITEMS/mcl_copper/functions.lua | 57 ++++++++++++++++++++--------- mods/ITEMS/mcl_copper/nodes.lua | 6 +++ 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/mods/CORE/mcl_oxidization/init.lua b/mods/CORE/mcl_oxidization/init.lua index cd0094655..58c90a67f 100644 --- a/mods/CORE/mcl_oxidization/init.lua +++ b/mods/CORE/mcl_oxidization/init.lua @@ -4,9 +4,9 @@ --- DateTime: 2/15/23 1:11 AM --- -function register_oxidation_abm(abm_name, node_name, oxidized_variant) +function register_oxidation_abm(node_name) minetest.register_abm({ - label = abm_name, + label = node_name .. "_oxidization_abm", nodenames = { node_name }, interval = 500, chance = 3, diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index 8410526ac..c3b97fd4c 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -32,32 +32,55 @@ local block_oxidation = { } local stair_oxidation = { - { "slab", "cut", "exposed_cut" }, - { "slab", "exposed_cut", "weathered_cut" }, - { "slab", "weathered_cut", "oxidized_cut" }, - { "slab", "cut_top", "exposed_cut_top" }, - { "slab", "exposed_cut_top", "weathered_cut_top" }, - { "slab", "weathered_cut_top", "oxidized_cut_double" }, - { "slab", "cut_double", "exposed_cut_double" }, - { "slab", "exposed_cut_double", "weathered_cut_double" }, - { "slab", "weathered_cut_double", "oxidized_cut_double" }, { "stair", "cut", "exposed_cut" }, - { "stair", "exposed_cut", "weathered_cut" }, - { "stair", "weathered_cut", "oxidized_cut" }, { "stair", "cut_inner", "exposed_cut_inner" }, - { "stair", "exposed_cut_inner", "weathered_cut_inner" }, - { "stair", "weathered_cut_inner", "oxidized_cut_inner" }, { "stair", "cut_outer", "exposed_cut_outer" }, + { "stair", "exposed_cut", "weathered_cut" }, + { "stair", "exposed_cut_inner", "weathered_cut_inner" }, { "stair", "exposed_cut_outer", "weathered_cut_outer" }, + { "stair", "weathered_cut", "oxidized_cut" }, + { "stair", "weathered_cut_inner", "oxidized_cut_inner" }, { "stair", "weathered_cut_outer", "oxidized_cut_outer" } } +local slab_oxidization = { + { "slab", "cut", "exposed_cut" }, + { "slab", "cut_top", "exposed_cut_top" }, + { "slab", "cut_double", "exposed_cut_double" }, + { "slab", "exposed_cut", "weathered_cut" }, + { "slab", "exposed_cut_top", "weathered_cut_top" }, + { "slab", "exposed_cut_double", "weathered_cut_double" }, + { "slab", "weathered_cut", "oxidized_cut" }, + { "slab", "weathered_cut_top", "oxidized_cut_double" }, + { "slab", "weathered_cut_double", "oxidized_cut_double" }, +} + for _, b in pairs(block_oxidation) do - register_oxidation_abm("Copper oxidation", "mcl_copper:block" .. b[1], "mcl_copper:block" .. b[2]) + register_oxidation_abm("mcl_copper:block" .. b[1]) end +local def +local def_variant_oxidized +local def_variant_waxed +-- local def_variant_scraped + for _, s in pairs(stair_oxidation) do - register_oxidation_abm("Copper oxidation", "mcl_stairs:" .. s[1] .. "_copper_" .. s[2], "mcl_stairs:" .. s[1] .. "_copper_" .. s[3]) - -- TODO: Make stairs and slabs be waxable / scrapable. Place the Node overrides here, just like they are on the copper nodes, and it will work properly. May need to update mcl_honey to call the waxing function for stairs and slabs. -end + register_oxidation_abm("Copper oxidation", "mcl_stairs:" .. s[1] .. "_copper_" .. s[2]) + def = "mcl_stairs:" .. s[1] .. "_copper_" .. s[2] + def_variant_oxidized = "mcl_stairs:" .. s[1] .. "_copper_" .. s[3] + minetest.override_item(def, { _mcl_oxidized_variant = def_variant_oxidized }) + + def_variant_waxed = "mcl_stairs:" .. s[1] .. "_copper_" .. s[2] .. "_waxed" + minetest.override_item(def, { _mcl_copper_waxed_variant = def_variant_waxed }) +end +for _, s in pairs(slab_oxidization) do + register_oxidation_abm("Copper oxidation", "mcl_stairs:" .. s[1] .. "_copper_" .. s[2]) + def = "mcl_stairs:" .. s[1] .. "_copper_" .. s[2] + def_variant_oxidized = "mcl_stairs:" .. s[1] .. "_copper_" .. s[3] + minetest.override_item(def, { _mcl_oxidized_variant = def_variant_oxidized }) + + def_variant_waxed = "mcl_stairs:" .. s[1] .. "_copper_" .. s[2] .. "_waxed" + minetest.override_item(def, { _mcl_copper_waxed_variant = def_variant_waxed }) +end +-- TODO: Do Scraped (mcl_stripped_variant) for stairs and slabs. diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index c8bb139cf..c6f03c74f 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -34,6 +34,7 @@ minetest.register_node("mcl_copper:block", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 3, + _mcl_oxidized_variant = "mcl_copper:block_exposed", _mcl_copper_waxed_variant = "mcl_copper:waxed_block", }) @@ -58,6 +59,7 @@ minetest.register_node("mcl_copper:block_exposed", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_oxidized_variant = "mcl_copper:block_weathered", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed", _mcl_stripped_variant = "mcl_copper:block", }) @@ -83,6 +85,7 @@ minetest.register_node("mcl_copper:block_weathered", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_oxidized_variant = "mcl_copper:block_oxidized", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered", _mcl_stripped_variant = "mcl_copper:block_exposed", }) @@ -133,6 +136,7 @@ minetest.register_node("mcl_copper:block_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_oxidized_variant = "mcl_copper:block_cut_exposed", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut", }) @@ -158,6 +162,7 @@ minetest.register_node("mcl_copper:block_exposed_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut", + _mcl_oxidized_variant = "mcl_copper:block_cut_weathered", _mcl_stripped_variant = "mcl_copper:block_cut", }) @@ -183,6 +188,7 @@ minetest.register_node("mcl_copper:block_weathered_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_exposed_cut", + _mcl_oxidized_variant = "mcl_copper:block_cut_oxidized", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut", })