From Minetest Developer Wiki
Jump to: navigation, search



minetest.register_decoration(decoration definition)


The decoration definition is a table containing the following fields:

deco_type = "simple", -- See "Decoration types"
place_on = "default:dirt_with_grass",

  • Node that decoration can be placed on

sidelen = 8,

  • Size of divisions made in the chunk being generated.
  • If the chunk size is not evenly divisible by sidelen, sidelen is made equal to the chunk size.

fill_ratio = 0.02,

  • Ratio of the division to be uniformly filled by the decoration.
  • Used only if noise_params is not specified.

noise_params = {offset=0, scale=.45, spread={x=100, y=100, z=100}, seed=354, octaves=3, persist=0.7},

  • NoiseParams structure describing the 2D perlin noise used for decoration distribution.
  • The value of the perlin noise at the center of the division is the fill_ratio used for this division.

biomes = {"Oceanside", "Hills", "Plains"},

  • List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
  • and ignored if the Mapgen being used does not support biomes.

Simple-type parameters

decoration = "default:grass",

  • The node name used as the decoration.
  • If instead a list of strings, a randomly selected node from the list is placed as the decoration.

height = 1,

  • Number of nodes high the decoration is made.
  • If height_max is not 0, this is the lower bound of the randomly selected height.

height_max = 0,

  • Number of nodes the decoration can be at maximum.
  • If absent, the parameter 'height' is used as a constant.

spawn_by = "default:water",

  • Node that the decoration only spawns next to, in a 1-node square radius.

num_spawn_by = 1,

  • Number of spawn_by nodes that must be surrounding the decoration position to occur.
  • If absent or -1, decorations occur next to any nodes.

Schematic-type parameters

schematic = "foobar.mts",

  • If schematic is a string, it is the filepath relative to the current working directory of the
  • specified Minetest schematic file.
  • - OR -, could instead be a table containing two mandatory fields, size and data,
  • and an optional table yslice_prob:

schematic = {
        size = {x=4, y=6, z=4},
        data = {
                {name="cobble", param1=255, param2=0},
                {name="dirt_with_grass", param1=255, param2=0},
        yslice_prob = {
                {ypos=2, prob=128},
                {ypos=5, prob=64},

  • See 'Schematic specifier' for details.

replacements = {{"oldname", "convert_to"}, ...},
flags = "place_center_x, place_center_z",

  • Flags for schematic decorations. See 'Schematic attributes'.

rotation = "90" --rotate schematic 90 degrees on placement

  • Rotation can be "0", "90", "180", "270", or "random".


Simple decoration

This code would spawn a single block (an example bush in this case) on top of an example grass block in a grassland biome, assuming this biome has been specified before:

	deco_type = "simple",
	place_on = "example:earth_with_grass",
	sidelen = 16,
	fill_ratio = 0.03,
	biomes = {"grassland"},
	decoration = "example:bush",
	height = 1,

Schematic decoration

This is a slightly modified code snippet from an early version of the game “Weird”. It first generates a simple cuboid as schematic in-line and then uses minetest.register_decoration to scatter the cuboids around a biome.

--[[ This code specifies a schematic entirely in-line. It is a 3×4×3 cuboid out of cheese blocks. ]]
local cuboid = {}
for j=3, 3*4*3 do
	table.insert(cuboid, {name = "mobs:cheeseblock", param1=255, param2=0})
--[[ This will scatter the cuboid schematic all over the biome “cheese” which has been specified somewhere else in the code ]]
	deco_type = "schematic",
	place_on = "mobs:cheeseblock",
	sidelen = 16,
	fill_ratio = 0.005,
	biomes = {"cheese"},
	schematic = {
		size = {x=3, y=4, z=3},
		data = cuboid,
	-- Note that place_center_y is set to false. This is because we want the cuboids to appear as if they lie "on" the surface..
	flags = {place_center_x = true, place_center_y = false, place_center_z = true},
Mbox important.png This article is incomplete.
Please help expand this article to include more useful information.
Personal tools