-- easy_minerals
-- Configurable ore generation inspired by Minecraft-style distribution

--------------------------------------------------
-- CONFIGURATION
-- Edit these values freely
--------------------------------------------------

local ORES = {

    coal = {
        node = "default:stone_with_coal",
        scarcity = 8,      -- Lower = more common
        num_ores = 20,     -- Ores per cluster
        size = 5,          -- Cluster size
        y_max = 64,
        y_min = -31000
    },

    iron = {
        node = "default:stone_with_iron",
        scarcity = 10,
        num_ores = 15,
        size = 4,
        y_max = 54,
        y_min = -31000
    },

    copper = {
        node = "default:stone_with_copper",
        scarcity = 12,
        num_ores = 12,
        size = 4,
        y_max = 48,
        y_min = -31000
    },

    gold = {
        node = "default:stone_with_gold",
        scarcity = 15,
        num_ores = 9,
        size = 3,
        y_max = -16,
        y_min = -31000
    },

    diamond = {
        node = "default:stone_with_diamond",
        scarcity = 20,
        num_ores = 5,
        size = 3,
        y_max = -64,
        y_min = -31000
    },

    mese = {
        node = "default:stone_with_mese",
        scarcity = 24,
        num_ores = 4,
        size = 3,
        y_max = -128,
        y_min = -31000
    }
}

--------------------------------------------------
-- CLEAR PREVIOUS ORE REGISTRATIONS
--------------------------------------------------

minetest.clear_registered_ores()

--------------------------------------------------
-- REGISTER ORES
--------------------------------------------------

for name, def in pairs(ORES) do

    minetest.register_ore({
        ore_type       = "scatter",
        ore            = def.node,
        wherein        = "default:stone",
        clust_scarcity = def.scarcity * def.scarcity * def.scarcity,
        clust_num_ores = def.num_ores,
        clust_size     = def.size,
        y_max          = def.y_max,
        y_min          = def.y_min,
    })

    minetest.log("action", "[easy_minerals] Registered ore: " .. name)
end
