diff --git a/lua_api.html b/lua_api.html index 66d6e30..73bf069 100644 --- a/lua_api.html +++ b/lua_api.html @@ -4,7 +4,7 @@ layout: default ---
If you have any difficulty in understanding this, please read Programming in Lua.
init.lua
scripts in a shared environment.
$path_share/games/gameid/
$path_user/games/gameid/
where gameid
is unique to each game.
The game directory contains the file game.conf
, which contains:
name = <Human-readable full name of the game>
-
-e.g.
-name = Minetest
-
-Optionally, game.conf can also contain:
-disallowed_mapgens = <comma-separated mapgens>
-
-e.g.
-disallowed_mapgens = v5,v6,flat
-
-These mapgens are removed from the list of mapgens for the game.
-The game directory can contain the file minetest.conf, which will be used -to set default settings when running the particular game. -It can also contain a settingtypes.txt in the same format as the one in builtin. -This settingtypes.txt will be parsed by the menu and the settings will be displayed -in the "Games" category in the settings tab.
+Where gameid
is unique to each game.
The game directory can contain the following files:
+game.conf
, which contains:
+minetest.conf
:
+ Used to set default settings when running this game.settingtypes.txt
:
+ In the same format as the one in builtin.
+ This settingtypes.txt will be parsed by the menu and the settings will be
+ displayed in the "Games" category in the advanced settings tab.textures
the server will load it as a
+ texturepack, overriding mod textures.
+ Any server texturepack will override mod textures and the game texturepack.Games can provide custom main menu images. They are put inside a menu
directory
-inside the game directory.
The images are named $identifier.png
, where $identifier
is
-one of overlay,background,footer,header
.
-If you want to specify multiple images for one identifier, add additional images named
-like $identifier.$n.png
, with an ascending number $n starting with 1, and a random
-image will be chosen from the provided ones.
Games can provide custom main menu images. They are put inside a menu
+directory inside the game directory.
The images are named $identifier.png
, where $identifier
is one of
+overlay
, background
, footer
, header
.
+If you want to specify multiple images for one identifier, add additional
+images named like $identifier.$n.png
, with an ascending number $n starting
+with 1, and a random image will be chosen from the provided ones.
Generic:
#
, which are comments.
mods |-- modname -| |-- depends.txt +| |-- mod.conf | |-- screenshot.png -| |-- description.txt | |-- settingtypes.txt | |-- init.lua | |-- models @@ -553,16 +559,32 @@ empty, except for lines starting with
#
, which are comments.modname
The location of this directory can be fetched by using
+minetest.get_modpath(modname)
.mod.conf
+A key-value store of mod details.
++
+- #
+name
- the mod name. Allows Minetest to determine the mod name even if the + folder is wrongly named.- #
+description
- Description of mod to be shown in the Mods tab of the mainmenu.- #
+depends
- A comma separated list of dependencies. These are mods that must + be loaded before this mod.- #
+optional_depends
- A comma separated list of optional dependencies. + Like a dependency, but no error if the mod doesn't exist.Note: to support 0.4.x, please also provide depends.txt.
++
screenshot.png
A screenshot shown in the mod manager within the main menu. It should +have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
+
depends.txt
Deprecated: you should use mod.conf instead.
+This file is used if there are no dependencies in mod.conf.
List of mods that have to be loaded before loading this mod.
A single line contains a single modname.
Optional dependencies can be defined by appending a question mark to a single modname. This means that if the specified mod is missing, it does not prevent this mod from being loaded.
--
screenshot.png
A screenshot shown in the mod manager within the main menu. It should -have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
+
description.txt
Deprecated: you should use mod.conf instead.
+This file is used if there is no description in mod.conf.
A file containing a description to be shown in the Mods tab of the mainmenu.
settingtypes.txt
A file in the same format as the one in builtin. It will be parsed by the @@ -714,7 +736,8 @@ on top of
cobble.png
.<n>
= animation frame count *<p>
= current animation frameDraw a step of the crack animation on the texture. -
+crack
draws it normally, whilecracko
lays it over, keeping transparent pixels intact.crack
draws it normally, whilecracko
lays it over, keeping transparent +pixels intact.Example:
@@ -785,7 +808,8 @@ Rotations are counter-clockwise.default_cobble.png^[crack:10:1
default_stone.png^[transformFXR90
-
[inventorycube{<top>{<left>{<right>
Escaping does not apply here and
+^
is replaced by&
in texture names instead.Escaping does not apply here and
^
is replaced by&
in texture names +instead.Create an inventory cube texture using the side textures.
Example:
[inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png @@ -826,8 +850,8 @@ texture pixel.
Multiplies texture colors with the given color.
+color. Meaning white surfaces get a lot of your new color while black parts +don't change very much.<color>
is specified as aColorString
. Result is more like what you'd expect if you put a color on top of another -color. Meaning white surfaces get a lot of your new color while black parts don't -change very much.Hardware coloring
The goal of hardware coloring is to simplify the creation of colorful nodes. If your textures use the same pattern, and they only @@ -860,17 +884,19 @@ node or
-ItemStack
. The palette is read from left to right and from top to bottom. If the palette has less than 256 pixels, then it is stretched to contain exactly 256 pixels (after arranging the pixels to one line). The indexing starts from 0.Examples: - 16x16 palette, index = 0: the top left corner - 16x16 palette, index = 4: the fifth pixel in the first row - 16x16 palette, index = 16: the pixel below the top left corner - 16x16 palette, index = 255: the bottom right corner - 2 (width)x4 (height) palette, index=31: the top left corner. +
+ to ensure the total 256 pixels. +Examples:
++
2x4 palette, index=32: the top right corner - 2x4 palette, index=63: the top right corner - 2x4 palette, index=64: the pixel below the top left corner- 16x16 palette, index = 0: the top left corner
+- 16x16 palette, index = 4: the fifth pixel in the first row
+- 16x16 palette, index = 16: the pixel below the top left corner
+- 16x16 palette, index = 255: the bottom right corner
+- 2 (width)x4 (height) palette, index=31: the top left corner. The palette has 8 pixels, so each pixel is stretched to 32 pixels, - to ensure the total 256 pixels. -
2x4 palette, index=32: the top right corner +2x4 palette, index=63: the top right corner +2x4 palette, index=64: the pixel below the top left corner +Using palettes with items
When registering an item, set the item definition's
@@ -881,34 +907,40 @@ index of the pixel to use.palette
field to a texture. You can also use texture modifiers.When registering a node, set the item definition's
+palette
field to a texture. You can also use texture modifiers. The node's color depends on itsparam2
, so you also must set an -appropriatedrawtype
: -drawtype = "color"
for nodes which use their fullparam2
for +appropriateparamtype2
:+
- #
+paramtype2 = "color"
for nodes which use their fullparam2
for palette indexing. These nodes can have 256 different colors. - The palette should contain 256 pixels. -drawtype = "colorwallmounted"
for nodes which use the first + The palette should contain 256 pixels.- #
+paramtype2 = "colorwallmounted"
for nodes which use the first five bits (most significant) ofparam2
for palette indexing. The remaining three bits are describing rotation, as inwallmounted
- draw type. Division by 8 yields the palette index (without stretching the + paramtype2. Division by 8 yields the palette index (without stretching the palette). These nodes can have 32 different colors, and the palette should contain 32 pixels. - Examples: - *param2 = 17
is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1) - pixel will be picked from the palette. - *param2 = 35
is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1) - pixel will be picked from the palette. -*drawtype = "colorfacedir"
for nodes which use the first + Examples: +- #
+paramtype2 = "colorfacedir"
for nodes which use the first three bits ofparam2
for palette indexing. The remaining - five bits are describing rotation, as infacedir
draw type. + five bits are describing rotation, as infacedir
paramtype2. Division by 32 yields the palette index (without stretching the palette). These nodes can have 8 different colors, and the palette should contain 8 pixels. - Examples: - *param2 = 17
is 0 * 32 + 17, so the rotation is 17 and the - first (= 0 + 1) pixel will be picked from the palette. - *param2 = 35
is 1 * 32 + 3, so the rotation is 3 and the - second (= 1 + 1) pixel will be picked from the palette. + Examples: +To colorize a node on the map, set its
+to the node's paramtype2).param2
value (according -to the node's draw type).Conversion between nodes in the inventory and the on the map
Static coloring is the same for both cases, there is no need for conversion.
@@ -919,8 +951,8 @@ automatically transferred between node and item forms by the engine, when a player digs or places a colored node. You can disable this feature by setting thedrop
field of the node to itself (without metadata). -To transfer the color to a special drop, you need a drop table. -Example: +To transfer the color to a special drop, you need a drop table. +Example:
minetest.register_node("mod:stone", { description = "Stone", tiles = {"default_stone.png"}, @@ -1083,7 +1115,7 @@ the global
andminetest.registered_*
tables.
minetest.unregister_item(name)
@@ -1099,7 +1131,7 @@ the global
- Unregisters the item name from engine, and deletes the entry with key
-- #
+name
fromminetest.registered_items
and from the associated item- #
name
fromminetest.registered_items
and from the associated item- #table according to its nature:
minetest.registered_nodes[]
etcminetest.registered_*
tables.
minetest.unregister_biome(name)
- Unregisters the biome name from engine, and deletes the entry with key
-- #
+name
fromminetest.registered_biome
- #
name
fromminetest.registered_biome
# @@ -1114,7 +1146,8 @@ the global @@ -1124,9 +1157,11 @@ the globalminetest.registered_*
tables.
minetest.register_decoration(decoration definition)
minetest.registered_*
tables.returns an integer uniquely identifying the registered schematic #added to minetest.registered_schematic
with the key ofschematic.name
#if -schematic.name
is nil, the key is the returned IDif the schematic is loaded from a file, schematic.name is set to the filename -if the function is called when loading the mod, and schematic.name is a relative - path, then the current mod path will be prepended to the schematic filename +if the schematic is loaded from a file, schematic.name is set to the + filename. +if the function is called when loading the mod, and schematic.name is a + relative path, then the current mod path will be prepended to the + schematic filename. # @@ -1220,20 +1255,22 @@ paramtype2 == "leveled" ^ Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted". Leveled nodebox: The level of the top face of the nodebox is stored in param2. - The other faces are defined by 'fixed = {}' like 'type = "fixed"' nodeboxes. + The other faces are defined by 'fixed = {}' like 'type = "fixed"' + nodeboxes. The nodebox height is (param2 / 64) nodes. The maximum accepted value of param2 is 127. Rooted plantlike: The height of the 'plantlike' section is stored in param2. The height is (param2 / 16) nodes. paramtype2 == "degrotate" -^ The rotation of this node is stored in param2. Plants are rotated this way. +^ Only valid for "plantlike". The rotation of the node is stored in param2. Values range 0 - 179. The value stored in param2 is multiplied by two to - get the actual rotation of the node. + get the actual rotation in degrees of the node. paramtype2 == "meshoptions" -^ Only valid for "plantlike". The value of param2 becomes a bitfield which can - be used to change how the client draws plantlike nodes. Bits 0, 1 and 2 form - a mesh selector. Currently the following meshes are choosable: +^ Only valid for "plantlike". The value of param2 becomes a bitfield which + can be used to change how the client draws plantlike nodes. + Bits 0, 1 and 2 form a mesh selector. + Currently the following meshes are choosable: 0 = a "x" shaped plant (ordinary plant) 1 = a "+" shaped plant (just rotated 45 degrees) 2 = a "*" shaped plant with 3 faces instead of 2 @@ -1260,7 +1297,8 @@ paramtype2 == "colorwallmounted" is picked from the palette. The palette should have 32 pixels. paramtype2 == "glasslikeliquidlevel" -^ Only valid for "glasslike_framed" or "glasslike_framed_optional" drawtypes. +^ Only valid for "glasslike_framed" or "glasslike_framed_optional" + drawtypes. param2 values 0-63 define 64 levels of internal liquid, 0 being empty and 63 being full. Liquid texture is defined using `special_tiles = {"modname_tilename.png"},` @@ -1270,30 +1308,127 @@ paramtype2 == "glasslikeliquidlevel" There are a bunch of different looking node types.
Look for examples in
games/minimal
orgames/minetest_game
.-
+- #
-normal
- #
-airlike
- #
-liquid
- #
-flowingliquid
- #
-glasslike
- #
-glasslike_framed
- #
-glasslike_framed_optional
- #
-allfaces
- #
-allfaces_optional
- #
-torchlike
- #
-signlike
- #
-plantlike
- #
-firelike
- #
-fencelike
- #
-raillike
- #
-nodebox
-- See below- #
-mesh
-- Use models for nodes, see below- #
+plantlike_rooted
-- See below- #
+normal
+
-- A node-sized cube.
+
*_optional
drawtypes need less rendering time if deactivated (always client side).- #
+airlike
+
+- Invisible, uses no texture.
+- #
+liquid
+
+- The cubic source node for a liquid.
+- #
+flowingliquid
+
+- The flowing version of a liquid, appears with various heights and slopes.
+- #
+glasslike
+
+- Often used for partially-transparent nodes.
+- Only external sides of textures are visible.
+- #
+glasslike_framed
+
+- All face-connected nodes are drawn as one volume within a surrounding + frame.
+- #The frame appearence is generated from the edges of the first texture + specified in
+tiles
. The width of the edges used are 1/16th of texture + size: 1 pixel for 16x16, 2 pixels for 32x32 etc.- #The glass 'shine' (or other desired detail) on each node face is supplied + by the second texture specified in
+tiles
.- #
+glasslike_framed_optional
+
+- This switches between the above 2 drawtypes according to the menu setting + 'Connected Glass'.
+- #
+allfaces
+
+- Often used for partially-transparent nodes.
+- External and internal sides of textures are visible.
+- #
+allfaces_optional
+
+- Often used for leaves nodes.
+- #This switches between
+normal
,glasslike
andallfaces
according to + the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.- #With 'Simple Leaves' selected, the texture specified in
+special_tiles
+ is used instead, if present. This allows a visually thicker texture to be + used to compensate for howglasslike
reduces visual thickness.- #
+torchlike
+
+- A single vertical texture.
+- #If placed on top of a node, uses the first texture specified in
+tiles
.- #If placed against the underside of a node, uses the second texture + specified in
+tiles
.- #If placed on the side of a node, uses the third texture specified in +
+tiles
and is perpendicular to that node.- #
+signlike
+
+- A single texture parallel to, and mounted against, the top, underside or + side of a node.
+- #
+plantlike
+
+- Two vertical and diagonal textures at right-angles to each other.
+- #See
+paramtype2 == "meshoptions"
above for other options.- #
+firelike
+
+- #When above a flat surface, appears as 6 textures, the central 2 as +
+plantlike
plus 4 more surrounding those.- If not above a surface the central 2 do not appear, but the texture + appears against the faces of surrounding nodes if they are present.
+- #
+fencelike
+
+- A 3D model suitable for a wooden fence.
+- One placed node appears as a single vertical post.
+- Adjacently-placed nodes cause horizontal bars to appear between them.
+- #
+raillike
+
+- Often used for tracks for mining carts.
+- #Requires 4 textures to be specified in
+tiles
, in order: Straight, + curved, t-junction, crossing.- #Each placed node automatically switches to a suitable rotated texture + determined by the adjacent
+raillike
nodes, in order to create a + continuous track network.- Becomes a sloping node if placed against stepped nodes.
+- #
+nodebox
+
+- Often used for stairs and slabs.
+- Allows defining nodes consisting of an arbitrary number of boxes.
+- See 'Node boxes' below for more information.
+- #
+mesh
+
+- Uses models for nodes.
+- Tiles should hold model materials textures.
+- Only static meshes are implemented.
+- For supported model formats see Irrlicht engine documentation.
+- #
+plantlike_rooted
+
+- #Enables underwater
+plantlike
without air bubbles around the nodes.- #Consists of a base cube at the co-ordinates of the node plus a +
+plantlike
extension above with a height ofparam2 / 16
nodes.- #The
+plantlike
extension visually passes through any nodes above the + base cube without affecting them.- #The base cube texture tiles are defined as normal, the
+plantlike
+ extension uses the defined special tile, for example: +special_tiles = { {name = "default_papyrus.png", tileable_vertical = true}},
*_optional
drawtypes need less rendering time if deactivated +(always client-side).Node boxes
-Node selection boxes are defined using "node boxes"
-The
+nodebox
node drawtype allows defining nodes consisting of an arbitrary -number of boxes. It allows defining stuff like stairs and slabs.Node selection boxes are defined using "node boxes".
A nodebox is defined as any of:
{ -- A normal cube; the default in most things @@ -1305,9 +1440,9 @@ number of boxes. It allows defining stuff like stairs and slabs. fixed = box OR {box1, box2, ...} } { - -- A variable height box (or boxes) with the top face position defined by - -- the node parameter 'leveled = ', or if 'paramtype2 == "leveled"' by - -- param2. + -- A variable height box (or boxes) with the top face position defined + -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"' + -- by param2. -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'. type = "leveled", fixed = box OR {box1, box2, ...} @@ -1341,7 +1476,8 @@ number of boxes. It allows defining stuff like stairs and slabs. disconnected_back = box OR {box1, box2, ...} disconnected_right = box OR {box1, box2, ...} disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour - disconnected_sides = box OR {box1, box2, ...} -- when there are *no* neighbours to the sides + disconnected_sides = box OR {box1, box2, ...} -- when there are *no* + neighbours to the sides }
A
@@ -1350,81 +1486,134 @@ number of boxes. It allows defining stuff like stairs and slabs.box
is defined as:A box of a regular node would look like:
-{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
Meshes
-If drawtype
-mesh
is used, tiles should hold model materials textures. -Only static meshes are implemented. -For supported model formats see Irrlicht engine documentation.Rooted plantlike drawtype
-The
+plantlike_rooted
drawtype was developed to enable underwater plants -without air bubbles around the plants. -It consists of a base cube at the co-ordinates of the node (the seabed / -lakebed / riverbed node) plus a 'plantlike' extension above with a height -defined by param2 (maximum height 16 nodes). This extension visually passes -through any nodes above the base cube without affecting them. -The node is dug by digging the base cube. -The base cube texture tiles are defined as normal, the plantlike extension -uses the defined 'special tile', for example: -special_tiles = { {name = "default_papyrus.png", tileable_vertical = true}},
Perlin noise
+Perlin noise creates a continuously-varying value depending on the input values. +Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes. +The result is used during map generation to create the terrain shape, vary heat +and humidity to distribute biomes, vary the density of decorations or vary the +structure of ores.
+Structure of perlin noise
+An 'octave' is a simple noise generator that outputs a value between -1 and 1. +The smooth wavy noise it generates has a single characteristic scale, almost +like a 'wavelength', so on its own does not create fine detail. +Due to this perlin noise combines several octaves to create variation on +multiple scales. Each additional octave has a smaller 'wavelength' than the +previous.
+This combination results in noise varying very roughly between -2.0 and 2.0 and +with an average value of 0.0, so
+scale
andoffset
are then used to multiply +and offset the noise variation.The final perlin noise variation is created as follows:
+noise = offset + scale * (octave1 + + octave2 * persistence + + octave3 * persistence ^ 2 + + octave4 * persistence ^ 3 + + ...)
Noise Parameters
-Noise Parameters, or commonly called "
+NoiseParams
", define the properties of -perlin noise.Noise Parameters are commonly called
NoiseParams
.-
offset
Offset that the noise is translated by (i.e. added) after calculation.
+After the multiplication by
scale
this is added to the result and is the final +step in creating the noise value. +Can be positive or negative.-
scale
Factor that the noise is scaled by (i.e. multiplied) after calculation.
+Once all octaves have been combined, the result is multiplied by this. +Can be positive or negative.
-
spread
Vector containing values by which each coordinate is divided by before calculation. -Higher spread values result in larger noise features.
-A value of
+{x=250, y=250, z=250}
is common.For octave1, this is roughly the change of input value needed for a very large +variation in the noise value generated by octave1. It is almost like a +'wavelength' for the wavy noise variation. +Each additional octave has a 'wavelength' that is smaller than the previous +octave, to create finer detail.
+spread
will therefore roughly be the typical +size of the largest structures in the final noise variation.
spread
is a vector with values for x, y, z to allow the noise variation to be +stretched or compressed in the desired axes. +Values are positive numbers.-
seed
Random seed for the noise. Add the world seed to a seed offset for world-unique noise. -In the case of
+minetest.get_perlin()
, this value has the world seed automatically added.This is a whole number that determines the entire pattern of the noise +variation. Altering it enables different noise patterns to be created. +With other parameters equal, different seeds produce different noise patterns +and identical seeds produce identical noise patterns.
+For this parameter you can randomly choose any whole number. Usually it is +preferable for this to be different from other seeds, but sometimes it is useful +to be able to create identical noise patterns.
+When used in mapgen this is actually a 'seed offset', it is added to the +'world seed' to create the seed used by the noise, to ensure the noise has a +different pattern in different worlds.
-
octaves
Number of times the noise gradient is accumulated into the noise.
-Increase this number to increase the amount of detail in the resulting noise.
-A value of
+6
is common.The number of simple noise generators that are combined. +A whole number, 1 or more. +Each additional octave adds finer detail to the noise but also increases the +noise calculation load. +3 is a typical minimum for a high quality, complex and natural-looking noise +variation. 1 octave has a slight 'gridlike' appearence.
+Choose the number of octaves according to the
spread
andlacunarity
, and the +size of the finest detail you require. For example: +ifspread
is 512 nodes,lacunarity
is 2.0 and finest detail required is 16 +nodes, octaves will be 6 because the 'wavelengths' of the octaves will be +512, 256, 128, 64, 32, 16 nodes.-
persistence
Factor by which the effect of the noise gradient function changes with each successive octave.
-Values less than
-1
make the details of successive octaves' noise diminish, while values -greater than1
make successive octaves stronger.A value of
+0.6
is common.Each additional octave has an amplitude that is the amplitude of the previous +octave multiplied by
+persistence
, to reduce the amplitude of finer details, +as is often helpful and natural to do so. +Since this controls the balance of fine detail to large-scale detail +persistence
can be thought of as the 'roughness' of the noise.A positive or negative non-zero number, often between 0.3 and 1.0. +A common medium value is 0.5, such that each octave has half the amplitude of +the previous octave. +This may need to be tuned when altering
lacunarity
; when doing so consider +that a common medium value is 1 / lacunarity.-
lacunarity
Factor by which the noise feature sizes change with each successive octave.
-A value of
+2.0
is common.Each additional octave has a 'wavelength' that is the 'wavelength' of the +previous octave multiplied by 1 / lacunarity, to create finer detail. +'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
+A positive number no smaller than 1.0. +Values below 2.0 create higher quality noise at the expense of requiring more +octaves to cover a paticular range of 'wavelengths'.
-
flags
Leave this field unset for no special handling.
-Currently supported are
+defaults
,eased
andabsvalue
.Leave this field unset for no special handling. +Currently supported are
defaults
,eased
andabsvalue
:-
defaults
Specify this if you would like to keep auto-selection of eased/not-eased while specifying -some other flags.
+Specify this if you would like to keep auto-selection of eased/not-eased while +specifying some other flags.
-
eased
Maps noise gradient values onto a quintic S-curve before performing interpolation. -This results in smooth, rolling noise. Disable this (
+noeased
) for sharp-looking noise. -If no flags are specified (or defaults is), 2D noise is eased and 3D noise is not eased.Maps noise gradient values onto a quintic S-curve before performing +interpolation. This results in smooth, rolling noise. +Disable this (
noeased
) for sharp-looking noise with a slightly gridded +appearence. +If no flags are specified (or defaults is), 2D noise is eased and 3D noise is +not eased. +Easing a 3D noise significantly increases the noise calculation load, so use +with restraint.-
absvalue
Accumulates the absolute value of each noise gradient result.
-Noise parameters format example for 2D or 3D perlin noise or perlin noise maps:
+The absolute value of each octave's noise variation is used when combining the +octaves. The final perlin noise variation is created as follows:
+noise = offset + scale * (abs(octave1) + + abs(octave2) * persistence + + abs(octave3) * persistence ^ 2 + + abs(octave4) * persistence ^ 3 + + ...)
+Format example
+For 2D or 3D perlin noise or perlin noise maps:
+np_terrain = { offset = 0, scale = 1, - spread = {x=500, y=500, z=500}, + spread = {x = 500, y = 500, z = 500}, seed = 571347, octaves = 5, persist = 0.63, lacunarity = 2.0, - flags = "defaults, absvalue" + flags = "defaults, absvalue", } -^ A single noise parameter table can be used to get 2D or 3D noise, - when getting 2D noise spread.z is ignored.
For 2D noise the Z component of
spread
is still defined but is ignored. +A single noise parameter table can be used for 2D or 3D noise.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 thenoise_threshold
, giving the ability to create -a non-equal distribution of ore.If
noise_params
is specified, the ore will be placed if the 3D perlin noise +at that point is greater than thenoise_threshold
, 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
column_height_minnoise_params
andnoise_threshold
. This is essentially an @@ -1433,31 +1622,33 @@ improved version of the so-called "stratus" ore seen in some unofficial mods.column_height_max
. Ifcolumn_height_min
is not specified, this parameter defaults to 1. Ifcolumn_height_max
is not specified, this parameter defaults toclust_size
-for reverse compatibility. New code should prefercolumn_height_max
. -The
-column_midpoint_factor
parameter controls the position of the column at which -ore emanates 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
+for reverse compatibility. New code should preferclust_scarcity
andclust_num_ores
are ignored for this ore type.column_height_max
. +The
+column_midpoint_factor
parameter controls the position of the column at +which ore emanates 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
andclust_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
andnoise_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
andnp_puff_bottom
, respectively.noise_params
andnoise_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
andnp_puff_bottom
, respectively.
blob
Creates a deformed sphere of ore according to 3d perlin noise described by -
noise_params
. The maximum size of the blob isclust_size
, and +noise_params
. The maximum size of the blob isclust_size
, andclust_scarcity
has the same meaning as with thescatter
type.
vein
Creates veins of ore varying in density by according to the intersection of two instances of 3d perlin noise with different seeds, both described by
noise_params
.+inside the vein, which is
random_factor
varies the influence random chance has on placement of an ore -inside the vein, which is1
by default. Note that modifying this parameter may -require adjustingnoise_threshold
.1
by default. Note that modifying this parameter +may require adjustingnoise_threshold
.The parameters
clust_scarcity
,clust_num_ores
, andclust_size
are ignored by this ore type.This ore type is difficult to control since it is sensitive to small changes. @@ -1469,6 +1660,7 @@ The following is a decent set of parameters to work from:
seed = 5390, octaves = 4, persist = 0.5, + lacunarity = 2.0, flags = "eased", }, noise_threshold = 1.6 @@ -1478,8 +1670,8 @@ computationally expensive than any other ore.
stratum
Creates a single undulating ore stratum that is continuous across mapchunk borders and horizontally spans the world.
-The 2D perlin noise described by
noise_params
defines the Y co-ordinate of the -stratum midpoint. The 2D perlin noise described bynp_stratum_thickness
+The 2D perlin noise described by
@@ -1487,8 +1679,8 @@ unlimited. to y_max in a simple horizontal stratum.noise_params
defines the Y co-ordinate of +the stratum midpoint. The 2D perlin noise described bynp_stratum_thickness
defines the stratum's vertical thickness (in units of nodes). Due to being continuous across mapchunk borders the stratum's vertical thickness is unlimited.A parameter
-stratum_thickness
can be provided instead of the noise parameternp_stratum_thickness
, to create a constant thickness.Leaving out one or both noise parameters makes the ore generation less intensive, -useful when adding multiple strata.
+Leaving out one or both noise parameters makes the ore generation less +intensive, useful when adding multiple strata.
@@ -1501,14 +1693,15 @@ solid-ore stratum would require a
y_min
andy_max
define the limits of the ore generation and for performance reasons should be set as close together as possible but without clipping the stratum's Y variation.clust_scarcity
of 1.Currently supported flags:
puff_cliffs
,puff_additive_composition
.-
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
.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
ornp_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 thanpuff
.By default, when noise described by
np_puff_top
ornp_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 thanpuff
.Decoration types
The varying types of decorations that can be placed.
@@ -1528,22 +1721,30 @@ structures, such as trees, cave spikes, rocks, and so on. Minetest Schematic file (
simple
.mts
) or through raw data supplied through Lua, in the form of a table. This table specifies the following fields:-
- #The
-size
field is a 3D vector containing the dimensions of the provided schematic. (required)- #The
+yslice_prob
field is a table of {ypos, prob} which sets theypos
th vertical slice - of the schematic to have aprob / 256 * 100
chance of occurring. (default: 255)- #The
+size
field is a 3D vector containing the dimensions of the provided + schematic. (required)- #The
yslice_prob
field is a table of {ypos, prob} which sets theypos
th + vertical slice of the schematic to have aprob / 256 * 100
chance of + occurring. (default: 255)- #The
-data
field is a flat table of MapNode tables making up the schematic, in the order of[z [y [x]]]
. (required) - Each MapNode table contains:- #
-name
: the name of the map node to place (required)- #
-prob
(aliasparam1
): the probability of this node being placed (default: 255)- #
-param2
: the raw param2 value of the node being placed onto the map (default: 0)- #
+ Each MapNode table contains:force_place
: boolean representing if the node should forcibly overwrite any - previous contents (default: false)+
+- #
+name
: the name of the map node to place (required)- #
+prob
(aliasparam1
): the probability of this node being placed + (default: 255)- #
+param2
: the raw param2 value of the node being placed onto the map + (default: 0)- #
+force_place
: boolean representing if the node should forcibly overwrite + any previous contents (default: false)About probability values:
-
- #A probability value of
-0
or1
means that node will never appear (0% chance).- #A probability value of
+254
or255
means the node will always appear (100% chance).- #A probability value of
+0
or1
means that node will never appear + (0% chance).- #A probability value of
254
or255
means the node will always appear + (100% chance).- #If the probability value
@@ -1556,27 +1757,30 @@ in the form of a table. This table specifies the following fields:p
is greater than1
, then there is a(p / 256 * 100)
percent chance that node will appear when the schematic is placed on the map.- #
place_center_x
: Placement of this decoration is centered along the X axis.- #
place_center_y
: Placement of this decoration is centered along the Y axis.- #
-place_center_z
: Placement of this decoration is centered along the Z axis.- #
+force_placement
: Schematic nodes other than "ignore" will replace existing nodes.- #
force_placement
: Schematic nodes other than "ignore" will replace existing + nodes.HUD element types
The position field is used for all element types.
-To account for differing resolutions, the position coordinates are the percentage -of the screen, ranging in value from
+0
to1
.To account for differing resolutions, the position coordinates are the +percentage of the screen, ranging in value from
0
to1
.The name field is not yet used, but should contain a description of what the HUD element represents. The direction field is the direction in which something is drawn.
-
0
draws from left to right,1
draws from right to left,2
draws from top to bottom, and3
draws from bottom to top.The
-alignment
field specifies how the item will be aligned. It ranges from-1
to1
, -with0
being the center,-1
is moved to the left/up, and1
is to the right/down. -Fractional values can be used.The
-offset
field specifies a pixel offset from the position. Contrary to position, -the offset is not scaled to screen size. This allows for some precisely-positioned -items in the HUD.Note:
-offset
will adapt to screen DPI as well as user defined scaling factor!Below are the specific uses for fields in each type; fields not listed for that type are ignored.
-Note: Future revisions to the HUD API may be incompatible; the HUD API is still -in the experimental stages.
+The
+alignment
field specifies how the item will be aligned. It ranges from +-1
to1
, with0
being the center.-1
is moved to the left/up, and1
+is to the right/down. Fractional values can be used.The
+offset
field specifies a pixel offset from the position. Contrary to +position, the offset is not scaled to screen size. This allows for some +precisely positioned items in the HUD.Note:
+offset
will adapt to screen DPI as well as user defined scaling +factor!Below are the specific uses for fields in each type; fields not listed for that +type are ignored.
+Note: Future revisions to the HUD API may be incompatible; the HUD API is +still in the experimental stages.
image
Displays an image on the HUD.
@@ -1594,8 +1798,8 @@ in the experimental stages.
@@ -1607,7 +1811,8 @@ in the experimental stages. If odd, will end with a vertically center-split texture.- #
scale
: Defines the bounding rectangle of the text. A value such as{x=100, y=100}
should work.- #
-text
: The text to be displayed in the HUD element.- #
+number
: An integer containing the RGB value of the color used to draw the text. - Specify0xFFFFFF
for white text,0xFF0000
for red, and so on.- #
number
: An integer containing the RGB value of the color used to draw the + text. Specify0xFFFFFF
for white text,0xFF0000
for red, and so on.- #
alignment
: The alignment of the text.- #
offset
: offset in pixels from position.# direction
# -offset
: offset in pixels from position.# +size
: If used, will force full-image size to this value (override texture pack image size)# size
: If used, will force full-image size to this value (override texture + pack image size)
inventory
@@ -1620,9 +1825,10 @@ in the experimental stages.
waypoint
Displays distance to selected world position.
-
- #
+name
: The name of the waypoint.- #
name
: The name of the waypoint.- #
-text
: Distance suffix. Can be blank.- #
+number:
An integer containing the RGB value of the color used to draw the text.- #
number:
An integer containing the RGB value of the color used to draw the + text.- #
world_pos
: World position of the waypoint.Representations of simple things
@@ -1637,8 +1843,8 @@ in the experimental stages.- #
{type="object", ref=ObjectRef}
Flag Specifier Format
-Flags using the standardized flag specifier format can be specified in either of -two ways, by string or table.
+Flags using the standardized flag specifier format can be specified in either +of two ways, by string or table.
The string format is a comma-delimited set of flag names; whitespace and unrecognized flag fields are ignored. Specifying a flag in the string sets the flag, and specifying a flag prefixed by the string
group disables the regular damage mechanism for players punching it by hand or a non-tool item, so that it can do something else than take damage."no"
explicitly @@ -1942,8 +2148,7 @@ Currently a smoke puff will appear when an entity dies.On the Lua side, every punch calls:
-+entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, damage) -
entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, damage)
This should never be called directly, because damage is usually not handled by the entity itself.
@@ -1958,13 +2163,12 @@ Return value of this function will determine if damage is done by this function (retval true) or shall be done by engine (retval false)
To punch an entity/object in Lua, call:
-+object:punch(puncher, time_from_last_punch, tool_capabilities, direction) -
object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
- Return value is tool wear.
- Parameters are equal to the above callback.
-- #If
+direction
equalsnil
andpuncher
does not equalnil
, -direction
will be automatically filled in based on the location ofpuncher
.- #If
direction
equalsnil
andpuncher
does not equalnil
,direction
+ will be automatically filled in based on the location ofpuncher
.Node Metadata
The instance of a node in the world normally only contains the three values @@ -2012,10 +2216,11 @@ meta:from_table({
Item metadata only contains a key-value store.
Some of the values in the key-value store are handled specially:
-
- #
+description
: Set the item stack's description. Defaults toidef.description
- #
description
: Set the item stack's description. Defaults to +idef.description
.- #
color
: AColorString
, which sets the stack's color.- #
+ current color from the palette.palette_index
: If the item has a palette, this is used to get the - current color from the palette.Example stuff:
local meta = stack:get_meta() @@ -2027,6 +2232,9 @@ print(dump(meta:to_table())) supported. It is a string, with a somewhat strange format.
Spaces and newlines can be inserted between the blocks, as is used in the examples.
+WARNING: Minetest allows you to add elements to every single formspec instance +using player:set_formspec_prepend(), which may be the reason backgrounds are +appearing when you don't expect them to. See
no_prepend[]
Examples
Chest
size[8,9] @@ -2056,26 +2264,51 @@ list[current_player;craftpreview;7,1;1,1;]
position[<X>,<Y>]
-
- Define the position of the formspec
-- A value between 0.0 and 1.0 represents a position inside the screen
-- The default value is the center of the screen (0.5, 0.5)
+- #Must be used after
+size
element.- #Defines the position on the game window of the formspec's
+anchor
point.- For X and Y, 0.0 and 1.0 represent opposite edges of the game window, + for example:
++
+- [0.0, 0.0] sets the position to the top left corner of the game window.
+- [1.0, 1.0] sets the position to the bottom right of the game window.
+- Defaults to the center of the game window [0.5, 0.5].
anchor[<X>,<Y>]
-
+- Define the anchor of the formspec
-- A value between 0.0 and 1.0 represents an anchor inside the formspec
-- The default value is the center of the formspec (0.5, 0.5)
+- #Must be used after both
+size
andposition
(if present) elements.- Defines the location of the anchor point within the formspec.
+- For X and Y, 0.0 and 1.0 represent opposite edges of the formspec, + for example:
++
+- [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
+- [1.0, 0.0] sets the anchor to the top right of the formspec.
+- +
+Defaults to the center of the formspec [0.5, 0.5].
+- # +
++
position
andanchor
elements need suitable values to avoid a formspec + extending off the game window due to particular game window sizes.+
no_prepend[]
+
- #Must be used after the
+size
,position
, andanchor
elements (if present).- Disables player:set_formspec_prepend() from applying to this formspec.
container[<X>,<Y>]
-
- Start of a container block, moves all physical elements in the container by (X, Y)
+- Start of a container block, moves all physical elements in the container by + (X, Y).
- #Must have matching
container_end
- Containers can be nested, in which case the offsets are added (child containers are relative to parent containers)
container_end[]
-
- End of a container, following elements are no longer relative to this container
+- End of a container, following elements are no longer relative to this + container.
list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]
@@ -2136,7 +2369,8 @@ list[current_player;craftpreview;7,1;1,1;]
bgcolor[<color>;<fullscreen>]
- #Sets background color of formspec as
-ColorString
- #If
+true
, the background color is drawn fullscreen (does not effect the size of the formspec)- #If
true
, the background color is drawn fullscreen (does not effect the size + of the formspec).
background[<X>,<Y>;<W>,<H>;<texture name>]
@@ -2157,26 +2391,26 @@ list[current_player;craftpreview;7,1;1,1;]
pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]
- Textual password style field; will be sent to server when a button is clicked
-- When enter is pressed in field, fields.key_enter_field will be sent with the name - of this field.
+- When enter is pressed in field, fields.key_enter_field will be sent with the + name of this field.
- #
x
andy
position the field relative to the top left of the menu- #
w
andh
are the size of the field- #Fields are a set height, but will be vertically centred on
h
- Position and size units are inventory slots
-- #
+name
is the name of the field as returned in fields toon_receive_fields
- #
name
is the name of the field as returned in fields toon_receive_fields
- #
label
, if not blank, will be text printed on the top left above the field- See field_close_on_enter to stop enter closing the formspec
field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]
-
- Textual field; will be sent to server when a button is clicked
-- #When enter is pressed in field,
+fields.key_enter_field
will be sent with the name - of this field.- #When enter is pressed in field,
fields.key_enter_field
will be sent with + the name of this field.- #
x
andy
position the field relative to the top left of the menu- #
w
andh
are the size of the field- #Fields are a set height, but will be vertically centred on
h
- Position and size units are inventory slots
-- #
+name
is the name of the field as returned in fields toon_receive_fields
- #
name
is the name of the field as returned in fields toon_receive_fields
- #
label
, if not blank, will be text printed on the top left above the field- #
default
is the default value of the field
- #
default
may contain variable references such as${text}'
which @@ -2189,24 +2423,25 @@ list[current_player;craftpreview;7,1;1,1;]
field[<name>;<label>;<default>]
- As above, but without position/size units
-- #When enter is pressed in field,
+fields.key_enter_field
will be sent with the name - of this field.- #When enter is pressed in field,
fields.key_enter_field
will be sent with + the name of this field.- Special field for creating simple forms, such as sign text input
-- #Must be used without a
+size[]
element- #Must be used without a
size[]
element- A "Proceed" button will be added automatically
- #See
field_close_on_enter
to stop enter closing the formspec
field_close_on_enter[<name>;<close_on_enter>]
- -
is the name of the field - if
+is false, pressing enter in the field will submit the form but not close it - if
is false, pressing enter in the field will submit the + form but not close it. - defaults to true when not specified (ie: no tag for a field)
textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]
- Same as fields above, but with multi-line input
- if the text overflows a vertical scrollbar is added
-- if the name is empty the textarea is readonly. The label is not displayed then
+- if the name is empty the textarea is readonly, the label is not displayed.
label[<X>,<Y>;<label>]
@@ -2241,7 +2476,8 @@ list[current_player;craftpreview;7,1;1,1;]
@@ -2249,8 +2485,8 @@ list[current_player;craftpreview;7,1;1,1;]- #
x
,y
,w
,h
, andname
work as per button- #
texture name
is the filename of an image- Position and size units are inventory slots
-- #
+noclip=true
means the image button doesn't need to be within specified formsize- #
noclip=true
means the image button doesn't need to be within specified + formsize.- #
drawborder
: draw button border or not- #
pressed texture name
is the filename of an image on pressed state- Position and size units are inventory slots
@@ -2266,8 +2502,10 @@ list[current_player;craftpreview;7,1;1,1;]
button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]
- Scrollable item list showing arbitrary text elements
- #
x
andy
position the itemlist relative to the top left of the menu- #
-w
andh
are the size of the itemlist- #
-name
fieldname sent to server on doubleclick value is current selected element- #
listelements
can be prepended by #color in hexadecimal format RRGGBB (only),+
- #
+name
fieldname sent to server on doubleclick value is current selected + element.- #
@@ -2277,20 +2515,22 @@ list[current_player;craftpreview;7,1;1,1;]listelements
can be prepended by #color in hexadecimal format RRGGBB + (only).
- if you want a listelement to start with "#" write "##".
- Scrollable itemlist showing arbitrary text elements
- #
x
andy
position the item list relative to the top left of the menu- #
-w
andh
are the size of the item list- #
+name
fieldname sent to server on doubleclick value is current selected element- #
name
fieldname sent to server on doubleclick value is current selected + element.- #
listelements
can be prepended by #RRGGBB (only) in hexadecimal format
- if you want a listelement to start with "#" write "##"
- Index to be selected within textlist
- #
-true
/false
: draw transparent background- #See also
+minetest.explode_textlist_event
(main menu:engine.explode_textlist_event
)- #See also
minetest.explode_textlist_event
+ (main menu:engine.explode_textlist_event
).
tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]
- Show a tabheader at specific position (ignores formsize)
- #
-x
andy
position the itemlist relative to the top left of the menu- #
+name
fieldname data is transferred to Lua- #
name
fieldname data is transferred to Lua- #
caption 1
...: name shown on top of tab- #
current_tab
: index of selected tab 1...- #
@@ -2321,7 +2561,7 @@ list[current_player;craftpreview;7,1;1,1;]transparent
(optional): show transparent@@ -2338,7 +2578,8 @@ list[current_player;craftpreview;7,1;1,1;]
- Show a checkbox
- #
-x
andy
: position of checkbox- #
+name
fieldname data is transferred to Lua- #
name
fieldname data is transferred to Lua- #
label
to be shown left of checkbox- #
selected
(optional):true
/false
- #
orientation
:vertical
/horizontal
- Fieldname data is transferred to Lua
- #Value this trackbar is set to (
-0
-1000
)- #See also
+minetest.explode_scrollbar_event
(main menu:engine.explode_scrollbar_event
)- #See also
minetest.explode_scrollbar_event
+ (main menu:engine.explode_scrollbar_event
).
table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]
@@ -2346,10 +2587,11 @@ list[current_player;craftpreview;7,1;1,1;]
- #Displays cells as defined by the previous
tablecolumns[]
- #
x
andy
: position the itemlist relative to the top left of the menu- #
-w
andh
are the size of the itemlist- #
+name
: fieldname sent to server on row select or doubleclick- #
name
: fieldname sent to server on row select or doubleclick- #
cell 1
...cell n
: cell contents given in row-major order- #
-selected idx
: index of row to be selected within table (first row =1
)- #See also
+minetest.explode_table_event
(main menu:engine.explode_table_event
)- #See also
minetest.explode_table_event
+ (main menu:engine.explode_table_event
).
tableoptions[<opt 1>;<opt 2>;...]
@@ -2385,10 +2627,14 @@ list[current_player;craftpreview;7,1;1,1;]
- #Sets columns for
table[]
- #Types:
text
,image
,color
,indent
,tree
- #
-text
: show cell contents as text- #
-image
: cell contents are an image index, use column options to define images- #
-color
: cell contents are a ColorString and define color of following cell- #
-indent
: cell contents are a number and define indentation of following cell- #
+tree
: same as indent, but user can open and close subtrees (treeview-like)- #
+image
: cell contents are an image index, use column options to define + images.- #
+color
: cell contents are a ColorString and define color of following + cell.- #
+indent
: cell contents are a number and define indentation of following + cell.- #
tree
: same as indent, but user can open and close subtrees + (treeview-like).- #Column options:
@@ -2414,14 +2660,15 @@ list[current_player;craftpreview;7,1;1,1;]
- #
color
column options:Note: do not use a element name starting with
+key_
; those names are reserved to -pass key press events to formspec!Note: do not use a element name starting with
key_
; those names are +reserved to pass key press events to formspec!Inventory locations
- #
@@ -2444,9 +2691,9 @@ pass key press events to formspec!"context"
: Selected node metadata (deprecated:"current_name"
)
#RRGGBBAA
defines a color in hexadecimal format and alpha channel.Named colors are also supported and are equivalent to CSS Color Module Level 4. -To specify the value of the alpha channel, append
+To specify the value of the alpha channel, append#AA
to the end of the color name -(e.g.colorname#08
). For named colors the hexadecimal string representing the alpha -value must (always) be two hexadecimal digits.#AA
to the end of the color +name (e.g.colorname#08
). For named colors the hexadecimal string +representing the alpha value must (always) be two hexadecimal digits.
ColorSpec
A ColorSpec specifies a 32-bit color. It can be written in either: table form, each element ranging from 0..255 (a, if absent, defaults to 255): @@ -2468,8 +2715,8 @@ The following functions provide escape sequences:
- #
minetest.colorize(color, message)
:
- #Equivalent to:
+ message .. + minetest.get_color_escape_sequence("#ffffff")minetest.get_color_escape_sequence(color) .. - message .. - minetest.get_color_escape_sequence("#ffffff")
# minetest.get_background_escape_sequence(color)
@@ -2492,7 +2739,8 @@ The following functions provide escape sequences:
Spatial Vectors
-For the following functions,
+v
,v1
,v2
are vectors,p1
,p2
are positions:For the following functions,
v
,v1
,v2
are vectors, +p1
,p2
are positions:
- #
vector.new(a[, b, c])
:
- Returns a vector.
@@ -2527,7 +2775,8 @@ The following functions provide escape sequences:- #
vector.apply(v, func)
:- #
vector.equals(v1, v2)
:@@ -2560,14 +2809,14 @@ The following functions provide escape sequences:
Helper functions
-
- #
dump2(obj, name, dumped)
: returns a string which makesobj
human readable, - handles reference loops+
- #
-dump2(obj, name, dumped)
: returns a string which makesobj
+ human-readable, handles reference loops.- #
-dump(obj, dumped)
: returns a string which makesobj
human readable- #
string:trim()
: returns the string whithout whitespace pre- and suffixes- #
minetest.formspec_escape(string)
: returns a string-
- escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs
+- escapes the characters "[", "]", "\", "," and ";", which can not be used + in formspecs.
- #
-minetest.is_yes(arg)
@@ -2640,80 +2890,101 @@ The following functions provide escape sequences:
- #returns a deep copy of
table
- #
minetest.pointed_thing_to_face_pos(placer, pointed_thing)
: returns a position+
- #
minetest.pointed_thing_to_face_pos(placer, pointed_thing)
: returns a + position.
- returns the exact position on the surface of a pointed node
Translations
-Texts can be translated client-side with the help of
+minetest.translate
and translation files.Texts can be translated client-side with the help of
minetest.translate
and +translation files.Translating a string
-Two functions are provided to translate strings:
+minetest.translate
andminetest.get_translator
.Two functions are provided to translate strings:
minetest.translate
and +minetest.get_translator
.
- # -
+
minetest.get_translator(textdomain)
is a simple wrapper aroundminetest.translate
, and -minetest.get_translator(textdomain)(str, ...)
is equivalent tominetest.translate(textdomain, str, ...)
. - It is intended to be used in the following way, so that it avoids verbose repetitions ofminetest.translate
:
minetest.get_translator(textdomain)
is a simple wrapper around +minetest.translate
, andminetest.get_translator(textdomain)(str, ...)
is + equivalent tominetest.translate(textdomain, str, ...)
. + It is intended to be used in the following way, so that it avoids verbose + repetitions ofminetest.translate
:local S = minetest.get_translator(textdomain) S(str, ...)
As an extra commodity, if
textdomain
is nil, it is assumed to be "" instead.-
-- #
+minetest.translate(textdomain, str, ...)
translates the stringstr
with the giventextdomain
- for disambiguation. The textdomain must match the textdomain specified in the translation file in order - to get the string translated. This can be used so that a string is translated differently in different contexts. - It is advised to use the name of the mod as textdomain whenever possible, to avoid clashes with other mods. - This function must be given a number of arguments equal to the number of arguments the translated string expects. - Arguments are literal strings -- they will not be translated, so if you want them to be, they need to come as - outputs ofminetest.translate
as well.- #
minetest.translate(textdomain, str, ...)
translates the stringstr
with + the giventextdomain
for disambiguation. The textdomain must match the + textdomain specified in the translation file in order to get the string + translated. This can be used so that a string is translated differently in + different contexts. + It is advised to use the name of the mod as textdomain whenever possible, to + avoid clashes with other mods. + This function must be given a number of arguments equal to the number of + arguments the translated string expects. + Arguments are literal strings -- they will not be translated, so if you want + them to be, they need to come as outputs ofminetest.translate
as well.For instance, suppose we want to translate "@1 Wool" with "@1" being replaced by the translation of "Red". - We can do the following:
+For instance, suppose we want to translate "@1 Wool" with "@1" being replaced + by the translation of "Red". We can do the following:
-local S = minetest.get_translator() S("@1 Wool", S("Red"))
This will be displayed as "Red Wool" on old clients and on clients that do not have localization enabled. - However, if we have for instance a translation file named
+wool.fr.tr
containing the following:This will be displayed as "Red Wool" on old clients and on clients that do + not have localization enabled. However, if we have for instance a translation + file named
wool.fr.tr
containing the following:@1 Wool=Laine @1 Red=Rouge
this will be displayed as "Laine Rouge" on clients with a French locale.
Operations on translated strings
-The output of
+minetest.translate
is a string, with escape sequences adding additional information to that string -so that it can be translated on the different clients. In particular, you can't expect operations like string.length -to work on them like you would expect them to, or string.gsub to work in the expected manner. However, string -concatenation will still work as expected (note that you should only use this for things like formspecs; do not -translate sentences by breaking them into parts; arguments should be used instead), and operations such as -minetest.colorize
which are only concatenation under the hood as well.The output of
minetest.translate
is a string, with escape sequences adding +additional information to that string so that it can be translated on the +different clients. In particular, you can't expect operations like string.length +to work on them like you would expect them to, or string.gsub to work in the +expected manner. However, string concatenation will still work as expected +(note that you should only use this for things like formspecs; do not translate +sentences by breaking them into parts; arguments should be used instead), and +operations such asminetest.colorize
which are also concatenation.Translation file format
-A translation file has the suffix
.[lang].tr
, where[lang]
is the language it corresponds to. +A translation file has the suffix
.[lang].tr
, where[lang]
is the language +it corresponds to. The file should be a text file, with the following format:-
- #Lines beginning with
+# textdomain:
(the space is significant) can be used to specify the text - domain of all following translations in the file.- #Lines beginning with
# textdomain:
(the space is significant) can be used + to specify the text domain of all following translations in the file.- All other empty lines or lines beginning with
-#
are ignored.- #Other lines should be in the format
+original=translated
. Bothoriginal
andtranslated
can - contain escape sequences beginning with@
to insert arguments, literal@
,=
or newline - (See ### Escapes below). There must be no extraneous whitespace around the=
or at the beginning - or the end of the line.- #Other lines should be in the format
original=translated
. Bothoriginal
+ andtranslated
can contain escape sequences beginning with@
to insert + arguments, literal@
,=
or newline (See ### Escapes below). + There must be no extraneous whitespace around the=
or at the beginning or + the end of the line.Escapes
-Strings that need to be translated can contain several escapes, preceded by
+@
. -@@
acts as a literal@
. -@n
, wheren
is a digit between 1 and 9, is an argument for the translated string that will be inlined - when translation. Due to how translations are implemented, the original translation string must have - its arguments in increasing order, without gaps or repetitions, starting from 1. -@=
acts as a literal=
. It is not required in strings given tominetest.translate
, but is in translation - files to avoid being confused with the=
separating the original from the translation. -@\n
(where the\n
is a literal newline) acts as a literal newline. As with@=
, this escape is not required - in strings given tominetest.translate
, but is in translation files. -*@n
acts as a literal newline as well.Strings that need to be translated can contain several escapes, preceded by
+@
.+
- +
@@
acts as a literal@
.- #
+@n
, wheren
is a digit between 1 and 9, is an argument for the translated + string that will be inlined when translation. Due to how translations are + implemented, the original translation string must have its arguments in + increasing order, without gaps or repetitions, starting from 1.- +
@=
acts as a literal=
. It is not required in strings given to +minetest.translate
, but is in translation files to avoid being confused + with the=
separating the original from the translation.- #
+@\n
(where the\n
is a literal newline) acts as a literal newline. + As with@=
, this escape is not required in strings given to +minetest.translate
, but is in translation files.- #
+@n
acts as a literal newline as well.
minetest
namespace referenceUtilities
-
- #
-minetest.get_current_modname()
: returns the currently loading mod's name, when we are loading a mod- #
minetest.get_modpath(modname)
: returns e.g."/home/user/.minetest/usermods/modname"
+
- #
+minetest.get_current_modname()
: returns the currently loading mod's name, + when loading a mod.- #
@@ -2732,7 +3003,7 @@ The file should be a text file, with the following format: chat_send_player_param3 = true, get_all_craft_recipes_works = true, use_texture_alpha = true, --- ^ The transparency channel of textures can be used optionally +-- ^ The transparency channel of textures can optionally be used on nodes no_legacy_abms = true, -- ^ Tree and grass ABMs are no longer done from C++ texture_names_parens = true, @@ -2743,6 +3014,9 @@ The file should be a text file, with the following format: -- ^ add_entity supports passing initial staticdata to on_activate no_chat_message_prediction = true, -- ^ Chat messages are no longer predicted + object_use_texture_alpha = true +-- ^ The transparency channel of textures can optionally be used on +-- objects (ie: players and lua entities) }minetest.get_modpath(modname)
: returns e.g. +"/home/user/.minetest/usermods/modname"
.
- #Useful for loading additional
.lua
modules or static data from mod@@ -2750,7 +3024,8 @@ The file should be a text file, with the following format:
-- #
arg
: string or table in format{foo=true, bar=true}
- #
missing_features
:{foo=true, bar=true}
- #
-minetest.get_player_information(player_name)
:- #Returns a table containing information about a player. Example return value:
{ +
- #Returns a table containing information about a player. + Example return value:
{ address = "127.0.0.1", -- IP address of client ip_version = 4, -- IPv4 / IPv6 min_rtt = 0.01, -- minimum round trip time @@ -2779,14 +3054,14 @@ The file should be a text file, with the following format:
- #
minetest.get_dir_list(path, [is_dir])
: returns list of entry names+
- is_dir is one of:
+- nil: return all entries,
- true: return only subdirectory names, or
- false: return only file names.
-# @@ -2794,7 +3069,8 @@ The file should be a text file, with the following format: engine version. Components:minetest.safe_file_write(path, content)
: returns boolean indicating success-
- #Replaces contents of file at path with new contents in a safe (atomic) way. - Use this instead of below code when writing e.g. database files: +
- #Replaces contents of file at path with new contents in a safe (atomic) + way. Use this instead of below code when writing e.g. database files:
local f = io.open(path, "wb"); f:write(content); f:close()
- #
project
: Name of the project, eg, "Minetest"- #
-string
: Simple version, eg, "1.2.3-dev"- #
hash
: Full git version (only set if available), eg, "1.2.3-dev-01234567-dirty" +- #
hash
: Full git version (only set if available), + eg, "1.2.3-dev-01234567-dirty". Use this for informational purposes only. The information in the returned table does not represent the capabilities of the engine, nor is it reliable or verifiable. Compatible forks will have a different name and @@ -2847,11 +3123,14 @@ The file should be a text file, with the following format:- #
minetest.clear_craft(recipe)
- Will erase existing craft based either on output item or on input recipe.
-- #Specify either output or input only. If you specify both, input will be ignored. For input use the same recipe table - syntax as for
+minetest.register_craft(recipe)
. For output specify only the item, without a quantity.- #Specify either output or input only. If you specify both, input will be + ignored. For input use the same recipe table syntax as for +
minetest.register_craft(recipe)
. For output specify only the item, + without a quantity.- If no erase candidate could be found, Lua exception will be thrown.
-- Warning! The type field ("shaped","cooking" or any other) will be ignored if the recipe - contains output. Erasing is then done independently from the crafting method.
+- Warning! The type field ("shaped","cooking" or any other) will be + ignored if the recipe contains output. Erasing is then done independently + from the crafting method.
- #
@@ -2876,8 +3155,8 @@ The file should be a text file, with the following format:minetest.register_ore(ore definition)
- #
@@ -2885,14 +3164,14 @@ The file should be a text file, with the following format:minetest.register_on_shutdown(func())
- Called before server shutdown
-- Warning: If the server terminates abnormally (i.e. crashes), the registered - callbacks will likely not be run. Data should be saved at +
- Warning: If the server terminates abnormally (i.e. crashes), the + registered callbacks will likely not be run. Data should be saved at semi-frequent intervals as well as on server shutdown.
- Called when a node has been placed
- #If return
true
no item is taken fromitemstack
- #
-placer
may be any valid ObjectRef or nil.- #Not recommended; use
+on_construct
orafter_place_node
in node definition - whenever possible- #Not recommended; use
on_construct
orafter_place_node
in node + definition whenever possible.# minetest.register_on_dignode(func(pos, oldnode, digger))
# minetest.register_on_punchnode(func(pos, node, puncher, pointed_thing))
@@ -2901,37 +3180,54 @@ The file should be a text file, with the following format:
# minetest.register_on_generated(func(minp, maxp, blockseed))
- Called after generating a piece of world. Modifying nodes inside the area - is a bit faster than usually.
+ is a bit faster than usually.# -minetest.register_on_newplayer(func(ObjectRef))
- Called after a new player has been created
# minetest.register_on_dieplayer(func(ObjectRef))
-
-- Called when a player dies
-# minetest.register_on_punchplayer(func(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))
- Called when a player is punched
- #
player
- ObjectRef - Player that was punched- #
-hitter
- ObjectRef - Player that hit- #
+time_from_last_punch
: Meant for disallowing spamming of clicks (can be nil)- #
time_from_last_punch
: Meant for disallowing spamming of clicks + (can be nil).- #
tool_capabilities
: capability table of used tool (can be nil)- #
+ the puncher to the punched.dir
: unit vector of direction of punch. Always defined. Points from - the puncher to the punched.# damage
- number that represents the damage calculated by the engine#should return -true
to prevent the default damage mechanism# +minetest.register_on_player_hpchange(func(player, hp_change), modifier)
+
+- #
+minetest.register_on_player_hpchange(func(player, hp_change, reason), modifier)
- Called when the player gets damaged or healed
- #
player
: ObjectRef of the player- #
+hp_change
: the amount of change. Negative when it is damage.- #
reason
: a PlayerHPChangeReason table. +- #
+ Note: modifiers only get a temporary hp_change that can be modified by later modifiers. + modifiers can return true as a second argument to stop the execution of further functions. + Non-modifiers receive the final hp change calculated by the modifiers.modifier
: when true, the function should return the actualhp_change
. - Note: modifiers only get a temporary hp_change that can be modified by later modifiers. - modifiers can return true as a second argument to stop the execution of further functions. - Non-modifiers receive the final hp change calculated by the modifiers.# minetest.register_on_dieplayer(func(ObjectRef, reason))
+
- Called when a player dies
+- #
reason
: a PlayerHPChangeReason table, see register_on_player_hpchange# minetest.register_on_respawnplayer(func(ObjectRef))
@@ -2942,7 +3238,8 @@ The file should be a text file, with the following format:
# minetest.register_on_prejoinplayer(func(name, ip))
- Called before a player joins the game
-- If it returns a string, the player is disconnected with that string as reason
+- If it returns a string, the player is disconnected with that string as + reason.
# +minetest.register_on_joinplayer(func(ObjectRef))
@@ -2954,6 +3251,13 @@ The file should be a text file, with the following format:
- #
timed_out
: True for timeout, false for other reasons.# minetest.register_on_auth_fail(func(name, ip))
+# +minetest.register_on_cheat(func(ObjectRef, cheat))
-
- Called when a player cheats
- #
cheat
:{type=<cheat_type>}
, where<cheat_type>
is one of:@@ -2969,7 +3273,8 @@ The file should be a text file, with the following format:
- #
minetest.register_on_chat_message(func(name, message))
- #
minetest.register_on_player_receive_fields(func(player, formname, fields))
@@ -2981,44 +3286,48 @@ The file should be a text file, with the following format:
- #
minetest.register_on_craft(func(itemstack, player, old_craft_grid, craft_inv))
- #Called when
player
crafts something- #
-itemstack
is the output- #
+old_craft_grid
contains the recipe (Note: the one in the inventory is cleared)- #
old_craft_grid
contains the recipe (Note: the one in the inventory is + cleared).- #
-craft_inv
is the inventory with the crafting grid- #Return either an
+ItemStack
, to replace the output, ornil
, to not modify it- #Return either an
ItemStack
, to replace the output, ornil
, to not + modify it.- #
minetest.register_craft_predict(func(itemstack, player, old_craft_grid, craft_inv))
-
- The same as before, except that it is called before the player crafts, to make - craft prediction, and it should not change anything.
+- The same as before, except that it is called before the player crafts, to + make craft prediction, and it should not change anything.
- #
minetest.register_on_protection_violation(func(pos, name))
-
- #Called by
-builtin
and mods when a player violates protection at a position - (eg, digs a node or punches a protected entity).- #The registered functions can be called using
-minetest.record_protection_violation
- The provided function should check that the position is protected by the mod - calling this function before it prints a message, if it does, to allow for - multiple protection mods.
+- #Called by
+builtin
and mods when a player violates protection at a + position (eg, digs a node or punches a protected entity).- #The registered functions can be called using +
+minetest.record_protection_violation
.- The provided function should check that the position is protected by the + mod calling this function before it prints a message, if it does, to + allow for multiple protection mods.
- #
minetest.register_on_item_eat(func(hp_change, replace_with_item, itemstack, user, pointed_thing))
- #
minetest.register_on_priv_grant(function(name, granter, priv))
- #Called when
-granter
grants the privpriv
toname
.- Note that the callback will be called twice if it's done by a player, once with granter being the player name, - and again with granter being nil.
+- Note that the callback will be called twice if it's done by a player, + once with granter being the player name, and again with granter being nil.
- #
minetest.register_on_priv_revoke(function(name, revoker, priv))
- #Called when
-revoker
revokes the privpriv
fromname
.- Note that the callback will be called twice if it's done by a player, once with revoker being the player name, - and again with revoker being nil.
+- Note that the callback will be called twice if it's done by a player, + once with revoker being the player name, and again with revoker being nil.
- #
@@ -3045,16 +3354,21 @@ The file should be a text file, with the following format:minetest.register_can_bypass_userlimit(function(name, ip))
- #
minetest.register_privilege(name, definition)
- #
-definition
:"description text"
- #
-definition
:{ description = "description text", give_to_singleplayer = boolean}
- the default ofgive_to_singleplayer
is true- #To allow players with
-basic_privs
to grant, seebasic_privs
minetest.conf setting.- #
-on_grant(name, granter_name)
: Called when given to playername
bygranter_name
. -granter_name
will be nil if the priv was granted by a mod.- #
-on_revoke(name, revoker_name)
: Called when taken from playername
byrevoker_name
. -revoker_name
will be nil if the priv was revoked by a mod- Note that the above two callbacks will be called twice if a player is responsible - - once with the player name, and then with a nil player name.
-- Return true in the above callbacks to stop register_on_priv_grant or revoke being called.
+- #
+definition
: +{description = "description text", give_to_singleplayer = boolean}
+ the default ofgive_to_singleplayer
is true.- #To allow players with
+basic_privs
to grant, seebasic_privs
+ minetest.conf setting.- #
+on_grant(name, granter_name)
: Called when given to playername
by +granter_name
. +granter_name
will be nil if the priv was granted by a mod.- #
+on_revoke(name, revoker_name)
: Called when taken from playername
by +revoker_name
. +revoker_name
will be nil if the priv was revoked by a mod- Note that the above two callbacks will be called twice if a player is + responsible, once with the player name, and then with a nil player name.
+- Return true in the above callbacks to stop register_on_priv_grant or + revoke being called.
- #
minetest.register_authentication_handler(authentication handler definition)
@@ -3079,7 +3393,8 @@ The file should be a text file, with the following format:
- #
minetest.get_player_privs(name) -> {priv1=true,...}
- # -
+
minetest.check_player_privs(player_or_name, ...)
: returnsbool, missing_privs
minetest.check_player_privs(player_or_name, ...)
: + returnsbool, missing_privs
- A quickhand for checking privileges.
- #
@@ -3092,8 +3407,8 @@ The file should be a text file, with the following format:player_or_name
: Either a Player object or the name of a player.@@ -3108,7 +3423,8 @@ The file should be a text file, with the following format:
- Returns true if the "password entry" for a player with name matches given password, false otherwise.
-- #The "password entry" is the password representation generated by the engine - as returned as part of a
+get_auth()
call on the auth handler.- #The "password entry" is the password representation generated by the + engine as returned as part of a
get_auth()
call on the auth handler.- Only use this function for making it possible to log in via password from external protocols such as IRC, other uses are frowned upon.
- # -
+
minetest.get_player_ip(name)
: returns an IP address string for the playername
minetest.get_player_ip(name)
: returns an IP address string for the player +name
.@@ -3123,18 +3439,21 @@ The file should be a text file, with the following format:
- The player needs to be online for this to be successful.
- #
-minetest.notify_authentication_modified(name)
- #
-minetest.set_player_password(name, password_hash)
: Set password hash of playername
- #
+minetest.set_player_privs(name, {priv1=true,...})
: Set privileges of playername
- #
+minetest.set_player_password(name, password_hash)
: Set password hash of + playername
.- #
minetest.set_player_privs(name, {priv1=true,...})
: Set privileges of player +name
.- #
minetest.auth_reload()
- #See
reload()
in authentication handler definition+
minetest.set_player_password
,minetest_set_player_privs
,minetest_get_player_privs
-andminetest.auth_reload
call the authentication handler.
minetest.set_player_password
,minetest_set_player_privs
, +minetest_get_player_privs
andminetest.auth_reload
call the authentication +handler.Chat
# minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)
+
+- Set node on all positions set in the first argument.
+- #e.g.
+minetest.bulk_set_node({ {x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})
- #For node specification or position syntax see
+minetest.set_node
call- Faster than set_node due to single call, but still considerably slower + than Lua Voxel Manipulators (LVM) for large numbers of nodes. + Unlike LVMs, this will call node callbacks. It also allows setting nodes + in spread out positions which would cause LVMs to waste memory. + For setting a cube, this is 1.3x faster than set_node whereas LVM is 20 + times faster.
+# minetest.swap_node(pos, node)
@@ -3160,8 +3491,8 @@ and
- Set node at position, but don't remove metadata
minetest.auth_reload
call the authentication handler.# minetest.get_node(pos)
- #Returns the node at the given position as table in the format -
+{name="node_name", param1=0, param2=0}
, returns{name="ignore", param1=0, param2=0}
- for unloaded areas.{name="node_name", param1=0, param2=0}
, + returns{name="ignore", param1=0, param2=0}
for unloaded areas.# minetest.get_node_or_nil(pos)
@@ -3200,7 +3531,8 @@ and
minetest.auth_reload
call the authentication handler.- #
minetest.find_nodes_with_meta(pos1, pos2)
-
- Get a table of positions of nodes that have metadata within a region {pos1, pos2}
+- Get a table of positions of nodes that have metadata within a region + {pos1, pos2}.
- #
minetest.get_meta(pos)
@@ -3214,7 +3546,8 @@ and
minetest.auth_reload
call the authentication handler.- # -
+
minetest.add_entity(pos, name, [staticdata])
: Spawn Lua-defined entity at position
minetest.add_entity(pos, name, [staticdata])
: Spawn Lua-defined entity at + position.@@ -3224,7 +3557,8 @@ and
- #Returns
ObjectRef
, ornil
if failedminetest.auth_reload
call the authentication handler.# -minetest.get_player_by_name(name)
: Get anObjectRef
to a player# minetest.get_objects_inside_radius(pos, radius)
: returns a list of ObjectRefs# -minetest.get_timeofday()
# -minetest.get_gametime()
: returns the time, in seconds, since the world was created# minetest.get_day_count()
: returns number days elapsed since world was created,-
- accounting for time changes.
+- #
+minetest.get_gametime()
: returns the time, in seconds, since the world was + created.- #
-minetest.get_day_count()
: returns number days elapsed since world was + created.+
- accounts for time changes.
- #
minetest.find_node_near(pos, radius, nodenames, [search_center])
: returns pos ornil
+
- #
-minetest.find_node_near(pos, radius, nodenames, [search_center])
: returns + pos ornil
.- #
minetest.find_nodes_in_area(pos1, pos2, nodenames)
: returns a list of positions+
- #
-minetest.find_nodes_in_area(pos1, pos2, nodenames)
: returns a list of + positions.
- #
nodenames
: e.g.{"ignore", "group:tree"}
or"default:dirt"
- First return value: Table with all node positions
-- Second return value: Table with the count of each node with the node name as index
+- Second return value: Table with the count of each node with the node name + as index.
+- Area volume is limited to 4,096,000 nodes
- #
minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)
: returns a list of positions+
- #
minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)
: returns a + list of positions.
- #
nodenames
: e.g.{"ignore", "group:tree"}
or"default:dirt"
- Return value: Table with all node positions with a node air above
+- Area volume is limited to 4,096,000 nodes
- #
@@ -3267,118 +3609,186 @@ andminetest.get_perlin(noiseparams)
minetest.auth_reload
call the authentication handler.- #
+minetest.set_gen_notify(flags, {deco_ids})
-
+- Set the types of on-generate notifications that should be collected
-- #
+flags
is a flag field with the available flags:dungeon
,temple
,cave_begin
, -cave_end
,large_cave_begin
,large_cave_end
,decoration
- Set the types of on-generate notifications that should be collected.
+- #
+flags
is a flag field with the available flags:+
+- dungeon
+- temple
+- cave_begin
+- cave_end
+- large_cave_begin
+- large_cave_end
+- decoration
+- The second parameter is a list of IDS of decorations which notification + is requested for.
+- #
+minetest.get_gen_notify()
+
+- #Returns a flagstring and a table with the
+deco_id
s.- #`minetest.get_decoration_id(decoration_name)
-+
- #Returns the decoration ID number for the provided decoration name string, + or
nil
on failure.- The second parameter is a list of IDS of decorations which notification is requested for
-- #
get_gen_notify()
: returns a flagstring and a table with thedeco_id
s- #
+minetest.get_mapgen_object(objectname)
- Return requested mapgen object if available (see "Mapgen objects")
- #
+minetest.get_heat(pos)
+
+- #Returns the heat at the position, or
+nil
on failure.- #
+minetest.get_humidity(pos)
+
+- #Returns the humidity at the position, or
+nil
on failure.- #
minetest.get_biome_data(pos)
+- #
+minetest.get_biome_id(biome_name)
-
+- Returns the biome id, as used in the biomemap Mapgen object, for a - given biome_name string.
+- #Returns the biome id, as used in the biomemap Mapgen object and returned + by
+minetest.get_biome_data(pos)
, for a given biome_name string.- #
+minetest.get_biome_name(biome_id)
+- #
-minetest.get_mapgen_params()
- #
-minetest.get_mapgen_params()
Returns mapgen parameters, a table containing -mgname
,seed
,chunksize
,water_level
, andflags
.- #Deprecated: use
minetest.get_mapgen_setting(name)
instead- #
minetest.set_mapgen_params(MapgenParams)
-
- #Deprecated: use
-minetest.set_mapgen_setting(name, value, override)
instead- Set map generation parameters
-- #Function cannot be called after the registration period; only initialization - and
-on_mapgen_init
- #Takes a table as an argument with the fields
mgname
,seed
,water_level
, - andflags
.-
- Leave field unset to leave that parameter unchanged
-- #
-flags
contains a comma-delimited string of flags to set, - or if the prefix"no"
is attached, clears instead.- #
+flags
is in the same format and has the same options asmg_flags
inminetest.conf
- #Deprecated: use
+minetest.set_mapgen_setting(name, value, override)
+ instead.- Set map generation parameters.
+- #Function cannot be called after the registration period; only + initialization and
+on_mapgen_init
.- #Takes a table as an argument with the fields:
+- Leave field unset to leave that parameter unchanged.
+- #
+flags
contains a comma-delimited string of flags to set, or if the + prefix"no"
is attached, clears instead.- #
flags
is in the same format and has the same options asmg_flags
in +minetest.conf
.- #
minetest.get_mapgen_setting(name)
-
- Gets the active mapgen setting (or nil if none exists) in string format with the following - order of precedence: - 1) Settings loaded from map_meta.txt or overrides set during mod execution +
- Gets the active mapgen setting (or nil if none exists) in string + format with the following order of precedence: + 1) Settings loaded from map_meta.txt or overrides set during mod + execution. 2) Settings set by mods without a metafile override 3) Settings explicitly set in the user config file, minetest.conf 4) Settings set as the user config default
- #
-minetest.get_mapgen_setting_noiseparams(name)
- #
-minetest.set_mapgen_setting(name, value, [override_meta])
- #Sets a mapgen param to
-value
, and will take effect if the corresponding mapgen setting - is not already present in map_meta.txt.- #
-override_meta
is an optional boolean (default:false
). If this is set to true, - the setting will become the active setting regardless of the map metafile contents.- #Note: to set the seed, use
-"seed"
, not"fixed_map_seed"
- #
+minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])
- #
+minetest.set_mapgen_setting(name, value, [override_meta])
+
+- #Sets a mapgen param to
+value
, and will take effect if the corresponding + mapgen setting is not already present in map_meta.txt.- #
+override_meta
is an optional boolean (default:false
). If this is set + to true, the setting will become the active setting regardless of the map + metafile contents.- #Note: to set the seed, use
+"seed"
, not"fixed_map_seed"
.- #
-minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])
- Same as above, except value is a NoiseParams table.
-- #
-minetest.set_noiseparams(name, noiseparams, set_default)
- #
+minetest.get_noiseparams(name)
: returns a table of the noiseparams for name- #
+minetest.set_noiseparams(name, noiseparams, set_default)
+- #
minetest.get_noiseparams(name)
+
+- Returns a table of the noiseparams for name.
+- #
minetest.generate_ores(vm, pos1, pos2)
- #
minetest.generate_decorations(vm, pos1, pos2)
- #
minetest.clear_objects([options])
- Clear all objects in the environment
- #Takes an optional table as an argument with the field
mode
.-
- #mode =
-"full"
: Load and go through every mapblock, clearing objects (default).- #mode =
+"quick"
: Clear objects immediately in loaded mapblocks; - clear objects in unloaded mapblocks only when the mapblocks are next activated.- #mode =
+"full"
: Load and go through every mapblock, clearing + objects (default).- #mode =
"quick"
: Clear objects immediately in loaded mapblocks, + clear objects in unloaded mapblocks only when the + mapblocks are next activated.- #
minetest.emerge_area(pos1, pos2, [callback], [param])
-
@@ -3490,16 +3914,19 @@ and- #Queue all blocks in the area from
-pos1
topos2
, inclusive, to be asynchronously- fetched from memory, loaded from disk, or if inexistent, generates them.
-- #If
-callback
is a valid Lua function, this will be called for each block emerged.- The function signature of callback is:
-- #
-function EmergeAreaCallback(blockpos, action, calls_remaining, param)
- # -
-
- #
+blockpos
is the block coordinates of the block that had been emerged- #Queue all blocks in the area from
+pos1
topos2
, inclusive, to be + asynchronously fetched from memory, loaded from disk, or if inexistent, + generates them.- #If
+callback
is a valid Lua function, this will be called for each block + emerged.- #The function signature of callback is:
++
- #
function EmergeAreaCallback(blockpos, action, calls_remaining, param)
+
- #
+blockpos
is the block coordinates of the block that had been + emerged.- #
-action
could be one of the following constant values:- # -
-- #
-minetest.EMERGE_CANCELLED
,minetest.EMERGE_ERRORED
,minetest.EMERGE_FROM_MEMORY
,- #
-minetest.EMERGE_FROM_DISK
,minetest.EMERGE_GENERATED
- # -
--
- #
calls_remaining
is the number of callbacks to be expected after this one- # -
--
-- #
-param
is the user-defined parameter passed to emerge_area (or nil if the- parameter was absent)
- #
minetest.delete_area(pos1, pos2)
@@ -3403,10 +3813,12 @@ and
minetest.auth_reload
call the authentication handler.- #
minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)
- returns table containing path
-- #returns a table of 3D points representing a path from
+pos1
topos2
ornil
- #returns a table of 3D points representing a path from
pos1
topos2
or +nil
.- #
pos1
: start position- #
-pos2
: end position- #
+searchdistance
: number of blocks to search in each direction using a maximum metric- #
searchdistance
: number of blocks to search in each direction using a + maximum metric.- #
max_jump
: maximum height difference to consider walkable- #
max_drop
: maximum height difference to consider droppable- #
@@ -3470,14 +3882,26 @@ andalgorithm
: One of"A*_noprefetch"
(default),"A*"
,"Dijkstra"
minetest.auth_reload
call the authentication handler. of nodes to fall.- #
minetest.get_spawn_level(x, z)
+
+- #Returns a player spawn y co-ordinate for the provided (x, z) + co-ordinates, or
+nil
for an unsuitable spawn point.- #For most mapgens a 'suitable spawn point' is one with y between +
+water_level
andwater_level + 16
, and in mgv7 well away from rivers, + sonil
will be returned for many (x, z) co-ordinates.- The spawn level returned is for a player spawn in unmodified terrain.
+- The spawn level is intentionally above terrain level to cope with + full-node biome 'dust' nodes.
+Mod channels
You can find mod channels communication scheme in
docs/mod_channels.png
.
- #
minetest.mod_channel_join(channel_name)
- #Server joins channel
+ should listen from incoming messages with +channel_name
, and creates it if necessary. You - should listen from incoming messages withminetest.register_on_modchannel_message
- call to receive incoming messagesminetest.register_on_modchannel_message
call to receive incoming + messages.minetest.auth_reload
call the authentication handler.- #
{type="detached", name="creative"}
- #
minetest.create_detached_inventory(name, callbacks, [player_name])
: returns anInvRef
+
- #
minetest.create_detached_inventory(name, callbacks, [player_name])
: returns + anInvRef
.
- callbacks: See "Detached inventory callbacks"
-- #
+player_name
: Make detached inventory available to one player exclusively, - by default they will be sent to every player (even if not used). - Note that this parameter is mostly just a workaround and will be removed in future releases.- #
player_name
: Make detached inventory available to one player + exclusively, by default they will be sent to every player (even if not + used). + Note that this parameter is mostly just a workaround and will be removed + in future releases.- Creates a detached inventory. If it already exists, it is cleared.
- #
@@ -3515,20 +3942,23 @@ andminetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
: - returns left over ItemStack+ returns left over ItemStack.
- #See
minetest.item_eat
andminetest.register_on_item_eat
minetest.auth_reload
call the authentication handler.- #
minetest.close_formspec(playername, formname)
- #
-playername
: name of player to close formspec- #
-formname
: has to exactly match the one given inshow_formspec
, or the formspec will - not close.- #calling
+show_formspec(playername, formname, "")
is equal to this expression- #
+formname
: has to exactly match the one given inshow_formspec
, or the + formspec will not close.- #calling
show_formspec(playername, formname, "")
is equal to this + expression.- #to close a formspec regardless of the formname, call -
+minetest.close_formspec(playername, "")
. USE THIS ONLY WHEN ABSOLUTELY NECESSARY!minetest.close_formspec(playername, "")
. + USE THIS ONLY WHEN ABSOLUTELY NECESSARY!- #
minetest.formspec_escape(string)
: returns a string-
- escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs
+- escapes the characters "[", "]", "\", "," and ";", which can not be used + in formspecs.
- #
minetest.explode_table_event(string)
: returns a table
- #returns e.g.
-{type="CHG", row=1, column=2}
- #
type
is one of:+
- #
type
is one of:- #
minetest.explode_textlist_event(string)
: returns a table
- #returns e.g.
-{type="CHG", index=1}
- #
-type
is one of:+
- #
type
is one of:- #
minetest.explode_scrollbar_event(string)
: returns a table+
- #returns e.g.
-{type="CHG", value=500}
- #
+type
is one of:+
- #
type
is one of:- #
minetest.dir_to_facedir(dir, is6d)
-
- #Convert a vector to a facedir value, used in
-param2
forparamtype2="facedir"
;- #passing something non-
+nil
/false
for the optional second parameter causes it to - take the y component into account- #Convert a vector to a facedir value, used in
+param2
for +paramtype2="facedir"
.- #passing something non-
nil
/false
for the optional second parameter + causes it to take the y component into account.- #
minetest.facedir_to_dir(facedir)
-
- Convert a facedir back into a vector aimed directly out the "back" of a node
+- Convert a facedir back into a vector aimed directly out the "back" of a + node.
- #
minetest.dir_to_wallmounted(dir)
- #
minetest.wallmounted_to_dir(wallmounted)
-
- Convert a wallmounted value back into a vector aimed directly out the "back" of a node
+- Convert a wallmounted value back into a vector aimed directly out the + "back" of a node.
- #
minetest.dir_to_yaw(dir)
@@ -3594,14 +4028,15 @@ and
minetest.auth_reload
call the authentication handler.- #
minetest.is_colored_paramtype(ptype)
- #
minetest.strip_param2_color(param2, paramtype2)
- #
minetest.get_node_drops(nodename, toolname)
@@ -3613,7 +4048,7 @@ and
minetest.auth_reload
call the authentication handler.- #
input.method
="normal"
or"cooking"
or"fuel"
- #
input.width
= for example3
- #
+input.items
= for example -{ stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9 }
{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}
- #
output.item
=ItemStack
, if unsuccessful: emptyItemStack
- #
output.time
= a number, if unsuccessful:0
- #
output.replacements
= list ofItemStack
s that couldn't be placed in @@ -3627,57 +4062,52 @@ andminetest.auth_reload
call the authentication handler.- #
input.method
="normal"
or"cooking"
or"fuel"
- #
input.width
= for example3
- #
+input.items
= for example -{ stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9 }
{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}
- #
input.items
=nil
if no recipe found- #
@@ -3690,7 +4120,8 @@ andminetest.get_all_craft_recipes(query item)
: returns a table ornil
-
- #returns indexed table with all registered recipes for query item (node) - or
-nil
if no recipe was found- #recipe entry table:
-{ - method = 'normal' or 'cooking' or 'fuel' - width = 0-3, 0 means shapeless recipe - items = indexed [1-9] table with recipe items - output = string with item name and quantity -} -* Example query for `"default:gold_ingot"` will return table: - -{ - [1]={method = "cooking", width = 3, output = "default:gold_ingot", - items = {1 = "default:gold_lump"}}, - [2]={method = "normal", width = 1, output = "default:gold_ingot 9", - items = {1 = "default:goldblock"}} -} -
-
+- #
-minetest.handle_node_drops(pos, drops, digger)
-
-- #
-drops
: list of itemstrings- Handles drops from nodes after digging: Default action is to put them into - digger's inventory
-- Can be overridden to get different functionality (e.g. dropping items on - ground)
-- #
-minetest.itemstring_with_palette(item, palette_index)
: returns an item string-
-- Creates an item string which contains palette index information - for hardware colorization. You can use the returned string - as an output in a craft recipe.
-- #
-item
: the item stack which becomes colored. Can be in string, - table and native form.- #
-palette_index
: this index is added to the item stack- #
-minetest.itemstring_with_color(item, colorstring)
: returns an item string-
-- Creates an item string which contains static color information - for hardware colorization. Use this method if you wish to colorize - an item that does not own a palette. You can use the returned string - as an output in a craft recipe.
-- #
-item
: the item stack which becomes colored. Can be in string, - table and native form.- #
-colorstring
: the new color of the item stack- #returns indexed table with all registered recipes for query item (node) + or
+nil
if no recipe was found.- # +
recipe entry table:
+{ + method = 'normal' or 'cooking' or 'fuel' + width = 0-3, 0 means shapeless recipe + items = indexed [1-9] table with recipe items + output = string with item name and quantity + } + * Example query for
+"default:gold_ingot"
will return table:{ + [1]={method = "cooking", width = 3, output = "default:gold_ingot", + items = {1 = "default:gold_lump"}}, + [2]={method = "normal", width = 1, output = "default:gold_ingot 9", + items = {1 = "default:goldblock"}} + } +
minetest.handle_node_drops(pos, drops, digger)
+ *drops
: list of itemstrings + * Handles drops from nodes after digging: Default action is to put them + into digger's inventory. + * Can be overridden to get different functionality (e.g. dropping items on + ground) +minetest.itemstring_with_palette(item, palette_index)
: returns an item + string. + * Creates an item string which contains palette index information + for hardware colorization. You can use the returned string + as an output in a craft recipe. + *item
: the item stack which becomes colored. Can be in string, + table and native form. + *palette_index
: this index is added to the item stack +*minetest.itemstring_with_color(item, colorstring)
: returns an item string + * Creates an item string which contains static color information + for hardware colorization. Use this method if you wish to colorize + an item that does not own a palette. You can use the returned string + as an output in a craft recipe. + *item
: the item stack which becomes colored. Can be in string, + table and native form. + *colorstring
: the new color of the item stackminetest.auth_reload
call the authentication handler.- #
actor
:"player:<name>"
, also"liquid"
.- #
@@ -3768,17 +4200,22 @@ andminetest.rollback_revert_actions_by(actor, seconds)
: returnsboolean, log_messages
+
- #
minetest.rollback_revert_actions_by(actor, seconds)
: returns +boolean, log_messages
.@@ -3753,7 +4184,8 @@ and
- Revert latest actions of someone
- #
actor
:"player:<name>"
, also"liquid"
.minetest.auth_reload
call the authentication handler.- #
minetest.sound_fade(handle, step, gain)
- #
gain
the target gain for the fade.minetest.auth_reload
call the authentication handler.Server
-
- #
+minetest.request_shutdown([message],[reconnect],[delay])
: request for server shutdown. Will displaymessage
to clients, -reconnect
== true displays a reconnect button, -delay
adds an optional delay (in seconds) before shutdown - negative delay cancels the current active shutdown - zero delay triggers an immediate shutdown.- #
minetest.request_shutdown([message],[reconnect],[delay])
: request for + server shutdown. Will displaymessage
to clients. +- #
minetest.cancel_shutdown_requests()
: cancel current delayed shutdown- #
minetest.get_server_status()
: returns server status string- #
-minetest.get_server_uptime()
: returns the server uptime in seconds- #
minetest.remove_player(name)
: remove player from database (if he is not connected).-
- As auth data is not removed, minetest.player_exists will continue to return true. - Call the below method as well if you want to remove auth data too.
+- #
@@ -3789,25 +4226,28 @@ andminetest.remove_player(name)
: remove player from database (if they are not + connected).+
- As auth data is not removed, minetest.player_exists will continue to + return true. Call the below method as well if you want to remove auth + data too.
- Returns a code (0: successful, 1: no such player, 2: player is connected)
minetest.auth_reload
call the authentication handler.Bans
-
- #
+minetest.get_ban_list()
: returns the ban list (same asminetest.get_ban_description("")
)- #
minetest.get_ban_list()
: returns the ban list + (same asminetest.get_ban_description("")
).- #
minetest.get_ban_description(ip_or_name)
: returns ban description (string)- #
minetest.ban_player(name)
: ban a player- #
-minetest.unban_player_or_ip(name)
: unban player or IP address- #
+minetest.kick_player(name, [reason])
: disconnect a player with a optional reason- #
minetest.kick_player(name, [reason])
: disconnect a player with a optional + reason.Particles
- #
minetest.add_particle(particle definition)
- #
minetest.add_particlespawner(particlespawner definition)
-
@@ -3832,31 +4273,36 @@ and- #Add a
+ParticleSpawner
, an object that spawns an amount of particles overtime
seconds- #Add a
ParticleSpawner
, an object that spawns an amount of particles + overtime
seconds.- #Returns an
id
, and -1 if adding didn't succeed- #
Deprecated: minetest.add_particlespawner(amount, time, minpos, maxpos, @@ -3821,9 +4261,10 @@ and
minetest.auth_reload
call the authentication handler.- #
minetest.delete_particlespawner(id, player)
-
- #Delete
-ParticleSpawner
withid
(return value fromminetest.add_particlespawner
)- If playername is specified, only deletes on the player's client,
-- otherwise on all clients
+- #Delete
+ParticleSpawner
withid
(return value from +minetest.add_particlespawner
).- If playername is specified, only deletes on the player's client, + otherwise on all clients.
minetest.auth_reload
call the authentication handler.- #
minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)
-
- Create a schematic from the volume of map specified by the box formed by p1 and p2.
-- #Apply the specified probability and per-node force-place to the specified nodes - according to the
probability_list
.-
- #
probability_list
is an array of tables containing two fields,pos
andprob
.+
- Create a schematic from the volume of map specified by the box formed by + p1 and p2.
+- #Apply the specified probability and per-node force-place to the specified + nodes according to the
-probability_list
.+
- #
probability_list
is an array of tables containing two fields,pos
+ andprob
.
- #
-pos
is the 3D vector specifying the absolute coordinates of the node being modified,- #
+prob
is an integer value from0
to255
that encodes probability and - per-node force-place. Probability has levels 0-127, then 128 is added to - encode per-node force-place. - For probability stated as 0-255, divide by 2 and round down to get values - 0-127, then add 128 to apply per-node force-place.- #
prob
is an integer value from0
to255
that encodes + probability and per-node force-place. Probability has levels + 0-127, then 128 may be added to encode per-node force-place. + For probability stated as 0-255, divide by 2 and round down to + get values 0-127, then add 128 to apply per-node force-place.- If there are two or more entries with the same pos value, the last entry is used.
-- #If
+pos
is not inside the box formed byp1
andp2
, it is ignored.- #If
pos
is not inside the box formed byp1
andp2
, it is + ignored.- #If
probability_list
equalsnil
, no probabilities are applied.- #Apply the specified probability to the specified horizontal slices according to the -
slice_prob_list
.-
- #
-slice_prob_list
is an array of tables containing two fields,ypos
andprob
.-
- #
-ypos
indicates the y position of the slice with a probability applied, - the lowest slice beingypos = 0
.- #If slice probability list equals
+nil
, no slice probabilities are applied.- #Apply the specified probability to the specified horizontal slices + according to the
slice_prob_list
.+
@@ -3864,57 +4310,82 @@ and- #
slice_prob_list
is an array of tables containing two fields,ypos
+ andprob
.minetest.auth_reload
call the authentication handler.- Saves schematic in the Minetest Schematic format to filename.
- # -
+
minetest.place_schematic(pos, schematic, rotation, replacements, force_placement)
- # +
+
minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)
-
+- #Place the schematic specified by schematic (see: Schematic specifier) at
+pos
.- #Place the schematic specified by schematic (see: Schematic specifier) at +
pos
.- #
rotation
can equal"0"
,"90"
,"180"
,"270"
, or"random"
.- #If the
rotation
parameter is omitted, the schematic is not rotated.- #
-replacements
={["old_name"] = "convert_to", ...}
- #
+force_placement
is a boolean indicating whether nodes other thanair
and -ignore
are replaced by the schematic- #
force_placement
is a boolean indicating whether nodes other thanair
+ andignore
are replaced by the schematic.- Returns nil if the schematic could not be loaded.
-- Warning: Once you have loaded a schematic from a file, it will be cached. Future calls - will always use the cached version and the replacement list defined for it, - regardless of whether the file or the replacement list parameter have changed. - The only way to load the file anew is to restart the server.
+- Warning: Once you have loaded a schematic from a file, it will be + cached. Future calls will always use the cached version and the + replacement list defined for it, regardless of whether the file or the + replacement list parameter have changed. The only way to load the file + anew is to restart the server.
+- #
-flags
is a flag field with the available flags:+
- place_center_x
+- place_center_y
+- place_center_z
- # -
+
minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement)
:- # +
minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)
:-
- #This function is analogous to minetest.place_schematic, but places a schematic onto the - specified VoxelManip object
-vmanip
instead of the whole map.- Returns false if any part of the schematic was cut-off due to the VoxelManip not - containing the full area required, and true if the whole schematic was able to fit.
+- #This function is analogous to minetest.place_schematic, but places a + schematic onto the specified VoxelManip object
+vmanip
instead of the + map.- Returns false if any part of the schematic was cut-off due to the + VoxelManip not containing the full area required, and true if the whole + schematic was able to fit.
- Returns nil if the schematic could not be loaded.
-- After execution, any external copies of the VoxelManip contents are invalidated.
+- After execution, any external copies of the VoxelManip contents are + invalidated.
+- #
flags
is a flag field with the available flags:+
+- place_center_x
+- place_center_y
+- place_center_z
+- #
minetest.serialize_schematic(schematic, format, options)
-
- Return the serialized schematic specified by schematic (see: Schematic specifier)
+- Return the serialized schematic specified by schematic + (see: Schematic specifier)
- #in the
-format
of either "mts" or "lua".- "mts" - a string containing the binary MTS data used in the MTS file format
-- "lua" - a string containing Lua code representing the schematic in table format
-- #
-options
is a table containing the following optional parameters:- #If
-lua_use_comments
is true andformat
is "lua", the Lua code generated will have (X, Z)- position comments for every X row generated in the schematic data for easier reading.
-- #If
-lua_num_indent_spaces
is a nonzero number andformat
is "lua", the Lua code generated- will use that number of spaces as indentation instead of a tab character.
+- "mts" - a string containing the binary MTS data used in the MTS file + format.
+- "lua" - a string containing Lua code representing the schematic in table + format.
+- #
options
is a table containing the following optional parameters:+
+- #If
+lua_use_comments
is true andformat
is "lua", the Lua code + generated will have (X, Z) position comments for every X row + generated in the schematic data for easier reading.- #If
+lua_num_indent_spaces
is a nonzero number andformat
is "lua", + the Lua code generated will use that number of spaces as indentation + instead of a tab character.HTTP Requests:
- #
minetest.request_http_api()
:-
- #returns
-HTTPApiTable
containing http functions if the calling mod has been granted - access by being listed in thesecure.http_mods
orsecure.trusted_mods
setting, - otherwise returnsnil
.- #The returned table contains the functions
-fetch
,fetch_async
andfetch_async_get
- described below.- Only works at init time and must be called from the mod's main scope (not from a function).
+- #returns
+HTTPApiTable
containing http functions if the calling mod has + been granted access by being listed in thesecure.http_mods
or +secure.trusted_mods
setting, otherwise returnsnil
.- #The returned table contains the functions
+fetch
,fetch_async
and +fetch_async_get
described below.- Only works at init time and must be called from the mod's main scope + (not from a function).
- Function only exists if minetest server was built with cURL support.
- DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN A LOCAL VARIABLE!
@@ -3923,11 +4394,12 @@ andminetest.auth_reload
call the authentication handler.- #
HTTPApiTable.fetch(HTTPRequest req, callback)
- Performs given request asynchronously and calls callback upon completion
- #callback:
-function(HTTPRequestResult res)
- Use this HTTP function if you are unsure, the others are for advanced use.
+- Use this HTTP function if you are unsure, the others are for advanced use
- #
HTTPApiTable.fetch_async(HTTPRequest req)
: returns handle- #
HTTPApiTable.fetch_async_get(handle)
: returns HTTPRequestResult@@ -3946,10 +4418,12 @@ and
minetest.auth_reload
call the authentication handler.Misc.
- #
-minetest.get_connected_players()
: returns list ofObjectRefs
- #
+minetest.player_exists(name)
: boolean, whether player exists (regardless of online status)- #
+minetest.is_player(o)
: boolean, whethero
is a player- #
minetest.player_exists(name)
: boolean, whether player exists + (regardless of online status)- #
@@ -3980,12 +4454,12 @@ andminetest.hud_replace_builtin(name, hud_definition)
minetest.auth_reload
call the authentication handler.- #
minetest.raillike_group(name)
: returns a rating
- Returns rating of the connect_to_raillike group corresponding to name
-- If name is not yet the name of a connect_to_raillike group, a new group id
-- is created, with that name
+- If name is not yet the name of a connect_to_raillike group, a new group + id is created, with that name.
- #
minetest.get_content_id(name)
: returns an integer- #
-minetest.get_name_from_content_id(content_id)
: returns a string@@ -3996,25 +4470,30 @@ and
minetest.auth_reload
call the authentication handler.- Convert a string containing JSON data into the Lua equivalent
- #
nullvalue
: returned in place of the JSON null; defaults tonil
- #On success returns a table, a string, a number, a boolean or
-nullvalue
- #On failure outputs an error message and returns
+nil
- #On failure outputs an error message and returns
nil
- #Example:
parse_json("[10, {\"a\":false}]")
, returns{10, {a = false}}
- #
minetest.write_json(data[, styled])
: returns a string ornil
and an error message+
- #
-minetest.write_json(data[, styled])
: returns a string ornil
and an error + message.
- Convert a Lua table into a JSON string
-- styled: Outputs in a human-readable format if this is set, defaults to false
+- styled: Outputs in a human-readable format if this is set, defaults to + false.
- Unserializable things like functions and userdata will cause an error.
- Warning: JSON is more strict than the Lua table format.
-
- You can only use strings and positive integers of at least one as keys.
+- You can only use strings and positive integers of at least one as + keys.
- You can not mix string and integer keys. - This is due to the fact that JSON has two distinct array and object values.
+ This is due to the fact that JSON has two distinct array and object + values.- #Example:
+write_json({10, {a = false}})
, returns"[10, {\"a\": false}]"
- #Example:
write_json({10, {a = false}})
, + returns"[10, {\"a\": false}]"
- #
minetest.serialize(table)
: returns a string-
@@ -4023,27 +4502,32 @@ and- #Convert a table containing tables, strings, numbers, booleans and
nil
s +- #Convert a table containing tables, strings, numbers, booleans and
nil
s into string form readable byminetest.deserialize
- #Example:
serialize({foo='bar'})
, returns'return { ["foo"] = "bar" }'
minetest.auth_reload
call the authentication handler.- #Convert a string returned by
minetest.deserialize
into a table- #
string
is loaded in an empty sandbox environment.- Will load functions, but they cannot access the global environment.
-- #Example:
-deserialize('return { ["foo"] = "bar" }')
, returns{foo='bar'}
- #Example:
+deserialize('print("foo")')
, returnsnil
(function call fails)-
-- #
-error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)
- #Example:
+deserialize('return { ["foo"] = "bar" }')
, + returns{foo='bar'}
- #Example:
deserialize('print("foo")')
, returnsnil
+ (function call fails), returns +error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)
- #
minetest.compress(data, method, ...)
: returnscompressed_data
+
- Compress a string of data.
- #
-method
is a string identifying the compression method to be used.- Supported compression methods:
-- #Deflate (zlib):
-"deflate"
- +
...
indicates method-specific arguments. Currently defined arguments are:- #Supported compression methods:
++
+- #Deflate (zlib):
+"deflate"
- +
...
indicates method-specific arguments. Currently defined arguments + are:
- #Deflate:
level
- Compression level,0
-9
ornil
.- #
minetest.decompress(compressed_data, method, ...)
: returns data
- Decompress a string of data (using ZLib).
-- #See documentation on
-minetest.compress()
for supported compression methods.- currently supported.
-- +
...
indicates method-specific arguments. Currently, no methods use this.- #See documentation on
+minetest.compress()
for supported compression + methods....
indicates method-specific arguments. Currently, no methods use this- #
minetest.rgba(red, green, blue[, alpha])
: returns a string@@ -4063,14 +4547,15 @@ and
@@ -4133,11 +4635,13 @@ endminetest.auth_reload
call the authentication handler.- #
-
minetest.is_protected(pos, name)
: returns boolean-
- #Returns true, if player
-name
shouldn't be abled to dig atpos
or do other - actions, definable by mods, due to some mod-defined ownership-like concept. - Returns false or nil, if the player is allowed to do such actions.- #
-name
will be "" for non-players or unknown players.- This function should be overridden by protection mods and should be used to - check if a player can interact at a position.
-- This function should call the old version of itself if the position is not - protected by the mod.
+- #Returns true, if player
+name
shouldn't be able to dig atpos
or do + other actions, definable by mods, due to some mod-defined ownership-like + concept.- Returns false or nil, if the player is allowed to do such actions.
+- #
+name
will be "" for non-players or unknown players.- This function should be overridden by protection mods and should be used + to check if a player can interact at a position.
+- This function should call the old version of itself if the position is + not protected by the mod.
- #Example:
+local old_is_protected = minetest.is_protected function minetest.is_protected(pos, name) if mymod:position_protected_from(pos, name) then @@ -4082,30 +4567,47 @@ end +
- #`minetest.is_area_protected(pos1, pos2, player_name, interval)
+
- #Returns the position of the first node that
+player_name
may not modify + in the specified cuboid betweenpos1
andpos2
.- #Returns
+false
if no protections were found.- #Applies
+is_protected()
to a 3D lattice of points in the defined volume. + The points are spaced evenly throughout the volume and have a spacing + similar to, but no larger than,interval
.- All corners and edges of the defined volume are checked.
+- #
+interval
defaults to 4.- #
+interval
should be carefully chosen and maximised to avoid an excessive + number of points being checked.- #Like
minetest.is_protected
, this function may be extended or + overwritten by mods to provide a faster implementation to check the + cuboid for intersections.- #
minetest.rotate_and_place(itemstack, placer, pointed_thing, infinitestacks, orient_flags)
- #Attempt to predict the desired orientation of the facedir-capable node - defined by
+ defined byitemstack
, and place it accordingly (on-wall, on the floor, or - hanging from the ceiling). Stacks are handled normally if theinfinitestacks
- field is false or omitted (else, the itemstack is not changed).orient_flags
- is an optional table containing extra tweaks to the placement code:itemstack
, and place it accordingly (on-wall, on the floor, + or hanging from the ceiling). Stacks are handled normally if the +infinitestacks
field is false or omitted (else, the itemstack is not + changed).orient_flags
is an optional table containing extra tweaks to + the placement code:- #
+invert_wall
: iftrue
, place wall-orientation on the ground and ground- - orientation on the wall.- #
invert_wall
: iftrue
, place wall-orientation on the ground and + ground-orientation on the wall.- #
force_wall
: iftrue
, always place the node in wall orientation.- #
force_ceiling
: iftrue
, always place on the ceiling.- #
-force_floor
: iftrue
, always place the node on the floor.- #
-force_facedir
: iftrue
, forcefully reset the facedir to north when placing on - the floor or ceiling- The first four options are mutually-exclusive; the last in the list takes - precedence over the first.
+- #
+force_facedir
: iftrue
, forcefully reset the facedir to north + when placing on the floor or ceiling.- The first four options are mutually-exclusive; the last in the list + takes precedence over the first.
- #
minetest.rotate_node(itemstack, placer, pointed_thing)
-
- #calls
+rotate_and_place()
with infinitestacks set according to the state of - the creative mode setting, and checks for "sneak" to set theinvert_wall
- parameter.- #calls
rotate_and_place()
with infinitestacks set according to the state + of the creative mode setting, and checks for "sneak" to set the +invert_wall
parameter.- #
+
minetest.request_insecure_environment()
: returns an environment containing insecure functions if the calling mod has been listed as trusted in the -secure.trusted_mods
setting or security is disabled, otherwise returnsnil
.secure.trusted_mods
setting or security is disabled, otherwise returns +nil
.-
- Only works at init time and must be called from the mod's main scope (not from a function).
-- DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE IT IN - A LOCAL VARIABLE!
+- Only works at init time and must be called from the mod's main scope (not + from a function).
+- DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE + IT IN A LOCAL VARIABLE!
- # @@ -4151,8 +4655,8 @@ end
@@ -4211,12 +4715,14 @@ end
- #
minetest.env
:EnvRef
of the server environment and world.
- #Any function in the minetest namespace can be called using the syntax -
+minetest.env:somefunction(somearguments)
- instead ofminetest.somefunction(somearguments)
minetest.env:somefunction(somearguments)
+ instead ofminetest.somefunction(somearguments)
- Deprecated, but support is not to be dropped soon
- #
-leave()
: leave the mod channel.
- #Server leaves channel
-channel_name
.- No more incoming or outgoing messages can be sent to this channel from server mods.
-- This invalidate all future object usage
-- Ensure your set mod_channel to nil after that to free Lua resources
+- No more incoming or outgoing messages can be sent to this channel from + server mods.
+- This invalidate all future object usage.
+- Ensure your set mod_channel to nil after that to free Lua resources.
- #
+is_writeable()
: returns true if channel is writeable and mod can send over it.- #
is_writeable()
: returns true if channel is writeable and mod can send over + it.- #
send_all(message)
: Sendmessage
though the mod channel.
- If mod channel is not writeable or invalid, message will be dropped.
- Message size is limited to 65535 characters by protocol.
@@ -4258,8 +4764,9 @@ Can be obtained viaminetest.get_meta(pos)
.- #
get_inventory()
: returnsInvRef
- #
+ status will only be remembered if an associated key-value pair exists, + meaning it's best to call this when initializing all other meta (e.g. +mark_as_private(name or {name1, name2, ...})
: Mark specific vars as private This will prevent them from being sent to the client. Note that the "private" - status will only be remembered if an associated key-value pair exists, meaning - it's best to call this when initializing all other meta (e.g.on_construct
).on_construct
).
ItemStackMetaRef
ItemStack metadata: reference extra data and functionality stored in a stack. @@ -4268,8 +4775,9 @@ Can be obtained via
item:get_meta()
.@@ -4289,7 +4797,8 @@ Can be gotten via
- All methods in MetaDataRef
- #
set_tool_capabilities([tool_capabilities])
-
- overrides the item's tool capabilities
-- a nil value will clear the override data and restore the original behavior
+- Overrides the item's tool capabilities
+- A nil value will clear the override data and restore the original + behavior.
minetest.get_node_timer(pos)
.- set a timer's state
- #
timeout
is in seconds, and supports fractional values (0.1 etc)- #
-elapsed
is in seconds, and supports fractional values (0.1 etc)- #will trigger the node's
+on_timer
function after(timeout - elapsed)
seconds- #will trigger the node's
on_timer
function after(timeout - elapsed)
+ seconds.- #
start(timeout)
@@ -4306,7 +4815,8 @@ Can be gotten via
minetest.get_node_timer(pos)
.- #
get_elapsed()
: returns current elapsed time in seconds- #
is_started()
: returns boolean state of timer@@ -4334,33 +4844,44 @@ Can be gotten via
minetest.get_node_timer(pos)
.- #
right_click(clicker)
;clicker
is anotherObjectRef
- #
-get_hp()
: returns number of hitpoints (2 * number of hearts)- #
+set_hp(hp)
: set number of hitpoints (2 * number of hearts)- #
set_hp(hp, reason)
: set number of hitpoints (2 * number of hearts).+
+- See reason in register_on_player_hpchange
+- #
-get_inventory()
: returns anInvRef
- #
+get_wield_list()
: returns the name of the inventory list the wielded item is in- #
get_wield_list()
: returns the name of the inventory list the wielded item + is in.- #
get_wield_index()
: returns the index of the wielded item- #
-get_wielded_item()
: returns anItemStack
- #
+set_wielded_item(item)
: replaces the wielded item, returnstrue
if successful- #
set_wielded_item(item)
: replaces the wielded item, returnstrue
if + successful.- #
set_armor_groups({group1=rating, group2=rating, ...})
- #
-get_armor_groups()
: returns a table with the armor group ratings- #
+set_animation(frame_range, frame_speed, frame_blend, frame_loop)
- #
+set_animation(frame_range, frame_speed, frame_blend, frame_loop)
+- #
+get_animation()
: returnsrange
,frame_speed
,frame_blend
and +frame_loop
.- #
set_animation_frame_speed(frame_speed)
+
- #
+frame_speed
: number, default:15.0
- #
-set_attach(parent, bone, position, rotation)
- #
+get_attach()
: returns parent, bone, position, rotation or nil if it isn't attached- #
get_attach()
: returns parent, bone, position, rotation or nil if it isn't + attached.- #
set_detach()
- #
@@ -4423,7 +4944,8 @@ Can be gotten viaset_bone_position(bone, position, rotation)
minetest.get_node_timer(pos)
. table {x, y, z} representing the player's instantaneous velocity in nodes/s- #
get_look_dir()
: get camera direction as a unit vector- #
get_look_vertical()
: pitch in radians-
- Angle ranges between -pi/2 and pi/2, which are straight up and down respectively.
+- Angle ranges between -pi/2 and pi/2, which are straight up and down + respectively.
- #
get_look_horizontal()
: yaw in radians@@ -4435,19 +4957,25 @@ Can be gotten via
minetest.get_node_timer(pos)
.- #
-set_look_horizontal(radians)
: sets look yaw-
- radians - Angle from the +z direction, where positive is counter-clockwise.
+- radians - Angle from the +z direction, where positive is + counter-clockwise.
- #
get_look_pitch()
: pitch in radians - Deprecated as broken. Useget_look_vertical
.-
- Angle ranges between -pi/2 and pi/2, which are straight down and up respectively.
+- #
-get_look_pitch()
: pitch in radians - Deprecated as broken. Use +get_look_vertical
.+
- Angle ranges between -pi/2 and pi/2, which are straight down and up + respectively.
- #
get_look_yaw()
: yaw in radians - Deprecated as broken. Useget_look_horizontal
.+
- #
-get_look_yaw()
: yaw in radians - Deprecated as broken. Use +get_look_horizontal
.
- Angle is counter-clockwise from the +x direction.
- #
-set_look_pitch(radians)
: sets look pitch - Deprecated. Useset_look_vertical
.- #
+set_look_yaw(radians)
: sets look yaw - Deprecated. Useset_look_horizontal
.- #
+set_look_pitch(radians)
: sets look pitch - Deprecated. Use +set_look_vertical
.- #
set_look_yaw(radians)
: sets look yaw - Deprecated. Use +set_look_horizontal
.- #
get_breath()
: returns players breath- #
-set_breath(value)
: sets players breath
- #values:
@@ -4460,13 +4988,14 @@ Can be gotten via
minetest.get_node_timer(pos)
.- #
set_attribute(attribute, value)
:- #
get_attribute(attribute)
:- #
set_inventory_formspec(formspec)
@@ -4475,14 +5004,24 @@ Can be gotten via
minetest.get_node_timer(pos)
.- #
+get_inventory_formspec()
: returns a formspec string- #
+set_formspec_prepend(formspec)
:+
+- the formspec string will be added to every formspec shown to the user, + except for those with a no_prepend[] tag.
+- This should be used to set style elements such as background[] and + bgcolor[], any non-style elements (eg: label) may result in weird behaviour.
+- Only affects formspecs shown after this is called.
+- #
get_formspec_prepend(formspec)
: returns a formspec string.- #
get_player_control()
: returns table with player pressed keys
- The table consists of fields with boolean value representing the pressed - keys, the fields are jump, right, left, LMB, RMB, sneak, aux1, down and up
+ keys, the fields are jump, right, left, LMB, RMB, sneak, aux1, down, up.- #example:
{jump=false, right=true, left=false, LMB=false, RMB=false, sneak=true, aux1=false, down=false, up=false}
- #
get_player_control_bits()
: returns integer with bit packed player pressed keys+
- #
get_player_control_bits()
: returns integer with bit packed player pressed + keys.@@ -4506,18 +5045,21 @@ Can be gotten via
- bit nr/meaning: 0/up, 1/down, 2/left, 3/right, 4/jump, 5/aux1, 6/sneak, 7/LMB, 8/RMB
minetest.get_node_timer(pos)
.- #
hud_add(hud definition)
: add a HUD element described by HUD def, returns ID number on success- #
-hud_remove(id)
: remove the HUD element of the specified id- #
hud_change(id, stat, value)
: change a value of a previously added HUD element-
- #element
+stat
values:position
,name
,scale
,text
,number
,item
,dir
- #
hud_change(id, stat, value)
: change a value of a previously added HUD + element.+
- #element
stat
values: +position
,name
,scale
,text
,number
,item
,dir
- #
hud_get(id)
: gets the HUD element definition structure of the specified ID- #
@@ -4543,7 +5085,7 @@ Can be gotten viahud_set_flags(flags)
: sets specified HUD flags totrue
/false
-
- #
-flags
: (is visible)hotbar
,healthbar
,crosshair
,wielditem
,breathbar
, -minimap
,minimap_radar
- #pass a table containing a
-true
/false
value of each flag to be set or unset- #if a flag equals
-nil
, the flag is not modified- #note that setting
-minimap
modifies the client's permission to view the minimap -- the client may locally elect to not view the minimap
+- #
+flags
: (is visible)hotbar
,healthbar
,crosshair
,wielditem
, +breathbar
,minimap
,minimap_radar
- #pass a table containing a
+true
/false
value of each flag to be set or + unset.- #if a flag equals
+nil
, the flag is not modified- #note that setting
minimap
modifies the client's permission to view the + minimap - the client may locally elect to not view the minimap.- #minimap
radar
is only usable whenminimap
is trueminetest.get_node_timer(pos)
.- #
hud_get_hotbar_selected_image
: returns texturename- #
set_sky(bgcolor, type, {texture names}, clouds)
- #
-bgcolor
: ColorSpec, defaults to white- #
type
: Available types:+
- #
type
: Available types:
- #
"regular"
: Uses 0 textures,bgcolor
ignored- #
"skybox"
: Uses 6 textures,bgcolor
used- #
@@ -4557,20 +5099,25 @@ Can be gotten via"plain"
: Uses 0 textures,bgcolor
usedminetest.get_node_timer(pos)
.- #
-set_clouds(parameters)
: set cloud parameters
- #
parameters
is a table with the following optional fields:
- #
-density
: from0
(no clouds) to1
(full clouds) (default0.4
)- #
+color
: basic cloud color with alpha channel, ColorSpec (default#fff0f0e5
)- #
color
: basic cloud color with alpha channel, ColorSpec + (default#fff0f0e5
).- #
-ambient
: cloud color lower bound, use for a "glow at night" effect. ColorSpec (alpha ignored, default#000000
)- #
+height
: cloud height, i.e. y of cloud base (default per conf, usually120
)- #
height
: cloud height, i.e. y of cloud base (default per conf, + usually120
)- #
-thickness
: cloud thickness in nodes (default16
)- #
+speed
: 2D cloud speed + direction in nodes per second (default{x=0, z=-2}
)- #
speed
: 2D cloud speed + direction in nodes per second + (default{x=0, z=-2}
).- #
+get_clouds()
: returns a table with the current cloud parameters as inset_clouds
- #
get_clouds()
: returns a table with the current cloud parameters as in +set_clouds
.- #
override_day_night_ratio(ratio or nil)
-
- #
-0
...1
: Overrides day-night ratio, controlling sunlight to a specific amount- #
+nil
: Disables override, defaulting to sunlight based on day-night cycle- #
+0
...1
: Overrides day-night ratio, controlling sunlight to a specific + amount.- #
nil
: Disables override, defaulting to sunlight based on day-night cycle- #
@@ -4582,8 +5129,10 @@ Can be gotten viaget_day_night_ratio()
: returns the ratio or nil if it isn't overriddenminetest.get_node_timer(pos)
. frame_speed=30): -- < animation frame speed-
- #
-get_local_animation()
: returns stand, walk, dig, dig+walk tables andframe_speed
- #
+set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
: defines offset value for camera per player- #
+get_local_animation()
: returns stand, walk, dig, dig+walk tables and +frame_speed
.- #
set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
: defines offset value for + camera per player.- in first person view
- #in third person view (max. values
{x=-10/10,y=-10,15,z=-5/5}
)- #
@@ -4597,7 +5146,7 @@ Can be gotten viaget_eye_offset()
: returnsoffset_first
andoffset_third
minetest.get_node_timer(pos)
.- #
is_empty(listname)
: returntrue
if list is empty- #
get_size(listname)
: get size of a list- #
set_size(listname, size)
: set size of a list- #
@@ -4608,64 +5157,85 @@ Can be gotten viaget_width(listname)
: get width of a listminetest.get_node_timer(pos)
.- #
set_list(listname, list)
: set full list (size will not change)- #
get_lists()
: returns list of inventory lists- #
-set_lists(lists)
: sets inventory lists (size will not change)- #
+add_item(listname, stack)
: add item somewhere in list, returns leftoverItemStack
- #
add_item(listname, stack)
: add item somewhere in list, returns leftover +ItemStack
.- #
room_for_item(listname, stack):
returnstrue
if the stack of items can be fully added to the list- #
-contains_item(listname, stack, [match_meta])
: returnstrue
if the stack of items can be fully taken from the list. - Ifmatch_meta
is false, only the items' names are compared (default:false
).- #
-remove_item(listname, stack)
: take as many items as specified from the list, - returns the items that were actually removed (as anItemStack
) -- note that - any item metadata is ignored, so attempting to remove a specific unique - item this way will likely remove the wrong one -- to do that useset_stack
- with an emptyItemStack
- #
+get_location()
: returns a location compatible tominetest.get_inventory(location)
+ If
match_meta
is false, only the items' names are compared + (default:false
).- #
+remove_item(listname, stack)
: take as many items as specified from the + list, returns the items that were actually removed (as anItemStack
) + -- note that any item metadata is ignored, so attempting to remove a specific + unique item this way will likely remove the wrong one -- to do that use +set_stack
with an emptyItemStack
.- #
get_location()
: returns a location compatible to +minetest.get_inventory(location)
.
- #returns
{type="undefined"}
in case location is not known-
AreaStore
A fast access data structure to store areas, and find areas near a given position or area. +
A fast access data structure to store areas, and find areas near a given +position or area. Every area has a
+You can create an emptydata
string attribute to store additional information. -You can create an emptyAreaStore
by callingAreaStore()
, orAreaStore(type_name)
. -If you chose the parameter-less constructor, a fast implementation will be automatically -chosen for you.AreaStore
by callingAreaStore()
, or +AreaStore(type_name)
. +If you chose the parameter-less constructor, a fast implementation will be +automatically chosen for you.Methods
-
- #
get_area(id, include_borders, include_data)
: returns the area with the idid
. - (optional) Boolean valuesinclude_borders
andinclude_data
control what's copied. +- #
-get_area(id, include_borders, include_data)
: returns the area with the id +id
. + (optional) Boolean valuesinclude_borders
andinclude_data
control what's + copied. Returns nil if specified area id does not exist.- #
+get_areas_for_pos(pos, include_borders, include_data)
: returns all areas that contain - the positionpos
. (optional) Boolean valuesinclude_borders
andinclude_data
control - what's copied.- #
get_areas_for_pos(pos, include_borders, include_data)
: returns all areas + that contain the positionpos
. + (optional) Boolean valuesinclude_borders
andinclude_data
control what's + copied.- #
-get_areas_in_area(edge1, edge2, accept_overlap, include_borders, include_data)
: - returns all areas that contain all nodes inside the area specified byedge1
andedge2
(inclusive). - Ifaccept_overlap
is true, also areas are returned that have nodes in common with the specified area. - (optional) Boolean valuesinclude_borders
andinclude_data
control what's copied.- #
-insert_area(edge1, edge2, data, [id])
: inserts an area into the store. Returns the new area's ID, - or nil if the insertion failed. The (inclusive) positionsedge1
andedge2
describe the area. -data
is a string stored with the area. If passed,id
will be used as the internal area ID, - it must be a unique number between 0 and 2^32-2. If you use theid
parameter you must always use it, - or insertions are likely to fail due to conflicts.- #
+reserve(count)
: reserves resources for at mostcount
many contained areas. + returns all areas that contain all nodes inside the area specified byedge1
+ andedge2
(inclusive). + Ifaccept_overlap
is true, also areas are returned that have nodes in + common with the specified area. + (optional) Boolean valuesinclude_borders
andinclude_data
control what's + copied.- #
+insert_area(edge1, edge2, data, [id])
: inserts an area into the store. + Returns the new area's ID, or nil if the insertion failed. + The (inclusive) positionsedge1
andedge2
describe the area. +data
is a string stored with the area. If passed,id
will be used as the + internal area ID, it must be a unique number between 0 and 2^32-2. If you use + theid
parameter you must always use it, or insertions are likely to fail + due to conflicts.- #
-reserve(count)
: reserves resources for at mostcount
many contained + areas. Only needed for efficiency, and only some implementations profit.- #
+remove_area(id)
: removes the area with the given id from the store, returns success.- #
remove_area(id)
: removes the area with the given id from the store, returns + success.- #
-set_cache_params(params)
: sets params for the included prefiltering cache. - Calling invalidates the cache, so that its elements have to be newly generated.+ Calling invalidates the cache, so that its elements have to be newly + generated.
- #
params
: { - enabled = boolean, -- whether to enable, default true - block_radius = number, -- the radius (in nodes) of the areas the cache generates - prefiltered lists for, minimum 16, default 64 - limit = number, -- the cache's size, minimum 20, default 1000 + enabled = boolean, -- whether to enable, default true + block_radius = number, -- the radius (in nodes) of the areas the cache + generates prefiltered lists for, minimum 16, + default 64. + limit = number, -- the cache's size, minimum 20, default 1000 }- #
-to_string()
: Experimental. Returns area store serialized as a (binary) string.- #
-to_file(filename)
: Experimental. Liketo_string()
, but writes the data to a file.- #
from_string(str)
: Experimental. Deserializes string and loads it into the AreaStore. +- #
+to_string()
: Experimental. Returns area store serialized as a (binary) + string.- #
+to_file(filename)
: Experimental. Liketo_string()
, but writes the data to + a file.- #
-from_string(str)
: Experimental. Deserializes string and loads it into the + AreaStore. Returns success and, optionally, an error message.- #
+from_file(filename)
: Experimental. Likefrom_string()
, but reads the data from a file.- #
from_file(filename)
: Experimental. Likefrom_string()
, but reads the data + from a file.
ItemStack
An
@@ -4675,7 +5245,8 @@ an itemstring, a table orItemStack
is a stack of items.nil
.@@ -4739,13 +5312,15 @@ Uses a well-known LCG algorithm introduced by K&R.
- #
is_empty()
: returnstrue
if stack is empty.- #
-get_name()
: returns item name (e.g."default:stone"
).- #
+set_name(item_name)
: returns a boolean indicating whether the item was cleared- #
set_name(item_name)
: returns a boolean indicating whether the item was + cleared.- #
get_count()
: Returns number of items on the stack.- #
set_count(count)
: returns a boolean indicating whether the item was cleared
- #
@@ -4687,21 +5258,23 @@ an itemstring, a table orcount
: number, unsigned 16 bit integernil
.- #
-get_meta()
: returns ItemStackMetaRef. See section for more details- #
+get_metadata()
: (DEPRECATED) Returns metadata (a string attached to an item stack).- #
get_metadata()
: (DEPRECATED) Returns metadata (a string attached to an item + stack).- #
set_metadata(metadata)
: (DEPRECATED) Returns true.- #
clear()
: removes all items from the stack, making it empty.- #
replace(item)
: replace the contents of this stack.- #
to_string()
: returns the stack in itemstring form.- #
-to_table()
: returns the stack in Lua table form.- #
+get_stack_max()
: returns the maximum size of the stack (depends on the item).- #
get_stack_max()
: returns the maximum size of the stack (depends on the + item).- #
get_free_space()
: returnsget_stack_max() - get_count()
.- #
is_known()
: returnstrue
if the item name refers to a defined item type.- #
get_definition()
: returns the item definition table.- #
+ or those of the hand if none are defined for this item typeget_tool_capabilities()
: returns the digging properties of the item, - or those of the hand if none are defined for this item type- #
add_wear(amount)
- #
+ this one.item_fits(item)
: returnstrue
if item or stack can be fully added to - this one.- #
take_item(n)
: returns takenItemStack
- #
peek_item(n)
: returns takenItemStack
PcgRandom
A 32-bit pseudorandom number generator. -Uses PCG32, an algorithm of the permuted congruential generator family, offering very strong randomness.
+Uses PCG32, an algorithm of the permuted congruential generator family, +offering very strong randomness.It can be created via
PcgRandom(seed)
orPcgRandom(seed, sequence)
.Methods
- #
next()
: return next integer random number [-2147483648
...2147483647
]- #
-next(min, max)
: return next integer random number [min
...max
]- #
rand_normal_dist(min, max, num_trials=6)
: return normally distributed random number [min
...max
]+
- #
rand_normal_dist(min, max, num_trials=6)
: return normally distributed + random number [min
...max
].
- This is only a rough approximation of a normal distribution with:
- #
mean = (max - min) / 2
, and- #
@@ -4755,11 +5330,12 @@ Uses PCG32, an algorithm of the permuted congruential generator family, offeringvariance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)
SecureRandom
Interface for the operating system's crypto-secure PRNG.
-It can be created via
+SecureRandom()
. The constructor returns nil if a secure random device cannot be -be found on the system.It can be created via
SecureRandom()
. The constructor returns nil if a +secure random device cannot be found on the system.Methods
-
- #
+next_bytes([count])
: return nextcount
(default 1, capped at 2048) many random bytes, as a string.- #
next_bytes([count])
: return nextcount
(default 1, capped at 2048) many + random bytes, as a string.
PerlinNoise
A perlin noise generator. @@ -4776,85 +5352,111 @@ or
minetest.get_perlin(noiseparams)
.A fast, bulk perlin noise generator.
It can be created via
-PerlinNoiseMap(noiseparams, size)
orminetest.get_perlin_map(noiseparams, size)
.Format of
size
is{x=dimx, y=dimy, z=dimz}
. Thez
component is omitted +Format of
-size
is{x=dimx, y=dimy, z=dimz}
. Thez
component is omitted for 2D noise, and it must be must be larger than 1 for 3D noise (otherwisenil
is returned).For each of the functions with an optional
+buffer
parameter: Ifbuffer
is not -nil, this table will be used to store the result instead of creating a new table.For each of the functions with an optional
buffer
parameter: Ifbuffer
is +not nil, this table will be used to store the result instead of creating a new +table.Methods
- #
-get_2d_map(pos)
: returns a<size.x>
times<size.y>
2D array of 2D noise with values starting atpos={x=,y=}
- #
-get_3d_map(pos)
: returns a<size.x>
times<size.y>
times<size.z>
3D array - of 3D noise with values starting atpos={x=,y=,z=}
- #
+get_2d_map_flat(pos, buffer)
: returns a flat<size.x * size.y>
element array of 2D noise - with values starting atpos={x=,y=}
- #
+get_3d_map(pos)
: returns a<size.x>
times<size.y>
times<size.z>
+ 3D array of 3D noise with values starting atpos={x=,y=,z=}
.- #
get_2d_map_flat(pos, buffer)
: returns a flat<size.x * size.y>
element + array of 2D noise with values starting atpos={x=,y=}
- #
-get_3d_map_flat(pos, buffer)
: Same asget2dMap_flat
, but 3D noise- #
-calc_2d_map(pos)
: Calculates the 2d noise map starting atpos
. The result is stored internally.- #
-calc_3d_map(pos)
: Calculates the 3d noise map starting atpos
. The result is stored internally.- #
get_map_slice(slice_offset, slice_size, buffer)
: In the form of an array, returns a slice of the - most recently computed noise results. The result slice begins at coordinatesslice_offset
and - takes a chunk ofslice_size
. - E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer offset y = 20: +- #
+calc_2d_map(pos)
: Calculates the 2d noise map starting atpos
. The result + is stored internally.- #
+calc_3d_map(pos)
: Calculates the 3d noise map starting atpos
. The result + is stored internally.- #
get_map_slice(slice_offset, slice_size, buffer)
: In the form of an array, + returns a slice of the most recently computed noise results. The result slice + begins at coordinatesslice_offset
and takes a chunk ofslice_size
. + E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer + offset y = 20:noisevals = noise:get_map_slice({y=20}, {y=2})
- It is important to note thatslice_offset
offset coordinates begin at 1, and are relative to - the starting position of the most recently calculated noise. - To grab a single vertical column of noise starting at map coordinates x = 1023, y=1000, z = 1000: + It is important to note thatslice_offset
offset coordinates begin at 1, + and are relative to the starting position of the most recently calculated + noise. + To grab a single vertical column of noise starting at map coordinates + x = 1023, y=1000, z = 1000:noise:calc_3d_map({x=1000, y=1000, z=1000})
noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})
VoxelManip
About VoxelManip
-VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator' facility. The purpose of -this object is for fast, low-level, bulk access to reading and writing Map content. As such, setting -map nodes through VoxelManip will lack many of the higher level features and concepts you may be used -to with other methods of setting nodes. For example, nodes will not have their construction and -destruction callbacks run, and no rollback information is logged.
-It is important to note that VoxelManip is designed for speed, and not ease of use or flexibility. -If your mod requires a map manipulation facility that will handle 100% of all edge cases, or the use -of high level node placement features, perhaps
-minetest.set_node()
is better suited for the job.In addition, VoxelManip might not be faster, or could even be slower, for your specific use case. -VoxelManip is most effective when setting very large areas of map at once - for example, if only -setting a 5x5x5 node area, a
+minetest.set_node()
loop may be more optimal. Always profile code -using both methods of map manipulation to determine which is most appropriate for your usage.VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator' +facility. The purpose of this object is for fast, low-level, bulk access to +reading and writing Map content. As such, setting map nodes through VoxelManip +will lack many of the higher level features and concepts you may be used to +with other methods of setting nodes. For example, nodes will not have their +construction and destruction callbacks run, and no rollback information is +logged.
+It is important to note that VoxelManip is designed for speed, and not ease +of use or flexibility. If your mod requires a map manipulation facility that +will handle 100% of all edge cases, or the use of high level node placement +features, perhaps
+minetest.set_node()
is better suited for the job.In addition, VoxelManip might not be faster, or could even be slower, for your +specific use case. VoxelManip is most effective when setting large areas of map +at once - for example, if only setting a 3x3x3 node area, a +
+minetest.set_node()
loop may be more optimal. Always profile code using both +methods of map manipulation to determine which is most appropriate for your +usage.A recent simple test of setting cubic areas showed that
minetest.set_node()
+is faster than a VoxelManip for a 3x3x3 node cube or smaller.Using VoxelManip
A VoxelManip object can be created any time using either:
-VoxelManip([p1, p2])
, orminetest.get_voxel_manip([p1, p2])
.If the optional position parameters are present for either of these routines, the specified region -will be pre-loaded into the VoxelManip object on creation. Otherwise, the area of map you wish to -manipulate must first be loaded into the VoxelManip object using
-VoxelManip:read_from_map()
.Note that
-VoxelManip:read_from_map()
returns two position vectors. The region formed by these -positions indicate the minimum and maximum (respectively) positions of the area actually loaded in -the VoxelManip, which may be larger than the area requested. For convenience, the loaded area -coordinates can also be queried any time after loading map data withVoxelManip:get_emerged_area()
.Now that the VoxelManip object is populated with map data, your mod can fetch a copy of this data -using either of two methods.
-VoxelManip:get_node_at()
, which retrieves an individual node in a -MapNode formatted table at the position requested is the simplest method to use, but also the slowest.Nodes in a VoxelManip object may also be read in bulk to a flat array table using: -
+VoxelManip:get_data()
for node content (in Content ID form, see section 'Content IDs'), -VoxelManip:get_light_data()
for node light levels, and -VoxelManip:get_param2_data()
for the node type-dependent "param2" values.If the optional position parameters are present for either of these routines, +the specified region will be pre-loaded into the VoxelManip object on creation. +Otherwise, the area of map you wish to manipulate must first be loaded into the +VoxelManip object using
+VoxelManip:read_from_map()
.Note that
+VoxelManip:read_from_map()
returns two position vectors. The region +formed by these positions indicate the minimum and maximum (respectively) +positions of the area actually loaded in the VoxelManip, which may be larger +than the area requested. For convenience, the loaded area coordinates can also +be queried any time after loading map data withVoxelManip:get_emerged_area()
.Now that the VoxelManip object is populated with map data, your mod can fetch a +copy of this data using either of two methods.
+VoxelManip:get_node_at()
, +which retrieves an individual node in a MapNode formatted table at the position +requested is the simplest method to use, but also the slowest.Nodes in a VoxelManip object may also be read in bulk to a flat array table +using:
++
- #
+VoxelManip:get_data()
for node content (in Content ID form, see section + 'Content IDs'),- #
+VoxelManip:get_light_data()
for node light levels, and- #
+VoxelManip:get_param2_data()
for the node type-dependent "param2" values.See section 'Flat array format' for more details.
-It is very important to understand that the tables returned by any of the above three functions -represent a snapshot of the VoxelManip's internal state at the time of the call. This copy of the -data will not magically update itself if another function modifies the internal VoxelManip state. -Any functions that modify a VoxelManip's contents work on the VoxelManip's internal state unless -otherwise explicitly stated.
-Once the bulk data has been edited to your liking, the internal VoxelManip state can be set using: -
-VoxelManip:set_data()
for node content (in Content ID form, see section 'Content IDs'), -VoxelManip:set_light_data()
for node light levels, and -VoxelManip:set_param2_data()
for the node type-dependentparam2
values.The parameter to each of the above three functions can use any table at all in the same flat array -format as produced by
-get_data()
et al. and is not required to be a table retrieved fromget_data()
.Once the internal VoxelManip state has been modified to your liking, the changes can be committed back -to the map by calling
+VoxelManip:write_to_map()
.It is very important to understand that the tables returned by any of the above +three functions represent a snapshot of the VoxelManip's internal state at the +time of the call. This copy of the data will not magically update itself if +another function modifies the internal VoxelManip state. +Any functions that modify a VoxelManip's contents work on the VoxelManip's +internal state unless otherwise explicitly stated.
+Once the bulk data has been edited to your liking, the internal VoxelManip +state can be set using:
++
+- #
+VoxelManip:set_data()
for node content (in Content ID form, see section + 'Content IDs'),- #
+VoxelManip:set_light_data()
for node light levels, and- #
+VoxelManip:set_param2_data()
for the node type-dependentparam2
values.The parameter to each of the above three functions can use any table at all in +the same flat array format as produced by
+get_data()
etc. and is not required +to be a table retrieved fromget_data()
.Once the internal VoxelManip state has been modified to your liking, the +changes can be committed back to the map by calling
VoxelManip:write_to_map()
Flat array format
Let
-Nx = p2.X - p1.X + 1
,Ny = p2.Y - p1.Y + 1
, andNz = p2.Z - p1.Z + 1
.Then, for a loaded region of p1..p2, this array ranges from
+1
up to and including the value of -the expressionNx * Ny * Nz
.Then, for a loaded region of p1..p2, this array ranges from
1
up to and +including the value of the expressionNx * Ny * Nz
.Positions offset from p1 are present in the array with the format of:
]
[ (0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0), @@ -4869,74 +5471,92 @@ the expression
Nx * Ny * Nz
.and the array index for a position p contained completely in p1..p2 is:
-
(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1
Note that this is the same "flat 3D array" format as
+PerlinNoiseMap:get3dMap_flat()
. -VoxelArea objects (see section 'VoxelArea') can be used to simplify calculation of the index -for a single point in a flat VoxelManip array.Note that this is the same "flat 3D array" format as +
PerlinNoiseMap:get3dMap_flat()
. +VoxelArea objects (see section 'VoxelArea') can be used to simplify calculation +of the index for a single point in a flat VoxelManip array.Content IDs
-A Content ID is a unique integer identifier for a specific node type. These IDs are used by VoxelManip -in place of the node name string for
VoxelManip:get_data()
andVoxelManip:set_data()
. You can use -minetest.get_content_id()
to look up the Content ID for the specified node name, and -minetest.get_name_from_content_id()
to look up the node name string for a given Content ID. -After registration of a node, its Content ID will remain the same throughout execution of the mod. +A Content ID is a unique integer identifier for a specific node type. +These IDs are used by VoxelManip in place of the node name string for +
VoxelManip:get_data()
andVoxelManip:set_data()
. You can use +minetest.get_content_id()
to look up the Content ID for the specified node +name, andminetest.get_name_from_content_id()
to look up the node name string +for a given Content ID. +After registration of a node, its Content ID will remain the same throughout +execution of the mod. Note that the node being queried needs to have already been been registered.The following builtin node types have their Content IDs defined as constants:
minetest.CONTENT_UNKNOWN
: ID for "unknown" nodesminetest.CONTENT_AIR
: ID for "air" nodesminetest.CONTENT_IGNORE
: ID for "ignore" nodesminetest.CONTENT_UNKNOWN
: ID for "unknown" nodesminetest.CONTENT_AIR
: ID for "air" nodesminetest.CONTENT_IGNORE
: ID for "ignore" nodesInside of on_generated()
callbacks, it is possible to retrieve the same VoxelManip object used by the
-core's Map Generator (commonly abbreviated Mapgen). Most of the rules previously described still apply
-but with a few differences:
Inside of on_generated()
callbacks, it is possible to retrieve the same
+VoxelManip object used by the core's Map Generator (commonly abbreviated
+Mapgen). Most of the rules previously described still apply but with a few
+differences:
minetest.get_mapgen_object("voxelmanip")
VoxelManip:read_from_map()
before using a Mapgen VoxelManip.on_generated()
callbacks of some mods may place individual nodes in the generated area using
- non-VoxelManip map modification methods. Because the same Mapgen VoxelManip object is passed through
- each on_generated()
callback, it becomes necessary for the Mapgen VoxelManip object to maintain
- consistency with the current map state. For this reason, calling any of the following functions:
+minetest.get_mapgen_object("voxelmanip")
VoxelManip:read_from_map()
before using
+ a Mapgen VoxelManip.on_generated()
callbacks of some mods may place individual nodes in the
+ generated area using non-VoxelManip map modification methods. Because the
+ same Mapgen VoxelManip object is passed through each on_generated()
+ callback, it becomes necessary for the Mapgen VoxelManip object to maintain
+ consistency with the current map state. For this reason, calling any of the
+ following functions:
minetest.add_node()
, minetest.set_node()
, or minetest.swap_node()
- will also update the Mapgen VoxelManip object's internal state active on the current thread.VoxelManip:calc_lighting()
or VoxelManip:set_lighting()
.VoxelManip:calc_lighting()
or VoxelManip:set_lighting()
.If any VoxelManip contents were set to a liquid node, VoxelManip:update_liquids()
must be called
-for these liquid nodes to begin flowing. It is recommended to call this function only after having
-written all buffered data back to the VoxelManip object, save for special situations where the modder
-desires to only have certain liquid nodes begin flowing.
The functions minetest.generate_ores()
and minetest.generate_decorations()
will generate all
-registered decorations and ores throughout the full area inside of the specified VoxelManip object.
minetest.place_schematic_on_vmanip()
is otherwise identical to minetest.place_schematic()
,
-except instead of placing the specified schematic directly on the map at the specified position, it
-will place the schematic inside of the VoxelManip.
If any VoxelManip contents were set to a liquid node,
+VoxelManip:update_liquids()
must be called for these liquid nodes to begin
+flowing. It is recommended to call this function only after having written all
+buffered data back to the VoxelManip object, save for special situations where
+the modder desires to only have certain liquid nodes begin flowing.
The functions minetest.generate_ores()
and minetest.generate_decorations()
+will generate all registered decorations and ores throughout the full area
+inside of the specified VoxelManip object.
minetest.place_schematic_on_vmanip()
is otherwise identical to
+minetest.place_schematic()
, except instead of placing the specified schematic
+directly on the map at the specified position, it will place the schematic
+inside the VoxelManip.
VoxelManip:get_data()
, and an "ignore" node at any position for
- VoxelManip:get_node_at()
.on_generated()
callback, consider passing
- a file-scoped table as the optional parameter to VoxelManip:get_data()
, which serves as a static
- buffer the function can use to write map data to instead of returning a new table each call. This
- greatly enhances performance by avoiding unnecessary memory allocations.VoxelManip:get_data()
, and an
+ "ignore" node at any position for VoxelManip:get_node_at()
.on_generated()
+ callback, consider passing a file-scoped table as the optional parameter to
+ VoxelManip:get_data()
, which serves as a static buffer the function can use
+ to write map data to instead of returning a new table each call. This greatly
+ enhances performance by avoiding unnecessary memory allocations.read_from_map(p1, p2)
: Loads a chunk of map into the VoxelManip object containing
- the region formed by p1
and p2
.read_from_map(p1, p2)
: Loads a chunk of map into the VoxelManip object
+ containing the region formed by p1
and p2
.pmin
, actual emerged pmax
write_to_map([light])
: Writes the data loaded from the VoxelManip
back to the map.VoxelManip:set_data()
before calling thiswrite_to_map([light])
: Writes the data loaded from the VoxelManip
back to
+ the map.VoxelManip:set_data()
before
+ calling this.light
is true, then lighting is automatically recalculated.
The default value is true.
If light
is false, no light calculations happen, and you should correct
@@ -4947,50 +5567,64 @@ will place the schematic inside of the VoxelManip.
get_node_at(pos)
: Returns a MapNode
table of the node currently loaded in
the VoxelManip
at that positionset_node_at(pos, node)
: Sets a specific MapNode
in the VoxelManip
at that positionget_data([buffer])
: Retrieves the node content data loaded into the VoxelManip
objectset_node_at(pos, node)
: Sets a specific MapNode
in the VoxelManip
at
+ that position.get_data([buffer])
: Retrieves the node content data loaded into the
+ VoxelManip
object.
set_data(data)
: Sets the data contents of the VoxelManip
objectupdate_map()
: Does nothing, kept for compatibility.set_lighting(light, [p1, p2])
: Set the lighting within the VoxelManip
to a uniform valueset_lighting(light, [p1, p2])
: Set the lighting within the VoxelManip
to
+ a uniform value.light
is a table, {day=<0...15>, night=<0...15>}
VoxelManip
object from minetest.get_mapgen_object
p1
, p2
) is the area in which lighting is set;
- defaults to the whole area if left outVoxelManip
object from
+ minetest.get_mapgen_object
.p1
, p2
) is the area in which lighting is set, defaults to the whole
+ area if left out.get_light_data()
: Gets the light data read into the VoxelManip
object0
to 255
0
to 15
each)0
to
+ 255
.0
to 15
each).light = day + (night * 16)
set_light_data(light_data)
: Sets the param1
(light) contents of each node
- in the VoxelManip
VoxelManip
.get_light_data()
returnsget_param2_data([buffer])
: Gets the raw param2
data read into the VoxelManip
object0
to 255
buffer
is present, this table will be used to store the result insteadget_param2_data([buffer])
: Gets the raw param2
data read into the
+ VoxelManip
object.
set_param2_data(param2_data)
: Sets the param2
contents of each node in the VoxelManip
calc_lighting([p1, p2], [propagate_shadow])
: Calculate lighting within the VoxelManip
VoxelManip
object from minetest.get_mapgen_object
p1
, p2
) is the area in which lighting is set; defaults to the whole area
- if left out or nilpropagate_shadow
is an optional boolean deciding whether shadows in a generated
- mapchunk above are propagated down into the mapchunk; defaults to true
if left outset_param2_data(param2_data)
: Sets the param2
contents of each node in
+ the VoxelManip
.calc_lighting([p1, p2], [propagate_shadow])
: Calculate lighting within the
+ VoxelManip
.VoxelManip
object from
+ minetest.get_mapgen_object
.p1
, p2
) is the area in which lighting is set, defaults to the whole
+ area if left out or nil.propagate_shadow
is an optional boolean deciding whether shadows in a
+ generated mapchunk above are propagated down into the mapchunk, defaults
+ to true
if left out.update_liquids()
: Update liquid flowwas_modified()
: Returns true
or false
if the data in the voxel manipulator
- had been modified since the last read from map, due to a call to
- minetest.set_data()
on the loaded area elsewherewas_modified()
: Returns true
or false
if the data in the voxel
+ manipulator had been modified since the last read from map, due to a call to
+ minetest.set_data()
on the loaded area elsewhere.get_emerged_area()
: Returns actual emerged minimum and maximum positions.VoxelArea
getExtent()
: returns a 3D vector containing the size of the area formed by
- MinEdge
and MaxEdge
getVolume()
: returns the volume of the area formed by MinEdge
and MaxEdge
index(x, y, z)
: returns the index of an absolute position in a flat array starting at 1
MinEdge
and MaxEdge
.getVolume()
: returns the volume of the area formed by MinEdge
and
+ MaxEdge
.index(x, y, z)
: returns the index of an absolute position in a flat array
+ starting at 1
.VoxelManip
, raw Schematic specifiers,
- PerlinNoiseMap:get2d
/3dMap
, and so onPerlinNoiseMap:get2d
/3dMap
, and so on.indexp(p)
: same as above, except takes a vectorposition(i)
: returns the absolute position vector corresponding to index i
contains(x, y, z)
: check if (x
,y
,z
) is inside area formed by MinEdge
and MaxEdge
position(i)
: returns the absolute position vector corresponding to index
+ i
.contains(x, y, z)
: check if (x
,y
,z
) is inside area formed by
+ MinEdge
and MaxEdge
.containsp(p)
: same as above, except takes a vectorcontainsi(i)
: same as above, except takes an index i
iter(minx, miny, minz, maxx, maxy, maxz)
: returns an iterator that returns indicesminx
,miny
,minz
) to (maxx
,maxy
,maxz
) in the order of [z [y [x]]]
iter(minx, miny, minz, maxx, maxy, maxz)
: returns an iterator that returns
+ indices.minx
,miny
,minz
) to (maxx
,maxy
,maxz
) in the order of
+ [z [y [x]]]
.iterp(minp, maxp)
: same as above, except takes a vectorget(key)
: returns a valueget_bool(key, [default])
: returns a boolean
get_np_group(key)
: returns a NoiseParams tableset(key, value)
="{}#
.\n"""
.minetest.settings
).\n"""
.minetest.settings
).set_bool(key, value)
It can be created via Raycast(pos1, pos2, objects, liquids)
or
minetest.raycast(pos1, pos2, objects, liquids)
where:
- * pos1
: start of the ray
- * pos2
: end of the ray
- * objects
: if false, only nodes will be returned. Default is true.
- * `liquids' : if false, liquid nodes won't be returned. Default is false.
pos1
: start of the ray
+ pos2
: end of the ray
+ objects
: if false, only nodes will be returned. Default is true.
+ `liquids' : if false, liquid nodes won't be returned. Default is false.
next()
: returns a pointed_thing
A mapgen object is a construct used in map generation. Mapgen objects can be used
-by an on_generate
callback to speed up operations by avoiding unnecessary
-recalculations; these can be retrieved using the minetest.get_mapgen_object()
-function. If the requested Mapgen object is unavailable, or get_mapgen_object()
-was called outside of an on_generate()
callback, nil
is returned.
A mapgen object is a construct used in map generation. Mapgen objects can be
+used by an on_generate
callback to speed up operations by avoiding
+unnecessary recalculations, these can be retrieved using the
+minetest.get_mapgen_object()
function. If the requested Mapgen object is
+unavailable, or get_mapgen_object()
was called outside of an on_generate()
+callback, nil
is returned.
The following Mapgen objects are currently available:
voxelmanip
This returns three values; the VoxelManip
object to be used, minimum and maximum
-emerged position, in that order. All mapgens support this object.
This returns three values; the VoxelManip
object to be used, minimum and
+maximum emerged position, in that order. All mapgens support this object.
heightmap
Returns an array containing the y coordinates of the ground levels of nodes in the most recently generated chunk by the current mapgen.
@@ -5097,9 +5739,12 @@ recently generated chunk by the current mapgen. generated chunk by the current mapgen.gennotify
Returns a table mapping requested generation notification types to arrays of
-positions at which the corresponding generated structures are located at within
+positions at which the corresponding generated structures are located within
the current chunk. To set the capture of positions of interest to be recorded
-on generate, use minetest.set_gen_notify()
.
minetest.set_gen_notify()
.
+For decorations, the returned positions are the ground surface 'place_on'
+nodes, not the decorations themselves. A 'simple' type decoration is often 1
+node above the returned position and possibly displaced by 'place_offset_y'.
Possible fields of the table returned are:
dungeon
self
:.name
, which is the registered name ("mod:thing")
.object
, which is an ObjectRef
pointing to the object.name
, which is the registered name ("mod:thing")
.object
, which is an ObjectRef
pointing to the
+ object.on_step(self, dtime)
dtime
is usually 0.1 seconds, as per the dedicated_server_step
setting
- in minetest.conf
.dtime
is usually 0.1 seconds, as per the dedicated_server_step
+ setting in minetest.conf
.on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
puncher
: an ObjectRef
(can be nil
)time_from_last_punch
: Meant for disallowing spamming of clicks (can be nil
)time_from_last_punch
: Meant for disallowing spamming of clicks
+ (can be nil
).tool_capabilities
: capability table of used tool (can be nil
)dir
: unit vector of direction of punch. Always defined. Points from
- the puncher to the punched.on_death(self, killer)
Warning -L-system generation currently creates lighting bugs in the form of mapblock-sized shadows. -Often these bugs appear as subtle shadows in water.
treedef={
axiom, --string initial tree axiom
@@ -5181,7 +5825,8 @@ Often these bugs appear as subtle shadows in water.
thin_branches, --boolean true -> use thin (1 node) branches
fruit, --string fruit node name
fruit_chance, --num chance (0-100) to replace leaves with fruit node
- seed, --num random seed; if no seed is provided, the engine will create one
+ seed, --num random seed, if no seed is provided, the engine
+ will create one.
}
register_abm
)register_lbm
)glasslike_framed_optional
.
- Note: supported by solid nodes and nodeboxes only.glasslike_framed_optional
.
+ Note: supported by solid nodes and nodeboxes only.scale
) nodes,
- instead of just one, in each direction. Works for world-aligned
- textures only.
- Note that as the effect is applied on per-mapblock basis, 16
should
- be equally divisible by scale
or you may get wrong results.16
should
+ be equally divisible by scale
or you may get wrong results.{name="image.png", color=ColorSpec}
Note that in params, use of symbols is as follows:
+<>
signifies a placeholder to be replaced when the command is used. For
+ example, when a player name is needed: <name>
[]
signifies param is optional and not required when the command is used.
+ For example, if you require param1 but param2 is optional:
+ <param1> [<param2>]
|
signifies exclusive or. The command requires one param from the options
+ provided. For example: <param1> | <param2>
()
signifies grouping. For example, when param1 and param2 are both
+ required, or only param3 is required: (<param1> <param2>) | <param3>
{
allow_move = func(inv, from_list, from_index, to_list, to_index, count, player),
@@ -6035,18 +6790,20 @@ preserve_metadata = func(pos, oldnode, oldmeta, drops) --[[
on_move = func(inv, from_list, from_index, to_list, to_index, count, player),
on_put = func(inv, listname, index, stack, player),
on_take = func(inv, listname, index, stack, player),
--- ^ Called after the actual action has happened, according to what was allowed.
+-- ^ Called after the actual action has happened, according to what was
+-- ^ allowed.
-- ^ No return value
}
hud_add
, hud_get
){
hud_elem_type = "image", -- see HUD element types
--- ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
+-- ^ type of HUD element, can be either of "image", "text", "statbar",
+ "inventory".
position = {x=0.5, y=0.5},
-- ^ Left corner position of element
name = "<name>",
- scale = {x=2, y=2},
+ scale = {x = 2, y = 2},
text = "<text>",
number = 2,
item = 3,
@@ -6091,7 +6848,8 @@ preserve_metadata = func(pos, oldnode, oldmeta, drops) --[[
{
amount = 1,
time = 1,
--- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
+-- ^ If time is 0 has infinite lifespan and spawns the amount on a
+-- ^ per-second basis.
minpos = {x=0, y=0, z=0},
maxpos = {x=0, y=0, z=0},
minvel = {x=0, y=0, z=0},
@@ -6103,78 +6861,94 @@ preserve_metadata = func(pos, oldnode, oldmeta, drops) --[[
minsize = 1,
maxsize = 1,
-- ^ The particle's properties are random values in between the bounds:
--- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
--- ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
+-- ^ minpos/maxpos, minvel/maxvel (velocity),
+-- ^ minacc/maxacc (acceleration), minsize/maxsize,
+-- ^ minexptime/maxexptime (expirationtime).
collisiondetection = false,
-- ^ collisiondetection: if true uses collision detection
collision_removal = false,
-- ^ collision_removal: if true then particle is removed when it collides,
-- ^ requires collisiondetection = true to have any effect
attached = ObjectRef,
--- ^ attached: if defined, particle positions, velocities and accelerations
--- ^ are relative to this object's position and yaw.
+-- ^ attached: if defined, particle positions, velocities and
+-- ^ accelerations are relative to this object's position and yaw.
vertical = false,
-- ^ vertical: if true faces player using y axis only
texture = "image.png",
-- ^ Uses texture (string)
playername = "singleplayer"
--- ^ Playername is optional, if specified spawns particle only on the player's client
+-- ^ Playername is optional, if specified spawns particle only on the
+-- ^ player's client.
+ animation = {Tile Animation definition},
+-- ^ optional, specifies how to animate the particle texture
+ glow = 0
+-- ^ optional, specify particle self-luminescence in darkness
}
HTTPRequest
definition (HTTPApiTable.fetch_async
, HTTPApiTable.fetch_async
)
{
url = "http://example.org",
timeout = 10,
- -- ^ Timeout for connection in seconds. Default is 3 seconds.
- post_data = "Raw POST request data string" OR { field1 = "data1", field2 = "data2" },
- -- ^ Optional, if specified a POST request with post_data is performed.
- -- ^ Accepts both a string and a table. If a table is specified, encodes table
- -- ^ as x-www-form-urlencoded key-value pairs.
- -- ^ If post_data ist not specified, a GET request is performed instead.
+-- ^ Timeout for connection in seconds. Default is 3 seconds.
+ post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
+-- ^ Optional, if specified a POST request with post_data is performed.
+-- ^ Accepts both a string and a table. If a table is specified, encodes
+-- ^ table as x-www-form-urlencoded key-value pairs.
+-- ^ If post_data ist not specified, a GET request is performed instead.
user_agent = "ExampleUserAgent",
- -- ^ Optional, if specified replaces the default minetest user agent with given string
+-- ^ Optional, if specified replaces the default minetest user agent with
+-- ^ given string.
extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
- -- ^ Optional, if specified adds additional headers to the HTTP request. You must make sure
- -- ^ that the header strings follow HTTP specification ("Key: Value").
+-- ^ Optional, if specified adds additional headers to the HTTP request.
+-- ^ You must make sure that the header strings follow HTTP specification
+-- ^ ("Key: Value").
multipart = boolean
- -- ^ Optional, if true performs a multipart HTTP request. Default is false.
+-- ^ Optional, if true performs a multipart HTTP request.
+-- ^ Default is false.
}
HTTPRequestResult
definition (HTTPApiTable.fetch
callback, HTTPApiTable.fetch_async_get
)
{
completed = true,
- -- ^ If true, the request has finished (either succeeded, failed or timed out)
+-- ^ If true, the request has finished (either succeeded, failed or timed
+ out).
succeeded = true,
- -- ^ If true, the request was successful
+-- ^ If true, the request was successful
timeout = false,
- -- ^ If true, the request timed out
+-- ^ If true, the request timed out
code = 200,
- -- ^ HTTP status code
+-- ^ HTTP status code
data = "response"
}
Authentication handler definition
{
get_auth = func(name),
--- ^ Get authentication data for existing player `name` (`nil` if player doesn't exist)
--- ^ returns following structure `{password=<string>, privileges=<table>, last_login=<number or nil>}`
+-- ^ Get authentication data for existing player `name` (`nil` if player
+ doesn't exist).
+-- ^ returns following structure:
+-- ^ `{password=<string>, privileges=<table>, last_login=<number or nil>}`
create_auth = func(name, password),
-- ^ Create new auth data for player `name`
--- ^ Note that `password` is not plain-text but an arbitrary representation decided by the engine
+-- ^ Note that `password` is not plain-text but an arbitrary
+-- ^ representation decided by the engine
delete_auth = func(name),
--- ^ Delete auth data of player `name`, returns boolean indicating success (false if player nonexistant)
+-- ^ Delete auth data of player `name`, returns boolean indicating success
+-- ^ (false if player nonexistant).
set_password = func(name, password),
-- ^ Set password of player `name` to `password`
Auth data should be created if not present
set_privileges = func(name, privileges),
-- ^ Set privileges of player `name`
--- ^ `privileges` is in table form, auth data should be created if not present
+-- ^ `privileges` is in table form, auth data should be created if not
+-- ^ present.
reload = func(),
-- ^ Reload authentication data from the storage location
-- ^ Returns boolean indicating success
record_login = func(name),
-- ^ Called when player joins, used for keeping track of last_login
iterate = func(),
--- ^ Returns an iterator (use with `for` loops) for all player names currently in the auth database
+-- ^ Returns an iterator (use with `for` loops) for all player names
+-- ^ currently in the auth database.
}
\ No newline at end of file