Mapgen Parameters

From Minetest Developer Wiki
Jump to: navigation, search

All map generator algorithms have a few common parameters, plus any mapgen-specific options such as noise parameters or threshhold values. Only mapgen-generic parameters are listed here; mapgen-specific ones are listed in the corresponding mapgen wiki page.

Contents

[edit] Mapgen parameter source precedence

There are several sources which the map generator may retrieve parameters from. In order from highest precedence to lowest they are:

  • Hard-coded
  • Lua mods
  • map_meta.txt
  • Game-specific config file
  • Global config file
  • Default settings (set in defaultsettings.cpp)
  • Default object constructor values

[edit] List of mapgen parameters

[edit] Mapgen name

The name of the map generator algorithm being used. Currently supported:

Mapgen name Developer responsible Description
v6 kwolekr, celeron55 The current default map generator. Uses an improved Mapgen v2 algorithm for base terrain; terrain is generated entirely using 2D Perlin noise.
v7 kwolekr The next generation map generator with an emphasis on generating interesting and playable terrain. Has full support for the internal biome infrastructure and uses a mixture of 2D and both positive and negative 3D noise for terrain.
indev proller Mapgen v6 with some interesting experimental features and tweaks added, such as floatlands, terrain that gets higher in scale the further the from the origin, and extremely large caves.
math proller Generates terrain based off of 3d fractals, e.g. Mandelbulb. Not intended to be used for a traditional game of Minetest.
singlenode celeron55 Places only a single node everywhere, namely the one aliased to mapgen_singlenode (by default air). Intended to be used by mods that perform total mapgen takeovers.

[edit] Seed

A 64-bit unsigned integer value. At this time, only the lower 32 bits are currently used for randomization.

[edit] Water level

The y coordinate at which water starts being placed, for mapgens that do place water.
This is also the position at which blocks are assumed to be underground if no block above is present, and thus is not given sunlight.

[edit] Flags parameter

The flags parameter is a set of booleans indicating whether or not a certain option is enabled. Flags can be a combination of the possible values detailed in the table below.
Like all other config and Lua flag fields, they are represented as a comma-delimited string. E.g. the flag string "trees, caves, flat" would direct the Mapgen to create flat terrain with trees and caves.
An exhaustive list of currently recognized Mapgen flags:

Lua/config flag name Internal constant Respected by Description
trees MG_TREES v6, indev Place trees on the map according to the tree noise distribution.
caves MG_CAVES v6, indev, v7 Carve out caves from the terrain.
dungeons MG_DUNGEONS v6, indev, v7 Randomly place dungeons onto the map.
flat MG_FLAT v6, indev, v7 Make all terrain occur at the y position 0, resulting in a flat map. Note that this attribute does NOT turn off trees, caves, or any other feature.
nolight MG_NOLIGHT v6, indev, v7, singlenode Do not calculate lighting; instead leave set to 0 (total darkness). This is intended to be set by custom Lua map generators, NOT end users.
v6_jungles MGV6_JUNGLES v6, indev Place 0.3-style jungles on the map according to v6's own
note.png
Note: not biome
humidity noise distribution.
v6_biome_blend MGV6_BIOME_BLEND v6, indev Dither nodes between biomes to create a transition between them.
v7_mountains MGV7_MOUNTAINS Place 3d noise-defined mountains. Currently, not user-accessible.
v7_ridges MGV7_RIDGES Place 3d noise-defined rivers and ridges. Currently, not user-accessible.

[edit] Chunk size

The side length (in MapBlocks) of the cubic area that is generated at once. Default is 5; larger values take longer to generate but blocks generate quicker on average and could produce larger, more intricate caves and dungeons.
Don't mess around with this if you don't know what you're doing! This parameter cannot be modified through the Lua API.

[edit] Mapgen Parameter Lua API

The task of getting and setting mapgen parameters is much trickier than it seems it should be. For this reason there exists a small but effective set of API for accomplishing this.

[edit] minetest.register_on_mapgen_init()

Available in 0.4.8+

Registers a callback that is called after mods initially run but before the environment is created, while the mapgen is being initialized. This allows modification of map generation parameters via minetest.set_mapgen_params() and registration of additional decorations, nodes, etc. required by the mapgen.

  • mapgen_params — Table of mapgen parameters. Fields that are unset/nil leave that parameter unchanged.
    • mgname — Name of the mapgen to use (e.g. "singlenode", "v6", "v7").
    • seed — Seed
    • water_level — Water level.
    • flags — Comma-delimited string of flags to set. Clears a flag if the prefix "no" is added. Same format and options as "mg_flags" in minetest.conf.

Note that this callback is the correct place for a mod to determine and override map generation parameters; reading the configuration file for parameter overrides is incorrect, since there are many other sources from which the mapgen parameters could be set.


[edit] minetest.set_mapgen_params()

Available in 0.4.10+

Sets map generation parameters. Cannot be called after the registration period; only initialization and on_mapgen_init (calls made elsewhere will not have any effect).

If there are multiple callbacks registered to run on_mapgen_init and there are multiple calls to minetest.set_mapgen_params(), the effective parameter modification is the one passed to the most recent call to minetest.set_mapgen_params(). Also, since parameter modification does not take effect until after all on_mapgen_init callbacks have been completed, prior staged changes are not visible to later callbacks.

  • mapgen_params — Table of mapgen parameters. Fields that are unset/nil leave that parameter unchanged.
    • mgname — Name of the mapgen to use (e.g. "singlenode", "v6", "v7").
    • seed — Seed
    • water_level — Water level.
    • flags — Comma-delimited string of flags to set. Clears a flag if the prefix "no" is added. Same format and options as "mg_flags" in minetest.conf.
Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox