Created mcl_oxidization API, and converted mcl_copper to use it. Documented API.
parent
b2e0b9b08b
commit
c3cf92baa6
|
@ -0,0 +1,46 @@
|
||||||
|
# Mineclone Oxidization API
|
||||||
|
This document explains the API of this mod.
|
||||||
|
|
||||||
|
### `register_oxidation_abm(abm_name, 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:
|
||||||
|
`abm_name`: A unique name for the abm to register.
|
||||||
|
|
||||||
|
`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("Copper oxidation", "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.
|
||||||
|
|
|
@ -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(abm_name, node_name, oxidized_variant)
|
||||||
|
minetest.register_abm({
|
||||||
|
label = abm_name,
|
||||||
|
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
|
|
@ -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.
|
|
@ -1,17 +1,5 @@
|
||||||
--local deepslate_mod = minetest.get_modpath("mcl_deepslate")
|
--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 = {
|
local stairs = {
|
||||||
{"stair", "exposed", "_inner", "cut_inner"},
|
{"stair", "exposed", "_inner", "cut_inner"},
|
||||||
|
|
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue