minetest.register_ore

From Minetest Developer Wiki
Jump to: navigation, search

Contents

Syntax

minetest.register_ore(ore_def)
  • ore_def A table describing how the ore should generate

Description

Registers an ore to generate, this replaces default.generate_ore()

The ore_def table contains:

ore_type See Ore types "scatter"
ore The name of the ore node "default:stone_with_coal"
wherein The node that the ore will generate inside of "default:stone"
clust_scarcity Ore has a 1 out of clust_scarcity chance of spawning in a node. 8*8*8
clust_num_ores Number of ores in a cluster 8
clust_size Size of the bounding box of the cluster 3
height_min The lowest level that the ore will generate at -31000
height_max The highest level that the ore will generate at 64
noise_threshhold If noise is above this threshold, ore is placed. Not needed for a uniform distribution 0.5
noise_params NoiseParams structure describing the perlin noise used for ore distribution {offset=0, scale=1, spread={x=100, y=100, z=100}, seed=23, octaves=3, persist=0.70}
random_factor Multiplier of the randomness contribution to the noise value at any given point to decide if ore should be placed. Set to 0 for solid veins. This parameter is only valid for ore_type == "vein". 1.0

The NoiseParams table is mandatory for the sheet ore type, it can also be specified for the scatter type, if it is not specified ores will be distributed evenly.

The structure is in the format:

{offset=0, scale=1, spread={x=100, y=100, z=100}, seed=23, octaves=3, persist=0.70}


Ore types

These tell in what manner the ore is generated. All default ores are of the uniformly-distributed scatter type.

scatter

Randomly chooses a location and generates a cluster of ore.

If noise_params is specified, the ore will be placed if the 3d perlin noise at that point is greater than the noise_threshhold, giving the ability to create a non-equal distribution of ore.

sheet

Creates a sheet of ore in a blob shape according to the 2D perlin noise described by `noise_params` and `noise_threshold`. This is essentially an improved version of the so-called "stratus" ore seen in some unofficial mods.

This sheet consists of vertical columns of uniform randomly distributed height, varying between the inclusive range `column_height_min` and `column_height_max`. If `column_height_min` is not specified, this parameter defaults to 1. If `column_height_max` is not specified, this parameter defaults to `clust_size` for reverse compatibility. New code should prefer `column_height_max`.

The `column_midpoint_factor` parameter controls the position of the column at which ore eminates from. If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow equally starting from each direction. `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If this parameter is not specified, the default is 0.5.

The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this ore type.

puff

Creates a sheet of ore in a cloud-like puff shape.

As with the `sheet` ore type, the size and shape of puffs are described by `noise_params` and `noise_threshold` and are placed at random vertical positions within the currently generated chunk.

The vertical top and bottom displacement of each puff are determined by the noise parameters `np_puff_top` and `np_puff_bottom`, respectively.

blob

Creates a deformed sphere blobs of ore according to 3d perlin noise described by noise_params. The maximum size of the blob is clust_size, and clust_scarcity has the same meaning as with scatter type.

vein

Creates veins of ore varying in density by according to the intersection of two instances 3d perlin noise with diffferent seeds both described by noise_params. random_factor varies the influence random chance has on placement of an ore inside the vein, which is 1 by default. Note that modifying this parameter may require adjusting noise_threshhold. The parameters clust_scarcity, clust_num_ores, and clust_size are ignored by this ore type. This ore type is difficult to control since it is sensitive to small changes. The following is a decent set of parameters to work from:

	noise_params = {
		offset = 0,
		scale = 3,
		spread = {x=200, y=200, z=200},
		seed = 5390,
		octaves = 4,
		persist = 0.5,
		flags = "eased",
	},
	noise_threshhold = 1.6

WARNING: Use this ore type *very* sparingly since it is ~200x more computationally expensive than any other ore.


Ore attributes

See section "Flag Specifier Format".

Currently supported flags: `absheight`

absheight

Also produce this same ore between the height range of `-y_max` and `-y_min`.

Useful for having ore in sky realms without having to duplicate ore entries.

puff_cliffs

If set, puff ore generation will not taper down large differences in displacement when approaching the edge of a puff. This flag has no effect for ore types other than `puff`.

puff_additive_composition

By default, when noise described by `np_puff_top` or `np_puff_bottom` results in a negative displacement, the sub-column at that point is not generated. With this attribute set, puff ore generation will instead generate the absolute difference in noise displacement values. This flag has no effect for ore types other than `puff`.


Example

minetest.register_ore({
    ore_type       = "scatter",
    ore            = "default:stone_with_coal",
    wherein        = "default:stone",
    clust_scarcity = 8*8*8,
    clust_num_ores = 8,
    clust_size     = 3,
    height_min     = -31000,
    height_max     = 64,
})


See also

ore generation code

Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox