minetest.register_on_mapgen_init

From Minetest Developer Wiki
Jump to: navigation, search

Contents

Syntax

minetest.register_on_mapgen_init(func(mapgen_params))

Description

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"). Same format and options as "mg_name" in minetest.conf
    • 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.

See Also

Examples

  ## excerpt from map_meta.txt, also suitable for use in minetest.conf
  mg_flags = trees, caves, nodungeons, noflat, light
  mg_name = v6
  seed = 7977035405896799191
  water_level = 1
  ## excerpt from map_meta.txt, also suitable for use in minetest.conf
  mg_flags = trees, caves, dungeons, noflat, light
  mg_name = v7
  seed = 8156045081748912411
  water_level = 1
Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox