1
0
Fork 0

Compare commits

...

6 Commits

7 changed files with 192 additions and 70 deletions

View File

@ -0,0 +1,44 @@
# Mineclone Oxidization API
This document explains the API of this mod.
### `register_oxidation_abm(node_name)`
Registers the ABM for the oxidization of nodes. It expects that the variable
`_mcl_oxidized_variant` be set with the node name of the oxidized version.
#### Parameters:
`node_name`: the name of the node to check, and to oxidize.
#### Usage:
To use this API, add `_mcl_oxidized_variant = my_oxidized_node_name,` to the node
definition of the desired node, and then call
`register_oxidation_abm(my_oxidizable_node_abm, my_oxidizable_node)` in your code.
This abm will swap out the nodes with the more oxidized version of the node, one
stage at a time.
#### Example of Usage:
From mcl_copper:
```lua
local block_oxidation = {
{ "", "_exposed" },
{ "_cut", "_exposed_cut" },
{ "_exposed", "_weathered" },
{ "_exposed_cut", "_weathered_cut" },
{ "_weathered", "_oxidized" },
{ "_weathered_cut", "_oxidized_cut" }
}
for _, b in pairs(block_oxidation) do
register_oxidation_abm("mcl_copper:block" .. b[1], "mcl_copper:block" .. b[2])
end
```
### Oxidization Removal
Make sure that the Oxidized Node has this in its definition:
`_mcl_stripped_variant = my_less_oxidized_node,`
And axes in mineclone will scrape the oxidization level down, usually by one stage.
An example of usage: `_mcl_stripped_variant = "mcl_copper:block",`
Implementation of other tools for scraping does not yet exist, but may in the future.

View File

@ -0,0 +1,20 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by michieal.
--- DateTime: 2/15/23 1:11 AM
---
function register_oxidation_abm(node_name)
minetest.register_abm({
label = node_name .. "_oxidization_abm",
nodenames = { node_name },
interval = 500,
chance = 3,
action = function(pos, node)
local def = minetest.registered_nodes[node_name]
if def and def._mcl_oxidized_variant then
minetest.swap_node(pos, { name = oxidized_variant, param2 = node.param2 })
end
end,
})
end

View File

@ -0,0 +1,4 @@
title = Oxidization API for Mineclone 2
name = mcl_oxidization
author = Michieal, NO11
description = Turns NO11's oxidization function into an API.

View File

@ -1,39 +1,3 @@
--local deepslate_mod = minetest.get_modpath("mcl_deepslate")
local function register_oxidation_abm(abm_name, node_name, oxidized_variant)
minetest.register_abm({
label = abm_name,
nodenames = { node_name },
interval = 500,
chance = 3,
action = function(pos, node)
minetest.swap_node(pos, { name = oxidized_variant, param2 = node.param2 })
end,
})
end
--[[
local stairs = {
{"stair", "exposed", "_inner", "cut_inner"},
{"stair", "weathered", "_inner", "exposed_cut_inner"},
{"stair", "exposed", "_outer", "cut_outer"},
{"stair", "weathered", "_outer", "exposed_cut_outer"},
{"stair", "oxidized", "_outer", "weathered_cut_outer"},
{"stair", "oxidized", "_inner", "weathered_cut_inner"},
{"slab", "exposed", "","cut"},
{"slab", "oxidized", "","weathered_cut"},
{"slab", "weathered", "","exposed_cut"},
{"slab", "exposed", "_top","cut_top"},
{"slab", "oxidized", "_top", "weathered_cut_top"},
{"slab", "weathered", "_top","exposed_cut_top"},
{"slab", "exposed", "_double","cut_double"},
{"slab", "oxidized", "_double","weathered_cut_double"},
{"slab", "weathered", "_double","exposed_cut_double"},
{"stair", "exposed", "","cut"},
{"stair", "oxidized", "", "weathered_cut"},
{"stair", "weathered", "", "exposed_cut"},
}]]
local block_oxidation = { local block_oxidation = {
{ "", "_exposed" }, { "", "_exposed" },
{ "_cut", "_exposed_cut" }, { "_cut", "_exposed_cut" },
@ -43,33 +7,117 @@ local block_oxidation = {
{ "_weathered_cut", "_oxidized_cut" } { "_weathered_cut", "_oxidized_cut" }
} }
local stair_oxidation = { local stair_oxidization = {
{ "slab", "cut", "exposed_cut" }, { "cut", "exposed_cut" },
{ "slab", "exposed_cut", "weathered_cut" }, { "cut_inner", "exposed_cut_inner" },
{ "slab", "weathered_cut", "oxidized_cut" }, { "cut_outer", "exposed_cut_outer" },
{ "slab", "cut_top", "exposed_cut_top" }, { "exposed_cut", "weathered_cut" },
{ "slab", "exposed_cut_top", "weathered_cut_top" }, { "exposed_cut_inner", "weathered_cut_inner" },
{ "slab", "weathered_cut_top", "oxidized_cut_double" }, { "exposed_cut_outer", "weathered_cut_outer" },
{ "slab", "cut_double", "exposed_cut_double" }, { "weathered_cut", "oxidized_cut" },
{ "slab", "exposed_cut_double", "weathered_cut_double" }, { "weathered_cut_inner", "oxidized_cut_inner" },
{ "slab", "weathered_cut_double", "oxidized_cut_double" }, { "weathered_cut_outer", "oxidized_cut_outer" }
{ "stair", "cut", "exposed_cut" }, }
{ "stair", "exposed_cut", "weathered_cut" },
{ "stair", "weathered_cut", "oxidized_cut" }, local slab_oxidization = {
{ "stair", "cut_inner", "exposed_cut_inner" }, { "cut", "exposed_cut" },
{ "stair", "exposed_cut_inner", "weathered_cut_inner" }, { "cut_top", "exposed_cut_top" },
{ "stair", "weathered_cut_inner", "oxidized_cut_inner" }, { "cut_double", "exposed_cut_double" },
{ "stair", "cut_outer", "exposed_cut_outer" }, { "exposed_cut", "weathered_cut" },
{ "stair", "exposed_cut_outer", "weathered_cut_outer" }, { "exposed_cut_top", "weathered_cut_top" },
{ "stair", "weathered_cut_outer", "oxidized_cut_outer" } { "exposed_cut_double", "weathered_cut_double" },
{ "weathered_cut", "oxidized_cut" },
{ "weathered_cut_top", "oxidized_cut_double" },
{ "weathered_cut_double", "oxidized_cut_double" },
} }
for _, b in pairs(block_oxidation) do 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 end
for _, s in pairs(stair_oxidation) do local def
register_oxidation_abm("Copper oxidation", "mcl_stairs:" .. s[1] .. "_copper_" .. s[2], "mcl_stairs:" .. s[1] .. "_copper_" .. s[3]) local def_variant_oxidized
-- 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. local def_variant_waxed
local def_variant_scraped
-- register abm, then set up oxidized and waxed variants.
for i = 1, #stair_oxidization do
register_oxidation_abm("mcl_stairs:stair_copper_" .. stair_oxidization[i][1])
register_oxidation_abm("mcl_stairs:slab_copper_" .. slab_oxidization[i][1])
-- stairs
def = "mcl_stairs:stair_copper_" .. stair_oxidization[i][1]
def_variant_oxidized = "mcl_stairs:stair_copper_" .. stair_oxidization[i][2]
minetest.override_item(def, { _mcl_oxidized_variant = def_variant_oxidized })
def_variant_waxed = "mcl_stairs:stair_waxed_copper_" .. stair_oxidization[i][2]
minetest.override_item(def, { _mcl_waxed_variant = def_variant_waxed })
-- slabs
def = "mcl_stairs:slab_copper_" .. slab_oxidization[i][1]
def_variant_oxidized = "mcl_stairs:slab_copper_" .. slab_oxidization[i][2]
minetest.override_item(def, { _mcl_oxidized_variant = def_variant_oxidized })
def_variant_waxed = "mcl_stairs:slab_waxed_copper_" .. slab_oxidization[i][1]
minetest.override_item(def, { _mcl_waxed_variant = def_variant_waxed })
end end
-- Set up scraped variants.
for i = 1, #stair_oxidization do
-- does both stairs and slabs.
if i > 3 then
def = "mcl_stairs:stair_copper_" .. stair_oxidization[i][1]
def_variant_scraped = "mcl_stairs:stair_copper_" .. stair_oxidization[i - 3][1]
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
def = "mcl_stairs:slab_copper_" .. slab_oxidization[i][1]
def_variant_scraped = "mcl_stairs:slab_copper_" .. slab_oxidization[i - 3][1]
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
end
if i > 6 then
def = "mcl_stairs:stair_copper_" .. stair_oxidization[i][2]
def_variant_scraped = "mcl_stairs:stair_copper_" .. stair_oxidization[i][1]
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
def = "mcl_stairs:slab_copper_" .. slab_oxidization[i][2]
def_variant_scraped = "mcl_stairs:slab_copper_" .. slab_oxidization[i][1]
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
end
end
-- Set up scraped variants for waxed stairs.
local waxed_variants = {
{ "waxed_copper_cut", "copper_cut" },
{ "waxed_copper_exposed_cut", "copper_exposed_cut" },
{ "waxed_copper_weathered_cut", "copper_weathered_cut" },
{ "waxed_copper_oxidized_cut", "copper_oxidized_cut" },
}
for i = 1, #waxed_variants do
-- stairs
def = "mcl_stairs:stair_" .. waxed_variants[i][1]
def_variant_scraped = "mcl_stairs:stair_" .. waxed_variants[i][2]
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
def = "mcl_stairs:stair_" .. waxed_variants[i][1] .. "_inner"
def_variant_scraped = "mcl_stairs:stair_" .. waxed_variants[i][2] .. "_inner"
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
def = "mcl_stairs:stair_" .. waxed_variants[i][1] .. "_outer"
def_variant_scraped = "mcl_stairs:stair_" .. waxed_variants[i][2] .. "_outer"
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
-- slab
def = "mcl_stairs:slab_" .. waxed_variants[i][1]
def_variant_scraped = "mcl_stairs:slab_" .. waxed_variants[i][2]
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
def = "mcl_stairs:slab_" .. waxed_variants[i][1] .. "_top"
def_variant_scraped = "mcl_stairs:slab_" .. waxed_variants[i][2] .. "_top"
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
def = "mcl_stairs:slab_" .. waxed_variants[i][1] .. "_double"
def_variant_scraped = "mcl_stairs:slab_" .. waxed_variants[i][2] .. "_double"
minetest.override_item(def, { _mcl_stripped_variant = def_variant_scraped })
end

View File

@ -1,4 +1,4 @@
name = mcl_copper name = mcl_copper
author = NO11 author = NO11
depends = mcl_core, mcl_sounds, mcl_stairs, mcl_util depends = mcl_core, mcl_sounds, mcl_stairs, mcl_util, mcl_oxidization
description = Adds Copper Ore, blocks and items. description = Adds Copper Ore, blocks and items.

View File

@ -34,7 +34,8 @@ minetest.register_node("mcl_copper:block", {
sounds = mcl_sounds.node_sound_metal_defaults(), sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 3, _mcl_hardness = 3,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block", _mcl_oxidized_variant = "mcl_copper:block_exposed",
_mcl_waxed_variant = "mcl_copper:waxed_block",
}) })
minetest.register_node("mcl_copper:waxed_block", { minetest.register_node("mcl_copper:waxed_block", {
@ -58,7 +59,8 @@ minetest.register_node("mcl_copper:block_exposed", {
sounds = mcl_sounds.node_sound_metal_defaults(), sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 5, _mcl_hardness = 5,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed", _mcl_oxidized_variant = "mcl_copper:block_weathered",
_mcl_waxed_variant = "mcl_copper:waxed_block_exposed",
_mcl_stripped_variant = "mcl_copper:block", _mcl_stripped_variant = "mcl_copper:block",
}) })
@ -83,7 +85,8 @@ minetest.register_node("mcl_copper:block_weathered", {
sounds = mcl_sounds.node_sound_metal_defaults(), sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 5, _mcl_hardness = 5,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered", _mcl_oxidized_variant = "mcl_copper:block_oxidized",
_mcl_waxed_variant = "mcl_copper:waxed_block_weathered",
_mcl_stripped_variant = "mcl_copper:block_exposed", _mcl_stripped_variant = "mcl_copper:block_exposed",
}) })
@ -108,7 +111,7 @@ minetest.register_node("mcl_copper:block_oxidized", {
sounds = mcl_sounds.node_sound_metal_defaults(), sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 5, _mcl_hardness = 5,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized", _mcl_waxed_variant = "mcl_copper:waxed_block_oxidized",
_mcl_stripped_variant = "mcl_copper:block_weathered", _mcl_stripped_variant = "mcl_copper:block_weathered",
}) })
@ -133,7 +136,8 @@ minetest.register_node("mcl_copper:block_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(), sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 5, _mcl_hardness = 5,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut", _mcl_oxidized_variant = "mcl_copper:block_cut_exposed",
_mcl_waxed_variant = "mcl_copper:waxed_block_cut",
}) })
minetest.register_node("mcl_copper:waxed_block_cut", { minetest.register_node("mcl_copper:waxed_block_cut", {
@ -157,7 +161,8 @@ minetest.register_node("mcl_copper:block_exposed_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(), sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 5, _mcl_hardness = 5,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut", _mcl_waxed_variant = "mcl_copper:waxed_block_exposed_cut",
_mcl_oxidized_variant = "mcl_copper:block_cut_weathered",
_mcl_stripped_variant = "mcl_copper:block_cut", _mcl_stripped_variant = "mcl_copper:block_cut",
}) })
@ -183,7 +188,8 @@ minetest.register_node("mcl_copper:block_weathered_cut", {
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 5, _mcl_hardness = 5,
_mcl_stripped_variant = "mcl_copper:block_exposed_cut", _mcl_stripped_variant = "mcl_copper:block_exposed_cut",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut", _mcl_oxidized_variant = "mcl_copper:block_cut_oxidized",
_mcl_waxed_variant = "mcl_copper:waxed_block_weathered_cut",
}) })
minetest.register_node("mcl_copper:waxed_block_weathered_cut", { minetest.register_node("mcl_copper:waxed_block_weathered_cut", {
@ -208,7 +214,7 @@ minetest.register_node("mcl_copper:block_oxidized_cut", {
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 5, _mcl_hardness = 5,
_mcl_stripped_variant = "mcl_copper:block_weathered_cut", _mcl_stripped_variant = "mcl_copper:block_weathered_cut",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut", _mcl_waxed_variant = "mcl_copper:waxed_block_oxidized_cut",
}) })
minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { minetest.register_node("mcl_copper:waxed_block_oxidized_cut", {

View File

@ -16,8 +16,8 @@ function mcl_honey.wax_block(pos, node, player, itemstack)
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
if def and def._mcl_copper_waxed_variant then if def and def._mcl_waxed_variant then
node.name = def._mcl_copper_waxed_variant node.name = def._mcl_waxed_variant
end end
minetest.set_node(pos, node) minetest.set_node(pos, node)