1 Minetest Lua Modding API Reference
2 ==================================
4 * More information at <http://www.minetest.net/>
5 * Developer Wiki: <http://dev.minetest.net/>
6 * (Unofficial) Minetest Modding Book by rubenwardy: <https://rubenwardy.com/minetest_modding_book/>
11 Content and functionality can be added to Minetest using Lua scripting
12 in run-time loaded mods.
14 A mod is a self-contained bunch of scripts, textures and other related
15 things, which is loaded by and interfaces with Minetest.
17 Mods are contained and ran solely on the server side. Definitions and media
18 files are automatically transferred to the client.
20 If you see a deficiency in the API, feel free to attempt to add the
21 functionality in the engine and API, and to document it here.
26 If you have any difficulty in understanding this, please read
27 [Programming in Lua](http://www.lua.org/pil/).
32 Mods are loaded during server startup from the mod load paths by running
33 the `init.lua` scripts in a shared environment.
38 Minetest keeps and looks for files mostly in two paths. `path_share` or `path_user`.
40 `path_share` contains possibly read-only content for the engine (incl. games and mods).
41 `path_user` contains mods or games installed by the user but also the users
44 With a local build (`RUN_IN_PLACE=1`) `path_share` and `path_user` both point to
45 the build directory. For system-wide builds on Linux the share path is usually at
46 `/usr/share/minetest` while the user path resides in `.minetest` in the home directory.
47 Paths on other operating systems will differ.
52 Games are looked up from:
54 * `$path_share/games/<gameid>/`
55 * `$path_user/games/<gameid>/`
57 Where `<gameid>` is unique to each game.
59 The game directory can contain the following files:
61 * `game.conf`, with the following keys:
62 * `title`: Required, a human-readable title to address the game, e.g. `title = Minetest Game`.
63 * `name`: (Deprecated) same as title.
64 * `description`: Short description to be shown in the content tab
65 * `allowed_mapgens = <comma-separated mapgens>`
66 e.g. `allowed_mapgens = v5,v6,flat`
67 Mapgens not in this list are removed from the list of mapgens for the
69 If not specified, all mapgens are allowed.
70 * `disallowed_mapgens = <comma-separated mapgens>`
71 e.g. `disallowed_mapgens = v5,v6,flat`
72 These mapgens are removed from the list of mapgens for the game.
73 When both `allowed_mapgens` and `disallowed_mapgens` are
74 specified, `allowed_mapgens` is applied before
76 * `disallowed_mapgen_settings= <comma-separated mapgen settings>`
77 e.g. `disallowed_mapgen_settings = mgv5_spflags`
78 These mapgen settings are hidden for this game in the world creation
79 dialog and game start menu. Add `seed` to hide the seed input field.
80 * `disabled_settings = <comma-separated settings>`
81 e.g. `disabled_settings = enable_damage, creative_mode`
82 These settings are hidden for this game in the "Start game" tab
83 and will be initialized as `false` when the game is started.
84 Prepend a setting name with an exclamation mark to initialize it to `true`
85 (this does not work for `enable_server`).
86 Only these settings are supported:
87 `enable_damage`, `creative_mode`, `enable_server`.
88 * `author`: The author of the game. It only appears when downloaded from
90 * `release`: Ignore this: Should only ever be set by ContentDB, as it is
91 an internal ID used to track versions.
93 Used to set default settings when running this game.
95 In the same format as the one in builtin.
96 This settingtypes.txt will be parsed by the menu and the settings will be
97 displayed in the "Games" category in the advanced settings tab.
98 * If the game contains a folder called `textures` the server will load it as a
99 texturepack, overriding mod textures.
100 Any server texturepack will override mod textures and the game texturepack.
105 Games can provide custom main menu images. They are put inside a `menu`
106 directory inside the game directory.
108 The images are named `$identifier.png`, where `$identifier` is one of
109 `overlay`, `background`, `footer`, `header`.
110 If you want to specify multiple images for one identifier, add additional
111 images named like `$identifier.$n.png`, with an ascending number $n starting
112 with 1, and a random image will be chosen from the provided ones.
117 Games can provide custom main menu music. They are put inside a `menu`
118 directory inside the game directory.
120 The music files are named `theme.ogg`.
121 If you want to specify multiple music files for one game, add additional
122 images named like `theme.$n.ogg`, with an ascending number $n starting
123 with 1 (max 10), and a random music file will be chosen from the provided ones.
131 Paths are relative to the directories listed in the [Paths] section above.
133 * `games/<gameid>/mods/`
135 * `worlds/<worldname>/worldmods/`
140 It is possible to include a game in a world; in this case, no mods or
141 games are loaded or checked from anywhere else.
143 This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
146 Mods should then be placed in `<worldname>/game/mods/`.
151 Mods can be put in a subdirectory, if the parent directory, which otherwise
152 should be a mod, contains a file named `modpack.conf`.
153 The file is a key-value store of modpack details.
155 * `name`: The modpack name. Allows Minetest to determine the modpack name even
156 if the folder is wrongly named.
157 * `description`: Description of mod to be shown in the Mods tab of the main
159 * `author`: The author of the modpack. It only appears when downloaded from
161 * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
162 internal ID used to track versions.
163 * `title`: A human-readable title to address the modpack.
165 Note: to support 0.4.x, please also create an empty modpack.txt file.
167 Mod directory structure
168 -----------------------
174 │ ├── settingtypes.txt
178 │ │ ├── modname_stuff.png
179 │ │ ├── modname_stuff_normal.png
180 │ │ ├── modname_something_else.png
181 │ │ ├── subfolder_foo
182 │ │ │ ├── modname_more_stuff.png
183 │ │ │ └── another_subfolder
184 │ │ └── bar_subfolder
193 The location of this directory can be fetched by using
194 `minetest.get_modpath(modname)`.
198 A `Settings` file that provides meta information about the mod.
200 * `name`: The mod name. Allows Minetest to determine the mod name even if the
201 folder is wrongly named.
202 * `description`: Description of mod to be shown in the Mods tab of the main
204 * `depends`: A comma separated list of dependencies. These are mods that must be
205 loaded before this mod.
206 * `optional_depends`: A comma separated list of optional dependencies.
207 Like a dependency, but no error if the mod doesn't exist.
208 * `author`: The author of the mod. It only appears when downloaded from
210 * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
211 internal ID used to track versions.
212 * `title`: A human-readable title to address the mod.
216 A screenshot shown in the mod manager within the main menu. It should
217 have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
221 **Deprecated:** you should use mod.conf instead.
223 This file is used if there are no dependencies in mod.conf.
225 List of mods that have to be loaded before loading this mod.
227 A single line contains a single modname.
229 Optional dependencies can be defined by appending a question mark
230 to a single modname. This means that if the specified mod
231 is missing, it does not prevent this mod from being loaded.
233 ### `description.txt`
235 **Deprecated:** you should use mod.conf instead.
237 This file is used if there is no description in mod.conf.
239 A file containing a description to be shown in the Mods tab of the main menu.
241 ### `settingtypes.txt`
243 The format is documented in `builtin/settingtypes.txt`.
244 It is parsed by the main menu settings dialogue to list mod-specific
245 settings in the "Mods" category.
249 The main Lua script. Running this script should register everything it
250 wants to register. Subsequent execution depends on minetest calling the
251 registered callbacks.
253 `minetest.settings` can be used to read custom or existing settings at load
254 time, if necessary. (See [`Settings`])
256 ### `textures`, `sounds`, `media`, `models`, `locale`
258 Media files (textures, sounds, whatever) that will be transferred to the
259 client and will be available for use by the mod and translation files for
260 the clients (see [Translations]).
262 It is suggested to use the folders for the purpose they are thought for,
263 eg. put textures into `textures`, translation files into `locale`,
264 models for entities or meshnodes into `models` et cetera.
266 These folders and subfolders can contain subfolders.
267 Subfolders with names starting with `_` or `.` are ignored.
268 If a subfolder contains a media file with the same name as a media file
269 in one of its parents, the parent's file is used.
271 Although it is discouraged, a mod can overwrite a media file of any mod that it
272 depends on by supplying a file with an equal name.
277 Registered names should generally be in this format:
281 `<whatever>` can have these characters:
285 This is to prevent conflicting names from corrupting maps and is
286 enforced by the mod loader.
288 Registered names can be overridden by prefixing the name with `:`. This can
289 be used for overriding the registrations of some other mod.
291 The `:` prefix can also be used for maintaining backwards compatibility.
295 In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
296 So the name should be `experimental:tnt`.
298 Any mod can redefine `experimental:tnt` by using the name
302 when registering it. For this to work correctly, that mod must have
303 `experimental` as a dependency.
311 Aliases of itemnames can be added by using
312 `minetest.register_alias(alias, original_name)` or
313 `minetest.register_alias_force(alias, original_name)`.
315 This adds an alias `alias` for the item called `original_name`.
316 From now on, you can use `alias` to refer to the item `original_name`.
318 The only difference between `minetest.register_alias` and
319 `minetest.register_alias_force` is that if an item named `alias` already exists,
320 `minetest.register_alias` will do nothing while
321 `minetest.register_alias_force` will unregister it.
323 This can be used for maintaining backwards compatibility.
325 This can also set quick access names for things, e.g. if
326 you have an item called `epiclylongmodname:stuff`, you could do
328 minetest.register_alias("stuff", "epiclylongmodname:stuff")
330 and be able to use `/giveme stuff`.
335 In a game, a certain number of these must be set to tell core mapgens which
336 of the game's nodes are to be used for core mapgen generation. For example:
338 minetest.register_alias("mapgen_stone", "default:stone")
340 ### Aliases for non-V6 mapgens
342 #### Essential aliases
345 * `mapgen_water_source`
346 * `mapgen_river_water_source`
348 `mapgen_river_water_source` is required for mapgens with sloping rivers where
349 it is necessary to have a river liquid node with a short `liquid_range` and
350 `liquid_renewable = false` to avoid flooding.
352 #### Optional aliases
354 * `mapgen_lava_source`
356 Fallback lava node used if cave liquids are not defined in biome definitions.
357 Deprecated, define cave liquids in biome definitions instead.
361 Fallback node used if dungeon nodes are not defined in biome definitions.
362 Deprecated, define dungeon nodes in biome definitions instead.
364 ### Aliases for Mapgen V6
369 * `mapgen_water_source`
370 * `mapgen_lava_source`
372 * `mapgen_dirt_with_grass`
383 * `mapgen_gravel` (falls back to stone)
384 * `mapgen_desert_stone` (falls back to stone)
385 * `mapgen_desert_sand` (falls back to sand)
386 * `mapgen_dirt_with_snow` (falls back to dirt_with_grass)
387 * `mapgen_snowblock` (falls back to dirt_with_grass)
388 * `mapgen_snow` (not placed if missing)
389 * `mapgen_ice` (falls back to water_source)
391 * `mapgen_jungletree` (falls back to tree)
392 * `mapgen_jungleleaves` (falls back to leaves)
393 * `mapgen_junglegrass` (not placed if missing)
394 * `mapgen_pine_tree` (falls back to tree)
395 * `mapgen_pine_needles` (falls back to leaves)
397 * `mapgen_stair_cobble` (falls back to cobble)
398 * `mapgen_mossycobble` (falls back to cobble)
399 * `mapgen_stair_desert_stone` (falls backto desert_stone)
401 ### Setting the node used in Mapgen Singlenode
403 By default the world is filled with air nodes. To set a different node use e.g.:
405 minetest.register_alias("mapgen_singlenode", "default:stone")
413 Mods should generally prefix their textures with `modname_`, e.g. given
414 the mod name `foomod`, a texture could be called:
418 Textures are referred to by their complete name, or alternatively by
419 stripping out the file extension:
421 * e.g. `foomod_foothing.png`
422 * e.g. `foomod_foothing`
424 Supported texture formats are PNG (`.png`), JPEG (`.jpg`), Bitmap (`.bmp`)
426 Since better alternatives exist, the latter two may be removed in the future.
431 There are various texture modifiers that can be used
432 to let the client generate textures on-the-fly.
433 The modifiers are applied directly in sRGB colorspace,
434 i.e. without gamma-correction.
436 ### Texture overlaying
438 Textures can be overlaid by putting a `^` between them.
442 default_dirt.png^default_grass_side.png
444 `default_grass_side.png` is overlaid over `default_dirt.png`.
445 The texture with the lower resolution will be automatically upscaled to
446 the higher resolution texture.
450 Textures can be grouped together by enclosing them in `(` and `)`.
452 Example: `cobble.png^(thing1.png^thing2.png)`
454 A texture for `thing1.png^thing2.png` is created and the resulting
455 texture is overlaid on top of `cobble.png`.
459 Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
460 passing complex texture names as arguments. Escaping is done with backslash and
461 is required for `^` and `:`.
463 Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
465 The lower 50 percent of `color.png^[mask:trans.png` are overlaid
466 on top of `cobble.png`.
468 ### Advanced texture modifiers
474 * `[crack:<t>:<n>:<p>`
475 * `[cracko:<t>:<n>:<p>`
479 * `<t>`: tile count (in each direction)
480 * `<n>`: animation frame count
481 * `<p>`: current animation frame
483 Draw a step of the crack animation on the texture.
484 `crack` draws it normally, while `cracko` lays it over, keeping transparent
489 default_cobble.png^[crack:10:1
491 #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
497 * `<file>`: texture to combine
499 Creates a texture of size `<w>` times `<h>` and blits the listed files to their
500 specified coordinates.
504 [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
506 #### `[resize:<w>x<h>`
508 Resizes the texture to the given dimensions.
512 default_sandstone.png^[resize:16x16
516 Makes the base image transparent according to the given ratio.
518 `r` must be between 0 (transparent) and 255 (opaque).
522 default_sandstone.png^[opacity:127
524 #### `[invert:<mode>`
526 Inverts the given channels of the base image.
527 Mode may contain the characters "r", "g", "b", "a".
528 Only the channels that are mentioned in the mode string will be inverted.
532 default_apple.png^[invert:rgb
536 Brightens the texture.
540 tnt_tnt_side.png^[brighten
544 Makes the texture completely opaque.
548 default_leaves.png^[noalpha
550 #### `[makealpha:<r>,<g>,<b>`
552 Convert one color to transparency.
556 default_cobble.png^[makealpha:128,128,128
560 * `<t>`: transformation(s) to apply
562 Rotates and/or flips the image.
564 `<t>` can be a number (between 0 and 7) or a transform name.
565 Rotations are counter-clockwise.
568 1 R90 rotate by 90 degrees
569 2 R180 rotate by 180 degrees
570 3 R270 rotate by 270 degrees
572 5 FXR90 flip X then rotate by 90 degrees
574 7 FYR90 flip Y then rotate by 90 degrees
578 default_stone.png^[transformFXR90
580 #### `[inventorycube{<top>{<left>{<right>`
582 Escaping does not apply here and `^` is replaced by `&` in texture names
585 Create an inventory cube texture using the side textures.
589 [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
591 Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
592 `dirt.png^grass_side.png` textures
594 #### `[lowpart:<percent>:<file>`
596 Blit the lower `<percent>`% part of `<file>` on the texture.
600 base.png^[lowpart:25:overlay.png
602 #### `[verticalframe:<t>:<n>`
604 * `<t>`: animation frame count
605 * `<n>`: current animation frame
607 Crops the texture to a frame of a vertical animation.
611 default_torch_animated.png^[verticalframe:16:8
615 Apply a mask to the base image.
617 The mask is applied using binary AND.
619 #### `[sheet:<w>x<h>:<x>,<y>`
621 Retrieves a tile at position x,y from the base image
622 which it assumes to be a tilesheet with dimensions w,h.
624 #### `[colorize:<color>:<ratio>`
626 Colorize the textures with the given color.
627 `<color>` is specified as a `ColorString`.
628 `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`". If
629 it is an int, then it specifies how far to interpolate between the
630 colors where 0 is only the texture color and 255 is only `<color>`. If
631 omitted, the alpha of `<color>` will be used as the ratio. If it is
632 the word "`alpha`", then each texture pixel will contain the RGB of
633 `<color>` and the alpha of `<color>` multiplied by the alpha of the
636 #### `[multiply:<color>`
638 Multiplies texture colors with the given color.
639 `<color>` is specified as a `ColorString`.
640 Result is more like what you'd expect if you put a color on top of another
641 color, meaning white surfaces get a lot of your new color while black parts
642 don't change very much.
646 Embed a base64 encoded PNG image in the texture string.
647 You can produce a valid string for this by calling
648 `minetest.encode_base64(minetest.encode_png(tex))`,
649 refer to the documentation of these functions for details.
650 You can use this to send disposable images such as captchas
651 to individual clients, or render things that would be too
652 expensive to compose with `[combine:`.
654 IMPORTANT: Avoid sending large images this way.
655 This is not a replacement for asset files, do not use it to do anything
656 that you could instead achieve by just using a file.
657 In particular consider `minetest.dynamic_add_media` and test whether
658 using other texture modifiers could result in a shorter string than
659 embedding a whole image, this may vary by use case.
664 The goal of hardware coloring is to simplify the creation of
665 colorful nodes. If your textures use the same pattern, and they only
666 differ in their color (like colored wool blocks), you can use hardware
667 coloring instead of creating and managing many texture files.
668 All of these methods use color multiplication (so a white-black texture
669 with red coloring will result in red-black color).
673 This method is useful if you wish to create nodes/items with
674 the same texture, in different colors, each in a new node/item definition.
678 When you register an item or node, set its `color` field (which accepts a
679 `ColorSpec`) to the desired color.
681 An `ItemStack`'s static color can be overwritten by the `color` metadata
682 field. If you set that field to a `ColorString`, that color will be used.
686 Each tile may have an individual static color, which overwrites every
687 other coloring method. To disable the coloring of a face,
688 set its color to white (because multiplying with white does nothing).
689 You can set the `color` property of the tiles in the node's definition
690 if the tile is in table format.
694 For nodes and items which can have many colors, a palette is more
695 suitable. A palette is a texture, which can contain up to 256 pixels.
696 Each pixel is one possible color for the node/item.
697 You can register one node/item, which can have up to 256 colors.
699 #### Palette indexing
701 When using palettes, you always provide a pixel index for the given
702 node or `ItemStack`. The palette is read from left to right and from
703 top to bottom. If the palette has less than 256 pixels, then it is
704 stretched to contain exactly 256 pixels (after arranging the pixels
705 to one line). The indexing starts from 0.
709 * 16x16 palette, index = 0: the top left corner
710 * 16x16 palette, index = 4: the fifth pixel in the first row
711 * 16x16 palette, index = 16: the pixel below the top left corner
712 * 16x16 palette, index = 255: the bottom right corner
713 * 2 (width) x 4 (height) palette, index = 31: the top left corner.
714 The palette has 8 pixels, so each pixel is stretched to 32 pixels,
715 to ensure the total 256 pixels.
716 * 2x4 palette, index = 32: the top right corner
717 * 2x4 palette, index = 63: the top right corner
718 * 2x4 palette, index = 64: the pixel below the top left corner
720 #### Using palettes with items
722 When registering an item, set the item definition's `palette` field to
723 a texture. You can also use texture modifiers.
725 The `ItemStack`'s color depends on the `palette_index` field of the
726 stack's metadata. `palette_index` is an integer, which specifies the
727 index of the pixel to use.
729 #### Linking palettes with nodes
731 When registering a node, set the item definition's `palette` field to
732 a texture. You can also use texture modifiers.
733 The node's color depends on its `param2`, so you also must set an
734 appropriate `paramtype2`:
736 * `paramtype2 = "color"` for nodes which use their full `param2` for
737 palette indexing. These nodes can have 256 different colors.
738 The palette should contain 256 pixels.
739 * `paramtype2 = "colorwallmounted"` for nodes which use the first
740 five bits (most significant) of `param2` for palette indexing.
741 The remaining three bits are describing rotation, as in `wallmounted`
742 paramtype2. Division by 8 yields the palette index (without stretching the
743 palette). These nodes can have 32 different colors, and the palette
744 should contain 32 pixels.
746 * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
747 pixel will be picked from the palette.
748 * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
749 pixel will be picked from the palette.
750 * `paramtype2 = "colorfacedir"` for nodes which use the first
751 three bits of `param2` for palette indexing. The remaining
752 five bits are describing rotation, as in `facedir` paramtype2.
753 Division by 32 yields the palette index (without stretching the
754 palette). These nodes can have 8 different colors, and the
755 palette should contain 8 pixels.
757 * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
758 first (= 0 + 1) pixel will be picked from the palette.
759 * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
760 second (= 1 + 1) pixel will be picked from the palette.
761 * `paramtype2 = "color4dir"` for nodes which use the first
762 six bits of `param2` for palette indexing. The remaining
763 two bits are describing rotation, as in `4dir` paramtype2.
764 Division by 4 yields the palette index (without stretching the
765 palette). These nodes can have 64 different colors, and the
766 palette should contain 64 pixels.
768 * `param2 = 17` is 4 * 4 + 1, so the rotation is 1 and the
769 fifth (= 4 + 1) pixel will be picked from the palette.
770 * `param2 = 35` is 8 * 4 + 3, so the rotation is 3 and the
771 ninth (= 8 + 1) pixel will be picked from the palette.
773 To colorize a node on the map, set its `param2` value (according
774 to the node's paramtype2).
776 ### Conversion between nodes in the inventory and on the map
778 Static coloring is the same for both cases, there is no need
781 If the `ItemStack`'s metadata contains the `color` field, it will be
782 lost on placement, because nodes on the map can only use palettes.
784 If the `ItemStack`'s metadata contains the `palette_index` field, it is
785 automatically transferred between node and item forms by the engine,
786 when a player digs or places a colored node.
787 You can disable this feature by setting the `drop` field of the node
788 to itself (without metadata).
789 To transfer the color to a special drop, you need a drop table.
793 minetest.register_node("mod:stone", {
794 description = "Stone",
795 tiles = {"default_stone.png"},
796 paramtype2 = "color",
797 palette = "palette.png",
800 -- assume that mod:cobblestone also has the same palette
801 {items = {"mod:cobblestone"}, inherit_color = true },
806 ### Colored items in craft recipes
808 Craft recipes only support item strings, but fortunately item strings
809 can also contain metadata. Example craft recipe registration:
811 minetest.register_craft({
812 output = minetest.itemstring_with_palette("wool:block", 3),
820 To set the `color` field, you can use `minetest.itemstring_with_color`.
822 Metadata field filtering in the `recipe` field are not supported yet,
823 so the craft output is independent of the color of the ingredients.
828 Sometimes hardware coloring is not enough, because it affects the
829 whole tile. Soft texture overlays were added to Minetest to allow
830 the dynamic coloring of only specific parts of the node's texture.
831 For example a grass block may have colored grass, while keeping the
834 These overlays are 'soft', because unlike texture modifiers, the layers
835 are not merged in the memory, but they are simply drawn on top of each
836 other. This allows different hardware coloring, but also means that
837 tiles with overlays are drawn slower. Using too much overlays might
840 For inventory and wield images you can specify overlays which
841 hardware coloring does not modify. You have to set `inventory_overlay`
842 and `wield_overlay` fields to an image name.
844 To define a node overlay, simply set the `overlay_tiles` field of the node
845 definition. These tiles are defined in the same way as plain tiles:
846 they can have a texture name, color etc.
847 To skip one face, set that overlay tile to an empty string.
849 Example (colored grass block):
851 minetest.register_node("default:dirt_with_grass", {
852 description = "Dirt with Grass",
853 -- Regular tiles, as usual
854 -- The dirt tile disables palette coloring
855 tiles = {{name = "default_grass.png"},
856 {name = "default_dirt.png", color = "white"}},
857 -- Overlay tiles: define them in the same style
858 -- The top and bottom tile does not have overlay
859 overlay_tiles = {"", "",
860 {name = "default_grass_side.png"}},
861 -- Global color, used in inventory
863 -- Palette in the world
864 paramtype2 = "color",
865 palette = "default_foilage.png",
874 Only Ogg Vorbis files are supported.
876 For positional playing of sounds, only single-channel (mono) files are
877 supported. Otherwise OpenAL will play them non-positionally.
879 Mods should generally prefix their sounds with `modname_`, e.g. given
880 the mod name "`foomod`", a sound could be called:
884 Sounds are referred to by their name with a dot, a single digit and the
885 file extension stripped out. When a sound is played, the actual sound file
886 is chosen randomly from the matching sounds.
888 When playing the sound `foomod_foosound`, the sound is chosen randomly
889 from the available ones of the following files:
891 * `foomod_foosound.ogg`
892 * `foomod_foosound.0.ogg`
893 * `foomod_foosound.1.ogg`
895 * `foomod_foosound.9.ogg`
897 Examples of sound parameter tables:
899 -- Play locationless on all clients
901 gain = 1.0, -- default
902 fade = 0.0, -- default, change to a value > 0 to fade the sound in
903 pitch = 1.0, -- default
905 -- Play locationless to one player
908 gain = 1.0, -- default
909 fade = 0.0, -- default, change to a value > 0 to fade the sound in
910 pitch = 1.0, -- default
912 -- Play locationless to one player, looped
915 gain = 1.0, -- default
918 -- Play at a location
920 pos = {x = 1, y = 2, z = 3},
921 gain = 1.0, -- default
922 max_hear_distance = 32, -- default, uses an euclidean metric
924 -- Play connected to an object, looped
926 object = <an ObjectRef>,
927 gain = 1.0, -- default
928 max_hear_distance = 32, -- default, uses an euclidean metric
931 -- Play at a location, heard by anyone *but* the given player
933 pos = {x = 32, y = 0, z = 100},
934 max_hear_distance = 40,
935 exclude_player = name,
938 Looped sounds must either be connected to an object or played locationless to
939 one player using `to_player = name`.
941 A positional sound will only be heard by players that are within
942 `max_hear_distance` of the sound position, at the start of the sound.
944 `exclude_player = name` can be applied to locationless, positional and object-
945 bound sounds to exclude a single player from hearing them.
950 Specifies a sound name, gain (=volume) and pitch.
951 This is either a string or a table.
953 In string form, you just specify the sound name or
954 the empty string for no sound.
956 Table form has the following fields:
959 * `gain`: Volume (`1.0` = 100%)
960 * `pitch`: Pitch (`1.0` = 100%)
962 `gain` and `pitch` are optional and default to `1.0`.
968 * `"default_place_node"`: Play e.g. `default_place_node.ogg`
969 * `{name = "default_place_node"}`: Same as above
970 * `{name = "default_place_node", gain = 0.5}`: 50% volume
971 * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
976 These sound files are played back by the engine if provided.
978 * `player_damage`: Played when the local player takes damage (gain = 0.5)
979 * `player_falling_damage`: Played when the local player takes
980 damage by falling (gain = 0.5)
981 * `player_jump`: Played when the local player jumps
982 * `default_dig_<groupname>`: Default node digging sound
983 (see node sound definition for details)
985 Registered definitions
986 ======================
988 Anything added using certain [Registration functions] gets added to one or more
989 of the global [Registered definition tables].
991 Note that in some cases you will stumble upon things that are not contained
992 in these tables (e.g. when a mod has been removed). Always check for
993 existence before trying to access the fields.
997 All nodes register with `minetest.register_node` get added to the table
998 `minetest.registered_nodes`.
1000 If you want to check the drawtype of a node, you could do it like this:
1002 local def = minetest.registered_nodes[nodename]
1003 local drawtype = def and def.drawtype
1011 Nodes are the bulk data of the world: cubes and other things that take the
1012 space of a cube. Huge amounts of them are handled efficiently, but they
1015 The definition of a node is stored and can be accessed by using
1017 minetest.registered_nodes[node.name]
1019 See [Registered definitions].
1021 Nodes are passed by value between Lua and the engine.
1022 They are represented by a table:
1024 {name="name", param1=num, param2=num}
1026 `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
1027 them for certain automated functions. If you don't use these functions, you can
1028 use them to store arbitrary values.
1033 The functions of `param1` and `param2` are determined by certain fields in the
1036 The function of `param1` is determined by `paramtype` in node definition.
1037 `param1` is reserved for the engine when `paramtype != "none"`.
1039 * `paramtype = "light"`
1040 * The value stores light with and without sun in its lower and upper 4 bits
1042 * Required by a light source node to enable spreading its light.
1043 * Required by the following drawtypes as they determine their visual
1044 brightness from their internal light value:
1054 * `paramtype = "none"`
1055 * `param1` will not be used by the engine and can be used to store
1058 The function of `param2` is determined by `paramtype2` in node definition.
1059 `param2` is reserved for the engine when `paramtype2 != "none"`.
1061 * `paramtype2 = "flowingliquid"`
1062 * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
1063 * The liquid level and a flag of the liquid are stored in `param2`
1064 * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
1065 see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
1066 to access/manipulate the content of this field
1067 * Bit 3: If set, liquid is flowing downwards (no graphical effect)
1068 * `paramtype2 = "wallmounted"`
1069 * Supported drawtypes: "torchlike", "signlike", "plantlike",
1070 "plantlike_rooted", "normal", "nodebox", "mesh"
1071 * The rotation of the node is stored in `param2`
1072 * Node is 'mounted'/facing towards one of 6 directions
1073 * You can make this value by using `minetest.dir_to_wallmounted()`
1074 * Values range 0 - 5
1075 * The value denotes at which direction the node is "mounted":
1076 0 = y+, 1 = y-, 2 = x+, 3 = x-, 4 = z+, 5 = z-
1077 * By default, on placement the param2 is automatically set to the
1078 appropriate rotation, depending on which side was pointed at
1079 * `paramtype2 = "facedir"`
1080 * Supported drawtypes: "normal", "nodebox", "mesh"
1081 * The rotation of the node is stored in `param2`.
1082 * Node is rotated around face and axis; 24 rotations in total.
1083 * Can be made by using `minetest.dir_to_facedir()`.
1084 * Chests and furnaces can be rotated that way, and also 'flipped'
1085 * Values range 0 - 23
1086 * facedir / 4 = axis direction:
1087 0 = y+, 1 = z+, 2 = z-, 3 = x+, 4 = x-, 5 = y-
1088 * The node is rotated 90 degrees around the X or Z axis so that its top face
1089 points in the desired direction. For the y- direction, it's rotated 180
1090 degrees around the Z axis.
1091 * facedir modulo 4 = left-handed rotation around the specified axis, in 90° steps.
1092 * By default, on placement the param2 is automatically set to the
1093 horizondal direction the player was looking at (values 0-3)
1094 * Special case: If the node is a connected nodebox, the nodebox
1095 will NOT rotate, only the textures will.
1096 * `paramtype2 = "4dir"`
1097 * Supported drawtypes: "normal", "nodebox", "mesh"
1098 * The rotation of the node is stored in `param2`.
1099 * Allows node to be rotated horizontally, 4 rotations in total
1100 * Can be made by using `minetest.dir_to_fourdir()`.
1101 * Chests and furnaces can be rotated that way, but not flipped
1102 * Values range 0 - 3
1103 * 4dir modulo 4 = rotation
1104 * Otherwise, behavior is identical to facedir
1105 * `paramtype2 = "leveled"`
1106 * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
1108 * The level of the top face of the nodebox is stored in `param2`.
1109 * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
1111 * The nodebox height is (`param2` / 64) nodes.
1112 * The maximum accepted value of `param2` is 127.
1114 * The height of the 'plantlike' section is stored in `param2`.
1115 * The height is (`param2` / 16) nodes.
1116 * `paramtype2 = "degrotate"`
1117 * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
1119 * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
1120 get the actual rotation in degrees of the node.
1121 * `paramtype2 = "meshoptions"`
1122 * Only valid for "plantlike" drawtype. `param2` encodes the shape and
1123 optional modifiers of the "plant". `param2` is a bitfield.
1124 * Bits 0 to 2 select the shape.
1125 Use only one of the values below:
1126 * 0 = a "x" shaped plant (ordinary plant)
1127 * 1 = a "+" shaped plant (just rotated 45 degrees)
1128 * 2 = a "*" shaped plant with 3 faces instead of 2
1129 * 3 = a "#" shaped plant with 4 faces instead of 2
1130 * 4 = a "#" shaped plant with 4 faces that lean outwards
1131 * 5-7 are unused and reserved for future meshes.
1132 * Bits 3 to 7 are used to enable any number of optional modifiers.
1133 Just add the corresponding value(s) below to `param2`:
1134 * 8 - Makes the plant slightly vary placement horizontally
1135 * 16 - Makes the plant mesh 1.4x larger
1136 * 32 - Moves each face randomly a small bit down (1/8 max)
1137 * values 64 and 128 (bits 6-7) are reserved for future use.
1138 * Example: `param2 = 0` selects a normal "x" shaped plant
1139 * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
1140 * `paramtype2 = "color"`
1141 * `param2` tells which color is picked from the palette.
1142 The palette should have 256 pixels.
1143 * `paramtype2 = "colorfacedir"`
1144 * Same as `facedir`, but with colors.
1145 * The first three bits of `param2` tells which color is picked from the
1146 palette. The palette should have 8 pixels.
1147 * `paramtype2 = "color4dir"`
1148 * Same as `facedir`, but with colors.
1149 * The first six bits of `param2` tells which color is picked from the
1150 palette. The palette should have 64 pixels.
1151 * `paramtype2 = "colorwallmounted"`
1152 * Same as `wallmounted`, but with colors.
1153 * The first five bits of `param2` tells which color is picked from the
1154 palette. The palette should have 32 pixels.
1155 * `paramtype2 = "glasslikeliquidlevel"`
1156 * Only valid for "glasslike_framed" or "glasslike_framed_optional"
1157 drawtypes. "glasslike_framed_optional" nodes are only affected if the
1158 "Connected Glass" setting is enabled.
1159 * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
1161 * Bits 6 and 7 modify the appearance of the frame and node faces. One or
1162 both of these values may be added to `param2`:
1163 * 64 - Makes the node not connect with neighbors above or below it.
1164 * 128 - Makes the node not connect with neighbors to its sides.
1165 * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
1166 * `paramtype2 = "colordegrotate"`
1167 * Same as `degrotate`, but with colors.
1168 * The first (most-significant) three bits of `param2` tells which color
1169 is picked from the palette. The palette should have 8 pixels.
1170 * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
1171 * `paramtype2 = "none"`
1172 * `param2` will not be used by the engine and can be used to store
1175 Nodes can also contain extra data. See [Node Metadata].
1180 There are a bunch of different looking node types.
1182 Look for examples in `games/devtest` or `games/minetest_game`.
1185 * A node-sized cube.
1187 * Invisible, uses no texture.
1189 * The cubic source node for a liquid.
1190 * Faces bordering to the same node are never rendered.
1191 * Connects to node specified in `liquid_alternative_flowing`.
1192 * Use `backface_culling = false` for the tiles you want to make
1193 visible when inside the node.
1195 * The flowing version of a liquid, appears with various heights and slopes.
1196 * Faces bordering to the same node are never rendered.
1197 * Connects to node specified in `liquid_alternative_source`.
1198 * Node textures are defined with `special_tiles` where the first tile
1199 is for the top and bottom faces and the second tile is for the side
1201 * `tiles` is used for the item/inventory/wield image rendering.
1202 * Use `backface_culling = false` for the special tiles you want to make
1203 visible when inside the node
1205 * Often used for partially-transparent nodes.
1206 * Only external sides of textures are visible.
1207 * `glasslike_framed`
1208 * All face-connected nodes are drawn as one volume within a surrounding
1210 * The frame appearance is generated from the edges of the first texture
1211 specified in `tiles`. The width of the edges used are 1/16th of texture
1212 size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
1213 * The glass 'shine' (or other desired detail) on each node face is supplied
1214 by the second texture specified in `tiles`.
1215 * `glasslike_framed_optional`
1216 * This switches between the above 2 drawtypes according to the menu setting
1219 * Often used for partially-transparent nodes.
1220 * External and internal sides of textures are visible.
1221 * `allfaces_optional`
1222 * Often used for leaves nodes.
1223 * This switches between `normal`, `glasslike` and `allfaces` according to
1224 the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
1225 * With 'Simple Leaves' selected, the texture specified in `special_tiles`
1226 is used instead, if present. This allows a visually thicker texture to be
1227 used to compensate for how `glasslike` reduces visual thickness.
1229 * A single vertical texture.
1230 * If `paramtype2="[color]wallmounted"`:
1231 * If placed on top of a node, uses the first texture specified in `tiles`.
1232 * If placed against the underside of a node, uses the second texture
1233 specified in `tiles`.
1234 * If placed on the side of a node, uses the third texture specified in
1235 `tiles` and is perpendicular to that node.
1236 * If `paramtype2="none"`:
1237 * Will be rendered as if placed on top of a node (see
1238 above) and only the first texture is used.
1240 * A single texture parallel to, and mounted against, the top, underside or
1242 * If `paramtype2="[color]wallmounted"`, it rotates according to `param2`
1243 * If `paramtype2="none"`, it will always be on the floor.
1245 * Two vertical and diagonal textures at right-angles to each other.
1246 * See `paramtype2 = "meshoptions"` above for other options.
1248 * When above a flat surface, appears as 6 textures, the central 2 as
1249 `plantlike` plus 4 more surrounding those.
1250 * If not above a surface the central 2 do not appear, but the texture
1251 appears against the faces of surrounding nodes if they are present.
1253 * A 3D model suitable for a wooden fence.
1254 * One placed node appears as a single vertical post.
1255 * Adjacently-placed nodes cause horizontal bars to appear between them.
1257 * Often used for tracks for mining carts.
1258 * Requires 4 textures to be specified in `tiles`, in order: Straight,
1259 curved, t-junction, crossing.
1260 * Each placed node automatically switches to a suitable rotated texture
1261 determined by the adjacent `raillike` nodes, in order to create a
1262 continuous track network.
1263 * Becomes a sloping node if placed against stepped nodes.
1265 * Often used for stairs and slabs.
1266 * Allows defining nodes consisting of an arbitrary number of boxes.
1267 * See [Node boxes] below for more information.
1269 * Uses models for nodes.
1270 * Tiles should hold model materials textures.
1271 * Only static meshes are implemented.
1272 * For supported model formats see Irrlicht engine documentation.
1273 * `plantlike_rooted`
1274 * Enables underwater `plantlike` without air bubbles around the nodes.
1275 * Consists of a base cube at the co-ordinates of the node plus a
1276 `plantlike` extension above
1277 * If `paramtype2="leveled", the `plantlike` extension has a height
1278 of `param2 / 16` nodes, otherwise it's the height of 1 node
1279 * If `paramtype2="wallmounted"`, the `plantlike` extension
1280 will be at one of the corresponding 6 sides of the base cube.
1281 Also, the base cube rotates like a `normal` cube would
1282 * The `plantlike` extension visually passes through any nodes above the
1283 base cube without affecting them.
1284 * The base cube texture tiles are defined as normal, the `plantlike`
1285 extension uses the defined special tile, for example:
1286 `special_tiles = {{name = "default_papyrus.png"}},`
1288 `*_optional` drawtypes need less rendering time if deactivated
1289 (always client-side).
1294 Node selection boxes are defined using "node boxes".
1296 A nodebox is defined as any of:
1299 -- A normal cube; the default in most things
1303 -- A fixed box (or boxes) (facedir param2 is used, if applicable)
1305 fixed = box OR {box1, box2, ...}
1308 -- A variable height box (or boxes) with the top face position defined
1309 -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
1311 -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
1313 fixed = box OR {box1, box2, ...}
1316 -- A box like the selection box for torches
1317 -- (wallmounted param2 is used, if applicable)
1318 type = "wallmounted",
1324 -- A node that has optional boxes depending on neighbouring nodes'
1325 -- presence and type. See also `connects_to`.
1327 fixed = box OR {box1, box2, ...}
1328 connect_top = box OR {box1, box2, ...}
1329 connect_bottom = box OR {box1, box2, ...}
1330 connect_front = box OR {box1, box2, ...}
1331 connect_left = box OR {box1, box2, ...}
1332 connect_back = box OR {box1, box2, ...}
1333 connect_right = box OR {box1, box2, ...}
1334 -- The following `disconnected_*` boxes are the opposites of the
1335 -- `connect_*` ones above, i.e. when a node has no suitable neighbour
1336 -- on the respective side, the corresponding disconnected box is drawn.
1337 disconnected_top = box OR {box1, box2, ...}
1338 disconnected_bottom = box OR {box1, box2, ...}
1339 disconnected_front = box OR {box1, box2, ...}
1340 disconnected_left = box OR {box1, box2, ...}
1341 disconnected_back = box OR {box1, box2, ...}
1342 disconnected_right = box OR {box1, box2, ...}
1343 disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour
1344 disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
1345 -- neighbours to the sides
1348 A `box` is defined as:
1350 {x1, y1, z1, x2, y2, z2}
1352 A box of a regular node would look like:
1354 {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
1356 To avoid collision issues, keep each value within the range of +/- 1.45.
1357 This also applies to leveled nodeboxes, where the final height shall not
1358 exceed this soft limit.
1362 Map terminology and coordinates
1363 ===============================
1365 Nodes, mapblocks, mapchunks
1366 ---------------------------
1368 A 'node' is the fundamental cubic unit of a world and appears to a player as
1369 roughly 1x1x1 meters in size.
1371 A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
1372 fundamental region of a world that is stored in the world database, sent to
1373 clients and handled by many parts of the engine.
1374 'mapblock' is preferred terminology to 'block' to help avoid confusion with
1375 'node', however 'block' often appears in the API.
1377 A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
1378 (80x80x80 nodes) and is the volume of world generated in one operation by
1380 The size in mapblocks has been chosen to optimise map generation.
1385 ### Orientation of axes
1387 For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
1389 ### Node coordinates
1391 Almost all positions used in the API use node coordinates.
1393 ### Mapblock coordinates
1395 Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
1396 specify a particular mapblock.
1397 For example blockpos (0,0,0) specifies the mapblock that extends from
1398 node position (0,0,0) to node position (15,15,15).
1400 #### Converting node position to the containing blockpos
1402 To calculate the blockpos of the mapblock that contains the node at 'nodepos',
1405 * blockpos = math.floor(nodepos / 16)
1407 #### Converting blockpos to min/max node positions
1409 To calculate the min/max node positions contained in the mapblock at 'blockpos',
1413 nodepos = blockpos * 16
1415 nodepos = blockpos * 16 + 15
1426 The position field is used for all element types.
1427 To account for differing resolutions, the position coordinates are the
1428 percentage of the screen, ranging in value from `0` to `1`.
1430 The `name` field is not yet used, but should contain a description of what the
1431 HUD element represents.
1433 The `direction` field is the direction in which something is drawn.
1434 `0` draws from left to right, `1` draws from right to left, `2` draws from
1435 top to bottom, and `3` draws from bottom to top.
1437 The `alignment` field specifies how the item will be aligned. It is a table
1438 where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
1439 moved to the left/up, and `1` is to the right/down. Fractional values can be
1442 The `offset` field specifies a pixel offset from the position. Contrary to
1443 position, the offset is not scaled to screen size. This allows for some
1444 precisely positioned items in the HUD.
1446 **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
1449 The `z_index` field specifies the order of HUD elements from back to front.
1450 Lower z-index elements are displayed behind higher z-index elements. Elements
1451 with same z-index are displayed in an arbitrary order. Default 0.
1452 Supports negative values. By convention, the following values are recommended:
1454 * -400: Graphical effects, such as vignette
1455 * -300: Name tags, waypoints
1457 * -100: Things that block the player's view, e.g. masks
1458 * 0: Default. For standard in-game HUD elements like crosshair, hotbar,
1459 minimap, builtin statbars, etc.
1460 * 100: Temporary text messages or notification icons
1461 * 1000: Full-screen effects such as full-black screen or credits.
1462 This includes effects that cover the entire screen
1464 If your HUD element doesn't fit into any category, pick a number
1465 between the suggested values
1467 Below are the specific uses for fields in each type; fields not listed for that
1472 Displays an image on the HUD.
1474 * `scale`: The scale of the image, with 1 being the original texture size.
1475 Only the X coordinate scale is used (positive values).
1476 Negative values represent that percentage of the screen it
1477 should take; e.g. `x=-100` means 100% (width).
1478 * `text`: The name of the texture that is displayed.
1479 * `alignment`: The alignment of the image.
1480 * `offset`: offset in pixels from position.
1484 Displays text on the HUD.
1486 * `scale`: Defines the bounding rectangle of the text.
1487 A value such as `{x=100, y=100}` should work.
1488 * `text`: The text to be displayed in the HUD element.
1489 * `number`: An integer containing the RGB value of the color used to draw the
1490 text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
1491 * `alignment`: The alignment of the text.
1492 * `offset`: offset in pixels from position.
1493 * `size`: size of the text.
1494 The player-set font size is multiplied by size.x (y value isn't used).
1495 * `style`: determines font style
1496 Bitfield with 1 = bold, 2 = italic, 4 = monospace
1500 Displays a horizontal bar made up of half-images with an optional background.
1502 * `text`: The name of the texture to use.
1503 * `text2`: Optional texture name to enable a background / "off state"
1504 texture (useful to visualize the maximal value). Both textures
1505 must have the same size.
1506 * `number`: The number of half-textures that are displayed.
1507 If odd, will end with a vertically center-split texture.
1508 * `item`: Same as `number` but for the "off state" texture
1509 * `direction`: To which direction the images will extend to
1510 * `offset`: offset in pixels from position.
1511 * `size`: If used, will force full-image size to this value (override texture
1516 * `text`: The name of the inventory list to be displayed.
1517 * `number`: Number of items in the inventory to be displayed.
1518 * `item`: Position of item that is selected.
1519 * `direction`: Direction the list will be displayed in
1520 * `offset`: offset in pixels from position.
1524 Displays distance to selected world position.
1526 * `name`: The name of the waypoint.
1527 * `text`: Distance suffix. Can be blank.
1528 * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
1529 If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
1530 When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
1531 `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
1532 `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
1533 `precision = n` will show multiples of `1/n`
1534 * `number:` An integer containing the RGB value of the color used to draw the
1536 * `world_pos`: World position of the waypoint.
1537 * `offset`: offset in pixels from position.
1538 * `alignment`: The alignment of the waypoint.
1540 ### `image_waypoint`
1542 Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
1544 * `scale`: The scale of the image, with 1 being the original texture size.
1545 Only the X coordinate scale is used (positive values).
1546 Negative values represent that percentage of the screen it
1547 should take; e.g. `x=-100` means 100% (width).
1548 * `text`: The name of the texture that is displayed.
1549 * `alignment`: The alignment of the image.
1550 * `world_pos`: World position of the waypoint.
1551 * `offset`: offset in pixels from position.
1555 Displays an image oriented or translated according to current heading direction.
1557 * `size`: The size of this element. Negative values represent percentage
1558 of the screen; e.g. `x=-100` means 100% (width).
1559 * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
1560 * `text`: The name of the texture to use.
1561 * `alignment`: The alignment of the image.
1562 * `offset`: Offset in pixels from position.
1563 * `direction`: How the image is rotated/translated:
1564 * 0 - Rotate as heading direction
1565 * 1 - Rotate in reverse direction
1566 * 2 - Translate as landscape direction
1567 * 3 - Translate in reverse direction
1569 If translation is chosen, texture is repeated horizontally to fill the whole element.
1573 Displays a minimap on the HUD.
1575 * `size`: Size of the minimap to display. Minimap should be a square to avoid
1577 * `alignment`: The alignment of the minimap.
1578 * `offset`: offset in pixels from position.
1580 Representations of simple things
1581 ================================
1583 Vector (ie. a position)
1584 -----------------------
1588 See [Spatial Vectors] for details.
1593 * `{type="nothing"}`
1594 * `{type="node", under=pos, above=pos}`
1595 * Indicates a pointed node selection box.
1596 * `under` refers to the node position behind the pointed face.
1597 * `above` refers to the node position in front of the pointed face.
1598 * `{type="object", ref=ObjectRef}`
1600 Exact pointing location (currently only `Raycast` supports these fields):
1602 * `pointed_thing.intersection_point`: The absolute world coordinates of the
1603 point on the selection box which is pointed at. May be in the selection box
1604 if the pointer is in the box too.
1605 * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
1607 * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
1608 selected selection box. This specifies which face is pointed at.
1609 Is a null vector `vector.zero()` when the pointer is inside the selection box.
1614 Flag Specifier Format
1615 =====================
1617 Flags using the standardized flag specifier format can be specified in either
1618 of two ways, by string or table.
1620 The string format is a comma-delimited set of flag names; whitespace and
1621 unrecognized flag fields are ignored. Specifying a flag in the string sets the
1622 flag, and specifying a flag prefixed by the string `"no"` explicitly
1623 clears the flag from whatever the default may be.
1625 In addition to the standard string flag format, the schematic flags field can
1626 also be a table of flag names to boolean values representing whether or not the
1627 flag is set. Additionally, if a field with the flag name prefixed with `"no"`
1628 is present, mapped to a boolean of any value, the specified flag is unset.
1630 E.g. A flag field of value
1632 {place_center_x = true, place_center_y=false, place_center_z=true}
1636 {place_center_x = true, noplace_center_y=true, place_center_z=true}
1638 which is equivalent to
1640 "place_center_x, noplace_center_y, place_center_z"
1644 "place_center_x, place_center_z"
1646 since, by default, no schematic attributes are set.
1654 Items are things that can be held by players, dropped in the map and
1655 stored in inventories.
1656 Items come in the form of item stacks, which are collections of equal
1657 items that occupy a single inventory slot.
1662 There are three kinds of items: nodes, tools and craftitems.
1664 * Node: Placeable item form of a node in the world's voxel grid
1665 * Tool: Has a changable wear property but cannot be stacked
1666 * Craftitem: Has no special properties
1668 Every registered node (the voxel in the world) has a corresponding
1669 item form (the thing in your inventory) that comes along with it.
1670 This item form can be placed which will create a node in the
1672 Both the 'actual' node and its item form share the same identifier.
1673 For all practical purposes, you can treat the node and its item form
1674 interchangeably. We usually just say 'node' to the item form of
1677 Note the definition of tools is purely technical. The only really
1678 unique thing about tools is their wear, and that's basically it.
1679 Beyond that, you can't make any gameplay-relevant assumptions
1680 about tools or non-tools. It is perfectly valid to register something
1681 that acts as tool in a gameplay sense as a craftitem, and vice-versa.
1683 Craftitems can be used for items that neither need to be a node
1689 All item stacks have an amount between 0 and 65535. It is 1 by
1690 default. Tool item stacks can not have an amount greater than 1.
1692 Tools use a wear (damage) value ranging from 0 to 65535. The
1693 value 0 is the default and is used for unworn tools. The values
1694 1 to 65535 are used for worn tools, where a higher value stands for
1695 a higher wear. Non-tools technically also have a wear property,
1696 but it is always 0. There is also a special 'toolrepair' crafting
1697 recipe that is only available to tools.
1702 Items and item stacks can exist in three formats: Serializes, table format
1705 When an item must be passed to a function, it can usually be in any of
1710 This is called "stackstring" or "itemstring". It is a simple string with
1713 1. Full item identifier ("item name")
1715 3. Optional wear value
1716 4. Optional item metadata
1720 <identifier> [<amount>[ <wear>[ <metadata>]]]
1724 * `"default:apple"`: 1 apple
1725 * `"default:dirt 5"`: 5 dirt
1726 * `"default:pick_stone"`: a new stone pickaxe
1727 * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
1728 * `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`:
1729 * a wooden pickaxe from the `default` mod,
1730 * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool),
1731 * with the `description` field set to `"My worn out pick"` in its metadata
1732 * `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`:
1733 * analogeous to the above example
1734 * note how the wear is set to `0` as dirt is not a tool
1736 You should ideally use the `ItemStack` format to build complex item strings
1737 (especially if they use item metadata)
1738 without relying on the serialization format. Example:
1740 local stack = ItemStack("default:pick_wood")
1741 stack:set_wear(21323)
1742 stack:get_meta():set_string("description", "My worn out pick")
1743 local itemstring = stack:to_string()
1745 Additionally the methods `minetest.itemstring_with_palette(item, palette_index)`
1746 and `minetest.itemstring_with_color(item, colorstring)` may be used to create
1747 item strings encoding color information in their metadata.
1755 {name="default:dirt", count=5, wear=0, metadata=""}
1757 A wooden pick about 1/3 worn out:
1759 {name="default:pick_wood", count=1, wear=21323, metadata=""}
1763 {name="default:apple", count=1, wear=0, metadata=""}
1767 A native C++ format with many helper methods. Useful for converting
1768 between formats. See the [Class reference] section for details.
1776 In a number of places, there is a group table. Groups define the
1777 properties of a thing (item, node, armor of entity, tool capabilities)
1778 in such a way that the engine and other mods can can interact with
1779 the thing without actually knowing what the thing is.
1784 Groups are stored in a table, having the group names with keys and the
1785 group ratings as values. Group ratings are integer values within the
1786 range [-32767, 32767]. For example:
1789 groups = {crumbly=3, soil=1}
1791 -- A more special dirt-kind of thing
1792 groups = {crumbly=2, soil=1, level=2, outerspace=1}
1794 Groups always have a rating associated with them. If there is no
1795 useful meaning for a rating for an enabled group, it shall be `1`.
1797 When not defined, the rating of a group defaults to `0`. Thus when you
1798 read groups, you must interpret `nil` and `0` as the same value, `0`.
1800 You can read the rating of a group for an item or a node by using
1802 minetest.get_item_group(itemname, groupname)
1807 Groups of items can define what kind of an item it is (e.g. wool).
1812 In addition to the general item things, groups are used to define whether
1813 a node is destroyable and how long it takes to destroy by a tool.
1818 For entities, groups are, as of now, used only for calculating damage.
1819 The rating is the percentage of damage caused by items with this damage group.
1820 See [Entity damage mechanism].
1822 object:get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
1823 object:set_armor_groups({fleshy=30, cracky=80})
1825 Groups of tool capabilities
1826 ---------------------------
1828 Groups in tool capabilities define which groups of nodes and entities they
1829 are effective towards.
1831 Groups in crafting recipes
1832 --------------------------
1834 In crafting recipes, you can specify a group as an input item.
1835 This means that any item in that group will be accepted as input.
1837 The basic syntax is:
1839 "group:<group_name>"
1841 For example, `"group:meat"` will accept any item in the `meat` group.
1843 It is also possible to require an input item to be in
1844 multiple groups at once. The syntax for that is:
1846 "group:<group_name_1>,<group_name_2>,(...),<group_name_n>"
1848 For example, `"group:leaves,birch,trimmed"` accepts any item which is member
1849 of *all* the groups `leaves` *and* `birch` *and* `trimmed`.
1851 An example recipe: Craft a raw meat soup from any meat, any water and any bowl:
1854 output = "food:meat_soup_raw",
1862 Another example: Craft red wool from white wool and red dye
1863 (here, "red dye" is defined as any item which is member of
1864 *both* the groups `dye` and `basecolor_red`).
1868 output = "wool:red",
1869 recipe = {"wool:white", "group:dye,basecolor_red"},
1875 The asterisk `(*)` after a group name describes that there is no engine
1876 functionality bound to it, and implementation is left up as a suggestion
1879 ### Node and item groups
1881 * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
1882 that the item should be hidden in item lists.
1885 ### Node-only groups
1887 * `attached_node`: if the node under it is not a walkable block the node will be
1888 dropped as an item. If the node is wallmounted the wallmounted direction is
1890 * `bouncy`: value is bounce speed in percent.
1891 If positive, jump/sneak on floor impact will increase/decrease bounce height.
1892 Negative value is the same bounciness, but non-controllable.
1893 * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1894 connect to each other
1895 * `dig_immediate`: Player can always pick up node without reducing tool wear
1896 * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
1897 * `3`: the node always gets the digging time 0 seconds (torch)
1898 * `disable_jump`: Player (and possibly other things) cannot jump from node
1899 or if their feet are in the node. Note: not supported for `new_move = false`
1900 * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
1901 the top of this node. There's also an armor group with the same name.
1902 The final player damage is determined by the following formula:
1905 * ((node_fall_damage_add_percent + 100) / 100) -- node group
1906 * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
1907 - (14) -- constant tolerance
1908 Negative damage values are discarded as no damage.
1909 * `falling_node`: if there is no walkable block under the node it will fall
1910 * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
1911 * `level`: Can be used to give an additional sense of progression in the game.
1912 * A larger level will cause e.g. a weapon of a lower level make much less
1913 damage, and get worn out much faster, or not be able to get drops
1914 from destroyed nodes.
1915 * `0` is something that is directly accessible at the start of gameplay
1916 * There is no upper limit
1917 * See also: `leveldiff` in [Tool Capabilities]
1918 * `slippery`: Players and items will slide on the node.
1919 Slipperiness rises steadily with `slippery` value, starting at 1.
1922 ### Tool-only groups
1924 * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
1925 `"toolrepair"` crafting recipe
1928 ### `ObjectRef` armor groups
1930 * `immortal`: Skips all damage and breath handling for an object. This group
1931 will also hide the integrated HUD status bars for players. It is
1932 automatically set to all players when damage is disabled on the server and
1933 cannot be reset (subject to change).
1934 * `fall_damage_add_percent`: Modifies the fall damage suffered by players
1935 when they hit the ground. It is analog to the node group with the same
1936 name. See the node group above for the exact calculation.
1937 * `punch_operable`: For entities; disables the regular damage mechanism for
1938 players punching it by hand or a non-tool item, so that it can do something
1939 else than take damage.
1943 Known damage and digging time defining groups
1944 ---------------------------------------------
1946 * `crumbly`: dirt, sand
1947 * `cracky`: tough but crackable stuff like stone.
1948 * `snappy`: something that can be cut using things like scissors, shears,
1949 bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
1950 * `choppy`: something that can be cut using force; e.g. trees, wooden planks
1951 * `fleshy`: Living things like animals and the player. This could imply
1952 some blood effects when hitting.
1953 * `explody`: Especially prone to explosions
1954 * `oddly_breakable_by_hand`:
1955 Can be added to nodes that shouldn't logically be breakable by the
1956 hand but are. Somewhat similar to `dig_immediate`, but times are more
1957 like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
1958 digging speed of an item if it can dig at a faster speed than this
1959 suggests for the hand.
1961 Examples of custom groups
1962 -------------------------
1964 Item groups are often used for defining, well, _groups of items_.
1966 * `meat`: any meat-kind of a thing (rating might define the size or healing
1967 ability or be irrelevant -- it is not defined as of yet)
1968 * `eatable`: anything that can be eaten. Rating might define HP gain in half
1970 * `flammable`: can be set on fire. Rating might define the intensity of the
1971 fire, affecting e.g. the speed of the spreading of an open fire.
1972 * `wool`: any wool (any origin, any color)
1973 * `metal`: any metal
1974 * `weapon`: any weapon
1975 * `heavy`: anything considerably heavy
1977 Digging time calculation specifics
1978 ----------------------------------
1980 Groups such as `crumbly`, `cracky` and `snappy` are used for this
1981 purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
1982 faster digging time.
1984 The `level` group is used to limit the toughness of nodes an item capable
1985 of digging can dig and to scale the digging times / damage to a greater extent.
1987 **Please do understand this**, otherwise you cannot use the system to it's
1990 Items define their properties by a list of parameters for groups. They
1991 cannot dig other groups; thus it is important to use a standard bunch of
1992 groups to enable interaction with items.
2000 'Tool capabilities' is a property of items that defines two things:
2002 1) Which nodes it can dig and how fast
2003 2) Which objects it can hurt by punching and by how much
2005 Tool capabilities are available for all items, not just tools.
2006 But only tools can receive wear from digging and punching.
2008 Missing or incomplete tool capabilities will default to the
2011 Tool capabilities definition
2012 ----------------------------
2014 Tool capabilities define:
2016 * Full punch interval
2017 * Maximum drop level
2018 * For an arbitrary list of node groups:
2019 * Uses (until the tool breaks)
2020 * Maximum level (usually `0`, `1`, `2` or `3`)
2023 * Punch attack uses (until the tool breaks)
2025 ### Full punch interval `full_punch_interval`
2027 When used as a weapon, the item will do full damage if this time is spent
2028 between punches. If e.g. half the time is spent, the item will do half
2031 ### Maximum drop level `max_drop_level`
2033 Suggests the maximum level of node, when dug with the item, that will drop
2034 its useful item. (e.g. iron ore to drop a lump of iron).
2036 This value is not used in the engine; it is the responsibility of the game/mod
2037 code to implement this.
2039 ### Uses `uses` (tools only)
2041 Determines how many uses the tool has when it is used for digging a node,
2042 of this group, of the maximum level. The maximum supported number of
2043 uses is 65535. The special number 0 is used for infinite uses.
2044 For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
2045 `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
2046 node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
2048 * `uses=10, leveldiff=0`: actual uses: 10
2049 * `uses=10, leveldiff=1`: actual uses: 30
2050 * `uses=10, leveldiff=2`: actual uses: 90
2052 For non-tools, this has no effect.
2054 ### Maximum level `maxlevel`
2056 Tells what is the maximum level of a node of this group that the item will
2059 ### Digging times `times`
2061 List of digging times for different ratings of the group, for nodes of the
2064 For example, as a Lua table, `times={[2]=2.00, [3]=0.70}`. This would
2065 result in the item to be able to dig nodes that have a rating of `2` or `3`
2066 for this group, and unable to dig the rating `1`, which is the toughest.
2067 Unless there is a matching group that enables digging otherwise.
2069 If the result digging time is 0, a delay of 0.15 seconds is added between
2070 digging nodes; If the player releases LMB after digging, this delay is set to 0,
2071 i.e. players can more quickly click the nodes away instead of holding LMB.
2075 List of damage for groups of entities. See [Entity damage mechanism].
2077 ### Punch attack uses (tools only)
2079 Determines how many uses (before breaking) the tool has when dealing damage
2080 to an object, when the full punch interval (see above) was always
2083 Wear received by the tool is proportional to the time spent, scaled by
2084 the full punch interval.
2086 For non-tools, this has no effect.
2088 Example definition of the capabilities of an item
2089 -------------------------------------------------
2091 tool_capabilities = {
2093 crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
2097 This makes the item capable of digging nodes that fulfil both of these:
2099 * Have the `crumbly` group
2100 * Have a `level` group less or equal to `2`
2102 Table of resulting digging times:
2104 crumbly 0 1 2 3 4 <- level
2106 1 0.80 1.60 1.60 - -
2107 2 0.60 1.20 1.20 - -
2108 3 0.40 0.80 0.80 - -
2110 level diff: 2 1 0 -1 -2
2112 Table of resulting tool uses:
2121 * At `crumbly==0`, the node is not diggable.
2122 * At `crumbly==3`, the level difference digging time divider kicks in and makes
2123 easy nodes to be quickly breakable.
2124 * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
2129 Entity damage mechanism
2130 =======================
2135 foreach group in cap.damage_groups:
2136 damage += cap.damage_groups[group]
2137 * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
2138 * (object.armor_groups[group] / 100.0)
2139 -- Where object.armor_groups[group] is 0 for inexistent values
2142 Client predicts damage based on damage groups. Because of this, it is able to
2143 give an immediate response when an entity is damaged or dies; the response is
2144 pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
2146 Currently a smoke puff will appear when an entity dies.
2148 The group `immortal` completely disables normal damage.
2150 Entities can define a special armor group, which is `punch_operable`. This
2151 group disables the regular damage mechanism for players punching it by hand or
2152 a non-tool item, so that it can do something else than take damage.
2154 On the Lua side, every punch calls:
2156 entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
2159 This should never be called directly, because damage is usually not handled by
2162 * `puncher` is the object performing the punch. Can be `nil`. Should never be
2163 accessed unless absolutely required, to encourage interoperability.
2164 * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
2165 * `tool_capabilities` can be `nil`.
2166 * `direction` is a unit vector, pointing from the source of the punch to
2168 * `damage` damage that will be done to entity
2169 Return value of this function will determine if damage is done by this function
2170 (retval true) or shall be done by engine (retval false)
2172 To punch an entity/object in Lua, call:
2174 object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
2176 * Return value is tool wear.
2177 * Parameters are equal to the above callback.
2178 * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
2179 will be automatically filled in based on the location of `puncher`.
2190 The instance of a node in the world normally only contains the three values
2191 mentioned in [Nodes]. However, it is possible to insert extra data into a node.
2192 It is called "node metadata"; See `NodeMetaRef`.
2194 Node metadata contains two things:
2199 Some of the values in the key-value store are handled specially:
2201 * `formspec`: Defines an inventory menu that is opened with the
2202 'place/use' key. Only works if no `on_rightclick` was
2203 defined for the node. See also [Formspec].
2204 * `infotext`: Text shown on the screen when the node is pointed at.
2205 Line-breaks will be applied automatically.
2206 If the infotext is very long, it will be truncated.
2210 local meta = minetest.get_meta(pos)
2211 meta:set_string("formspec",
2213 "list[context;main;0,0;8,4;]"..
2214 "list[current_player;main;0,5;8,4;]")
2215 meta:set_string("infotext", "Chest");
2216 local inv = meta:get_inventory()
2217 inv:set_size("main", 8*4)
2218 print(dump(meta:to_table()))
2221 main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
2222 [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
2223 [10] = "", [11] = "", [12] = "", [13] = "",
2224 [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
2225 [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
2226 [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
2227 [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
2231 formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
2239 Item stacks can store metadata too. See [`ItemStackMetaRef`].
2241 Item metadata only contains a key-value store.
2243 Some of the values in the key-value store are handled specially:
2245 * `description`: Set the item stack's description.
2246 See also: `get_description` in [`ItemStack`]
2247 * `short_description`: Set the item stack's short description.
2248 See also: `get_short_description` in [`ItemStack`]
2249 * `color`: A `ColorString`, which sets the stack's color.
2250 * `palette_index`: If the item has a palette, this is used to get the
2251 current color from the palette.
2252 * `count_meta`: Replace the displayed count with any string.
2253 * `count_alignment`: Set the alignment of the displayed count value. This is an
2254 int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
2255 4th bit specify the alignment in y-direction:
2256 0 = default, 1 = left / up, 2 = middle, 3 = right / down
2257 The default currently is the same as right/down.
2258 Example: 6 = 2 + 1*4 = middle,up
2262 local meta = stack:get_meta()
2263 meta:set_string("key", "value")
2264 print(dump(meta:to_table()))
2266 Example manipulations of "description" and expected output behaviors:
2268 print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
2269 print(ItemStack("foobar"):get_description()) --> Unknown Item
2271 local stack = ItemStack("default:stone")
2272 stack:get_meta():set_string("description", "Custom description\nAnother line")
2273 print(stack:get_description()) --> Custom description\nAnother line
2274 print(stack:get_short_description()) --> Custom description
2276 stack:get_meta():set_string("short_description", "Short")
2277 print(stack:get_description()) --> Custom description\nAnother line
2278 print(stack:get_short_description()) --> Short
2280 print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
2287 Formspec defines a menu. This supports inventories and some of the
2288 typical widgets like buttons, checkboxes, text input fields, etc.
2289 It is a string, with a somewhat strange format.
2291 A formspec is made out of formspec elements, which includes widgets
2292 like buttons but also can be used to set stuff like background color.
2294 Many formspec elements have a `name`, which is a unique identifier which
2295 is used when the server receives user input. You must not use the name
2296 "quit" for formspec elements.
2298 Spaces and newlines can be inserted between the blocks, as is used in the
2301 Position and size units are inventory slots unless the new coordinate system
2302 is enabled. `X` and `Y` position the formspec element relative to the top left
2303 of the menu or container. `W` and `H` are its width and height values.
2305 If the new system is enabled, all elements have unified coordinates for all
2306 elements with no padding or spacing in between. This is highly recommended
2307 for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
2310 Inventories with a `player:<name>` inventory location are only sent to the
2311 player named `<name>`.
2313 When displaying text which can contain formspec code, e.g. text set by a player,
2314 use `minetest.formspec_escape`.
2315 For colored text you can use `minetest.colorize`.
2317 Since formspec version 3, elements drawn in the order they are defined. All
2318 background elements are drawn before all other elements.
2320 **WARNING**: do _not_ use a element name starting with `key_`; those names are
2321 reserved to pass key press events to formspec!
2323 **WARNING**: Minetest allows you to add elements to every single formspec instance
2324 using `player:set_formspec_prepend()`, which may be the reason backgrounds are
2325 appearing when you don't expect them to, or why things are styled differently
2326 to normal. See [`no_prepend[]`] and [Styling Formspecs].
2334 list[context;main;0,0;8,4;]
2335 list[current_player;main;0,5;8,4;]
2340 list[context;fuel;2,3;1,1;]
2341 list[context;src;2,1;1,1;]
2342 list[context;dst;5,1;2,2;]
2343 list[current_player;main;0,5;8,4;]
2345 ### Minecraft-like player inventory
2348 image[1,0.6;1,2;player.png]
2349 list[current_player;main;0,3.5;8,4;]
2350 list[current_player;craft;3,0;3,3;]
2351 list[current_player;craftpreview;7,1;1,1;]
2356 * Formspec version 1 (pre-5.1.0):
2358 * Formspec version 2 (5.1.0):
2359 * Forced real coordinates
2360 * background9[]: 9-slice scaling parameters
2361 * Formspec version 3 (5.2.0):
2362 * Formspec elements are drawn in the order of definition
2363 * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
2364 * box[] and image[] elements enable clipping by default
2365 * new element: scroll_container[]
2366 * Formspec version 4 (5.4.0):
2367 * Allow dropdown indexing events
2368 * Formspec version 5 (5.5.0):
2369 * Added padding[] element
2370 * Formspec version 6 (5.6.0):
2371 * Add nine-slice images, animated_image, and fgimg_middle
2376 ### `formspec_version[<version>]`
2378 * Set the formspec version to a certain number. If not specified,
2379 version 1 is assumed.
2380 * Must be specified before `size` element.
2381 * Clients older than this version can neither show newer elements nor display
2382 elements with new arguments correctly.
2383 * Available since feature `formspec_version_element`.
2384 * See also: [Version History]
2386 ### `size[<W>,<H>,<fixed_size>]`
2388 * Define the size of the menu in inventory slots
2389 * `fixed_size`: `true`/`false` (optional)
2390 * deprecated: `invsize[<W>,<H>;]`
2392 ### `position[<X>,<Y>]`
2394 * Must be used after `size` element.
2395 * Defines the position on the game window of the formspec's `anchor` point.
2396 * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
2398 * [0.0, 0.0] sets the position to the top left corner of the game window.
2399 * [1.0, 1.0] sets the position to the bottom right of the game window.
2400 * Defaults to the center of the game window [0.5, 0.5].
2402 ### `anchor[<X>,<Y>]`
2404 * Must be used after both `size` and `position` (if present) elements.
2405 * Defines the location of the anchor point within the formspec.
2406 * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
2408 * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
2409 * [1.0, 0.0] sets the anchor to the top right of the formspec.
2410 * Defaults to the center of the formspec [0.5, 0.5].
2412 * `position` and `anchor` elements need suitable values to avoid a formspec
2413 extending off the game window due to particular game window sizes.
2415 ### `padding[<X>,<Y>]`
2417 * Must be used after the `size`, `position`, and `anchor` elements (if present).
2418 * Defines how much space is padded around the formspec if the formspec tries to
2419 increase past the size of the screen and coordinates have to be shrunk.
2420 * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
2421 screen), and 0.5 represents half the screen (which forces the coordinate size
2422 to 0). If negative, the formspec can extend off the edge of the screen.
2423 * Defaults to [0.05, 0.05].
2427 * Must be used after the `size`, `position`, `anchor`, and `padding` elements
2429 * Disables player:set_formspec_prepend() from applying to this formspec.
2431 ### `real_coordinates[<bool>]`
2433 * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
2434 * When set to true, all following formspec elements will use the new coordinate system.
2435 * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
2436 (if present), the form size will use the new coordinate system.
2437 * **Note**: Formspec prepends are not affected by the coordinates in the main form.
2438 They must enable it explicitly.
2439 * For information on converting forms to the new coordinate system, see `Migrating
2440 to Real Coordinates`.
2442 ### `container[<X>,<Y>]`
2444 * Start of a container block, moves all physical elements in the container by
2446 * Must have matching `container_end`
2447 * Containers can be nested, in which case the offsets are added
2448 (child containers are relative to parent containers)
2450 ### `container_end[]`
2452 * End of a container, following elements are no longer relative to this
2455 ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
2457 * Start of a scroll_container block. All contained elements will ...
2458 * take the scroll_container coordinate as position origin,
2459 * be additionally moved by the current value of the scrollbar with the name
2460 `scrollbar name` times `scroll factor` along the orientation `orientation` and
2461 * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
2462 * `orientation`: possible values are `vertical` and `horizontal`.
2463 * `scroll factor`: optional, defaults to `0.1`.
2464 * Nesting is possible.
2465 * Some elements might work a little different if they are in a scroll_container.
2466 * Note: If you want the scroll_container to actually work, you also need to add a
2467 scrollbar element with the specified name. Furthermore, it is highly recommended
2468 to use a scrollbaroptions element on this scrollbar.
2470 ### `scroll_container_end[]`
2472 * End of a scroll_container, following elements are no longer bound to this
2475 ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
2477 * Show an inventory list if it has been sent to the client.
2478 * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
2479 are moved) while the formspec is open, the formspec element may (but is not guaranteed
2480 to) adapt to the new inventory list.
2481 * Item slots are drawn in a grid from left to right, then up to down, ordered
2482 according to the slot index.
2483 * `W` and `H` are in inventory slots, not in coordinates.
2484 * `starting item index` (Optional): The index of the first (upper-left) item to draw.
2485 Indices start at `0`. Default is `0`.
2486 * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
2487 `starting item index`.
2488 * **Note**: With the new coordinate system, the spacing between inventory
2489 slots is one-fourth the size of an inventory slot by default. Also see
2490 [Styling Formspecs] for changing the size of slots and spacing.
2492 ### `listring[<inventory location>;<list name>]`
2494 * Appends to an internal ring of inventory lists.
2495 * Shift-clicking on items in one element of the ring
2496 will send them to the next inventory list inside the ring
2497 * The first occurrence of an element inside the ring will
2498 determine the inventory where items will be sent to
2502 * Shorthand for doing `listring[<inventory location>;<list name>]`
2503 for the last two inventory lists added by list[...]
2505 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
2507 * Sets background color of slots as `ColorString`
2508 * Sets background color of slots on mouse hovering
2510 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
2512 * Sets background color of slots as `ColorString`
2513 * Sets background color of slots on mouse hovering
2514 * Sets color of slots border
2516 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
2518 * Sets background color of slots as `ColorString`
2519 * Sets background color of slots on mouse hovering
2520 * Sets color of slots border
2521 * Sets default background color of tooltips
2522 * Sets default font color of tooltips
2524 ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2526 * Adds tooltip for an element
2527 * `bgcolor` tooltip background color as `ColorString` (optional)
2528 * `fontcolor` tooltip font color as `ColorString` (optional)
2530 ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2532 * Adds tooltip for an area. Other tooltips will take priority when present.
2533 * `bgcolor` tooltip background color as `ColorString` (optional)
2534 * `fontcolor` tooltip font color as `ColorString` (optional)
2536 ### `image[<X>,<Y>;<W>,<H>;<texture name>;<middle>]`
2539 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2540 * Requires formspec version >= 6.
2541 * See `background9[]` documentation for more information.
2543 ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
2545 * Show an animated image. The image is drawn like a "vertical_frames" tile
2546 animation (See [Tile animation definition]), but uses a frame count/duration for simplicity
2547 * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
2548 * `texture name`: The image to use.
2549 * `frame count`: The number of frames animating the image.
2550 * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
2551 * `frame start` (optional): The index of the frame to start on. Default `1`.
2552 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2553 * Requires formspec version >= 6.
2554 * See `background9[]` documentation for more information.
2556 ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
2558 * Show a mesh model.
2559 * `name`: Element name that can be used for styling
2560 * `mesh`: The mesh model to use.
2561 * `textures`: The mesh textures to use according to the mesh materials.
2562 Texture names must be separated by commas.
2563 * `rotation {X,Y}` (Optional): Initial rotation of the camera.
2564 The axes are euler angles in degrees.
2565 * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
2566 * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
2567 * `frame loop range` (Optional): Range of the animation frames.
2568 * Defaults to the full range of all available frames.
2569 * Syntax: `<begin>,<end>`
2570 * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
2572 ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
2574 * Show an inventory image of registered item/node
2576 ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
2578 * Sets background color of formspec.
2579 * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
2580 of the non-fullscreen and the fullscreen background.
2581 * `fullscreen` (optional) can be one of the following:
2582 * `false`: Only the non-fullscreen background color is drawn. (default)
2583 * `true`: Only the fullscreen background color is drawn.
2584 * `both`: The non-fullscreen and the fullscreen background color are drawn.
2585 * `neither`: No background color is drawn.
2586 * Note: Leave a parameter empty to not modify the value.
2587 * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
2588 are not bools are only available since formspec version 3.
2590 ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
2592 * Example for formspec 8x4 in 16x resolution: image shall be sized
2593 8 times 16px times 4 times 16px.
2595 ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
2597 * Example for formspec 8x4 in 16x resolution:
2598 image shall be sized 8 times 16px times 4 times 16px
2599 * If `auto_clip` is `true`, the background is clipped to the formspec size
2600 (`x` and `y` are used as offset values, `w` and `h` are ignored)
2602 ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
2604 * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
2605 * Middle is a rect which defines the middle of the 9-slice.
2606 * `x` - The middle will be x pixels from all sides.
2607 * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
2608 * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
2609 will be added to the width and height of the texture, allowing it to be used as the
2610 distance from the far end.
2611 * All numbers in middle are integers.
2612 * If `auto_clip` is `true`, the background is clipped to the formspec size
2613 (`x` and `y` are used as offset values, `w` and `h` are ignored)
2614 * Available since formspec version 2
2616 ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
2618 * Textual password style field; will be sent to server when a button is clicked
2619 * When enter is pressed in field, fields.key_enter_field will be sent with the
2621 * With the old coordinate system, fields are a set height, but will be vertically
2622 centred on `H`. With the new coordinate system, `H` will modify the height.
2623 * `name` is the name of the field as returned in fields to `on_receive_fields`
2624 * `label`, if not blank, will be text printed on the top left above the field
2625 * See `field_close_on_enter` to stop enter closing the formspec
2627 ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2629 * Textual field; will be sent to server when a button is clicked
2630 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2631 the name of this field.
2632 * With the old coordinate system, fields are a set height, but will be vertically
2633 centred on `H`. With the new coordinate system, `H` will modify the height.
2634 * `name` is the name of the field as returned in fields to `on_receive_fields`
2635 * `label`, if not blank, will be text printed on the top left above the field
2636 * `default` is the default value of the field
2637 * `default` may contain variable references such as `${text}` which
2638 will fill the value from the metadata value `text`
2639 * **Note**: no extra text or more than a single variable is supported ATM.
2640 * See `field_close_on_enter` to stop enter closing the formspec
2642 ### `field[<name>;<label>;<default>]`
2644 * As above, but without position/size units
2645 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2646 the name of this field.
2647 * Special field for creating simple forms, such as sign text input
2648 * Must be used without a `size[]` element
2649 * A "Proceed" button will be added automatically
2650 * See `field_close_on_enter` to stop enter closing the formspec
2652 ### `field_close_on_enter[<name>;<close_on_enter>]`
2654 * <name> is the name of the field
2655 * if <close_on_enter> is false, pressing enter in the field will submit the
2656 form but not close it.
2657 * defaults to true when not specified (ie: no tag for a field)
2659 ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2661 * Same as fields above, but with multi-line input
2662 * If the text overflows, a vertical scrollbar is added.
2663 * If the name is empty, the textarea is read-only and
2664 the background is not shown, which corresponds to a multi-line label.
2666 ### `label[<X>,<Y>;<label>]`
2668 * The label formspec element displays the text set in `label`
2669 at the specified position.
2670 * **Note**: If the new coordinate system is enabled, labels are
2671 positioned from the center of the text, not the top.
2672 * The text is displayed directly without automatic line breaking,
2673 so label should not be used for big text chunks. Newlines can be
2674 used to make labels multiline.
2675 * **Note**: With the new coordinate system, newlines are spaced with
2676 half a coordinate. With the old system, newlines are spaced 2/5 of
2679 ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
2680 * Displays a static formatted text with hyperlinks.
2681 * **Note**: This element is currently unstable and subject to change.
2682 * `x`, `y`, `w` and `h` work as per field
2683 * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
2684 * `text` is the formatted text using `Markup Language` described below.
2686 ### `vertlabel[<X>,<Y>;<label>]`
2687 * Textual label drawn vertically
2688 * `label` is the text on the label
2689 * **Note**: If the new coordinate system is enabled, vertlabels are
2690 positioned from the center of the text, not the left.
2692 ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
2694 * Clickable button. When clicked, fields will be sent.
2695 * With the old coordinate system, buttons are a set height, but will be vertically
2696 centred on `H`. With the new coordinate system, `H` will modify the height.
2697 * `label` is the text on the button
2699 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2701 * `texture name` is the filename of an image
2702 * **Note**: Height is supported on both the old and new coordinate systems
2705 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
2707 * `texture name` is the filename of an image
2708 * `noclip=true` means the image button doesn't need to be within specified
2710 * `drawborder`: draw button border or not
2711 * `pressed texture name` is the filename of an image on pressed state
2713 ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
2715 * `item name` is the registered name of an item/node
2716 * The item description will be used as the tooltip. This can be overridden with
2719 ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
2721 * When clicked, fields will be sent and the form will quit.
2722 * Same as `button` in all other respects.
2724 ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2726 * When clicked, fields will be sent and the form will quit.
2727 * Same as `image_button` in all other respects.
2729 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
2731 * Scrollable item list showing arbitrary text elements
2732 * `name` fieldname sent to server on doubleclick value is current selected
2734 * `listelements` can be prepended by #color in hexadecimal format RRGGBB
2736 * if you want a listelement to start with "#" write "##".
2738 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
2740 * Scrollable itemlist showing arbitrary text elements
2741 * `name` fieldname sent to server on doubleclick value is current selected
2743 * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
2744 * if you want a listelement to start with "#" write "##"
2745 * Index to be selected within textlist
2746 * `true`/`false`: draw transparent background
2747 * See also `minetest.explode_textlist_event`
2748 (main menu: `core.explode_textlist_event`).
2750 ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2752 * Show a tab**header** at specific position (ignores formsize)
2753 * `X` and `Y`: position of the tabheader
2754 * *Note*: Width and height are automatically chosen with this syntax
2755 * `name` fieldname data is transferred to Lua
2756 * `caption 1`...: name shown on top of tab
2757 * `current_tab`: index of selected tab 1...
2758 * `transparent` (optional): if true, tabs are semi-transparent
2759 * `draw_border` (optional): if true, draw a thin line at tab base
2761 ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2763 * Show a tab**header** at specific position (ignores formsize)
2764 * **Important note**: This syntax for tabheaders can only be used with the
2765 new coordinate system.
2766 * `X` and `Y`: position of the tabheader
2767 * `H`: height of the tabheader. Width is automatically determined with this syntax.
2768 * `name` fieldname data is transferred to Lua
2769 * `caption 1`...: name shown on top of tab
2770 * `current_tab`: index of selected tab 1...
2771 * `transparent` (optional): show transparent
2772 * `draw_border` (optional): draw border
2774 ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2776 * Show a tab**header** at specific position (ignores formsize)
2777 * **Important note**: This syntax for tabheaders can only be used with the
2778 new coordinate system.
2779 * `X` and `Y`: position of the tabheader
2780 * `W` and `H`: width and height of the tabheader
2781 * `name` fieldname data is transferred to Lua
2782 * `caption 1`...: name shown on top of tab
2783 * `current_tab`: index of selected tab 1...
2784 * `transparent` (optional): show transparent
2785 * `draw_border` (optional): draw border
2787 ### `box[<X>,<Y>;<W>,<H>;<color>]`
2789 * Simple colored box
2790 * `color` is color specified as a `ColorString`.
2791 If the alpha component is left blank, the box will be semitransparent.
2792 If the color is not specified, the box will use the options specified by
2793 its style. If the color is specified, all styling options will be ignored.
2795 ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2797 * Show a dropdown field
2798 * **Important note**: There are two different operation modes:
2799 1. handle directly on change (only changed dropdown is submitted)
2800 2. read the value on pressing a button (all dropdown values are available)
2801 * `X` and `Y`: position of the dropdown
2802 * `W`: width of the dropdown. Height is automatically chosen with this syntax.
2803 * Fieldname data is transferred to Lua
2804 * Items to be shown in dropdown
2805 * Index of currently selected dropdown item
2806 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2807 event field value for selected items.
2808 * `true`: Selected item index
2809 * `false` (default): Selected item value
2811 ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2813 * Show a dropdown field
2814 * **Important note**: This syntax for dropdowns can only be used with the
2815 new coordinate system.
2816 * **Important note**: There are two different operation modes:
2817 1. handle directly on change (only changed dropdown is submitted)
2818 2. read the value on pressing a button (all dropdown values are available)
2819 * `X` and `Y`: position of the dropdown
2820 * `W` and `H`: width and height of the dropdown
2821 * Fieldname data is transferred to Lua
2822 * Items to be shown in dropdown
2823 * Index of currently selected dropdown item
2824 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2825 event field value for selected items.
2826 * `true`: Selected item index
2827 * `false` (default): Selected item value
2829 ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
2832 * `name` fieldname data is transferred to Lua
2833 * `label` to be shown left of checkbox
2834 * `selected` (optional): `true`/`false`
2835 * **Note**: If the new coordinate system is enabled, checkboxes are
2836 positioned from the center of the checkbox, not the top.
2838 ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
2840 * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
2841 * There are two ways to use it:
2842 1. handle the changed event (only changed scrollbar is available)
2843 2. read the value on pressing a button (all scrollbars are available)
2844 * `orientation`: `vertical`/`horizontal`. Default horizontal.
2845 * Fieldname data is transferred to Lua
2846 * Value of this trackbar is set to (`0`-`1000`) by default
2847 * See also `minetest.explode_scrollbar_event`
2848 (main menu: `core.explode_scrollbar_event`).
2850 ### `scrollbaroptions[opt1;opt2;...]`
2851 * Sets options for all following `scrollbar[]` elements
2853 * Sets scrollbar minimum value, defaults to `0`.
2855 * Sets scrollbar maximum value, defaults to `1000`.
2856 If the max is equal to the min, the scrollbar will be disabled.
2858 * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
2860 * If this is set to a negative number, the value will be reset to `10`.
2862 * Sets scrollbar step value used by page up and page down.
2863 * If this is set to a negative number, the value will be reset to `100`.
2865 * Sets size of the thumb on the scrollbar. Size is calculated in the number of
2866 units the thumb spans out of the range of the scrollbar values.
2867 * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
2868 would span a tenth of the scrollbar space.
2869 * If this is set to zero or less, the value will be reset to `1`.
2870 * `arrows=<show/hide/default>`
2871 * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
2872 when the scrollbar gets too small, but shows them otherwise.
2874 ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
2876 * Show scrollable table using options defined by the previous `tableoptions[]`
2877 * Displays cells as defined by the previous `tablecolumns[]`
2878 * `name`: fieldname sent to server on row select or doubleclick
2879 * `cell 1`...`cell n`: cell contents given in row-major order
2880 * `selected idx`: index of row to be selected within table (first row = `1`)
2881 * See also `minetest.explode_table_event`
2882 (main menu: `core.explode_table_event`).
2884 ### `tableoptions[<opt 1>;<opt 2>;...]`
2886 * Sets options for `table[]`
2888 * default text color (`ColorString`), defaults to `#FFFFFF`
2889 * `background=#RRGGBB`
2890 * table background color (`ColorString`), defaults to `#000000`
2891 * `border=<true/false>`
2892 * should the table be drawn with a border? (default: `true`)
2893 * `highlight=#RRGGBB`
2894 * highlight background color (`ColorString`), defaults to `#466432`
2895 * `highlight_text=#RRGGBB`
2896 * highlight text color (`ColorString`), defaults to `#FFFFFF`
2897 * `opendepth=<value>`
2898 * all subtrees up to `depth < value` are open (default value = `0`)
2899 * only useful when there is a column of type "tree"
2901 ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
2903 * Sets columns for `table[]`
2904 * Types: `text`, `image`, `color`, `indent`, `tree`
2905 * `text`: show cell contents as text
2906 * `image`: cell contents are an image index, use column options to define
2908 * `color`: cell contents are a ColorString and define color of following
2910 * `indent`: cell contents are a number and define indentation of following
2912 * `tree`: same as indent, but user can open and close subtrees
2916 * for `text` and `image`: content alignment within cells.
2917 Available values: `left` (default), `center`, `right`, `inline`
2919 * for `text` and `image`: minimum width in em (default: `0`)
2920 * for `indent` and `tree`: indent width in em (default: `1.5`)
2921 * `padding=<value>`: padding left of the column, in em (default `0.5`).
2922 Exception: defaults to 0 for indent columns
2923 * `tooltip=<value>`: tooltip text (default: empty)
2924 * `image` column options:
2925 * `0=<value>` sets image for image index 0
2926 * `1=<value>` sets image for image index 1
2927 * `2=<value>` sets image for image index 2
2928 * and so on; defined indices need not be contiguous empty or
2929 non-numeric cells are treated as `0`.
2930 * `color` column options:
2931 * `span=<value>`: number of following columns to affect
2932 (default: infinite).
2934 ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2936 * Set the style for the element(s) matching `selector` by name.
2937 * `selector` can be one of:
2938 * `<name>` - An element name. Includes `*`, which represents every element.
2939 * `<name>:<state>` - An element name, a colon, and one or more states.
2940 * `state` is a list of states separated by the `+` character.
2941 * If a state is provided, the style will only take effect when the element is in that state.
2942 * All provided states must be active for the style to apply.
2943 * Note: this **must** be before the element is defined.
2944 * See [Styling Formspecs].
2947 ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2949 * Set the style for the element(s) matching `selector` by type.
2950 * `selector` can be one of:
2951 * `<type>` - An element type. Includes `*`, which represents every element.
2952 * `<type>:<state>` - An element type, a colon, and one or more states.
2953 * `state` is a list of states separated by the `+` character.
2954 * If a state is provided, the style will only take effect when the element is in that state.
2955 * All provided states must be active for the style to apply.
2956 * See [Styling Formspecs].
2958 ### `set_focus[<name>;<force>]`
2960 * Sets the focus to the element with the same `name` parameter.
2961 * **Note**: This element must be placed before the element it focuses.
2962 * `force` (optional, default `false`): By default, focus is not applied for
2963 re-sent formspecs with the same name so that player-set focus is kept.
2964 `true` sets the focus to the specified element for every sent formspec.
2965 * The following elements have the ability to be focused:
2980 Migrating to Real Coordinates
2981 -----------------------------
2983 In the old system, positions included padding and spacing. Padding is a gap between
2984 the formspec window edges and content, and spacing is the gaps between items. For
2985 example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
2986 and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
2987 in the new coordinate system from scratch.
2989 To recreate an old layout with padding, you'll need to pass the positions and sizes
2990 through the following formula to re-introduce padding:
2993 pos = (oldpos + 1)*spacing + padding
2999 You'll need to change the `size[]` tag like this:
3002 size = (oldsize-1)*spacing + padding*2 + 1
3005 A few elements had random offsets in the old system. Here is a table which shows these
3006 offsets when migrating:
3008 | Element | Position | Size | Notes
3009 |---------|------------|---------|-------
3010 | box | +0.3, +0.1 | 0, -0.4 |
3011 | button | | | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
3012 | list | | | Spacing is now 0.25 for both directions, meaning lists will be taller in height
3013 | label | 0, +0.3 | | The first line of text is now positioned centered exactly at the position specified
3018 Formspec elements can be themed using the style elements:
3020 style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
3021 style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
3022 style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
3023 style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
3027 property_name=property_value
3031 style_type[button;bgcolor=#006699]
3032 style[world_delete;bgcolor=red;textcolor=yellow]
3033 button[4,3.95;2.6,1;world_delete;Delete]
3035 A name/type can optionally be a comma separated list of names/types, like so:
3037 world_delete,world_create,world_configure
3040 A `*` type can be used to select every element in the formspec.
3042 Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
3044 world_delete:hovered+pressed
3047 States allow you to apply styles in response to changes in the element, instead of applying at all times.
3049 Setting a property to nothing will reset it to the default value. For example:
3051 style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
3052 style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
3055 ### Supported Element Types
3057 Some types may inherit styles from parent types.
3059 * animated_image, inherits from image
3062 * button_exit, inherits from button
3072 * pwdfield, inherits from field
3078 * vertlabel, inherits from label
3081 ### Valid Properties
3084 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3086 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3087 * Defaults to false in formspec_version version 3 or higher
3088 * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
3089 * Single value (e.g. `#FF0`): All corners/borders.
3090 * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
3091 top and bottom,left and right.
3092 * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
3093 * These work similarly to CSS borders.
3094 * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
3095 * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
3096 * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
3097 negative, the border will extend inside the box, whereas positive extends outside
3098 the box. A width of zero results in no border; this is default.
3099 * button, button_exit, image_button, item_image_button
3100 * alpha - boolean, whether to draw alpha in bgimg. Default true.
3101 * bgcolor - color, sets button tint.
3102 * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
3103 * This is deprecated, use states instead.
3104 * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
3105 * This is deprecated, use states instead.
3106 * bgimg - standard background image. Defaults to none.
3107 * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
3108 * This is deprecated, use states instead.
3109 * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
3110 See background9[] documentation for more details. This property also pads the
3111 button's content when set.
3112 * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
3113 * This is deprecated, use states instead.
3114 * font - Sets font type. This is a comma separated list of options. Valid options:
3115 * Main font type options. These cannot be combined with each other:
3116 * `normal`: Default font
3117 * `mono`: Monospaced font
3118 * Font modification options. If used without a main font type, `normal` is used:
3119 * `bold`: Makes font bold.
3120 * `italic`: Makes font italic.
3122 * font_size - Sets font size. Default is user-set. Can have multiple values:
3123 * `<number>`: Sets absolute font size to `number`.
3124 * `+<number>`/`-<number>`: Offsets default font size by `number` points.
3125 * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
3126 * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
3127 * content_offset - 2d vector, shifts the position of the button's content without resizing it.
3128 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3129 * padding - rect, adds space between the edges of the button and the content. This value is
3130 relative to bgimg_middle.
3131 * sound - a sound to be played when triggered.
3132 * textcolor - color, default white.
3134 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3135 * sound - a sound to be played when triggered.
3137 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3138 * sound - a sound to be played when the entry is changed.
3139 * field, pwdfield, textarea
3140 * border - set to false to hide the textbox background and border. Default true.
3141 * font - Sets font type. See button `font` property for more information.
3142 * font_size - Sets font size. See button `font_size` property for more information.
3143 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3144 * textcolor - color. Default white.
3146 * bgcolor - color, sets background color.
3147 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3148 * Default to false in formspec_version version 3 or higher
3150 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3151 * Default to false in formspec_version version 3 or higher
3153 * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
3155 * font - Sets font type. See button `font` property for more information.
3156 * font_size - Sets font size. See button `font_size` property for more information.
3157 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3159 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3160 * size - 2d vector, sets the size of inventory slots in coordinates.
3161 * spacing - 2d vector, sets the space between inventory slots in coordinates.
3162 * image_button (additional properties)
3163 * fgimg - standard image. Defaults to none.
3164 * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
3165 * This is deprecated, use states instead.
3166 * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
3167 * This is deprecated, use states instead.
3168 * fgimg_middle - Makes the fgimg textures render in 9-sliced mode and defines the middle rect.
3169 See background9[] documentation for more details.
3170 * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
3171 * sound - a sound to be played when triggered.
3173 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3175 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3176 * sound - a sound to be played when a different tab is selected.
3177 * textcolor - color. Default white.
3179 * font - Sets font type. See button `font` property for more information.
3180 * font_size - Sets font size. See button `font_size` property for more information.
3181 * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3186 * default - Equivalent to providing no states
3187 * button, button_exit, image_button, item_image_button
3188 * hovered - Active when the mouse is hovering over the element
3189 * pressed - Active when the button is pressed
3194 Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
3195 The markup language is currently unstable and subject to change. Use with caution.
3196 Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
3197 Tags can have attributes, in that case, attributes are in the opening tag in
3198 form of a key/value separated with equal signs. Attribute values should not be quoted.
3200 If you want to insert a literal greater-than sign or a backslash into the text,
3201 you must escape it by preceding it with a backslash.
3203 These are the technically basic tags but see below for usual tags. Base tags are:
3205 `<style color=... font=... size=...>...</style>`
3207 Changes the style of the text.
3209 * `color`: Text color. Given color is a `colorspec`.
3210 * `size`: Text size.
3211 * `font`: Text font (`mono` or `normal`).
3213 `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
3218 * `background`: Text background, a `colorspec` or `none`.
3219 * `margin`: Page margins in pixel.
3220 * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
3222 Inheriting styles (affects child elements):
3223 * `color`: Default text color. Given color is a `colorspec`.
3224 * `hovercolor`: Color of <action> tags when mouse is over.
3225 * `size`: Default text size.
3226 * `font`: Default text font (`mono` or `normal`).
3227 * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
3229 This tag needs to be placed only once as it changes the global settings of the
3230 text. Anyway, if several tags are placed, each changed will be made in the order
3233 `<tag name=... color=... hovercolor=... font=... size=...>`
3235 Defines or redefines tag style. This can be used to define new tags.
3236 * `name`: Name of the tag to define or change.
3237 * `color`: Text color. Given color is a `colorspec`.
3238 * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
3239 * `size`: Text size.
3240 * `font`: Text font (`mono` or `normal`).
3242 Following tags are the usual tags for text layout. They are defined by default.
3243 Other tags can be added using `<tag ...>` tag.
3245 `<normal>...</normal>`: Normal size text
3247 `<big>...</big>`: Big text
3249 `<bigger>...</bigger>`: Bigger text
3251 `<center>...</center>`: Centered text
3253 `<left>...</left>`: Left-aligned text
3255 `<right>...</right>`: Right-aligned text
3257 `<justify>...</justify>`: Justified text
3259 `<mono>...</mono>`: Monospaced font
3261 `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
3263 `<action name=...>...</action>`
3265 Make that text a clickable text triggering an action.
3267 * `name`: Name of the action (mandatory).
3269 When clicked, the formspec is send to the server. The value of the text field
3270 sent to `on_player_receive_fields` will be "action:" concatenated to the action
3273 `<img name=... float=... width=... height=...>`
3275 Draws an image which is present in the client media cache.
3277 * `name`: Name of the texture (mandatory).
3278 * `float`: If present, makes the image floating (`left` or `right`).
3279 * `width`: Force image width instead of taking texture width.
3280 * `height`: Force image height instead of taking texture height.
3282 If only width or height given, texture aspect is kept.
3284 `<item name=... float=... width=... height=... rotate=...>`
3286 Draws an item image.
3288 * `name`: Item string of the item to draw (mandatory).
3289 * `float`: If present, makes the image floating (`left` or `right`).
3290 * `width`: Item image width.
3291 * `height`: Item image height.
3292 * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
3293 rotation speeds in percent of standard speed (-1000 to 1000). Works only if
3294 `inventory_items_animations` is set to true.
3295 * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
3296 X, Y and Z being angles around each three axes. Works only if
3297 `inventory_items_animations` is set to true.
3305 * `"context"`: Selected node metadata (deprecated: `"current_name"`)
3306 * `"current_player"`: Player to whom the menu is shown
3307 * `"player:<name>"`: Any player
3308 * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
3309 * `"detached:<name>"`: A detached inventory
3311 Player Inventory lists
3312 ----------------------
3314 * `main`: list containing the default inventory
3315 * `craft`: list containing the craft input
3316 * `craftpreview`: list containing the craft prediction
3317 * `craftresult`: list containing the crafted output
3318 * `hand`: list containing an override for the empty hand
3319 * Is not created automatically, use `InvRef:set_size`
3320 * Is only used to enhance the empty hand's tool capabilities
3328 `#RGB` defines a color in hexadecimal format.
3330 `#RGBA` defines a color in hexadecimal format and alpha channel.
3332 `#RRGGBB` defines a color in hexadecimal format.
3334 `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
3336 Named colors are also supported and are equivalent to
3337 [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
3338 To specify the value of the alpha channel, append `#A` or `#AA` to the end of
3339 the color name (e.g. `colorname#08`).
3344 A ColorSpec specifies a 32-bit color. It can be written in any of the following
3347 * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
3348 * `colorspec = {a=255, r=0, g=255, b=0}`
3349 * numerical form: The raw integer value of an ARGB8 quad:
3350 * `colorspec = 0xFF00FF00`
3351 * string form: A ColorString (defined above):
3352 * `colorspec = "green"`
3360 Most text can contain escape sequences, that can for example color the text.
3361 There are a few exceptions: tab headers, dropdowns and vertical labels can't.
3362 The following functions provide escape sequences:
3364 * `minetest.get_color_escape_sequence(color)`:
3365 * `color` is a ColorString
3366 * The escape sequence sets the text color to `color`
3367 * `minetest.colorize(color, message)`:
3369 `minetest.get_color_escape_sequence(color) ..
3371 minetest.get_color_escape_sequence("#ffffff")`
3372 * `minetest.get_background_escape_sequence(color)`
3373 * `color` is a ColorString
3374 * The escape sequence sets the background of the whole text element to
3375 `color`. Only defined for item descriptions and tooltips.
3376 * `minetest.strip_foreground_colors(str)`
3377 * Removes foreground colors added by `get_color_escape_sequence`.
3378 * `minetest.strip_background_colors(str)`
3379 * Removes background colors added by `get_background_escape_sequence`.
3380 * `minetest.strip_colors(str)`
3381 * Removes all color escape sequences.
3389 Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
3390 and has a class to represent them (`vector.*`), which this chapter is about.
3391 For details on what a spatial vectors is, please refer to Wikipedia:
3392 https://en.wikipedia.org/wiki/Euclidean_vector.
3394 Spatial vectors are used for various things, including, but not limited to:
3396 * any 3D spatial vector (x/y/z-directions)
3397 * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
3398 meaning here. Therefore, most vector operations make no sense in this use case.)
3400 Note that they are *not* used for:
3402 * n-dimensional vectors where n is not 3 (ie. n=2)
3403 * arrays of the form `{num, num, num}`
3405 The API documentation may refer to spatial vectors, as produced by `vector.new`,
3406 by any of the following notations:
3408 * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
3409 * `vector.new(x, y, z)`
3410 * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
3415 Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
3416 Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
3417 Note: Those old-style vectors can still be found in old mod code. Hence, mod and
3418 engine APIs still need to be able to cope with them in many places.
3420 Manually constructed tables are deprecated and highly discouraged. This interface
3421 should be used to ensure seamless compatibility between mods and the Minetest API.
3422 This is especially important to callback function parameters and functions overwritten
3424 Also, though not likely, the internal implementation of a vector might change in
3426 In your own code, or if you define your own API, you can, of course, still use
3427 other representations of vectors.
3429 Vectors provided by API functions will provide an instance of this class if not
3430 stated otherwise. Mods should adapt this for convenience reasons.
3432 Special properties of the class
3433 -------------------------------
3435 Vectors can be indexed with numbers and allow method and operator syntax.
3437 All these forms of addressing a vector `v` are valid:
3438 `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
3439 Note: Prefer letter over number indexing for performance and compatibility reasons.
3441 Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
3442 the same as `vector.foo(v, ...)`, apart from deprecated functionality.
3444 `tostring` is defined for vectors, see `vector.to_string`.
3446 The metatable that is used for vectors can be accessed via `vector.metatable`.
3449 All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
3450 Returned vectors always have a metatable set.
3452 Common functions and methods
3453 ----------------------------
3455 For the following functions (and subchapters),
3456 `v`, `v1`, `v2` are vectors,
3457 `p1`, `p2` are position vectors,
3458 `s` is a scalar (a number),
3459 vectors are written like this: `(x, y, z)`:
3461 * `vector.new([a[, b, c]])`:
3462 * Returns a new vector `(a, b, c)`.
3463 * Deprecated: `vector.new()` does the same as `vector.zero()` and
3464 `vector.new(v)` does the same as `vector.copy(v)`
3466 * Returns a new vector `(0, 0, 0)`.
3468 * Returns a copy of the vector `v`.
3469 * `vector.from_string(s[, init])`:
3470 * Returns `v, np`, where `v` is a vector read from the given string `s` and
3471 `np` is the next position in the string after the vector.
3472 * Returns `nil` on failure.
3473 * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
3474 spaces, leaving away commas and adding an additional comma to the end
3476 * `init`: If given starts looking for the vector at this string index.
3477 * `vector.to_string(v)`:
3478 * Returns a string of the form `"(x, y, z)"`.
3479 * `tostring(v)` does the same.
3480 * `vector.direction(p1, p2)`:
3481 * Returns a vector of length 1 with direction `p1` to `p2`.
3482 * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
3483 * `vector.distance(p1, p2)`:
3484 * Returns zero or a positive number, the distance between `p1` and `p2`.
3485 * `vector.length(v)`:
3486 * Returns zero or a positive number, the length of vector `v`.
3487 * `vector.normalize(v)`:
3488 * Returns a vector of length 1 with direction of vector `v`.
3489 * If `v` has zero length, returns `(0, 0, 0)`.
3490 * `vector.floor(v)`:
3491 * Returns a vector, each dimension rounded down.
3492 * `vector.round(v)`:
3493 * Returns a vector, each dimension rounded to nearest integer.
3494 * At a multiple of 0.5, rounds away from zero.
3495 * `vector.apply(v, func)`:
3496 * Returns a vector where the function `func` has been applied to each
3498 * `vector.combine(v, w, func)`:
3499 * Returns a vector where the function `func` has combined both components of `v` and `w`
3501 * `vector.equals(v1, v2)`:
3502 * Returns a boolean, `true` if the vectors are identical.
3503 * `vector.sort(v1, v2)`:
3504 * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
3505 * `vector.angle(v1, v2)`:
3506 * Returns the angle between `v1` and `v2` in radians.
3507 * `vector.dot(v1, v2)`:
3508 * Returns the dot product of `v1` and `v2`.
3509 * `vector.cross(v1, v2)`:
3510 * Returns the cross product of `v1` and `v2`.
3511 * `vector.offset(v, x, y, z)`:
3512 * Returns the sum of the vectors `v` and `(x, y, z)`.
3513 * `vector.check(v)`:
3514 * Returns a boolean value indicating whether `v` is a real vector, eg. created
3515 by a `vector.*` function.
3516 * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
3518 For the following functions `x` can be either a vector or a number:
3520 * `vector.add(v, x)`:
3522 * If `x` is a vector: Returns the sum of `v` and `x`.
3523 * If `x` is a number: Adds `x` to each component of `v`.
3524 * `vector.subtract(v, x)`:
3526 * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
3527 * If `x` is a number: Subtracts `x` from each component of `v`.
3528 * `vector.multiply(v, s)`:
3529 * Returns a scaled vector.
3530 * Deprecated: If `s` is a vector: Returns the Schur product.
3531 * `vector.divide(v, s)`:
3532 * Returns a scaled vector.
3533 * Deprecated: If `s` is a vector: Returns the Schur quotient.
3538 Operators can be used if all of the involved vectors have metatables:
3540 * Returns whether `v1` and `v2` are identical.
3542 * Returns the additive inverse of v.
3544 * Returns the sum of both vectors.
3545 * Note: `+` can not be used together with scalars.
3547 * Returns the difference of `v1` subtracted by `v2`.
3548 * Note: `-` can not be used together with scalars.
3549 * `v * s` or `s * v`:
3550 * Returns `v` scaled by `s`.
3552 * Returns `v` scaled by `1 / s`.
3554 Rotation-related functions
3555 --------------------------
3557 For the following functions `a` is an angle in radians and `r` is a rotation
3558 vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
3561 * `vector.rotate(v, r)`:
3562 * Applies the rotation `r` to `v` and returns the result.
3563 * `vector.rotate(vector.new(0, 0, 1), r)` and
3564 `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
3565 forward and up relative to an entity's rotation `r`.
3566 * `vector.rotate_around_axis(v1, v2, a)`:
3567 * Returns `v1` rotated around axis `v2` by `a` radians according to
3568 the right hand rule.
3569 * `vector.dir_to_rotation(direction[, up])`:
3570 * Returns a rotation vector for `direction` pointing forward using `up`
3572 * If `up` is omitted, the roll of the returned vector defaults to zero.
3573 * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
3578 There are more helper functions involving vectors, but they are listed elsewhere
3579 because they only work on specific sorts of vectors or involve things that are not
3584 * `minetest.hash_node_position` (Only works on node positions.)
3585 * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
3593 * `dump2(obj, name, dumped)`: returns a string which makes `obj`
3594 human-readable, handles reference loops.
3595 * `obj`: arbitrary variable
3596 * `name`: string, default: `"_"`
3597 * `dumped`: table, default: `{}`
3598 * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
3599 * `obj`: arbitrary variable
3600 * `dumped`: table, default: `{}`
3601 * `math.hypot(x, y)`
3602 * Get the hypotenuse of a triangle with legs x and y.
3603 Useful for distance calculation.
3604 * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
3605 * Get the sign of a number.
3606 * tolerance: number, default: `0.0`
3607 * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
3609 * `math.factorial(x)`: returns the factorial of `x`
3610 * `math.round(x)`: Returns `x` rounded to the nearest integer.
3611 * At a multiple of 0.5, rounds away from zero.
3612 * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
3613 * `separator`: string, default: `","`
3614 * `include_empty`: boolean, default: `false`
3615 * `max_splits`: number, if it's negative, splits aren't limited,
3617 * `sep_is_pattern`: boolean, it specifies whether separator is a plain
3618 string or a pattern (regex), default: `false`
3619 * e.g. `"a,b":split","` returns `{"a","b"}`
3620 * `string:trim()`: returns the string without whitespace pre- and suffixes
3621 * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
3622 * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
3623 * Adds newlines to the string to keep it within the specified character
3625 * Note that the returned lines may be longer than the limit since it only
3626 splits at word borders.
3627 * `limit`: number, maximal amount of characters in one line
3628 * `as_table`: boolean, if set to true, a table of lines instead of a string
3629 is returned, default: `false`
3630 * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
3631 * `pos`: table {x=X, y=Y, z=Z}
3632 * Converts the position `pos` to a human-readable, printable string
3633 * `decimal_places`: number, if specified, the x, y and z values of
3634 the position are rounded to the given decimal place.
3635 * `minetest.string_to_pos(string)`: returns a position or `nil`
3636 * Same but in reverse.
3637 * If the string can't be parsed to a position, nothing is returned.
3638 * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`:
3639 * returns two positions
3640 * Converts a string representing an area box into two positions
3641 * X1, Y1, ... Z2 are coordinates
3642 * `relative_to`: Optional. If set to a position, each coordinate
3643 can use the tilde notation for relative positions
3644 * Tilde notation: "~": Relative coordinate
3645 "~<number>": Relative coordinate plus <number>
3646 * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
3647 returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
3648 * `minetest.formspec_escape(string)`: returns a string
3649 * escapes the characters "[", "]", "\", "," and ";", which can not be used
3651 * `minetest.is_yes(arg)`
3652 * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
3653 * `minetest.is_nan(arg)`
3654 * returns true when the passed number represents NaN.
3655 * `minetest.get_us_time()`
3656 * returns time with microsecond precision. May not return wall time.
3657 * `table.copy(table)`: returns a table
3658 * returns a deep copy of `table`
3659 * `table.indexof(list, val)`: returns the smallest numerical index containing
3660 the value `val` in the table `list`. Non-numerical indices are ignored.
3661 If `val` could not be found, `-1` is returned. `list` must not have
3663 * `table.insert_all(table, other_table)`:
3664 * Appends all values in `other_table` to `table` - uses `#table + 1` to
3666 * `table.key_value_swap(t)`: returns a table with keys and values swapped
3667 * If multiple keys in `t` map to the same value, it is unspecified which
3668 value maps to that key.
3669 * `table.shuffle(table, [from], [to], [random_func])`:
3670 * Shuffles elements `from` to `to` in `table` in place
3671 * `from` defaults to `1`
3672 * `to` defaults to `#table`
3673 * `random_func` defaults to `math.random`. This function receives two
3674 integers as arguments and should return a random integer inclusively
3676 * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
3678 * returns the exact position on the surface of a pointed node
3679 * `minetest.get_tool_wear_after_use(uses [, initial_wear])`
3680 * Simulates a tool being used once and returns the added wear,
3681 such that, if only this function is used to calculate wear,
3682 the tool will break exactly after `uses` times of uses
3683 * `uses`: Number of times the tool can be used
3684 * `initial_wear`: The initial wear the tool starts with (default: 0)
3685 * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
3686 Simulates an item that digs a node.
3687 Returns a table with the following fields:
3688 * `diggable`: `true` if node can be dug, `false` otherwise.
3689 * `time`: Time it would take to dig the node.
3690 * `wear`: How much wear would be added to the tool (ignored for non-tools).
3691 `time` and `wear` are meaningless if node's not diggable
3693 * `groups`: Table of the node groups of the node that would be dug
3694 * `tool_capabilities`: Tool capabilities table of the item
3695 * `wear`: Amount of wear the tool starts with (default: 0)
3696 * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
3697 Simulates an item that punches an object.
3698 Returns a table with the following fields:
3699 * `hp`: How much damage the punch would cause (between -65535 and 65535).
3700 * `wear`: How much wear would be added to the tool (ignored for non-tools).
3702 * `groups`: Damage groups of the object
3703 * `tool_capabilities`: Tool capabilities table of the item
3704 * `time_from_last_punch`: time in seconds since last punch action
3705 * `wear`: Amount of wear the item starts with (default: 0)
3713 Texts can be translated client-side with the help of `minetest.translate` and
3716 Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
3717 to generate and update translation files automatically from the Lua source.
3719 Translating a string
3720 --------------------
3722 Two functions are provided to translate strings: `minetest.translate` and
3723 `minetest.get_translator`.
3725 * `minetest.get_translator(textdomain)` is a simple wrapper around
3726 `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
3727 equivalent to `minetest.translate(textdomain, str, ...)`.
3728 It is intended to be used in the following way, so that it avoids verbose
3729 repetitions of `minetest.translate`:
3731 local S = minetest.get_translator(textdomain)
3734 As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
3736 * `minetest.translate(textdomain, str, ...)` translates the string `str` with
3737 the given `textdomain` for disambiguation. The textdomain must match the
3738 textdomain specified in the translation file in order to get the string
3739 translated. This can be used so that a string is translated differently in
3741 It is advised to use the name of the mod as textdomain whenever possible, to
3742 avoid clashes with other mods.
3743 This function must be given a number of arguments equal to the number of
3744 arguments the translated string expects.
3745 Arguments are literal strings -- they will not be translated, so if you want
3746 them to be, they need to come as outputs of `minetest.translate` as well.
3748 For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
3749 by the translation of "Red". We can do the following:
3751 local S = minetest.get_translator()
3752 S("@1 Wool", S("Red"))
3754 This will be displayed as "Red Wool" on old clients and on clients that do
3755 not have localization enabled. However, if we have for instance a translation
3756 file named `wool.fr.tr` containing the following:
3761 this will be displayed as "Laine Rouge" on clients with a French locale.
3763 Operations on translated strings
3764 --------------------------------
3766 The output of `minetest.translate` is a string, with escape sequences adding
3767 additional information to that string so that it can be translated on the
3768 different clients. In particular, you can't expect operations like string.length
3769 to work on them like you would expect them to, or string.gsub to work in the
3770 expected manner. However, string concatenation will still work as expected
3771 (note that you should only use this for things like formspecs; do not translate
3772 sentences by breaking them into parts; arguments should be used instead), and
3773 operations such as `minetest.colorize` which are also concatenation.
3775 Translation file format
3776 -----------------------
3778 A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
3779 it corresponds to. It must be put into the `locale` subdirectory of the mod.
3780 The file should be a text file, with the following format:
3782 * Lines beginning with `# textdomain:` (the space is significant) can be used
3783 to specify the text domain of all following translations in the file.
3784 * All other empty lines or lines beginning with `#` are ignored.
3785 * Other lines should be in the format `original=translated`. Both `original`
3786 and `translated` can contain escape sequences beginning with `@` to insert
3787 arguments, literal `@`, `=` or newline (See [Escapes] below).
3788 There must be no extraneous whitespace around the `=` or at the beginning or
3789 the end of the line.
3794 Strings that need to be translated can contain several escapes, preceded by `@`.
3796 * `@@` acts as a literal `@`.
3797 * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
3798 string that will be inlined when translated. Due to how translations are
3799 implemented, the original translation string **must** have its arguments in
3800 increasing order, without gaps or repetitions, starting from 1.
3801 * `@=` acts as a literal `=`. It is not required in strings given to
3802 `minetest.translate`, but is in translation files to avoid being confused
3803 with the `=` separating the original from the translation.
3804 * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
3805 As with `@=`, this escape is not required in strings given to
3806 `minetest.translate`, but is in translation files.
3807 * `@n` acts as a literal newline as well.
3809 Server side translations
3810 ------------------------
3812 On some specific cases, server translation could be useful. For example, filter
3813 a list on labels and send results to client. A method is supplied to achieve
3816 `minetest.get_translated_string(lang_code, string)`: Translates `string` using
3817 translations for `lang_code` language. It gives the same result as if the string
3818 was translated by the client.
3820 The `lang_code` to use for a given player can be retrieved from
3821 the table returned by `minetest.get_player_information(name)`.
3823 IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
3824 You do not need to use this to get translated strings to show up on the client.
3829 Perlin noise creates a continuously-varying value depending on the input values.
3830 Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
3831 The result is used during map generation to create the terrain shape, vary heat
3832 and humidity to distribute biomes, vary the density of decorations or vary the
3835 Structure of perlin noise
3836 -------------------------
3838 An 'octave' is a simple noise generator that outputs a value between -1 and 1.
3839 The smooth wavy noise it generates has a single characteristic scale, almost
3840 like a 'wavelength', so on its own does not create fine detail.
3841 Due to this perlin noise combines several octaves to create variation on
3842 multiple scales. Each additional octave has a smaller 'wavelength' than the
3845 This combination results in noise varying very roughly between -2.0 and 2.0 and
3846 with an average value of 0.0, so `scale` and `offset` are then used to multiply
3847 and offset the noise variation.
3849 The final perlin noise variation is created as follows:
3851 noise = offset + scale * (octave1 +
3852 octave2 * persistence +
3853 octave3 * persistence ^ 2 +
3854 octave4 * persistence ^ 3 +
3860 Noise Parameters are commonly called `NoiseParams`.
3864 After the multiplication by `scale` this is added to the result and is the final
3865 step in creating the noise value.
3866 Can be positive or negative.
3870 Once all octaves have been combined, the result is multiplied by this.
3871 Can be positive or negative.
3875 For octave1, this is roughly the change of input value needed for a very large
3876 variation in the noise value generated by octave1. It is almost like a
3877 'wavelength' for the wavy noise variation.
3878 Each additional octave has a 'wavelength' that is smaller than the previous
3879 octave, to create finer detail. `spread` will therefore roughly be the typical
3880 size of the largest structures in the final noise variation.
3882 `spread` is a vector with values for x, y, z to allow the noise variation to be
3883 stretched or compressed in the desired axes.
3884 Values are positive numbers.
3888 This is a whole number that determines the entire pattern of the noise
3889 variation. Altering it enables different noise patterns to be created.
3890 With other parameters equal, different seeds produce different noise patterns
3891 and identical seeds produce identical noise patterns.
3893 For this parameter you can randomly choose any whole number. Usually it is
3894 preferable for this to be different from other seeds, but sometimes it is useful
3895 to be able to create identical noise patterns.
3897 In some noise APIs the world seed is added to the seed specified in noise
3898 parameters. This is done to make the resulting noise pattern vary in different
3899 worlds, and be 'world-specific'.
3903 The number of simple noise generators that are combined.
3904 A whole number, 1 or more.
3905 Each additional octave adds finer detail to the noise but also increases the
3906 noise calculation load.
3907 3 is a typical minimum for a high quality, complex and natural-looking noise
3908 variation. 1 octave has a slight 'gridlike' appearance.
3910 Choose the number of octaves according to the `spread` and `lacunarity`, and the
3911 size of the finest detail you require. For example:
3912 if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
3913 nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
3914 512, 256, 128, 64, 32, 16 nodes.
3915 Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
3919 Each additional octave has an amplitude that is the amplitude of the previous
3920 octave multiplied by `persistence`, to reduce the amplitude of finer details,
3921 as is often helpful and natural to do so.
3922 Since this controls the balance of fine detail to large-scale detail
3923 `persistence` can be thought of as the 'roughness' of the noise.
3925 A positive or negative non-zero number, often between 0.3 and 1.0.
3926 A common medium value is 0.5, such that each octave has half the amplitude of
3927 the previous octave.
3928 This may need to be tuned when altering `lacunarity`; when doing so consider
3929 that a common medium value is 1 / lacunarity.
3933 Each additional octave has a 'wavelength' that is the 'wavelength' of the
3934 previous octave multiplied by 1 / lacunarity, to create finer detail.
3935 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
3937 A positive number no smaller than 1.0.
3938 Values below 2.0 create higher quality noise at the expense of requiring more
3939 octaves to cover a paticular range of 'wavelengths'.
3943 Leave this field unset for no special handling.
3944 Currently supported are `defaults`, `eased` and `absvalue`:
3948 Specify this if you would like to keep auto-selection of eased/not-eased while
3949 specifying some other flags.
3953 Maps noise gradient values onto a quintic S-curve before performing
3954 interpolation. This results in smooth, rolling noise.
3955 Disable this (`noeased`) for sharp-looking noise with a slightly gridded
3957 If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
3959 Easing a 3D noise significantly increases the noise calculation load, so use
3964 The absolute value of each octave's noise variation is used when combining the
3965 octaves. The final perlin noise variation is created as follows:
3967 noise = offset + scale * (abs(octave1) +
3968 abs(octave2) * persistence +
3969 abs(octave3) * persistence ^ 2 +
3970 abs(octave4) * persistence ^ 3 +
3975 For 2D or 3D perlin noise or perlin noise maps:
3980 spread = {x = 500, y = 500, z = 500},
3985 flags = "defaults, absvalue",
3988 For 2D noise the Z component of `spread` is still defined but is ignored.
3989 A single noise parameter table can be used for 2D or 3D noise.
4000 These tell in what manner the ore is generated.
4002 All default ores are of the uniformly-distributed scatter type.
4006 Randomly chooses a location and generates a cluster of ore.
4008 If `noise_params` is specified, the ore will be placed if the 3D perlin noise
4009 at that point is greater than the `noise_threshold`, giving the ability to
4010 create a non-equal distribution of ore.
4014 Creates a sheet of ore in a blob shape according to the 2D perlin noise
4015 described by `noise_params` and `noise_threshold`. This is essentially an
4016 improved version of the so-called "stratus" ore seen in some unofficial mods.
4018 This sheet consists of vertical columns of uniform randomly distributed height,
4019 varying between the inclusive range `column_height_min` and `column_height_max`.
4020 If `column_height_min` is not specified, this parameter defaults to 1.
4021 If `column_height_max` is not specified, this parameter defaults to `clust_size`
4022 for reverse compatibility. New code should prefer `column_height_max`.
4024 The `column_midpoint_factor` parameter controls the position of the column at
4025 which ore emanates from.
4026 If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
4027 equally starting from each direction.
4028 `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
4029 this parameter is not specified, the default is 0.5.
4031 The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
4036 Creates a sheet of ore in a cloud-like puff shape.
4038 As with the `sheet` ore type, the size and shape of puffs are described by
4039 `noise_params` and `noise_threshold` and are placed at random vertical
4040 positions within the currently generated chunk.
4042 The vertical top and bottom displacement of each puff are determined by the
4043 noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
4047 Creates a deformed sphere of ore according to 3d perlin noise described by
4048 `noise_params`. The maximum size of the blob is `clust_size`, and
4049 `clust_scarcity` has the same meaning as with the `scatter` type.
4053 Creates veins of ore varying in density by according to the intersection of two
4054 instances of 3d perlin noise with different seeds, both described by
4057 `random_factor` varies the influence random chance has on placement of an ore
4058 inside the vein, which is `1` by default. Note that modifying this parameter
4059 may require adjusting `noise_threshold`.
4061 The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
4064 This ore type is difficult to control since it is sensitive to small changes.
4065 The following is a decent set of parameters to work from:
4070 spread = {x=200, y=200, z=200},
4077 noise_threshold = 1.6
4079 **WARNING**: Use this ore type *very* sparingly since it is ~200x more
4080 computationally expensive than any other ore.
4084 Creates a single undulating ore stratum that is continuous across mapchunk
4085 borders and horizontally spans the world.
4087 The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
4088 the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
4089 defines the stratum's vertical thickness (in units of nodes). Due to being
4090 continuous across mapchunk borders the stratum's vertical thickness is
4093 If the noise parameter `noise_params` is omitted the ore will occur from y_min
4094 to y_max in a simple horizontal stratum.
4096 A parameter `stratum_thickness` can be provided instead of the noise parameter
4097 `np_stratum_thickness`, to create a constant thickness.
4099 Leaving out one or both noise parameters makes the ore generation less
4100 intensive, useful when adding multiple strata.
4102 `y_min` and `y_max` define the limits of the ore generation and for performance
4103 reasons should be set as close together as possible but without clipping the
4104 stratum's Y variation.
4106 Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
4107 solid-ore stratum would require a `clust_scarcity` of 1.
4109 The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
4110 `random_factor` are ignored by this ore type.
4115 See section [Flag Specifier Format].
4117 Currently supported flags:
4118 `puff_cliffs`, `puff_additive_composition`.
4122 If set, puff ore generation will not taper down large differences in
4123 displacement when approaching the edge of a puff. This flag has no effect for
4124 ore types other than `puff`.
4126 ### `puff_additive_composition`
4128 By default, when noise described by `np_puff_top` or `np_puff_bottom` results
4129 in a negative displacement, the sub-column at that point is not generated. With
4130 this attribute set, puff ore generation will instead generate the absolute
4131 difference in noise displacement values. This flag has no effect for ore types
4140 The varying types of decorations that can be placed.
4145 Creates a 1 times `H` times 1 column of a specified node (or a random node from
4146 a list, if a decoration list is specified). Can specify a certain node it must
4147 spawn next to, such as water or lava, for example. Can also generate a
4148 decoration of random height between a specified lower and upper bound.
4149 This type of decoration is intended for placement of grass, flowers, cacti,
4150 papyri, waterlilies and so on.
4155 Copies a box of `MapNodes` from a specified schematic file (or raw description).
4156 Can specify a probability of a node randomly appearing when placed.
4157 This decoration type is intended to be used for multi-node sized discrete
4158 structures, such as trees, cave spikes, rocks, and so on.
4167 --------------------
4169 A schematic specifier identifies a schematic by either a filename to a
4170 Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
4171 in the form of a table. This table specifies the following fields:
4173 * The `size` field is a 3D vector containing the dimensions of the provided
4174 schematic. (required field)
4175 * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
4176 sets the probability of a particular horizontal slice of the schematic being
4177 placed. (optional field)
4178 `ypos` = 0 for the lowest horizontal slice of a schematic.
4179 The default of `prob` is 255.
4180 * The `data` field is a flat table of MapNode tables making up the schematic,
4181 in the order of `[z [y [x]]]`. (required field)
4182 Each MapNode table contains:
4183 * `name`: the name of the map node to place (required)
4184 * `prob` (alias `param1`): the probability of this node being placed
4186 * `param2`: the raw param2 value of the node being placed onto the map
4188 * `force_place`: boolean representing if the node should forcibly overwrite
4189 any previous contents (default: false)
4191 About probability values:
4193 * A probability value of `0` or `1` means that node will never appear
4195 * A probability value of `254` or `255` means the node will always appear
4197 * If the probability value `p` is greater than `1`, then there is a
4198 `(p / 256 * 100)` percent chance that node will appear when the schematic is
4201 Schematic attributes
4202 --------------------
4204 See section [Flag Specifier Format].
4206 Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
4209 * `place_center_x`: Placement of this decoration is centered along the X axis.
4210 * `place_center_y`: Placement of this decoration is centered along the Y axis.
4211 * `place_center_z`: Placement of this decoration is centered along the Z axis.
4212 * `force_placement`: Schematic nodes other than "ignore" will replace existing
4218 Lua Voxel Manipulator
4219 =====================
4224 VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
4225 facility. The purpose of this object is for fast, low-level, bulk access to
4226 reading and writing Map content. As such, setting map nodes through VoxelManip
4227 will lack many of the higher level features and concepts you may be used to
4228 with other methods of setting nodes. For example, nodes will not have their
4229 construction and destruction callbacks run, and no rollback information is
4232 It is important to note that VoxelManip is designed for speed, and *not* ease
4233 of use or flexibility. If your mod requires a map manipulation facility that
4234 will handle 100% of all edge cases, or the use of high level node placement
4235 features, perhaps `minetest.set_node()` is better suited for the job.
4237 In addition, VoxelManip might not be faster, or could even be slower, for your
4238 specific use case. VoxelManip is most effective when setting large areas of map
4239 at once - for example, if only setting a 3x3x3 node area, a
4240 `minetest.set_node()` loop may be more optimal. Always profile code using both
4241 methods of map manipulation to determine which is most appropriate for your
4244 A recent simple test of setting cubic areas showed that `minetest.set_node()`
4245 is faster than a VoxelManip for a 3x3x3 node cube or smaller.
4250 A VoxelManip object can be created any time using either:
4251 `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
4253 If the optional position parameters are present for either of these routines,
4254 the specified region will be pre-loaded into the VoxelManip object on creation.
4255 Otherwise, the area of map you wish to manipulate must first be loaded into the
4256 VoxelManip object using `VoxelManip:read_from_map()`.
4258 Note that `VoxelManip:read_from_map()` returns two position vectors. The region
4259 formed by these positions indicate the minimum and maximum (respectively)
4260 positions of the area actually loaded in the VoxelManip, which may be larger
4261 than the area requested. For convenience, the loaded area coordinates can also
4262 be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
4264 Now that the VoxelManip object is populated with map data, your mod can fetch a
4265 copy of this data using either of two methods. `VoxelManip:get_node_at()`,
4266 which retrieves an individual node in a MapNode formatted table at the position
4267 requested is the simplest method to use, but also the slowest.
4269 Nodes in a VoxelManip object may also be read in bulk to a flat array table
4272 * `VoxelManip:get_data()` for node content (in Content ID form, see section
4274 * `VoxelManip:get_light_data()` for node light levels, and
4275 * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
4277 See section [Flat array format] for more details.
4279 It is very important to understand that the tables returned by any of the above
4280 three functions represent a snapshot of the VoxelManip's internal state at the
4281 time of the call. This copy of the data will not magically update itself if
4282 another function modifies the internal VoxelManip state.
4283 Any functions that modify a VoxelManip's contents work on the VoxelManip's
4284 internal state unless otherwise explicitly stated.
4286 Once the bulk data has been edited to your liking, the internal VoxelManip
4287 state can be set using:
4289 * `VoxelManip:set_data()` for node content (in Content ID form, see section
4291 * `VoxelManip:set_light_data()` for node light levels, and
4292 * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
4294 The parameter to each of the above three functions can use any table at all in
4295 the same flat array format as produced by `get_data()` etc. and is not required
4296 to be a table retrieved from `get_data()`.
4298 Once the internal VoxelManip state has been modified to your liking, the
4299 changes can be committed back to the map by calling `VoxelManip:write_to_map()`
4301 ### Flat array format
4304 `Nx = p2.X - p1.X + 1`,
4305 `Ny = p2.Y - p1.Y + 1`, and
4306 `Nz = p2.Z - p1.Z + 1`.
4308 Then, for a loaded region of p1..p2, this array ranges from `1` up to and
4309 including the value of the expression `Nx * Ny * Nz`.
4311 Positions offset from p1 are present in the array with the format of:
4314 (0, 0, 0), (1, 0, 0), (2, 0, 0), ... (Nx, 0, 0),
4315 (0, 1, 0), (1, 1, 0), (2, 1, 0), ... (Nx, 1, 0),
4317 (0, Ny, 0), (1, Ny, 0), (2, Ny, 0), ... (Nx, Ny, 0),
4318 (0, 0, 1), (1, 0, 1), (2, 0, 1), ... (Nx, 0, 1),
4320 (0, Ny, 2), (1, Ny, 2), (2, Ny, 2), ... (Nx, Ny, 2),
4322 (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
4325 and the array index for a position p contained completely in p1..p2 is:
4327 `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
4329 Note that this is the same "flat 3D array" format as
4330 `PerlinNoiseMap:get3dMap_flat()`.
4331 VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
4332 of the index for a single point in a flat VoxelManip array.
4336 A Content ID is a unique integer identifier for a specific node type.
4337 These IDs are used by VoxelManip in place of the node name string for
4338 `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
4339 `minetest.get_content_id()` to look up the Content ID for the specified node
4340 name, and `minetest.get_name_from_content_id()` to look up the node name string
4341 for a given Content ID.
4342 After registration of a node, its Content ID will remain the same throughout
4343 execution of the mod.
4344 Note that the node being queried needs to have already been been registered.
4346 The following builtin node types have their Content IDs defined as constants:
4348 * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
4349 * `minetest.CONTENT_AIR`: ID for "air" nodes
4350 * `minetest.CONTENT_IGNORE`: ID for "ignore" nodes
4352 ### Mapgen VoxelManip objects
4354 Inside of `on_generated()` callbacks, it is possible to retrieve the same
4355 VoxelManip object used by the core's Map Generator (commonly abbreviated
4356 Mapgen). Most of the rules previously described still apply but with a few
4359 * The Mapgen VoxelManip object is retrieved using:
4360 `minetest.get_mapgen_object("voxelmanip")`
4361 * This VoxelManip object already has the region of map just generated loaded
4362 into it; it's not necessary to call `VoxelManip:read_from_map()`.
4363 Note that the region of map it has loaded is NOT THE SAME as the `minp`, `maxp`
4364 parameters of `on_generated()`. Refer to `minetest.get_mapgen_object` docs.
4365 * The `on_generated()` callbacks of some mods may place individual nodes in the
4366 generated area using non-VoxelManip map modification methods. Because the
4367 same Mapgen VoxelManip object is passed through each `on_generated()`
4368 callback, it becomes necessary for the Mapgen VoxelManip object to maintain
4369 consistency with the current map state. For this reason, calling any of
4370 `minetest.add_node()`, `minetest.set_node()` or `minetest.swap_node()`
4371 will also update the Mapgen VoxelManip object's internal state active on the
4373 * After modifying the Mapgen VoxelManip object's internal buffer, it may be
4374 necessary to update lighting information using either:
4375 `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
4377 ### Other API functions operating on a VoxelManip
4379 If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
4380 `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
4381 flowing. It is recommended to call this function only after having written all
4382 buffered data back to the VoxelManip object, save for special situations where
4383 the modder desires to only have certain liquid nodes begin flowing.
4385 The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
4386 will generate all registered decorations and ores throughout the full area
4387 inside of the specified VoxelManip object.
4389 `minetest.place_schematic_on_vmanip()` is otherwise identical to
4390 `minetest.place_schematic()`, except instead of placing the specified schematic
4391 directly on the map at the specified position, it will place the schematic
4392 inside the VoxelManip.
4396 * Attempting to read data from a VoxelManip object before map is read will
4397 result in a zero-length array table for `VoxelManip:get_data()`, and an
4398 "ignore" node at any position for `VoxelManip:get_node_at()`.
4399 * If either a region of map has not yet been generated or is out-of-bounds of
4400 the map, that region is filled with "ignore" nodes.
4401 * Other mods, or the core itself, could possibly modify the area of map
4402 currently loaded into a VoxelManip object. With the exception of Mapgen
4403 VoxelManips (see above section), the internal buffers are not updated. For
4404 this reason, it is strongly encouraged to complete the usage of a particular
4405 VoxelManip object in the same callback it had been created.
4406 * If a VoxelManip object will be used often, such as in an `on_generated()`
4407 callback, consider passing a file-scoped table as the optional parameter to
4408 `VoxelManip:get_data()`, which serves as a static buffer the function can use
4409 to write map data to instead of returning a new table each call. This greatly
4410 enhances performance by avoiding unnecessary memory allocations.
4415 * `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object
4416 containing the region formed by `p1` and `p2`.
4417 * returns actual emerged `pmin`, actual emerged `pmax`
4418 * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
4420 * **important**: data must be set using `VoxelManip:set_data()` before
4422 * if `light` is true, then lighting is automatically recalculated.
4423 The default value is true.
4424 If `light` is false, no light calculations happen, and you should correct
4425 all modified blocks with `minetest.fix_light()` as soon as possible.
4426 Keep in mind that modifying the map where light is incorrect can cause
4428 * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
4429 the `VoxelManip` at that position
4430 * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
4432 * `get_data([buffer])`: Retrieves the node content data loaded into the
4433 `VoxelManip` object.
4434 * returns raw node data in the form of an array of node content IDs
4435 * if the param `buffer` is present, this table will be used to store the
4437 * `set_data(data)`: Sets the data contents of the `VoxelManip` object
4438 * `update_map()`: Does nothing, kept for compatibility.
4439 * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
4441 * `light` is a table, `{day=<0...15>, night=<0...15>}`
4442 * To be used only by a `VoxelManip` object from
4443 `minetest.get_mapgen_object`.
4444 * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4446 * `get_light_data([buffer])`: Gets the light data read into the
4448 * Returns an array (indices 1 to volume) of integers ranging from `0` to
4450 * Each value is the bitwise combination of day and night light values
4452 * `light = day + (night * 16)`
4453 * If the param `buffer` is present, this table will be used to store the
4455 * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
4456 in the `VoxelManip`.
4457 * expects lighting data in the same format that `get_light_data()` returns
4458 * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
4459 `VoxelManip` object.
4460 * Returns an array (indices 1 to volume) of integers ranging from `0` to
4462 * If the param `buffer` is present, this table will be used to store the
4464 * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
4466 * `calc_lighting([p1, p2], [propagate_shadow])`: Calculate lighting within the
4468 * To be used only by a `VoxelManip` object from
4469 `minetest.get_mapgen_object`.
4470 * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4471 area if left out or nil. For almost all uses these should be left out
4472 or nil to use the default.
4473 * `propagate_shadow` is an optional boolean deciding whether shadows in a
4474 generated mapchunk above are propagated down into the mapchunk, defaults
4475 to `true` if left out.
4476 * `update_liquids()`: Update liquid flow
4477 * `was_modified()`: Returns `true` or `false` if the data in the voxel
4478 manipulator had been modified since the last read from map, due to a call to
4479 `minetest.set_data()` on the loaded area elsewhere.
4480 * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
4485 A helper class for voxel areas.
4486 It can be created via `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
4487 The coordinates are *inclusive*, like most other things in Minetest.
4491 * `getExtent()`: returns a 3D vector containing the size of the area formed by
4492 `MinEdge` and `MaxEdge`.
4493 * `getVolume()`: returns the volume of the area formed by `MinEdge` and
4495 * `index(x, y, z)`: returns the index of an absolute position in a flat array
4497 * `x`, `y` and `z` must be integers to avoid an incorrect index result.
4498 * The position (x, y, z) is not checked for being inside the area volume,
4499 being outside can cause an incorrect index result.
4500 * Useful for things like `VoxelManip`, raw Schematic specifiers,
4501 `PerlinNoiseMap:get2d`/`3dMap`, and so on.
4502 * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
4503 * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
4504 is not checked for being inside the area volume.
4505 * `position(i)`: returns the absolute position vector corresponding to index
4507 * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
4508 `MinEdge` and `MaxEdge`.
4509 * `containsp(p)`: same as above, except takes a vector
4510 * `containsi(i)`: same as above, except takes an index `i`
4511 * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
4513 * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
4515 * `iterp(minp, maxp)`: same as above, except takes a vector
4517 ### Y stride and z stride of a flat array
4519 For a particular position in a voxel area, whose flat array index is known,
4520 it is often useful to know the index of a neighboring or nearby position.
4521 The table below shows the changes of index required for 1 node movements along
4522 the axes in a voxel area:
4524 Movement Change of index
4534 local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
4536 The values of `ystride` and `zstride` can be obtained using `area.ystride` and
4545 A mapgen object is a construct used in map generation. Mapgen objects can be
4546 used by an `on_generate` callback to speed up operations by avoiding
4547 unnecessary recalculations, these can be retrieved using the
4548 `minetest.get_mapgen_object()` function. If the requested Mapgen object is
4549 unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
4550 callback, `nil` is returned.
4552 The following Mapgen objects are currently available:
4556 This returns three values; the `VoxelManip` object to be used, minimum and
4557 maximum emerged position, in that order. All mapgens support this object.
4561 Returns an array containing the y coordinates of the ground levels of nodes in
4562 the most recently generated chunk by the current mapgen.
4566 Returns an array containing the biome IDs of nodes in the most recently
4567 generated chunk by the current mapgen.
4571 Returns an array containing the temperature values of nodes in the most
4572 recently generated chunk by the current mapgen.
4576 Returns an array containing the humidity values of nodes in the most recently
4577 generated chunk by the current mapgen.
4581 Returns a table mapping requested generation notification types to arrays of
4582 positions at which the corresponding generated structures are located within
4583 the current chunk. To enable the capture of positions of interest to be recorded
4584 call `minetest.set_gen_notify()` first.
4586 Possible fields of the returned table are:
4588 * `dungeon`: bottom center position of dungeon rooms
4589 * `temple`: as above but for desert temples (mgv6 only)
4592 * `large_cave_begin`
4594 * `decoration#id` (see below)
4596 Decorations have a key in the format of `"decoration#id"`, where `id` is the
4597 numeric unique decoration ID as returned by `minetest.get_decoration_id()`.
4598 For example, `decoration#123`.
4600 The returned positions are the ground surface 'place_on' nodes,
4601 not the decorations themselves. A 'simple' type decoration is often 1
4602 node above the returned position and possibly displaced by 'place_offset_y'.
4608 Functions receive a "luaentity" table as `self`:
4610 * It has the member `name`, which is the registered name `("mod:thing")`
4611 * It has the member `object`, which is an `ObjectRef` pointing to the object
4612 * The original prototype is visible directly via a metatable
4616 * `on_activate(self, staticdata, dtime_s)`
4617 * Called when the object is instantiated.
4618 * `dtime_s` is the time passed since the object was unloaded, which can be
4619 used for updating the entity state.
4620 * `on_deactivate(self, removal)`
4621 * Called when the object is about to get removed or unloaded.
4622 * `removal`: boolean indicating whether the object is about to get removed.
4623 Calling `object:remove()` on an active object will call this with `removal=true`.
4624 The mapblock the entity resides in being unloaded will call this with `removal=false`.
4625 * Note that this won't be called if the object hasn't been activated in the first place.
4626 In particular, `minetest.clear_objects({mode = "full"})` won't call this,
4627 whereas `minetest.clear_objects({mode = "quick"})` might call this.
4628 * `on_step(self, dtime, moveresult)`
4629 * Called on every server tick, after movement and collision processing.
4630 * `dtime`: elapsed time since last call
4631 * `moveresult`: table with collision info (only available if physical=true)
4632 * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
4633 * Called when somebody punches the object.
4634 * Note that you probably want to handle most punches using the automatic
4636 * `puncher`: an `ObjectRef` (can be `nil`)
4637 * `time_from_last_punch`: Meant for disallowing spamming of clicks
4639 * `tool_capabilities`: capability table of used item (can be `nil`)
4640 * `dir`: unit vector of direction of punch. Always defined. Points from the
4641 puncher to the punched.
4642 * `damage`: damage that will be done to entity.
4643 * Can return `true` to prevent the default damage mechanism.
4644 * `on_death(self, killer)`
4645 * Called when the object dies.
4646 * `killer`: an `ObjectRef` (can be `nil`)
4647 * `on_rightclick(self, clicker)`
4648 * Called when `clicker` pressed the 'place/use' key while pointing
4649 to the object (not neccessarily an actual rightclick)
4650 * `clicker`: an `ObjectRef` (may or may not be a player)
4651 * `on_attach_child(self, child)`
4652 * `child`: an `ObjectRef` of the child that attaches
4653 * `on_detach_child(self, child)`
4654 * `child`: an `ObjectRef` of the child that detaches
4655 * `on_detach(self, parent)`
4656 * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
4657 * This happens before the parent object is removed from the world
4658 * `get_staticdata(self)`
4659 * Should return a string that will be passed to `on_activate` when the
4660 object is instantiated the next time.
4662 Collision info passed to `on_step` (`moveresult` argument):
4665 touching_ground = boolean,
4666 -- Note that touching_ground is only true if the entity was moving and
4667 -- collided with ground.
4670 standing_on_object = boolean,
4674 type = string, -- "node" or "object",
4675 axis = string, -- "x", "y" or "z"
4676 node_pos = vector, -- if type is "node"
4677 object = ObjectRef, -- if type is "object"
4678 old_velocity = vector,
4679 new_velocity = vector,
4683 -- `collisions` does not contain data of unloaded mapblock collisions
4684 -- or when the velocity changes are negligibly small
4696 axiom, --string initial tree axiom
4697 rules_a, --string rules set A
4698 rules_b, --string rules set B
4699 rules_c, --string rules set C
4700 rules_d, --string rules set D
4701 trunk, --string trunk node name
4702 leaves, --string leaves node name
4703 leaves2, --string secondary leaves node name
4704 leaves2_chance,--num chance (0-100) to replace leaves with leaves2
4705 angle, --num angle in deg
4706 iterations, --num max # of iterations, usually 2 -5
4707 random_level, --num factor to lower nr of iterations, usually 0 - 3
4708 trunk_type, --string single/double/crossed) type of trunk: 1 node,
4709 -- 2x2 nodes or 3x3 in cross shape
4710 thin_branches, --boolean true -> use thin (1 node) branches
4711 fruit, --string fruit node name
4712 fruit_chance, --num chance (0-100) to replace leaves with fruit node
4713 seed, --num random seed, if no seed is provided, the engine
4717 Key for special L-System symbols used in axioms
4718 -----------------------------------------------
4720 * `G`: move forward one unit with the pen up
4721 * `F`: move forward one unit with the pen down drawing trunks and branches
4722 * `f`: move forward one unit with the pen down drawing leaves (100% chance)
4723 * `T`: move forward one unit with the pen down drawing trunks only
4724 * `R`: move forward one unit with the pen down placing fruit
4725 * `A`: replace with rules set A
4726 * `B`: replace with rules set B
4727 * `C`: replace with rules set C
4728 * `D`: replace with rules set D
4729 * `a`: replace with rules set A, chance 90%
4730 * `b`: replace with rules set B, chance 80%
4731 * `c`: replace with rules set C, chance 70%
4732 * `d`: replace with rules set D, chance 60%
4733 * `+`: yaw the turtle right by `angle` parameter
4734 * `-`: yaw the turtle left by `angle` parameter
4735 * `&`: pitch the turtle down by `angle` parameter
4736 * `^`: pitch the turtle up by `angle` parameter
4737 * `/`: roll the turtle to the right by `angle` parameter
4738 * `*`: roll the turtle to the left by `angle` parameter
4739 * `[`: save in stack current state info
4740 * `]`: recover from stack state info
4745 Spawn a small apple tree:
4747 pos = {x=230,y=20,z=4}
4750 rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
4751 rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
4752 trunk="default:tree",
4753 leaves="default:leaves",
4757 trunk_type="single",
4760 fruit="default:apple"
4762 minetest.spawn_tree(pos,apple_tree)
4768 Privileges provide a means for server administrators to give certain players
4769 access to special abilities in the engine, games or mods.
4770 For example, game moderators may need to travel instantly to any place in the world,
4771 this ability is implemented in `/teleport` command which requires `teleport` privilege.
4773 Registering privileges
4774 ----------------------
4776 A mod can register a custom privilege using `minetest.register_privilege` function
4777 to give server administrators fine-grained access control over mod functionality.
4779 For consistency and practical reasons, privileges should strictly increase the abilities of the user.
4780 Do not register custom privileges that e.g. restrict the player from certain in-game actions.
4785 A mod can call `minetest.check_player_privs` to test whether a player has privileges
4786 to perform an operation.
4787 Also, when registering a chat command with `minetest.register_chatcommand` a mod can
4788 declare privileges that the command requires using the `privs` field of the command
4791 Managing player privileges
4792 --------------------------
4794 A mod can update player privileges using `minetest.set_player_privs` function.
4795 Players holding the `privs` privilege can see and manage privileges for all
4796 players on the server.
4798 A mod can subscribe to changes in player privileges using `minetest.register_on_priv_grant`
4799 and `minetest.register_on_priv_revoke` functions.
4804 Minetest includes a set of built-in privileges that control capabilities
4805 provided by the Minetest engine and can be used by mods:
4807 * Basic privileges are normally granted to all players:
4808 * `shout`: can communicate using the in-game chat.
4809 * `interact`: can modify the world by digging, building and interacting
4810 with the nodes, entities and other players. Players without the `interact`
4811 privilege can only travel and observe the world.
4813 * Advanced privileges allow bypassing certain aspects of the gameplay:
4814 * `fast`: can use "fast mode" to move with maximum speed.
4815 * `fly`: can use "fly mode" to move freely above the ground without falling.
4816 * `noclip`: can use "noclip mode" to fly through solid nodes (e.g. walls).
4817 * `teleport`: can use `/teleport` command to move to any point in the world.
4818 * `creative`: can access creative inventory.
4819 * `bring`: can teleport other players to oneself.
4820 * `give`: can use `/give` and `/giveme` commands to give any item
4821 in the game to oneself or others.
4822 * `settime`: can use `/time` command to change current in-game time.
4823 * `debug`: can enable wireframe rendering mode.
4825 * Security-related privileges:
4826 * `privs`: can modify privileges of the players using `/grant[me]` and
4827 `/revoke[me]` commands.
4828 * `basic_privs`: can grant and revoke basic privileges as defined by
4829 the `basic_privs` setting.
4830 * `kick`: can kick other players from the server using `/kick` command.
4831 * `ban`: can ban other players using `/ban` command.
4832 * `password`: can use `/setpassword` and `/clearpassword` commands
4833 to manage players' passwords.
4834 * `protection_bypass`: can bypass node protection. Note that the engine does not act upon this privilege,
4835 it is only an implementation suggestion for games.
4837 * Administrative privileges:
4838 * `server`: can use `/fixlight`, `/deleteblocks` and `/deleteobjects`
4839 commands. Can clear inventory of other players using `/clearinv` command.
4840 * `rollback`: can use `/rollback_check` and `/rollback` commands.
4845 Minetest includes the following settings to control behavior of privileges:
4847 * `default_privs`: defines privileges granted to new players.
4848 * `basic_privs`: defines privileges that can be granted/revoked by players having
4849 the `basic_privs` privilege. This can be used, for example, to give
4850 limited moderation powers to selected users.
4852 'minetest' namespace reference
4853 ==============================
4858 * `minetest.get_current_modname()`: returns the currently loading mod's name,
4860 * `minetest.get_modpath(modname)`: returns the directory path for a mod,
4861 e.g. `"/home/user/.minetest/usermods/modname"`.
4862 * Returns nil if the mod is not enabled or does not exist (not installed).
4863 * Works regardless of whether the mod has been loaded yet.
4864 * Useful for loading additional `.lua` modules or static data from a mod,
4865 or checking if a mod is enabled.
4866 * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
4867 * Does not include disabled mods, even if they are installed.
4868 * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
4869 * Useful for storing custom data
4870 * `minetest.is_singleplayer()`
4871 * `minetest.features`: Table containing API feature flags
4874 glasslike_framed = true, -- 0.4.7
4875 nodebox_as_selectionbox = true, -- 0.4.7
4876 get_all_craft_recipes_works = true, -- 0.4.7
4877 -- The transparency channel of textures can optionally be used on
4879 use_texture_alpha = true,
4880 -- Tree and grass ABMs are no longer done from C++ (0.4.8)
4881 no_legacy_abms = true,
4882 -- Texture grouping is possible using parentheses (0.4.11)
4883 texture_names_parens = true,
4884 -- Unique Area ID for AreaStore:insert_area (0.4.14)
4885 area_store_custom_ids = true,
4886 -- add_entity supports passing initial staticdata to on_activate
4888 add_entity_with_staticdata = true,
4889 -- Chat messages are no longer predicted (0.4.16)
4890 no_chat_message_prediction = true,
4891 -- The transparency channel of textures can optionally be used on
4892 -- objects (ie: players and lua entities) (5.0.0)
4893 object_use_texture_alpha = true,
4894 -- Object selectionbox is settable independently from collisionbox
4896 object_independent_selectionbox = true,
4897 -- Specifies whether binary data can be uploaded or downloaded using
4898 -- the HTTP API (5.1.0)
4899 httpfetch_binary_data = true,
4900 -- Whether formspec_version[<version>] may be used (5.1.0)
4901 formspec_version_element = true,
4902 -- Whether AreaStore's IDs are kept on save/load (5.1.0)
4903 area_store_persistent_ids = true,
4904 -- Whether minetest.find_path is functional (5.2.0)
4905 pathfinder_works = true,
4906 -- Whether Collision info is available to an objects' on_step (5.3.0)
4907 object_step_has_moveresult = true,
4908 -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
4909 direct_velocity_on_players = true,
4910 -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
4911 use_texture_alpha_string_modes = true,
4912 -- degrotate param2 rotates in units of 1.5° instead of 2°
4913 -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
4914 degrotate_240_steps = true,
4915 -- ABM supports min_y and max_y fields in definition (5.5.0)
4916 abm_min_max_y = true,
4917 -- dynamic_add_media supports passing a table with options (5.5.0)
4918 dynamic_add_media_table = true,
4919 -- particlespawners support texpools and animation of properties,
4920 -- particle textures support smooth fade and scale animations, and
4921 -- sprite-sheet particle animations can by synced to the lifetime
4922 -- of individual particles (5.6.0)
4923 particlespawner_tweenable = true,
4924 -- allows get_sky to return a table instead of separate values (5.6.0)
4925 get_sky_as_table = true,
4926 -- VoxelManip:get_light_data accepts an optional buffer argument (5.7.0)
4927 get_light_data_buffer = true,
4928 -- When using a mod storage backend that is not "files" or "dummy",
4929 -- the amount of data in mod storage is not constrained by
4930 -- the amount of RAM available. (5.7.0)
4931 mod_storage_on_disk = true,
4932 -- "zstd" method for compress/decompress (5.7.0)
4933 compress_zstd = true,
4936 * `minetest.has_feature(arg)`: returns `boolean, missing_features`
4937 * `arg`: string or table in format `{foo=true, bar=true}`
4938 * `missing_features`: `{foo=true, bar=true}`
4939 * `minetest.get_player_information(player_name)`: Table containing information
4940 about a player. Example return value:
4943 address = "127.0.0.1", -- IP address of client
4944 ip_version = 4, -- IPv4 / IPv6
4945 connection_uptime = 200, -- seconds since client connected
4946 protocol_version = 32, -- protocol version used by client
4947 formspec_version = 2, -- supported formspec version
4948 lang_code = "fr" -- Language code used for translation
4949 -- the following keys can be missing if no stats have been collected yet
4950 min_rtt = 0.01, -- minimum round trip time
4951 max_rtt = 0.2, -- maximum round trip time
4952 avg_rtt = 0.02, -- average round trip time
4953 min_jitter = 0.01, -- minimum packet time jitter
4954 max_jitter = 0.5, -- maximum packet time jitter
4955 avg_jitter = 0.03, -- average packet time jitter
4956 -- the following information is available in a debug build only!!!
4957 -- DO NOT USE IN MODS
4958 --ser_vers = 26, -- serialization version used by client
4959 --major = 0, -- major version number
4960 --minor = 4, -- minor version number
4961 --patch = 10, -- patch version number
4962 --vers_string = "0.4.9-git", -- full version string
4963 --state = "Active" -- current client state
4966 * `minetest.mkdir(path)`: returns success.
4967 * Creates a directory specified by `path`, creating parent directories
4968 if they don't exist.
4969 * `minetest.rmdir(path, recursive)`: returns success.
4970 * Removes a directory specified by `path`.
4971 * If `recursive` is set to `true`, the directory is recursively removed.
4972 Otherwise, the directory will only be removed if it is empty.
4973 * Returns true on success, false on failure.
4974 * `minetest.cpdir(source, destination)`: returns success.
4975 * Copies a directory specified by `path` to `destination`
4976 * Any files in `destination` will be overwritten if they already exist.
4977 * Returns true on success, false on failure.
4978 * `minetest.mvdir(source, destination)`: returns success.
4979 * Moves a directory specified by `path` to `destination`.
4980 * If the `destination` is a non-empty directory, then the move will fail.
4981 * Returns true on success, false on failure.
4982 * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
4984 * nil: return all entries,
4985 * true: return only subdirectory names, or
4986 * false: return only file names.
4987 * `minetest.safe_file_write(path, content)`: returns boolean indicating success
4988 * Replaces contents of file at path with new contents in a safe (atomic)
4989 way. Use this instead of below code when writing e.g. database files:
4990 `local f = io.open(path, "wb"); f:write(content); f:close()`
4991 * `minetest.get_version()`: returns a table containing components of the
4992 engine version. Components:
4993 * `project`: Name of the project, eg, "Minetest"
4994 * `string`: Simple version, eg, "1.2.3-dev"
4995 * `hash`: Full git version (only set if available),
4996 eg, "1.2.3-dev-01234567-dirty".
4997 * `is_dev`: Boolean value indicating whether it's a development build
4998 Use this for informational purposes only. The information in the returned
4999 table does not represent the capabilities of the engine, nor is it
5000 reliable or verifiable. Compatible forks will have a different name and
5001 version entirely. To check for the presence of engine features, test
5002 whether the functions exported by the wanted features exist. For example:
5003 `if minetest.check_for_falling then ... end`.
5004 * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
5005 * `data`: string of data to hash
5006 * `raw`: return raw bytes instead of hex digits, default: false
5007 * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
5008 ColorString. If the ColorSpec is invalid, returns `nil`.
5009 * `colorspec`: The ColorSpec to convert
5010 * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
5011 string of four bytes in an RGBA layout, returned as a string.
5012 * `colorspec`: The ColorSpec to convert
5013 * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
5014 image and return it in string form.
5015 * `width`: Width of the image
5016 * `height`: Height of the image
5017 * `data`: Image data, one of:
5018 * array table of ColorSpec, length must be width*height
5019 * string with raw RGBA pixels, length must be width*height*4
5020 * `compression`: Optional zlib compression level, number in range 0 to 9.
5021 The data is one-dimensional, starting in the upper left corner of the image
5022 and laid out in scanlines going from left to right, then top to bottom.
5023 Please note that it's not safe to use string.char to generate raw data,
5024 use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
5025 The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
5026 You may use this to procedurally generate textures during server init.
5031 * `minetest.debug(...)`
5032 * Equivalent to `minetest.log(table.concat({...}, "\t"))`
5033 * `minetest.log([level,] text)`
5034 * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
5035 `"info"`, or `"verbose"`. Default is `"none"`.
5037 Registration functions
5038 ----------------------
5040 Call these functions only at load time!
5044 * `minetest.register_node(name, node definition)`
5045 * `minetest.register_craftitem(name, item definition)`
5046 * `minetest.register_tool(name, item definition)`
5047 * `minetest.override_item(name, redefinition)`
5048 * Overrides fields of an item registered with register_node/tool/craftitem.
5049 * Note: Item must already be defined, (opt)depend on the mod defining it.
5050 * Example: `minetest.override_item("default:mese",
5051 {light_source=minetest.LIGHT_MAX})`
5052 * `minetest.unregister_item(name)`
5053 * Unregisters the item from the engine, and deletes the entry with key
5054 `name` from `minetest.registered_items` and from the associated item table
5055 according to its nature: `minetest.registered_nodes`, etc.
5056 * `minetest.register_entity(name, entity definition)`
5057 * `minetest.register_abm(abm definition)`
5058 * `minetest.register_lbm(lbm definition)`
5059 * `minetest.register_alias(alias, original_name)`
5060 * Also use this to set the 'mapgen aliases' needed in a game for the core
5061 mapgens. See [Mapgen aliases] section above.
5062 * `minetest.register_alias_force(alias, original_name)`
5063 * `minetest.register_ore(ore definition)`
5064 * Returns an integer object handle uniquely identifying the registered
5066 * The order of ore registrations determines the order of ore generation.
5067 * `minetest.register_biome(biome definition)`
5068 * Returns an integer object handle uniquely identifying the registered
5069 biome on success. To get the biome ID, use `minetest.get_biome_id`.
5070 * `minetest.unregister_biome(name)`
5071 * Unregisters the biome from the engine, and deletes the entry with key
5072 `name` from `minetest.registered_biomes`.
5073 * Warning: This alters the biome to biome ID correspondences, so any
5074 decorations or ores using the 'biomes' field must afterwards be cleared
5076 * `minetest.register_decoration(decoration definition)`
5077 * Returns an integer object handle uniquely identifying the registered
5078 decoration on success. To get the decoration ID, use
5079 `minetest.get_decoration_id`.
5080 * The order of decoration registrations determines the order of decoration
5082 * `minetest.register_schematic(schematic definition)`
5083 * Returns an integer object handle uniquely identifying the registered
5084 schematic on success.
5085 * If the schematic is loaded from a file, the `name` field is set to the
5087 * If the function is called when loading the mod, and `name` is a relative
5088 path, then the current mod path will be prepended to the schematic
5090 * `minetest.clear_registered_biomes()`
5091 * Clears all biomes currently registered.
5092 * Warning: Clearing and re-registering biomes alters the biome to biome ID
5093 correspondences, so any decorations or ores using the 'biomes' field must
5094 afterwards be cleared and re-registered.
5095 * `minetest.clear_registered_decorations()`
5096 * Clears all decorations currently registered.
5097 * `minetest.clear_registered_ores()`
5098 * Clears all ores currently registered.
5099 * `minetest.clear_registered_schematics()`
5100 * Clears all schematics currently registered.
5104 * `minetest.register_craft(recipe)`
5105 * Check recipe table syntax for different types below.
5106 * `minetest.clear_craft(recipe)`
5107 * Will erase existing craft based either on output item or on input recipe.
5108 * Specify either output or input only. If you specify both, input will be
5109 ignored. For input use the same recipe table syntax as for
5110 `minetest.register_craft(recipe)`. For output specify only the item,
5112 * Returns false if no erase candidate could be found, otherwise returns true.
5113 * **Warning**! The type field ("shaped", "cooking" or any other) will be
5114 ignored if the recipe contains output. Erasing is then done independently
5115 from the crafting method.
5116 * `minetest.register_chatcommand(cmd, chatcommand definition)`
5117 * `minetest.override_chatcommand(name, redefinition)`
5118 * Overrides fields of a chatcommand registered with `register_chatcommand`.
5119 * `minetest.unregister_chatcommand(name)`
5120 * Unregisters a chatcommands registered with `register_chatcommand`.
5121 * `minetest.register_privilege(name, definition)`
5122 * `definition` can be a description or a definition table (see [Privilege
5124 * If it is a description, the priv will be granted to singleplayer and admin
5126 * To allow players with `basic_privs` to grant, see the `basic_privs`
5127 minetest.conf setting.
5128 * `minetest.register_authentication_handler(authentication handler definition)`
5129 * Registers an auth handler that overrides the builtin one.
5130 * This function can be called by a single mod once only.
5132 Global callback registration functions
5133 --------------------------------------
5135 Call these functions only at load time!
5137 * `minetest.register_globalstep(function(dtime))`
5138 * Called every server step, usually interval of 0.1s
5139 * `minetest.register_on_mods_loaded(function())`
5140 * Called after mods have finished loading and before the media is cached or the
5142 * `minetest.register_on_shutdown(function())`
5143 * Called before server shutdown
5144 * **Warning**: If the server terminates abnormally (i.e. crashes), the
5145 registered callbacks **will likely not be run**. Data should be saved at
5146 semi-frequent intervals as well as on server shutdown.
5147 * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
5148 * Called when a node has been placed
5149 * If return `true` no item is taken from `itemstack`
5150 * `placer` may be any valid ObjectRef or nil.
5151 * **Not recommended**; use `on_construct` or `after_place_node` in node
5152 definition whenever possible.
5153 * `minetest.register_on_dignode(function(pos, oldnode, digger))`
5154 * Called when a node has been dug.
5155 * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
5156 definition whenever possible.
5157 * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
5158 * Called when a node is punched
5159 * `minetest.register_on_generated(function(minp, maxp, blockseed))`
5160 * Called after generating a piece of world. Modifying nodes inside the area
5161 is a bit faster than usual.
5162 * `minetest.register_on_newplayer(function(ObjectRef))`
5163 * Called when a new player enters the world for the first time
5164 * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
5165 * Called when a player is punched
5166 * Note: This callback is invoked even if the punched player is dead.
5167 * `player`: ObjectRef - Player that was punched
5168 * `hitter`: ObjectRef - Player that hit
5169 * `time_from_last_punch`: Meant for disallowing spamming of clicks
5171 * `tool_capabilities`: Capability table of used item (can be nil)
5172 * `dir`: Unit vector of direction of punch. Always defined. Points from
5173 the puncher to the punched.
5174 * `damage`: Number that represents the damage calculated by the engine
5175 * should return `true` to prevent the default damage mechanism
5176 * `minetest.register_on_rightclickplayer(function(player, clicker))`
5177 * Called when the 'place/use' key was used while pointing a player
5178 (not neccessarily an actual rightclick)
5179 * `player`: ObjectRef - Player that is acted upon
5180 * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
5181 * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
5182 * Called when the player gets damaged or healed
5183 * `player`: ObjectRef of the player
5184 * `hp_change`: the amount of change. Negative when it is damage.
5185 * `reason`: a PlayerHPChangeReason table.
5186 * The `type` field will have one of the following values:
5187 * `set_hp`: A mod or the engine called `set_hp` without
5188 giving a type - use this for custom damage types.
5189 * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
5191 * `node_damage`: `damage_per_second` from a neighbouring node.
5192 `reason.node` will hold the node name or nil.
5195 * Any of the above types may have additional fields from mods.
5196 * `reason.from` will be `mod` or `engine`.
5197 * `modifier`: when true, the function should return the actual `hp_change`.
5198 Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
5199 Modifiers can return true as a second argument to stop the execution of further functions.
5200 Non-modifiers receive the final HP change calculated by the modifiers.
5201 * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
5202 * Called when a player dies
5203 * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
5204 * `minetest.register_on_respawnplayer(function(ObjectRef))`
5205 * Called when player is to be respawned
5206 * Called _before_ repositioning of player occurs
5207 * return true in func to disable regular player placement
5208 * `minetest.register_on_prejoinplayer(function(name, ip))`
5209 * Called when a client connects to the server, prior to authentication
5210 * If it returns a string, the client is disconnected with that string as
5212 * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
5213 * Called when a player joins the game
5214 * `last_login`: The timestamp of the previous login, or nil if player is new
5215 * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
5216 * Called when a player leaves the game
5217 * `timed_out`: True for timeout, false for other reasons.
5218 * `minetest.register_on_authplayer(function(name, ip, is_success))`
5219 * Called when a client attempts to log into an account.
5220 * `name`: The name of the account being authenticated.
5221 * `ip`: The IP address of the client
5222 * `is_success`: Whether the client was successfully authenticated
5223 * For newly registered accounts, `is_success` will always be true
5224 * `minetest.register_on_auth_fail(function(name, ip))`
5225 * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
5226 * `minetest.register_on_cheat(function(ObjectRef, cheat))`
5227 * Called when a player cheats
5228 * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
5230 * `interacted_too_far`
5231 * `interacted_with_self`
5232 * `interacted_while_dead`
5233 * `finished_unknown_dig`
5236 * `minetest.register_on_chat_message(function(name, message))`
5237 * Called always when a player says something
5238 * Return `true` to mark the message as handled, which means that it will
5239 not be sent to other players.
5240 * `minetest.register_on_chatcommand(function(name, command, params))`
5241 * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
5242 is checked to see if the command exists, but after the input is parsed.
5243 * Return `true` to mark the command as handled, which means that the default
5244 handlers will be prevented.
5245 * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
5246 * Called when the server received input from `player` in a formspec with
5247 the given `formname`. Specifically, this is called on any of the
5249 * a button was pressed,
5250 * Enter was pressed while the focus was on a text field
5251 * a checkbox was toggled,
5252 * something was selected in a dropdown list,
5253 * a different tab was selected,
5254 * selection was changed in a textlist or table,
5255 * an entry was double-clicked in a textlist or table,
5256 * a scrollbar was moved, or
5257 * the form was actively closed by the player.
5258 * Fields are sent for formspec elements which define a field. `fields`
5259 is a table containing each formspecs element value (as string), with
5260 the `name` parameter as index for each. The value depends on the
5261 formspec element type:
5262 * `animated_image`: Returns the index of the current frame.
5263 * `button` and variants: If pressed, contains the user-facing button
5264 text as value. If not pressed, is `nil`
5265 * `field`, `textarea` and variants: Text in the field
5266 * `dropdown`: Either the index or value, depending on the `index event`
5268 * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
5269 * `checkbox`: `"true"` if checked, `"false"` if unchecked
5270 * `textlist`: See `minetest.explode_textlist_event`
5271 * `table`: See `minetest.explode_table_event`
5272 * `scrollbar`: See `minetest.explode_scrollbar_event`
5273 * Special case: `["quit"]="true"` is sent when the user actively
5274 closed the form by mouse click, keypress or through a button_exit[]
5276 * Special case: `["key_enter"]="true"` is sent when the user pressed
5277 the Enter key and the focus was either nowhere (causing the formspec
5278 to be closed) or on a button. If the focus was on a text field,
5279 additionally, the index `key_enter_field` contains the name of the
5280 text field. See also: `field_close_on_enter`.
5281 * Newest functions are called first
5282 * If function returns `true`, remaining functions are not called
5283 * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
5284 * Called when `player` crafts something
5285 * `itemstack` is the output
5286 * `old_craft_grid` contains the recipe (Note: the one in the inventory is
5288 * `craft_inv` is the inventory with the crafting grid
5289 * Return either an `ItemStack`, to replace the output, or `nil`, to not
5291 * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
5292 * The same as before, except that it is called before the player crafts, to
5293 make craft prediction, and it should not change anything.
5294 * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
5295 * Determines how much of a stack may be taken, put or moved to a
5297 * `player` (type `ObjectRef`) is the player who modified the inventory
5298 `inventory` (type `InvRef`).
5299 * List of possible `action` (string) values and their
5300 `inventory_info` (table) contents:
5301 * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
5302 * `put`: `{listname=string, index=number, stack=ItemStack}`
5303 * `take`: Same as `put`
5304 * Return a numeric value to limit the amount of items to be taken, put or
5305 moved. A value of `-1` for `take` will make the source stack infinite.
5306 * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
5307 * Called after a take, put or move event from/to/in a player inventory
5308 * Function arguments: see `minetest.register_allow_player_inventory_action`
5309 * Does not accept or handle any return value.
5310 * `minetest.register_on_protection_violation(function(pos, name))`
5311 * Called by `builtin` and mods when a player violates protection at a
5312 position (eg, digs a node or punches a protected entity).
5313 * The registered functions can be called using
5314 `minetest.record_protection_violation`.
5315 * The provided function should check that the position is protected by the
5316 mod calling this function before it prints a message, if it does, to
5317 allow for multiple protection mods.
5318 * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
5319 * Called when an item is eaten, by `minetest.item_eat`
5320 * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
5321 * `minetest.register_on_priv_grant(function(name, granter, priv))`
5322 * Called when `granter` grants the priv `priv` to `name`.
5323 * Note that the callback will be called twice if it's done by a player,
5324 once with granter being the player name, and again with granter being nil.
5325 * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
5326 * Called when `revoker` revokes the priv `priv` from `name`.
5327 * Note that the callback will be called twice if it's done by a player,
5328 once with revoker being the player name, and again with revoker being nil.
5329 * `minetest.register_can_bypass_userlimit(function(name, ip))`
5330 * Called when `name` user connects with `ip`.
5331 * Return `true` to by pass the player limit
5332 * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
5333 * Called when an incoming mod channel message is received
5334 * You should have joined some channels to receive events.
5335 * If message comes from a server mod, `sender` field is an empty string.
5336 * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
5337 * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
5338 engine's liquid transformation process.
5339 * `pos_list` is an array of all modified positions.
5340 * `node_list` is an array of the old node that was previously at the position
5341 with the corresponding index in pos_list.
5346 * `minetest.settings`: Settings object containing all of the settings from the
5347 main config file (`minetest.conf`).
5348 * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
5349 parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
5354 * `minetest.string_to_privs(str[, delim])`:
5355 * Converts string representation of privs into table form
5356 * `delim`: String separating the privs. Defaults to `","`.
5357 * Returns `{ priv1 = true, ... }`
5358 * `minetest.privs_to_string(privs[, delim])`:
5359 * Returns the string representation of `privs`
5360 * `delim`: String to delimit privs. Defaults to `","`.
5361 * `minetest.get_player_privs(name) -> {priv1=true,...}`
5362 * `minetest.check_player_privs(player_or_name, ...)`:
5363 returns `bool, missing_privs`
5364 * A quickhand for checking privileges.
5365 * `player_or_name`: Either a Player object or the name of a player.
5366 * `...` is either a list of strings, e.g. `"priva", "privb"` or
5367 a table, e.g. `{ priva = true, privb = true }`.
5369 * `minetest.check_password_entry(name, entry, password)`
5370 * Returns true if the "password entry" for a player with name matches given
5371 password, false otherwise.
5372 * The "password entry" is the password representation generated by the
5373 engine as returned as part of a `get_auth()` call on the auth handler.
5374 * Only use this function for making it possible to log in via password from
5375 external protocols such as IRC, other uses are frowned upon.
5376 * `minetest.get_password_hash(name, raw_password)`
5377 * Convert a name-password pair to a password hash that Minetest can use.
5378 * The returned value alone is not a good basis for password checks based
5379 on comparing the password hash in the database with the password hash
5380 from the function, with an externally provided password, as the hash
5381 in the db might use the new SRP verifier format.
5382 * For this purpose, use `minetest.check_password_entry` instead.
5383 * `minetest.get_player_ip(name)`: returns an IP address string for the player
5385 * The player needs to be online for this to be successful.
5387 * `minetest.get_auth_handler()`: Return the currently active auth handler
5388 * See the [Authentication handler definition]
5389 * Use this to e.g. get the authentication data for a player:
5390 `local auth_data = minetest.get_auth_handler().get_auth(playername)`
5391 * `minetest.notify_authentication_modified(name)`
5392 * Must be called by the authentication handler for privilege changes.
5393 * `name`: string; if omitted, all auth data should be considered modified
5394 * `minetest.set_player_password(name, password_hash)`: Set password hash of
5396 * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
5398 * `minetest.auth_reload()`
5399 * See `reload()` in authentication handler definition
5401 `minetest.set_player_password`, `minetest.set_player_privs`,
5402 `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
5408 * `minetest.chat_send_all(text)`
5409 * `minetest.chat_send_player(name, text)`
5410 * `minetest.format_chat_message(name, message)`
5411 * Used by the server to format a chat message, based on the setting `chat_message_format`.
5412 Refer to the documentation of the setting for a list of valid placeholders.
5413 * Takes player name and message, and returns the formatted string to be sent to players.
5414 * Can be redefined by mods if required, for things like colored names or messages.
5415 * **Only** the first occurrence of each placeholder will be replaced.
5420 * `minetest.set_node(pos, node)`
5421 * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
5422 * Set node at position `pos`
5423 * `node`: table `{name=string, param1=number, param2=number}`
5424 * If param1 or param2 is omitted, it's set to `0`.
5425 * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
5426 * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
5427 * Set node on all positions set in the first argument.
5428 * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
5429 * For node specification or position syntax see `minetest.set_node` call
5430 * Faster than set_node due to single call, but still considerably slower
5431 than Lua Voxel Manipulators (LVM) for large numbers of nodes.
5432 Unlike LVMs, this will call node callbacks. It also allows setting nodes
5433 in spread out positions which would cause LVMs to waste memory.
5434 For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
5436 * `minetest.swap_node(pos, node)`
5437 * Set node at position, but don't remove metadata
5438 * `minetest.remove_node(pos)`
5439 * By default it does the same as `minetest.set_node(pos, {name="air"})`
5440 * `minetest.get_node(pos)`
5441 * Returns the node at the given position as table in the format
5442 `{name="node_name", param1=0, param2=0}`,
5443 returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
5444 * `minetest.get_node_or_nil(pos)`
5445 * Same as `get_node` but returns `nil` for unloaded areas.
5446 * `minetest.get_node_light(pos, timeofday)`
5447 * Gets the light value at the given position. Note that the light value
5448 "inside" the node at the given position is returned, so you usually want
5449 to get the light value of a neighbor.
5450 * `pos`: The position where to measure the light.
5451 * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5452 * Returns a number between `0` and `15` or `nil`
5453 * `nil` is returned e.g. when the map isn't loaded at `pos`
5454 * `minetest.get_natural_light(pos[, timeofday])`
5455 * Figures out the sunlight (or moonlight) value at pos at the given time of
5457 * `pos`: The position of the node
5458 * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5459 * Returns a number between `0` and `15` or `nil`
5460 * This function tests 203 nodes in the worst case, which happens very
5462 * `minetest.get_artificial_light(param1)`
5463 * Calculates the artificial light (light from e.g. torches) value from the
5465 * `param1`: The param1 value of a `paramtype = "light"` node.
5466 * Returns a number between `0` and `15`
5467 * Currently it's the same as `math.floor(param1 / 16)`, except that it
5468 ensures compatibility.
5469 * `minetest.place_node(pos, node)`
5470 * Place node with the same effects that a player would cause
5471 * `minetest.dig_node(pos)`
5472 * Dig node with the same effects that a player would cause
5473 * Returns `true` if successful, `false` on failure (e.g. protected location)
5474 * `minetest.punch_node(pos)`
5475 * Punch node with the same effects that a player would cause
5476 * `minetest.spawn_falling_node(pos)`
5477 * Change node into falling node
5478 * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
5480 * `minetest.find_nodes_with_meta(pos1, pos2)`
5481 * Get a table of positions of nodes that have metadata within a region
5483 * `minetest.get_meta(pos)`
5484 * Get a `NodeMetaRef` at that position
5485 * `minetest.get_node_timer(pos)`
5486 * Get `NodeTimerRef`
5488 * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
5490 * Returns `ObjectRef`, or `nil` if failed
5491 * `minetest.add_item(pos, item)`: Spawn item
5492 * Returns `ObjectRef`, or `nil` if failed
5493 * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
5494 * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
5496 * `radius`: using an euclidean metric
5497 * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
5499 * `pos1` and `pos2` are the min and max positions of the area to search.
5500 * `minetest.set_timeofday(val)`
5501 * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
5502 * `minetest.get_timeofday()`
5503 * `minetest.get_gametime()`: returns the time, in seconds, since the world was
5505 * `minetest.get_day_count()`: returns number days elapsed since world was
5507 * accounts for time changes.
5508 * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
5510 * `radius`: using a maximum metric
5511 * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5512 * `search_center` is an optional boolean (default: `false`)
5513 If true `pos` is also checked for the nodes
5514 * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
5515 * `pos1` and `pos2` are the min and max positions of the area to search.
5516 * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5517 * If `grouped` is true the return value is a table indexed by node name
5518 which contains lists of positions.
5519 * If `grouped` is false or absent the return values are as follows:
5520 first value: Table with all node positions
5521 second value: Table with the count of each node with the node name
5523 * Area volume is limited to 4,096,000 nodes
5524 * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
5526 * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5527 * Return value: Table with all node positions with a node air above
5528 * Area volume is limited to 4,096,000 nodes
5529 * `minetest.get_perlin(noiseparams)`
5530 * Return world-specific perlin noise.
5531 * The actual seed used is the noiseparams seed plus the world seed.
5532 * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
5533 * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
5534 * Return world-specific perlin noise.
5535 * `minetest.get_voxel_manip([pos1, pos2])`
5536 * Return voxel manipulator object.
5537 * Loads the manipulator from the map if positions are passed.
5538 * `minetest.set_gen_notify(flags, {deco_ids})`
5539 * Set the types of on-generate notifications that should be collected.
5540 * `flags` is a flag field with the available flags:
5548 * The second parameter is a list of IDs of decorations which notification
5550 * `minetest.get_gen_notify()`
5551 * Returns a flagstring and a table with the `deco_id`s.
5552 * `minetest.get_decoration_id(decoration_name)`
5553 * Returns the decoration ID number for the provided decoration name string,
5554 or `nil` on failure.
5555 * `minetest.get_mapgen_object(objectname)`
5556 * Return requested mapgen object if available (see [Mapgen objects])
5557 * `minetest.get_heat(pos)`
5558 * Returns the heat at the position, or `nil` on failure.
5559 * `minetest.get_humidity(pos)`
5560 * Returns the humidity at the position, or `nil` on failure.
5561 * `minetest.get_biome_data(pos)`
5562 * Returns a table containing:
5563 * `biome` the biome id of the biome at that position
5564 * `heat` the heat at the position
5565 * `humidity` the humidity at the position
5566 * Or returns `nil` on failure.
5567 * `minetest.get_biome_id(biome_name)`
5568 * Returns the biome id, as used in the biomemap Mapgen object and returned
5569 by `minetest.get_biome_data(pos)`, for a given biome_name string.
5570 * `minetest.get_biome_name(biome_id)`
5571 * Returns the biome name string for the provided biome id, or `nil` on
5573 * If no biomes have been registered, such as in mgv6, returns `default`.
5574 * `minetest.get_mapgen_params()`
5575 * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
5576 * Returns a table containing:
5582 * `minetest.set_mapgen_params(MapgenParams)`
5583 * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
5585 * Set map generation parameters.
5586 * Function cannot be called after the registration period.
5587 * Takes a table as an argument with the fields:
5593 * Leave field unset to leave that parameter unchanged.
5594 * `flags` contains a comma-delimited string of flags to set, or if the
5595 prefix `"no"` is attached, clears instead.
5596 * `flags` is in the same format and has the same options as `mg_flags` in
5598 * `minetest.get_mapgen_setting(name)`
5599 * Gets the *active* mapgen setting (or nil if none exists) in string
5600 format with the following order of precedence:
5601 1) Settings loaded from map_meta.txt or overrides set during mod
5603 2) Settings set by mods without a metafile override
5604 3) Settings explicitly set in the user config file, minetest.conf
5605 4) Settings set as the user config default
5606 * `minetest.get_mapgen_setting_noiseparams(name)`
5607 * Same as above, but returns the value as a NoiseParams table if the
5608 setting `name` exists and is a valid NoiseParams.
5609 * `minetest.set_mapgen_setting(name, value, [override_meta])`
5610 * Sets a mapgen param to `value`, and will take effect if the corresponding
5611 mapgen setting is not already present in map_meta.txt.
5612 * `override_meta` is an optional boolean (default: `false`). If this is set
5613 to true, the setting will become the active setting regardless of the map
5615 * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
5616 * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
5617 * Same as above, except value is a NoiseParams table.
5618 * `minetest.set_noiseparams(name, noiseparams, set_default)`
5619 * Sets the noiseparams setting of `name` to the noiseparams table specified
5621 * `set_default` is an optional boolean (default: `true`) that specifies
5622 whether the setting should be applied to the default config or current
5624 * `minetest.get_noiseparams(name)`
5625 * Returns a table of the noiseparams for name.
5626 * `minetest.generate_ores(vm, pos1, pos2)`
5627 * Generate all registered ores within the VoxelManip `vm` and in the area
5628 from `pos1` to `pos2`.
5629 * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5630 * `minetest.generate_decorations(vm, pos1, pos2)`
5631 * Generate all registered decorations within the VoxelManip `vm` and in the
5632 area from `pos1` to `pos2`.
5633 * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5634 * `minetest.clear_objects([options])`
5635 * Clear all objects in the environment
5636 * Takes an optional table as an argument with the field `mode`.
5637 * mode = `"full"` : Load and go through every mapblock, clearing
5639 * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
5640 clear objects in unloaded mapblocks only when the
5641 mapblocks are next activated.
5642 * `minetest.load_area(pos1[, pos2])`
5643 * Load the mapblocks containing the area from `pos1` to `pos2`.
5644 `pos2` defaults to `pos1` if not specified.
5645 * This function does not trigger map generation.
5646 * `minetest.emerge_area(pos1, pos2, [callback], [param])`
5647 * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
5648 asynchronously fetched from memory, loaded from disk, or if inexistent,
5650 * If `callback` is a valid Lua function, this will be called for each block
5652 * The function signature of callback is:
5653 `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
5654 * `blockpos` is the *block* coordinates of the block that had been
5656 * `action` could be one of the following constant values:
5657 * `minetest.EMERGE_CANCELLED`
5658 * `minetest.EMERGE_ERRORED`
5659 * `minetest.EMERGE_FROM_MEMORY`
5660 * `minetest.EMERGE_FROM_DISK`
5661 * `minetest.EMERGE_GENERATED`
5662 * `calls_remaining` is the number of callbacks to be expected after
5664 * `param` is the user-defined parameter passed to emerge_area (or
5665 nil if the parameter was absent).
5666 * `minetest.delete_area(pos1, pos2)`
5667 * delete all mapblocks in the area from pos1 to pos2, inclusive
5668 * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
5669 * Checks if there is anything other than air between pos1 and pos2.
5670 * Returns false if something is blocking the sight.
5671 * Returns the position of the blocking node when `false`
5672 * `pos1`: First position
5673 * `pos2`: Second position
5674 * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
5675 * Creates a `Raycast` object.
5676 * `pos1`: start of the ray
5677 * `pos2`: end of the ray
5678 * `objects`: if false, only nodes will be returned. Default is `true`.
5679 * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
5680 returned. Default is `false`.
5681 * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
5682 * returns table containing path that can be walked on
5683 * returns a table of 3D points representing a path from `pos1` to `pos2` or
5685 * Reasons for failure:
5686 * No path exists at all
5687 * No path exists within `searchdistance` (see below)
5688 * Start or end pos is buried in land
5689 * `pos1`: start position
5690 * `pos2`: end position
5691 * `searchdistance`: maximum distance from the search positions to search in.
5692 In detail: Path must be completely inside a cuboid. The minimum
5693 `searchdistance` of 1 will confine search between `pos1` and `pos2`.
5694 Larger values will increase the size of this cuboid in all directions
5695 * `max_jump`: maximum height difference to consider walkable
5696 * `max_drop`: maximum height difference to consider droppable
5697 * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
5698 Difference between `"A*"` and `"A*_noprefetch"` is that
5699 `"A*"` will pre-calculate the cost-data, the other will calculate it
5701 * `minetest.spawn_tree (pos, {treedef})`
5702 * spawns L-system tree at given `pos` with definition in `treedef` table
5703 * `minetest.transforming_liquid_add(pos)`
5704 * add node to liquid flow update queue
5705 * `minetest.get_node_max_level(pos)`
5706 * get max available level for leveled node
5707 * `minetest.get_node_level(pos)`
5708 * get level of leveled node (water, snow)
5709 * `minetest.set_node_level(pos, level)`
5710 * set level of leveled node, default `level` equals `1`
5711 * if `totallevel > maxlevel`, returns rest (`total-max`).
5712 * `minetest.add_node_level(pos, level)`
5713 * increase level of leveled node by level, default `level` equals `1`
5714 * if `totallevel > maxlevel`, returns rest (`total-max`)
5715 * `level` must be between -127 and 127
5716 * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
5717 * resets the light in a cuboid-shaped part of
5718 the map and removes lighting bugs.
5719 * Loads the area if it is not loaded.
5720 * `pos1` is the corner of the cuboid with the least coordinates
5721 (in node coordinates), inclusive.
5722 * `pos2` is the opposite corner of the cuboid, inclusive.
5723 * The actual updated cuboid might be larger than the specified one,
5724 because only whole map blocks can be updated.
5725 The actual updated area consists of those map blocks that intersect
5726 with the given cuboid.
5727 * However, the neighborhood of the updated area might change
5728 as well, as light can spread out of the cuboid, also light
5730 * returns `false` if the area is not fully generated,
5732 * `minetest.check_single_for_falling(pos)`
5733 * causes an unsupported `group:falling_node` node to fall and causes an
5734 unattached `group:attached_node` node to fall.
5735 * does not spread these updates to neighbours.
5736 * `minetest.check_for_falling(pos)`
5737 * causes an unsupported `group:falling_node` node to fall and causes an
5738 unattached `group:attached_node` node to fall.
5739 * spread these updates to neighbours and can cause a cascade
5741 * `minetest.get_spawn_level(x, z)`
5742 * Returns a player spawn y co-ordinate for the provided (x, z)
5743 co-ordinates, or `nil` for an unsuitable spawn point.
5744 * For most mapgens a 'suitable spawn point' is one with y between
5745 `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
5746 so `nil` will be returned for many (x, z) co-ordinates.
5747 * The spawn level returned is for a player spawn in unmodified terrain.
5748 * The spawn level is intentionally above terrain level to cope with
5749 full-node biome 'dust' nodes.
5754 You can find mod channels communication scheme in `doc/mod_channels.png`.
5756 * `minetest.mod_channel_join(channel_name)`
5757 * Server joins channel `channel_name`, and creates it if necessary. You
5758 should listen for incoming messages with
5759 `minetest.register_on_modchannel_message`
5764 `minetest.get_inventory(location)`: returns an `InvRef`
5767 * `{type="player", name="celeron55"}`
5768 * `{type="node", pos={x=, y=, z=}}`
5769 * `{type="detached", name="creative"}`
5770 * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
5772 * `callbacks`: See [Detached inventory callbacks]
5773 * `player_name`: Make detached inventory available to one player
5774 exclusively, by default they will be sent to every player (even if not
5776 Note that this parameter is mostly just a workaround and will be removed
5778 * Creates a detached inventory. If it already exists, it is cleared.
5779 * `minetest.remove_detached_inventory(name)`
5780 * Returns a `boolean` indicating whether the removal succeeded.
5781 * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
5782 returns leftover ItemStack or nil to indicate no inventory change
5783 * See `minetest.item_eat` and `minetest.register_on_item_eat`
5788 * `minetest.show_formspec(playername, formname, formspec)`
5789 * `playername`: name of player to show formspec
5790 * `formname`: name passed to `on_player_receive_fields` callbacks.
5791 It should follow the `"modname:<whatever>"` naming convention
5792 * `formspec`: formspec to display
5793 * `minetest.close_formspec(playername, formname)`
5794 * `playername`: name of player to close formspec
5795 * `formname`: has to exactly match the one given in `show_formspec`, or the
5796 formspec will not close.
5797 * calling `show_formspec(playername, formname, "")` is equal to this
5799 * to close a formspec regardless of the formname, call
5800 `minetest.close_formspec(playername, "")`.
5801 **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
5802 * `minetest.formspec_escape(string)`: returns a string
5803 * escapes the characters "[", "]", "\", "," and ";", which can not be used
5805 * `minetest.explode_table_event(string)`: returns a table
5806 * returns e.g. `{type="CHG", row=1, column=2}`
5808 * `"INV"`: no row selected
5810 * `"DCL"`: double-click
5811 * `minetest.explode_textlist_event(string)`: returns a table
5812 * returns e.g. `{type="CHG", index=1}`
5814 * `"INV"`: no row selected
5816 * `"DCL"`: double-click
5817 * `minetest.explode_scrollbar_event(string)`: returns a table
5818 * returns e.g. `{type="CHG", value=500}`
5820 * `"INV"`: something failed
5821 * `"CHG"`: has been changed
5822 * `"VAL"`: not changed
5827 * `minetest.inventorycube(img1, img2, img3)`
5828 * Returns a string for making an image of a cube (useful as an item image)
5829 * `minetest.get_pointed_thing_position(pointed_thing, above)`
5830 * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
5831 does not refer to a node or entity.
5832 * If the optional `above` parameter is true and the `pointed_thing` refers
5833 to a node, then it will return the `above` position of the `pointed_thing`.
5834 * `minetest.dir_to_facedir(dir, is6d)`
5835 * Convert a vector to a facedir value, used in `param2` for
5836 `paramtype2="facedir"`.
5837 * passing something non-`nil`/`false` for the optional second parameter
5838 causes it to take the y component into account.
5839 * `minetest.facedir_to_dir(facedir)`
5840 * Convert a facedir back into a vector aimed directly out the "back" of a
5842 * `minetest.dir_to_fourdir(dir)`
5843 * Convert a vector to a 4dir value, used in `param2` for
5844 `paramtype2="4dir"`.
5845 * `minetest.fourdir_to_dir(fourdir)`
5846 * Convert a 4dir back into a vector aimed directly out the "back" of a
5848 * `minetest.dir_to_wallmounted(dir)`
5849 * Convert a vector to a wallmounted value, used for
5850 `paramtype2="wallmounted"`.
5851 * `minetest.wallmounted_to_dir(wallmounted)`
5852 * Convert a wallmounted value back into a vector aimed directly out the
5854 * `minetest.dir_to_yaw(dir)`
5855 * Convert a vector into a yaw (angle)
5856 * `minetest.yaw_to_dir(yaw)`
5857 * Convert yaw (angle) to a vector
5858 * `minetest.is_colored_paramtype(ptype)`
5859 * Returns a boolean. Returns `true` if the given `paramtype2` contains
5860 color information (`color`, `colorwallmounted`, `colorfacedir`, etc.).
5861 * `minetest.strip_param2_color(param2, paramtype2)`
5862 * Removes everything but the color information from the
5863 given `param2` value.
5864 * Returns `nil` if the given `paramtype2` does not contain color
5866 * `minetest.get_node_drops(node, toolname)`
5867 * Returns list of itemstrings that are dropped by `node` when dug
5868 with the item `toolname` (not limited to tools).
5869 * `node`: node as table or node name
5870 * `toolname`: name of the item used to dig (can be `nil`)
5871 * `minetest.get_craft_result(input)`: returns `output, decremented_input`
5872 * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5873 * `input.width` = for example `3`
5874 * `input.items` = for example
5875 `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5876 * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
5877 * `output.time` = a number, if unsuccessful: `0`
5878 * `output.replacements` = List of replacement `ItemStack`s that couldn't be
5879 placed in `decremented_input.items`. Replacements can be placed in
5880 `decremented_input` if the stack of the replaced item has a count of 1.
5881 * `decremented_input` = like `input`
5882 * `minetest.get_craft_recipe(output)`: returns input
5883 * returns last registered recipe for output item (node)
5884 * `output` is a node or item type such as `"default:torch"`
5885 * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5886 * `input.width` = for example `3`
5887 * `input.items` = for example
5888 `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5889 * `input.items` = `nil` if no recipe found
5890 * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
5891 * returns indexed table with all registered recipes for query item (node)
5892 or `nil` if no recipe was found.
5893 * recipe entry table:
5894 * `method`: 'normal' or 'cooking' or 'fuel'
5895 * `width`: 0-3, 0 means shapeless recipe
5896 * `items`: indexed [1-9] table with recipe items
5897 * `output`: string with item name and quantity
5898 * Example result for `"default:gold_ingot"` with two recipes:
5902 method = "cooking", width = 3,
5903 output = "default:gold_ingot", items = {"default:gold_lump"}
5906 method = "normal", width = 1,
5907 output = "default:gold_ingot 9", items = {"default:goldblock"}
5911 * `minetest.handle_node_drops(pos, drops, digger)`
5912 * `drops`: list of itemstrings
5913 * Handles drops from nodes after digging: Default action is to put them
5914 into digger's inventory.
5915 * Can be overridden to get different functionality (e.g. dropping items on
5917 * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
5919 * Creates an item string which contains palette index information
5920 for hardware colorization. You can use the returned string
5921 as an output in a craft recipe.
5922 * `item`: the item stack which becomes colored. Can be in string,
5923 table and native form.
5924 * `palette_index`: this index is added to the item stack
5925 * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
5926 * Creates an item string which contains static color information
5927 for hardware colorization. Use this method if you wish to colorize
5928 an item that does not own a palette. You can use the returned string
5929 as an output in a craft recipe.
5930 * `item`: the item stack which becomes colored. Can be in string,
5931 table and native form.
5932 * `colorstring`: the new color of the item stack
5937 * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
5938 returns `{{actor, pos, time, oldnode, newnode}, ...}`
5939 * Find who has done something to a node, or near a node
5940 * `actor`: `"player:<name>"`, also `"liquid"`.
5941 * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
5942 `boolean, log_messages`.
5943 * Revert latest actions of someone
5944 * `actor`: `"player:<name>"`, also `"liquid"`.
5946 Defaults for the `on_place` and `on_drop` item definition functions
5947 -------------------------------------------------------------------
5949 * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
5950 * Place item as a node
5951 * `param2` overrides `facedir` and wallmounted `param2`
5952 * `prevent_after_place`: if set to `true`, `after_place_node` is not called
5953 for the newly placed node to prevent a callback and placement loop
5954 * returns `itemstack, position`
5955 * `position`: the location the node was placed to. `nil` if nothing was placed.
5956 * `minetest.item_place_object(itemstack, placer, pointed_thing)`
5958 * returns the leftover itemstack
5959 * **Note**: This function is deprecated and will never be called.
5960 * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
5961 * Wrapper that calls `minetest.item_place_node` if appropriate
5962 * Calls `on_rightclick` of `pointed_thing.under` if defined instead
5963 * **Note**: is not called when wielded item overrides `on_place`
5964 * `param2` overrides facedir and wallmounted `param2`
5965 * returns `itemstack, position`
5966 * `position`: the location the node was placed to. `nil` if nothing was placed.
5967 * `minetest.item_drop(itemstack, dropper, pos)`
5969 * returns the leftover itemstack
5970 * `minetest.item_eat(hp_change[, replace_with_item])`
5971 * Returns `function(itemstack, user, pointed_thing)` as a
5972 function wrapper for `minetest.do_item_eat`.
5973 * `replace_with_item` is the itemstring which is added to the inventory.
5974 If the player is eating a stack, then replace_with_item goes to a
5977 Defaults for the `on_punch` and `on_dig` node definition callbacks
5978 ------------------------------------------------------------------
5980 * `minetest.node_punch(pos, node, puncher, pointed_thing)`
5981 * Calls functions registered by `minetest.register_on_punchnode()`
5982 * `minetest.node_dig(pos, node, digger)`
5983 * Checks if node can be dug, puts item into inventory, removes node
5984 * Calls functions registered by `minetest.registered_on_dignodes()`
5989 * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
5990 * `spec` is a `SimpleSoundSpec`
5991 * `parameters` is a sound parameter table
5992 * `ephemeral` is a boolean (default: false)
5993 Ephemeral sounds will not return a handle and can't be stopped or faded.
5994 It is recommend to use this for short sounds that happen in response to
5995 player actions (e.g. door closing).
5996 * `minetest.sound_stop(handle)`
5997 * `handle` is a handle returned by `minetest.sound_play`
5998 * `minetest.sound_fade(handle, step, gain)`
5999 * `handle` is a handle returned by `minetest.sound_play`
6000 * `step` determines how fast a sound will fade.
6001 The gain will change by this much per second,
6002 until it reaches the target gain.
6003 Note: Older versions used a signed step. This is deprecated, but old
6004 code will still work. (the client uses abs(step) to correct it)
6005 * `gain` the target gain for the fade.
6006 Fading to zero will delete the sound.
6011 * `minetest.after(time, func, ...)` : returns job table to use as below.
6012 * Call the function `func` after `time` seconds, may be fractional
6013 * Optional: Variable number of arguments that are passed to `func`
6016 * Cancels the job function from being called
6021 The engine allows you to submit jobs to be ran in an isolated environment
6022 concurrently with normal server operation.
6023 A job consists of a function to be ran in the async environment, any amount of
6024 arguments (will be serialized) and a callback that will be called with the return
6025 value of the job function once it is finished.
6027 The async environment does *not* have access to the map, entities, players or any
6028 globals defined in the 'usual' environment. Consequently, functions like
6029 `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
6031 Arguments and return values passed through this can contain certain userdata
6032 objects that will be seamlessly copied (not shared) to the async environment.
6033 This allows you easy interoperability for delegating work to jobs.
6035 * `minetest.handle_async(func, callback, ...)`:
6036 * Queue the function `func` to be ran in an async environment.
6037 Note that there are multiple persistent workers and any of them may
6038 end up running a given job. The engine will scale the amount of
6039 worker threads automatically.
6040 * When `func` returns the callback is called (in the normal environment)
6041 with all of the return values as arguments.
6042 * Optional: Variable number of arguments that are passed to `func`
6043 * `minetest.register_async_dofile(path)`:
6044 * Register a path to a Lua file to be imported when an async environment
6045 is initialized. You can use this to preload code which you can then call
6046 later using `minetest.handle_async()`.
6048 ### List of APIs available in an async environment
6059 * only if transferred into environment; can't read/write to map
6062 Class instances that can be transferred between environments:
6069 * Standalone helpers such as logging, filesystem, encoding,
6070 hashing or compression APIs
6071 * `minetest.request_insecure_environment` (same restrictions apply)
6074 * `minetest.settings`
6075 * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
6076 `registered_craftitems` and `registered_aliases`
6077 * with all functions and userdata values replaced by `true`, calling any
6078 callbacks here is obviously not possible
6083 * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
6084 server shutdown. Will display `message` to clients.
6085 * `reconnect` == true displays a reconnect button
6086 * `delay` adds an optional delay (in seconds) before shutdown.
6087 Negative delay cancels the current active shutdown.
6088 Zero delay triggers an immediate shutdown.
6089 * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
6090 * `minetest.get_server_status(name, joined)`
6091 * Returns the server status string when a player joins or when the command
6092 `/status` is called. Returns `nil` or an empty string when the message is
6094 * `joined`: Boolean value, indicates whether the function was called when
6096 * This function may be overwritten by mods to customize the status message.
6097 * `minetest.get_server_uptime()`: returns the server uptime in seconds
6098 * `minetest.get_server_max_lag()`: returns the current maximum lag
6099 of the server in seconds or nil if server is not fully loaded yet
6100 * `minetest.remove_player(name)`: remove player from database (if they are not
6102 * As auth data is not removed, minetest.player_exists will continue to
6103 return true. Call the below method as well if you want to remove auth
6105 * Returns a code (0: successful, 1: no such player, 2: player is connected)
6106 * `minetest.remove_player_auth(name)`: remove player authentication data
6107 * Returns boolean indicating success (false if player nonexistant)
6108 * `minetest.dynamic_add_media(options, callback)`
6109 * `options`: table containing the following parameters
6110 * `filepath`: path to a media file on the filesystem
6111 * `to_player`: name of the player the media should be sent to instead of
6112 all players (optional)
6113 * `ephemeral`: boolean that marks the media as ephemeral,
6114 it will not be cached on the client (optional, default false)
6115 * `callback`: function with arguments `name`, which is a player name
6116 * Pushes the specified media file to client(s). (details below)
6117 The file must be a supported image, sound or model format.
6118 Dynamically added media is not persisted between server restarts.
6119 * Returns false on error, true if the request was accepted
6120 * The given callback will be called for every player as soon as the
6121 media is available on the client.
6123 * If `ephemeral`=false and `to_player` is unset the file is added to the media
6124 sent to clients on startup, this means the media will appear even on
6125 old clients if they rejoin the server.
6126 * If `ephemeral`=false the file must not be modified, deleted, moved or
6127 renamed after calling this function.
6128 * Regardless of any use of `ephemeral`, adding media files with the same
6129 name twice is not possible/guaranteed to work. An exception to this is the
6130 use of `to_player` to send the same, already existent file to multiple
6132 * Clients will attempt to fetch files added this way via remote media,
6133 this can make transfer of bigger files painless (if set up). Nevertheless
6134 it is advised not to use dynamic media for big media files.
6139 * `minetest.get_ban_list()`: returns a list of all bans formatted as string
6140 * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
6141 IP address or name formatted as string
6142 * `minetest.ban_player(name)`: ban the IP of a currently connected player
6143 * Returns boolean indicating success
6144 * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
6146 * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
6148 * Returns boolean indicating success (false if player nonexistant)
6149 * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
6150 optional reason, this will not prefix with 'Kicked: ' like kick_player.
6151 If no reason is given, it will default to 'Disconnected.'
6152 * Returns boolean indicating success (false if player nonexistant)
6157 * `minetest.add_particle(particle definition)`
6158 * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
6159 expirationtime, size, collisiondetection, texture, playername)`
6161 * `minetest.add_particlespawner(particlespawner definition)`
6162 * Add a `ParticleSpawner`, an object that spawns an amount of particles
6163 over `time` seconds.
6164 * Returns an `id`, and -1 if adding didn't succeed
6165 * Deprecated: `minetest.add_particlespawner(amount, time,
6169 minexptime, maxexptime,
6171 collisiondetection, texture, playername)`
6173 * `minetest.delete_particlespawner(id, player)`
6174 * Delete `ParticleSpawner` with `id` (return value from
6175 `minetest.add_particlespawner`).
6176 * If playername is specified, only deletes on the player's client,
6177 otherwise on all clients.
6182 * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
6183 * Create a schematic from the volume of map specified by the box formed by
6185 * Apply the specified probability and per-node force-place to the specified
6186 nodes according to the `probability_list`.
6187 * `probability_list` is an array of tables containing two fields, `pos`
6189 * `pos` is the 3D vector specifying the absolute coordinates of the
6190 node being modified,
6191 * `prob` is an integer value from `0` to `255` that encodes
6192 probability and per-node force-place. Probability has levels
6193 0-127, then 128 may be added to encode per-node force-place.
6194 For probability stated as 0-255, divide by 2 and round down to
6195 get values 0-127, then add 128 to apply per-node force-place.
6196 * If there are two or more entries with the same pos value, the
6198 * If `pos` is not inside the box formed by `p1` and `p2`, it is
6200 * If `probability_list` equals `nil`, no probabilities are applied.
6201 * Apply the specified probability to the specified horizontal slices
6202 according to the `slice_prob_list`.
6203 * `slice_prob_list` is an array of tables containing two fields, `ypos`
6205 * `ypos` indicates the y position of the slice with a probability
6206 applied, the lowest slice being `ypos = 0`.
6207 * If slice probability list equals `nil`, no slice probabilities
6209 * Saves schematic in the Minetest Schematic format to filename.
6211 * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
6212 * Place the schematic specified by schematic (see [Schematic specifier]) at
6214 * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
6215 * If the `rotation` parameter is omitted, the schematic is not rotated.
6216 * `replacements` = `{["old_name"] = "convert_to", ...}`
6217 * `force_placement` is a boolean indicating whether nodes other than `air`
6218 and `ignore` are replaced by the schematic.
6219 * Returns nil if the schematic could not be loaded.
6220 * **Warning**: Once you have loaded a schematic from a file, it will be
6221 cached. Future calls will always use the cached version and the
6222 replacement list defined for it, regardless of whether the file or the
6223 replacement list parameter have changed. The only way to load the file
6224 anew is to restart the server.
6225 * `flags` is a flag field with the available flags:
6230 * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
6231 * This function is analogous to minetest.place_schematic, but places a
6232 schematic onto the specified VoxelManip object `vmanip` instead of the
6234 * Returns false if any part of the schematic was cut-off due to the
6235 VoxelManip not containing the full area required, and true if the whole
6236 schematic was able to fit.
6237 * Returns nil if the schematic could not be loaded.
6238 * After execution, any external copies of the VoxelManip contents are
6240 * `flags` is a flag field with the available flags:
6245 * `minetest.serialize_schematic(schematic, format, options)`
6246 * Return the serialized schematic specified by schematic
6247 (see [Schematic specifier])
6248 * in the `format` of either "mts" or "lua".
6249 * "mts" - a string containing the binary MTS data used in the MTS file
6251 * "lua" - a string containing Lua code representing the schematic in table
6253 * `options` is a table containing the following optional parameters:
6254 * If `lua_use_comments` is true and `format` is "lua", the Lua code
6255 generated will have (X, Z) position comments for every X row
6256 generated in the schematic data for easier reading.
6257 * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
6258 the Lua code generated will use that number of spaces as indentation
6259 instead of a tab character.
6261 * `minetest.read_schematic(schematic, options)`
6262 * Returns a Lua table representing the schematic (see: [Schematic specifier])
6263 * `schematic` is the schematic to read (see: [Schematic specifier])
6264 * `options` is a table containing the following optional parameters:
6265 * `write_yslice_prob`: string value:
6266 * `none`: no `write_yslice_prob` table is inserted,
6267 * `low`: only probabilities that are not 254 or 255 are written in
6268 the `write_ylisce_prob` table,
6269 * `all`: write all probabilities to the `write_yslice_prob` table.
6270 * The default for this option is `all`.
6271 * Any invalid value will be interpreted as `all`.
6276 * `minetest.request_http_api()`:
6277 * returns `HTTPApiTable` containing http functions if the calling mod has
6278 been granted access by being listed in the `secure.http_mods` or
6279 `secure.trusted_mods` setting, otherwise returns `nil`.
6280 * The returned table contains the functions `fetch`, `fetch_async` and
6281 `fetch_async_get` described below.
6282 * Only works at init time and must be called from the mod's main scope
6283 (not from a function).
6284 * Function only exists if minetest server was built with cURL support.
6285 * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
6287 * `HTTPApiTable.fetch(HTTPRequest req, callback)`
6288 * Performs given request asynchronously and calls callback upon completion
6289 * callback: `function(HTTPRequestResult res)`
6290 * Use this HTTP function if you are unsure, the others are for advanced use
6291 * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
6292 * Performs given request asynchronously and returns handle for
6293 `HTTPApiTable.fetch_async_get`
6294 * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
6295 * Return response data for given asynchronous HTTP request
6300 * `minetest.get_mod_storage()`:
6301 * returns reference to mod private `StorageRef`
6302 * must be called during mod load time
6307 * `minetest.get_connected_players()`: returns list of `ObjectRefs`
6308 * `minetest.is_player(obj)`: boolean, whether `obj` is a player
6309 * `minetest.player_exists(name)`: boolean, whether player exists
6310 (regardless of online status)
6311 * `minetest.hud_replace_builtin(name, hud_definition)`
6312 * Replaces definition of a builtin hud element
6313 * `name`: `"breath"` or `"health"`
6314 * `hud_definition`: definition to replace builtin definition
6315 * `minetest.parse_relative_number(arg, relative_to)`: returns number or nil
6316 * Helper function for chat commands.
6317 * For parsing an optionally relative number of a chat command
6318 parameter, using the chat command tilde notation.
6319 * `arg`: String snippet containing the number; possible values:
6320 * `"<number>"`: return as number
6321 * `"~<number>"`: return `relative_to + <number>`
6322 * `"~"`: return `relative_to`
6323 * Anything else will return `nil`
6324 * `relative_to`: Number to which the `arg` number might be relative to
6326 * `minetest.parse_relative_number("5", 10)` returns 5
6327 * `minetest.parse_relative_number("~5", 10)` returns 15
6328 * `minetest.parse_relative_number("~", 10)` returns 10
6329 * `minetest.send_join_message(player_name)`
6330 * This function can be overridden by mods to change the join message.
6331 * `minetest.send_leave_message(player_name, timed_out)`
6332 * This function can be overridden by mods to change the leave message.
6333 * `minetest.hash_node_position(pos)`: returns an 48-bit integer
6334 * `pos`: table {x=number, y=number, z=number},
6335 * Gives a unique hash number for a node position (16+16+16=48bit)
6336 * `minetest.get_position_from_hash(hash)`: returns a position
6337 * Inverse transform of `minetest.hash_node_position`
6338 * `minetest.get_item_group(name, group)`: returns a rating
6339 * Get rating of a group of an item. (`0` means: not in group)
6340 * `minetest.get_node_group(name, group)`: returns a rating
6341 * Deprecated: An alias for the former.
6342 * `minetest.raillike_group(name)`: returns a rating
6343 * Returns rating of the connect_to_raillike group corresponding to name
6344 * If name is not yet the name of a connect_to_raillike group, a new group
6345 id is created, with that name.
6346 * `minetest.get_content_id(name)`: returns an integer
6347 * Gets the internal content ID of `name`
6348 * `minetest.get_name_from_content_id(content_id)`: returns a string
6349 * Gets the name of the content with that content ID
6350 * `minetest.parse_json(string[, nullvalue])`: returns something
6351 * Convert a string containing JSON data into the Lua equivalent
6352 * `nullvalue`: returned in place of the JSON null; defaults to `nil`
6353 * On success returns a table, a string, a number, a boolean or `nullvalue`
6354 * On failure outputs an error message and returns `nil`
6355 * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
6356 * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
6358 * Convert a Lua table into a JSON string
6359 * styled: Outputs in a human-readable format if this is set, defaults to
6361 * Unserializable things like functions and userdata will cause an error.
6362 * **Warning**: JSON is more strict than the Lua table format.
6363 1. You can only use strings and positive integers of at least one as
6365 2. You can not mix string and integer keys.
6366 This is due to the fact that JSON has two distinct array and object
6368 * Example: `write_json({10, {a = false}})`,
6369 returns `'[10, {"a": false}]'`
6370 * `minetest.serialize(table)`: returns a string
6371 * Convert a table containing tables, strings, numbers, booleans and `nil`s
6372 into string form readable by `minetest.deserialize`
6373 * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
6374 * `minetest.deserialize(string[, safe])`: returns a table
6375 * Convert a string returned by `minetest.serialize` into a table
6376 * `string` is loaded in an empty sandbox environment.
6377 * Will load functions if safe is false or omitted. Although these functions
6378 cannot directly access the global environment, they could bypass this
6379 restriction with maliciously crafted Lua bytecode if mod security is
6381 * This function should not be used on untrusted data, regardless of the
6382 value of `safe`. It is fine to serialize then deserialize user-provided
6383 data, but directly providing user input to deserialize is always unsafe.
6384 * Example: `deserialize('return { ["foo"] = "bar" }')`,
6385 returns `{foo="bar"}`
6386 * Example: `deserialize('print("foo")')`, returns `nil`
6387 (function call fails), returns
6388 `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
6389 * `minetest.compress(data, method, ...)`: returns `compressed_data`
6390 * Compress a string of data.
6391 * `method` is a string identifying the compression method to be used.
6392 * Supported compression methods:
6393 * Deflate (zlib): `"deflate"`
6394 * Zstandard: `"zstd"`
6395 * `...` indicates method-specific arguments. Currently defined arguments
6397 * Deflate: `level` - Compression level, `0`-`9` or `nil`.
6398 * Zstandard: `level` - Compression level. Integer or `nil`. Default `3`.
6399 Note any supported Zstandard compression level could be used here,
6400 but these are subject to change between Zstandard versions.
6401 * `minetest.decompress(compressed_data, method, ...)`: returns data
6402 * Decompress a string of data using the algorithm specified by `method`.
6403 * See documentation on `minetest.compress()` for supported compression
6405 * `...` indicates method-specific arguments. Currently, no methods use this
6406 * `minetest.rgba(red, green, blue[, alpha])`: returns a string
6407 * Each argument is a 8 Bit unsigned integer
6408 * Returns the ColorString from rgb or rgba values
6409 * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
6410 * `minetest.encode_base64(string)`: returns string encoded in base64
6411 * Encodes a string in base64.
6412 * `minetest.decode_base64(string)`: returns string or nil on failure
6413 * Padding characters are only supported starting at version 5.4.0, where
6414 5.5.0 and newer perform proper checks.
6415 * Decodes a string encoded in base64.
6416 * `minetest.is_protected(pos, name)`: returns boolean
6417 * Returning `true` restricts the player `name` from modifying (i.e. digging,
6418 placing) the node at position `pos`.
6419 * `name` will be `""` for non-players or unknown players.
6420 * This function should be overridden by protection mods. It is highly
6421 recommended to grant access to players with the `protection_bypass` privilege.
6422 * Cache and call the old version of this function if the position is
6423 not protected by the mod. This will allow using multiple protection mods.
6426 local old_is_protected = minetest.is_protected
6427 function minetest.is_protected(pos, name)
6428 if mymod:position_protected_from(pos, name) then
6431 return old_is_protected(pos, name)
6433 * `minetest.record_protection_violation(pos, name)`
6434 * This function calls functions registered with
6435 `minetest.register_on_protection_violation`.
6436 * `minetest.is_creative_enabled(name)`: returns boolean
6437 * Returning `true` means that Creative Mode is enabled for player `name`.
6438 * `name` will be `""` for non-players or if the player is unknown.
6439 * This function should be overridden by Creative Mode-related mods to
6440 implement a per-player Creative Mode.
6441 * By default, this function returns `true` if the setting
6442 `creative_mode` is `true` and `false` otherwise.
6443 * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
6444 * Returns the position of the first node that `player_name` may not modify
6445 in the specified cuboid between `pos1` and `pos2`.
6446 * Returns `false` if no protections were found.
6447 * Applies `is_protected()` to a 3D lattice of points in the defined volume.
6448 The points are spaced evenly throughout the volume and have a spacing
6449 similar to, but no larger than, `interval`.
6450 * All corners and edges of the defined volume are checked.
6451 * `interval` defaults to 4.
6452 * `interval` should be carefully chosen and maximised to avoid an excessive
6453 number of points being checked.
6454 * Like `minetest.is_protected`, this function may be extended or
6455 overwritten by mods to provide a faster implementation to check the
6456 cuboid for intersections.
6457 * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
6458 orient_flags, prevent_after_place])`
6459 * Attempt to predict the desired orientation of the facedir-capable node
6460 defined by `itemstack`, and place it accordingly (on-wall, on the floor,
6461 or hanging from the ceiling).
6462 * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
6463 stacks are handled normally.
6464 * `orient_flags`: Optional table containing extra tweaks to the placement code:
6465 * `invert_wall`: if `true`, place wall-orientation on the ground and
6466 ground-orientation on the wall.
6467 * `force_wall` : if `true`, always place the node in wall orientation.
6468 * `force_ceiling`: if `true`, always place on the ceiling.
6469 * `force_floor`: if `true`, always place the node on the floor.
6470 * `force_facedir`: if `true`, forcefully reset the facedir to north
6471 when placing on the floor or ceiling.
6472 * The first four options are mutually-exclusive; the last in the list
6473 takes precedence over the first.
6474 * `prevent_after_place` is directly passed to `minetest.item_place_node`
6475 * Returns the new itemstack after placement
6476 * `minetest.rotate_node(itemstack, placer, pointed_thing)`
6477 * calls `rotate_and_place()` with `infinitestacks` set according to the state
6478 of the creative mode setting, checks for "sneak" to set the `invert_wall`
6479 parameter and `prevent_after_place` set to `true`.
6481 * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
6482 tool_capabilities, dir, distance, damage)`
6483 * Returns the amount of knockback applied on the punched player.
6484 * Arguments are equivalent to `register_on_punchplayer`, except the following:
6485 * `distance`: distance between puncher and punched player
6486 * This function can be overriden by mods that wish to modify this behaviour.
6487 * You may want to cache and call the old function to allow multiple mods to
6488 change knockback behaviour.
6490 * `minetest.forceload_block(pos[, transient])`
6491 * forceloads the position `pos`.
6492 * returns `true` if area could be forceloaded
6493 * If `transient` is `false` or absent, the forceload will be persistent
6494 (saved between server runs). If `true`, the forceload will be transient
6495 (not saved between server runs).
6497 * `minetest.forceload_free_block(pos[, transient])`
6498 * stops forceloading the position `pos`
6499 * If `transient` is `false` or absent, frees a persistent forceload.
6500 If `true`, frees a transient forceload.
6502 * `minetest.compare_block_status(pos, condition)`
6503 * Checks whether the mapblock at positition `pos` is in the wanted condition.
6504 * `condition` may be one of the following values:
6505 * `"unknown"`: not in memory
6506 * `"emerging"`: in the queue for loading from disk or generating
6507 * `"loaded"`: in memory but inactive (no ABMs are executed)
6508 * `"active"`: in memory and active
6509 * Other values are reserved for future functionality extensions
6510 * Return value, the comparison status:
6511 * `false`: Mapblock does not fulfil the wanted condition
6512 * `true`: Mapblock meets the requirement
6513 * `nil`: Unsupported `condition` value
6515 * `minetest.request_insecure_environment()`: returns an environment containing
6516 insecure functions if the calling mod has been listed as trusted in the
6517 `secure.trusted_mods` setting or security is disabled, otherwise returns
6519 * Only works at init time and must be called from the mod's main scope
6520 (ie: the init.lua of the mod, not from another Lua file or within a function).
6521 * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
6522 IT IN A LOCAL VARIABLE!**
6524 * `minetest.global_exists(name)`
6525 * Checks if a global variable has been set, without triggering a warning.
6530 * `minetest.env`: `EnvRef` of the server environment and world.
6531 * Any function in the minetest namespace can be called using the syntax
6532 `minetest.env:somefunction(somearguments)`
6533 instead of `minetest.somefunction(somearguments)`
6534 * Deprecated, but support is not to be dropped soon
6539 ### Registered definition tables
6541 * `minetest.registered_items`
6542 * Map of registered items, indexed by name
6543 * `minetest.registered_nodes`
6544 * Map of registered node definitions, indexed by name
6545 * `minetest.registered_craftitems`
6546 * Map of registered craft item definitions, indexed by name
6547 * `minetest.registered_tools`
6548 * Map of registered tool definitions, indexed by name
6549 * `minetest.registered_entities`
6550 * Map of registered entity prototypes, indexed by name
6551 * Values in this table may be modified directly.
6552 Note: changes to initial properties will only affect entities spawned afterwards,
6553 as they are only read when spawning.
6554 * `minetest.object_refs`
6555 * Map of object references, indexed by active object id
6556 * `minetest.luaentities`
6557 * Map of Lua entities, indexed by active object id
6558 * `minetest.registered_abms`
6559 * List of ABM definitions
6560 * `minetest.registered_lbms`
6561 * List of LBM definitions
6562 * `minetest.registered_aliases`
6563 * Map of registered aliases, indexed by name
6564 * `minetest.registered_ores`
6565 * Map of registered ore definitions, indexed by the `name` field.
6566 * If `name` is nil, the key is the object handle returned by
6567 `minetest.register_ore`.
6568 * `minetest.registered_biomes`
6569 * Map of registered biome definitions, indexed by the `name` field.
6570 * If `name` is nil, the key is the object handle returned by
6571 `minetest.register_biome`.
6572 * `minetest.registered_decorations`
6573 * Map of registered decoration definitions, indexed by the `name` field.
6574 * If `name` is nil, the key is the object handle returned by
6575 `minetest.register_decoration`.
6576 * `minetest.registered_schematics`
6577 * Map of registered schematic definitions, indexed by the `name` field.
6578 * If `name` is nil, the key is the object handle returned by
6579 `minetest.register_schematic`.
6580 * `minetest.registered_chatcommands`
6581 * Map of registered chat command definitions, indexed by name
6582 * `minetest.registered_privileges`
6583 * Map of registered privilege definitions, indexed by name
6584 * Registered privileges can be modified directly in this table.
6586 ### Registered callback tables
6588 All callbacks registered with [Global callback registration functions] are added
6589 to corresponding `minetest.registered_*` tables.
6597 Sorted alphabetically.
6602 AreaStore is a data structure to calculate intersections of 3D cuboid volumes
6603 and points. The `data` field (string) may be used to store and retrieve any
6604 mod-relevant information to the specified area.
6606 Despite its name, mods must take care of persisting AreaStore data. They may
6607 use the provided load and write functions for this.
6612 * `AreaStore(type_name)`
6613 * Returns a new AreaStore instance
6614 * `type_name`: optional, forces the internally used API.
6615 * Possible values: `"LibSpatial"` (default).
6616 * When other values are specified, or SpatialIndex is not available,
6617 the custom Minetest functions are used.
6618 * `get_area(id, include_corners, include_data)`
6619 * Returns the area information about the specified ID.
6620 * Returned values are either of these:
6622 nil -- Area not found
6623 true -- Without `include_corners` and `include_data`
6625 min = pos, max = pos -- `include_corners == true`
6626 data = string -- `include_data == true`
6629 * `get_areas_for_pos(pos, include_corners, include_data)`
6630 * Returns all areas as table, indexed by the area ID.
6631 * Table values: see `get_area`.
6632 * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
6633 * Returns all areas that contain all nodes inside the area specified by`
6634 `corner1 and `corner2` (inclusive).
6635 * `accept_overlap`: if `true`, areas are returned that have nodes in
6636 common (intersect) with the specified area.
6637 * Returns the same values as `get_areas_for_pos`.
6638 * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
6639 * Returns the new area's ID, or nil if the insertion failed.
6640 * The (inclusive) positions `corner1` and `corner2` describe the area.
6641 * `data` is a string stored with the area.
6642 * `id` (optional): will be used as the internal area ID if it is an unique
6643 number between 0 and 2^32-2.
6645 * Requires SpatialIndex, no-op function otherwise.
6646 * Reserves resources for `count` many contained areas to improve
6647 efficiency when working with many area entries. Additional areas can still
6648 be inserted afterwards at the usual complexity.
6649 * `remove_area(id)`: removes the area with the given id from the store, returns
6651 * `set_cache_params(params)`: sets params for the included prefiltering cache.
6652 Calling invalidates the cache, so that its elements have to be newly
6654 * `params` is a table with the following fields:
6656 enabled = boolean, -- Whether to enable, default true
6657 block_radius = int, -- The radius (in nodes) of the areas the cache
6658 -- generates prefiltered lists for, minimum 16,
6660 limit = int, -- The cache size, minimum 20, default 1000
6661 * `to_string()`: Experimental. Returns area store serialized as a (binary)
6663 * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
6665 * `from_string(str)`: Experimental. Deserializes string and loads it into the
6667 Returns success and, optionally, an error message.
6668 * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
6674 An `InvRef` is a reference to an inventory.
6678 * `is_empty(listname)`: return `true` if list is empty
6679 * `get_size(listname)`: get size of a list
6680 * `set_size(listname, size)`: set size of a list
6681 * returns `false` on error (e.g. invalid `listname` or `size`)
6682 * `get_width(listname)`: get width of a list
6683 * `set_width(listname, width)`: set width of list; currently used for crafting
6684 * `get_stack(listname, i)`: get a copy of stack index `i` in list
6685 * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
6686 * `get_list(listname)`: return full list (list of `ItemStack`s)
6687 * `set_list(listname, list)`: set full list (size will not change)
6688 * `get_lists()`: returns table that maps listnames to inventory lists
6689 * `set_lists(lists)`: sets inventory lists (size will not change)
6690 * `add_item(listname, stack)`: add item somewhere in list, returns leftover
6692 * `room_for_item(listname, stack):` returns `true` if the stack of items
6693 can be fully added to the list
6694 * `contains_item(listname, stack, [match_meta])`: returns `true` if
6695 the stack of items can be fully taken from the list.
6696 If `match_meta` is false, only the items' names are compared
6698 * `remove_item(listname, stack)`: take as many items as specified from the
6699 list, returns the items that were actually removed (as an `ItemStack`)
6700 -- note that any item metadata is ignored, so attempting to remove a specific
6701 unique item this way will likely remove the wrong one -- to do that use
6702 `set_stack` with an empty `ItemStack`.
6703 * `get_location()`: returns a location compatible to
6704 `minetest.get_inventory(location)`.
6705 * returns `{type="undefined"}` in case location is not known
6709 Detached & nodemeta inventories provide the following callbacks for move actions:
6713 The `allow_*` callbacks return how many items can be moved.
6715 * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
6716 * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
6717 * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
6721 The `on_*` callbacks are called after the items have been placed in the inventories.
6723 * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
6724 * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
6725 * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
6729 When a player tries to put an item to a place where another item is, the items are *swapped*.
6730 This means that all callbacks will be called twice (once for each action).
6735 An `ItemStack` is a stack of items.
6737 It can be created via `ItemStack(x)`, where x is an `ItemStack`,
6738 an itemstring, a table or `nil`.
6742 * `is_empty()`: returns `true` if stack is empty.
6743 * `get_name()`: returns item name (e.g. `"default:stone"`).
6744 * `set_name(item_name)`: returns a boolean indicating whether the item was
6746 * `get_count()`: Returns number of items on the stack.
6747 * `set_count(count)`: returns a boolean indicating whether the item was cleared
6748 * `count`: number, unsigned 16 bit integer
6749 * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
6750 * `set_wear(wear)`: returns boolean indicating whether item was cleared
6751 * `wear`: number, unsigned 16 bit integer
6752 * `get_meta()`: returns ItemStackMetaRef. See section for more details
6753 * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
6755 * `set_metadata(metadata)`: (DEPRECATED) Returns true.
6756 * `get_description()`: returns the description shown in inventory list tooltips.
6757 * The engine uses this when showing item descriptions in tooltips.
6758 * Fields for finding the description, in order:
6759 * `description` in item metadata (See [Item Metadata].)
6760 * `description` in item definition
6762 * `get_short_description()`: returns the short description or nil.
6763 * Unlike the description, this does not include new lines.
6764 * Fields for finding the short description, in order:
6765 * `short_description` in item metadata (See [Item Metadata].)
6766 * `short_description` in item definition
6767 * first line of the description (From item meta or def, see `get_description()`.)
6768 * Returns nil if none of the above are set
6769 * `clear()`: removes all items from the stack, making it empty.
6770 * `replace(item)`: replace the contents of this stack.
6771 * `item` can also be an itemstring or table.
6772 * `to_string()`: returns the stack in itemstring form.
6773 * `to_table()`: returns the stack in Lua table form.
6774 * `get_stack_max()`: returns the maximum size of the stack (depends on the
6776 * `get_free_space()`: returns `get_stack_max() - get_count()`.
6777 * `is_known()`: returns `true` if the item name refers to a defined item type.
6778 * `get_definition()`: returns the item definition table.
6779 * `get_tool_capabilities()`: returns the digging properties of the item,
6780 or those of the hand if none are defined for this item type
6781 * `add_wear(amount)`
6782 * Increases wear by `amount` if the item is a tool, otherwise does nothing
6783 * Valid `amount` range is [0,65536]
6784 * `amount`: number, integer
6785 * `add_wear_by_uses(max_uses)`
6786 * Increases wear in such a way that, if only this function is called,
6787 the item breaks after `max_uses` times
6788 * Valid `max_uses` range is [0,65536]
6789 * Does nothing if item is not a tool or if `max_uses` is 0
6790 * `add_item(item)`: returns leftover `ItemStack`
6791 * Put some item or stack onto this stack
6792 * `item_fits(item)`: returns `true` if item or stack can be fully added to
6794 * `take_item(n)`: returns taken `ItemStack`
6795 * Take (and remove) up to `n` items from this stack
6796 * `n`: number, default: `1`
6797 * `peek_item(n)`: returns taken `ItemStack`
6798 * Copy (don't remove) up to `n` items from this stack
6799 * `n`: number, default: `1`
6804 ItemStack metadata: reference extra data and functionality stored in a stack.
6805 Can be obtained via `item:get_meta()`.
6809 * All methods in MetaDataRef
6810 * `set_tool_capabilities([tool_capabilities])`
6811 * Overrides the item's tool capabilities
6812 * A nil value will clear the override data and restore the original
6818 Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
6819 and [`PlayerMetaRef`].
6823 * `contains(key)`: Returns true if key present, otherwise false.
6824 * Returns `nil` when the MetaData is inexistent.
6825 * `get(key)`: Returns `nil` if key not present, else the stored string.
6826 * `set_string(key, value)`: Value of `""` will delete the key.
6827 * `get_string(key)`: Returns `""` if key not present.
6828 * `set_int(key, value)`
6829 * `get_int(key)`: Returns `0` if key not present.
6830 * `set_float(key, value)`
6831 * `get_float(key)`: Returns `0` if key not present.
6832 * `to_table()`: returns `nil` or a table with keys:
6833 * `fields`: key-value storage
6834 * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
6835 * `from_table(nil or {})`
6836 * Any non-table value will clear the metadata
6837 * See [Node Metadata] for an example
6838 * returns `true` on success
6840 * returns `true` if this metadata has the same key-value pairs as `other`
6845 An interface to use mod channels on client and server
6849 * `leave()`: leave the mod channel.
6850 * Server leaves channel `channel_name`.
6851 * No more incoming or outgoing messages can be sent to this channel from
6853 * This invalidate all future object usage.
6854 * Ensure you set mod_channel to nil after that to free Lua resources.
6855 * `is_writeable()`: returns true if channel is writeable and mod can send over
6857 * `send_all(message)`: Send `message` though the mod channel.
6858 * If mod channel is not writeable or invalid, message will be dropped.
6859 * Message size is limited to 65535 characters by protocol.
6864 Node metadata: reference extra data and functionality stored in a node.
6865 Can be obtained via `minetest.get_meta(pos)`.
6869 * All methods in MetaDataRef
6870 * `get_inventory()`: returns `InvRef`
6871 * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
6872 This will prevent them from being sent to the client. Note that the "private"
6873 status will only be remembered if an associated key-value pair exists,
6874 meaning it's best to call this when initializing all other meta (e.g.
6880 Node Timers: a high resolution persistent per-node timer.
6881 Can be gotten via `minetest.get_node_timer(pos)`.
6885 * `set(timeout,elapsed)`
6886 * set a timer's state
6887 * `timeout` is in seconds, and supports fractional values (0.1 etc)
6888 * `elapsed` is in seconds, and supports fractional values (0.1 etc)
6889 * will trigger the node's `on_timer` function after `(timeout - elapsed)`
6893 * equivalent to `set(timeout,0)`
6896 * `get_timeout()`: returns current timeout in seconds
6897 * if `timeout` equals `0`, timer is inactive
6898 * `get_elapsed()`: returns current elapsed time in seconds
6899 * the node's `on_timer` function will be called after `(timeout - elapsed)`
6901 * `is_started()`: returns boolean state of timer
6902 * returns `true` if timer is started, otherwise `false`
6907 Moving things in the game are generally these.
6908 This is basically a reference to a C++ `ServerActiveObject`.
6910 ### Advice on handling `ObjectRefs`
6912 When you receive an `ObjectRef` as a callback argument or from another API
6913 function, it is possible to store the reference somewhere and keep it around.
6914 It will keep functioning until the object is unloaded or removed.
6916 However, doing this is **NOT** recommended as there is (intentionally) no method
6917 to test if a previously acquired `ObjectRef` is still valid.
6918 Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
6919 Lua back to the engine.
6920 Doing so is much less error-prone and you will never need to wonder if the
6921 object you are working with still exists.
6925 It is possible to attach objects to other objects (`set_attach` method).
6927 When an object is attached, it is positioned relative to the parent's position
6928 and rotation. `get_pos` and `get_rotation` will always return the parent's
6929 values and changes via their setter counterparts are ignored.
6931 To change position or rotation call `set_attach` again with the new values.
6933 **Note**: Just like model dimensions, the relative position in `set_attach`
6934 must be multiplied by 10 compared to world positions.
6936 It is also possible to attach to a bone of the parent object. In that case the
6937 child will follow movement and rotation of that bone.
6941 * `get_pos()`: returns `{x=num, y=num, z=num}`
6942 * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
6943 * `get_velocity()`: returns the velocity, a vector.
6944 * `add_velocity(vel)`
6945 * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
6946 * In comparison to using get_velocity, adding the velocity and then using
6947 set_velocity, add_velocity is supposed to avoid synchronization problems.
6948 Additionally, players also do not support set_velocity.
6950 * Does not apply during free_move.
6951 * Note that since the player speed is normalized at each move step,
6952 increasing e.g. Y velocity beyond what would usually be achieved
6953 (see: physics overrides) will cause existing X/Z velocity to be reduced.
6954 * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
6955 pressing the jump key (assuming default settings)
6956 * `move_to(pos, continuous=false)`
6957 * Does an interpolated move for Lua entities for visually smooth transitions.
6958 * If `continuous` is true, the Lua entity will not be moved to the current
6959 position before starting the interpolated move.
6960 * For players this does the same as `set_pos`,`continuous` is ignored.
6961 * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
6962 * `puncher` = another `ObjectRef`,
6963 * `time_from_last_punch` = time since last punch action of the puncher
6964 * `direction`: can be `nil`
6965 * `right_click(clicker)`; `clicker` is another `ObjectRef`
6966 * `get_hp()`: returns number of health points
6967 * `set_hp(hp, reason)`: set number of health points
6968 * See reason in register_on_player_hpchange
6969 * Is limited to the range of 0 ... 65535 (2^16 - 1)
6970 * For players: HP are also limited by `hp_max` specified in object properties
6971 * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
6972 * `get_wield_list()`: returns the name of the inventory list the wielded item
6974 * `get_wield_index()`: returns the index of the wielded item
6975 * `get_wielded_item()`: returns an `ItemStack`
6976 * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
6978 * `set_armor_groups({group1=rating, group2=rating, ...})`
6979 * `get_armor_groups()`: returns a table with the armor group ratings
6980 * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
6981 * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
6982 * `frame_speed`: number, default: `15.0`
6983 * `frame_blend`: number, default: `0.0`
6984 * `frame_loop`: boolean, default: `true`
6985 * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
6987 * `set_animation_frame_speed(frame_speed)`
6988 * `frame_speed`: number, default: `15.0`
6989 * `set_attach(parent[, bone, position, rotation, forced_visible])`
6990 * `parent`: `ObjectRef` to attach to
6991 * `bone`: default `""` (the root bone)
6992 * `position`: relative position, default `{x=0, y=0, z=0}`
6993 * `rotation`: relative rotation in degrees, default `{x=0, y=0, z=0}`
6994 * `forced_visible`: Boolean to control whether the attached entity
6995 should appear in first person, default `false`.
6996 * Please also read the [Attachments] section above.
6997 * This command may fail silently (do nothing) when it would result
6998 in circular attachments.
6999 * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
7000 or nil if it isn't attached.
7001 * `get_children()`: returns a list of ObjectRefs that are attached to the
7004 * `set_bone_position([bone, position, rotation])`
7005 * `bone`: string. Default is `""`, the root bone
7006 * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
7007 * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
7008 * `get_bone_position(bone)`: returns position and rotation of the bone
7009 * `set_properties(object property table)`
7010 * `get_properties()`: returns object property table
7011 * `is_player()`: returns true for players, false otherwise
7012 * `get_nametag_attributes()`
7013 * returns a table with the attributes of the nametag of an object
7016 color = {a=0..255, r=0..255, g=0..255, b=0..255},
7017 bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
7019 * `set_nametag_attributes(attributes)`
7020 * sets the attributes of the nametag of an object
7023 text = "My Nametag",
7026 bgcolor = ColorSpec or false,
7027 -- ^ Sets background color of nametag
7028 -- `false` will cause the background to be set automatically based on user settings
7032 #### Lua entity only (no-op for other objects)
7034 * `remove()`: remove object
7035 * The object is removed after returning from Lua. However the `ObjectRef`
7036 itself instantly becomes unusable with all further method calls having
7037 no effect and returning `nil`.
7038 * `set_velocity(vel)`
7039 * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
7040 * `set_acceleration(acc)`
7042 * `get_acceleration()`: returns the acceleration, a vector
7043 * `set_rotation(rot)`
7044 * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
7045 and Z is roll (bank).
7046 * `get_rotation()`: returns the rotation, a vector (radians)
7047 * `set_yaw(yaw)`: sets the yaw in radians (heading).
7048 * `get_yaw()`: returns number in radians
7049 * `set_texture_mod(mod)`
7050 * Set a texture modifier to the base texture, for sprites and meshes.
7051 * When calling `set_texture_mod` again, the previous one is discarded.
7052 * `mod` the texture modifier. See [Texture modifiers].
7053 * `get_texture_mod()` returns current texture modifier
7054 * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
7055 * Specifies and starts a sprite animation
7056 * Animations iterate along the frame `y` position.
7057 * `start_frame`: {x=column number, y=row number}, the coordinate of the
7058 first frame, default: `{x=0, y=0}`
7059 * `num_frames`: Total frames in the texture, default: `1`
7060 * `framelength`: Time per animated frame in seconds, default: `0.2`
7061 * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
7062 position according to the view direction. default: `false`.
7063 * First column: subject facing the camera
7064 * Second column: subject looking to the left
7065 * Third column: subject backing the camera
7066 * Fourth column: subject looking to the right
7067 * Fifth column: subject viewed from above
7068 * Sixth column: subject viewed from below
7069 * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
7072 #### Player only (no-op for other objects)
7074 * `get_player_name()`: returns `""` if is not a player
7075 * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
7076 table {x, y, z} representing the player's instantaneous velocity in nodes/s
7077 * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
7078 * `get_look_dir()`: get camera direction as a unit vector
7079 * `get_look_vertical()`: pitch in radians
7080 * Angle ranges between -pi/2 and pi/2, which are straight up and down
7082 * `get_look_horizontal()`: yaw in radians
7083 * Angle is counter-clockwise from the +z direction.
7084 * `set_look_vertical(radians)`: sets look pitch
7085 * radians: Angle from looking forward, where positive is downwards.
7086 * `set_look_horizontal(radians)`: sets look yaw
7087 * radians: Angle from the +z direction, where positive is counter-clockwise.
7088 * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
7089 `get_look_vertical`.
7090 * Angle ranges between -pi/2 and pi/2, which are straight down and up
7092 * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
7093 `get_look_horizontal`.
7094 * Angle is counter-clockwise from the +x direction.
7095 * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
7096 `set_look_vertical`.
7097 * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
7098 `set_look_horizontal`.
7099 * `get_breath()`: returns player's breath
7100 * `set_breath(value)`: sets player's breath
7102 * `0`: player is drowning
7103 * max: bubbles bar is not shown
7104 * See [Object properties] for more information
7105 * Is limited to range 0 ... 65535 (2^16 - 1)
7106 * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
7108 * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
7109 Defaults to `false`.
7110 * `transition_time`: If defined, enables smooth FOV transition.
7111 Interpreted as the time (in seconds) to reach target FOV.
7112 If set to 0, FOV change is instantaneous. Defaults to 0.
7113 * Set `fov` to 0 to clear FOV override.
7114 * `get_fov()`: Returns the following:
7115 * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
7116 * Boolean indicating whether the FOV value is a multiplier.
7117 * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
7118 * `set_attribute(attribute, value)`: DEPRECATED, use get_meta() instead
7119 * Sets an extra attribute with value on player.
7120 * `value` must be a string, or a number which will be converted to a
7122 * If `value` is `nil`, remove attribute from player.
7123 * `get_attribute(attribute)`: DEPRECATED, use get_meta() instead
7124 * Returns value (a string) for extra attribute.
7125 * Returns `nil` if no attribute found.
7126 * `get_meta()`: Returns a PlayerMetaRef.
7127 * `set_inventory_formspec(formspec)`
7128 * Redefine player's inventory form
7129 * Should usually be called in `on_joinplayer`
7130 * If `formspec` is `""`, the player's inventory is disabled.
7131 * `get_inventory_formspec()`: returns a formspec string
7132 * `set_formspec_prepend(formspec)`:
7133 * the formspec string will be added to every formspec shown to the user,
7134 except for those with a no_prepend[] tag.
7135 * This should be used to set style elements such as background[] and
7136 bgcolor[], any non-style elements (eg: label) may result in weird behaviour.
7137 * Only affects formspecs shown after this is called.
7138 * `get_formspec_prepend(formspec)`: returns a formspec string.
7139 * `get_player_control()`: returns table with player pressed keys
7140 * The table consists of fields with the following boolean values
7141 representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
7142 `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
7143 * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
7144 and exist only to preserve backwards compatibility.
7145 * Returns an empty table `{}` if the object is not a player.
7146 * `get_player_control_bits()`: returns integer with bit packed player pressed
7159 * Returns `0` (no bits set) if the object is not a player.
7160 * `set_physics_override(override_table)`
7161 * `override_table` is a table with the following fields:
7162 * `speed`: multiplier to default walking speed value (default: `1`)
7163 * `jump`: multiplier to default jump value (default: `1`)
7164 * `gravity`: multiplier to default gravity value (default: `1`)
7165 * `sneak`: whether player can sneak (default: `true`)
7166 * `sneak_glitch`: whether player can use the new move code replications
7167 of the old sneak side-effects: sneak ladders and 2 node sneak jump
7169 * `new_move`: use new move/sneak code. When `false` the exact old code
7170 is used for the specific old sneak behaviour (default: `true`)
7171 * `get_physics_override()`: returns the table given to `set_physics_override`
7172 * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
7174 * `hud_remove(id)`: remove the HUD element of the specified id
7175 * `hud_change(id, stat, value)`: change a value of a previously added HUD
7177 * `stat` supports the same keys as in the hud definition table except for
7179 * `hud_get(id)`: gets the HUD element definition structure of the specified ID
7180 * `hud_set_flags(flags)`: sets specified HUD flags of player.
7181 * `flags`: A table with the following fields set to boolean values
7187 * `minimap`: Modifies the client's permission to view the minimap.
7188 The client may locally elect to not view the minimap.
7189 * `minimap_radar`: is only usable when `minimap` is true
7190 * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
7191 This includes map seed, player position, look direction, the pointed node and block bounds.
7192 Does not affect players with the `debug` privilege.
7193 * If a flag equals `nil`, the flag is not modified
7194 * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
7195 * See `hud_set_flags` for a list of flags that can be toggled.
7196 * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
7197 * `count`: number of items, must be between `1` and `32`
7198 * `hud_get_hotbar_itemcount`: returns number of visible items
7199 * `hud_set_hotbar_image(texturename)`
7200 * sets background image for hotbar
7201 * `hud_get_hotbar_image`: returns texturename
7202 * `hud_set_hotbar_selected_image(texturename)`
7203 * sets image for selected item of hotbar
7204 * `hud_get_hotbar_selected_image`: returns texturename
7205 * `set_minimap_modes({mode, mode, ...}, selected_mode)`
7206 * Overrides the available minimap modes (and toggle order), and changes the
7208 * `mode` is a table consisting of up to four fields:
7209 * `type`: Available type:
7210 * `off`: Minimap off
7211 * `surface`: Minimap in surface mode
7212 * `radar`: Minimap in radar mode
7213 * `texture`: Texture to be displayed instead of terrain map
7214 (texture is centered around 0,0 and can be scaled).
7215 Texture size is limited to 512 x 512 pixel.
7216 * `label`: Optional label to display on minimap mode toggle
7217 The translation must be handled within the mod.
7218 * `size`: Sidelength or diameter, in number of nodes, of the terrain
7219 displayed in minimap
7220 * `texture`: Only for texture type, name of the texture to display
7221 * `scale`: Only for texture type, scale of the texture map in nodes per
7222 pixel (for example a `scale` of 2 means each pixel represents a 2x2
7224 * `selected_mode` is the mode index to be selected after modes have been changed
7225 (0 is the first mode).
7226 * `set_sky(sky_parameters)`
7227 * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
7228 whether `set_sky` accepts this format. Check the legacy format otherwise.
7229 * Passing no arguments resets the sky to its default values.
7230 * `sky_parameters` is a table with the following optional fields:
7231 * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
7232 (default: `#ffffff`)
7233 * `type`: Available types:
7234 * `"regular"`: Uses 0 textures, `base_color` ignored
7235 * `"skybox"`: Uses 6 textures, `base_color` used as fog.
7236 * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
7237 (default: `"regular"`)
7238 * `textures`: A table containing up to six textures in the following
7239 order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
7240 * `clouds`: Boolean for whether clouds appear. (default: `true`)
7241 * `sky_color`: A table used in `"regular"` type only, containing the
7242 following values (alpha is ignored):
7243 * `day_sky`: ColorSpec, for the top half of the sky during the day.
7244 (default: `#61b5f5`)
7245 * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
7246 (default: `#90d3f6`)
7247 * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
7248 (default: `#b4bafa`)
7249 The resulting sky color will be a darkened version of the ColorSpec.
7250 Warning: The darkening of the ColorSpec is subject to change.
7251 * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
7252 (default: `#bac1f0`)
7253 The resulting sky color will be a darkened version of the ColorSpec.
7254 Warning: The darkening of the ColorSpec is subject to change.
7255 * `night_sky`: ColorSpec, for the top half of the sky during the night.
7256 (default: `#006bff`)
7257 The resulting sky color will be a dark version of the ColorSpec.
7258 Warning: The darkening of the ColorSpec is subject to change.
7259 * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
7260 (default: `#4090ff`)
7261 The resulting sky color will be a dark version of the ColorSpec.
7262 Warning: The darkening of the ColorSpec is subject to change.
7263 * `indoors`: ColorSpec, for when you're either indoors or underground.
7264 (default: `#646464`)
7265 * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
7266 at sunrise and sunset. (default: `#f47d1d`)
7267 * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
7268 at sunrise and sunset. (default: `#7f99cc`)
7269 * `fog_tint_type`: string, changes which mode the directional fog
7270 abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
7271 `"default"` uses the classic Minetest sun and moon tinting.
7272 Will use tonemaps, if set to `"default"`. (default: `"default"`)
7273 * `set_sky(base_color, type, {texture names}, clouds)`
7274 * Deprecated. Use `set_sky(sky_parameters)`
7275 * `base_color`: ColorSpec, defaults to white
7276 * `type`: Available types:
7277 * `"regular"`: Uses 0 textures, `bgcolor` ignored
7278 * `"skybox"`: Uses 6 textures, `bgcolor` used
7279 * `"plain"`: Uses 0 textures, `bgcolor` used
7280 * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
7281 `"plain"` custom skyboxes (default: `true`)
7282 * `get_sky(as_table)`:
7283 * `as_table`: boolean that determines whether the deprecated version of this
7284 function is being used.
7285 * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
7286 * Deprecated: `false` or `nil` returns base_color, type, table of textures,
7288 * `get_sky_color()`:
7289 * Deprecated: Use `get_sky(as_table)` instead.
7290 * returns a table with the `sky_color` parameters as in `set_sky`.
7291 * `set_sun(sun_parameters)`:
7292 * Passing no arguments resets the sun to its default values.
7293 * `sun_parameters` is a table with the following optional fields:
7294 * `visible`: Boolean for whether the sun is visible.
7296 * `texture`: A regular texture for the sun. Setting to `""`
7297 will re-enable the mesh sun. (default: "sun.png", if it exists)
7298 The texture appears non-rotated at sunrise and rotated 180 degrees
7299 (upside down) at sunset.
7300 * `tonemap`: A 512x1 texture containing the tonemap for the sun
7301 (default: `"sun_tonemap.png"`)
7302 * `sunrise`: A regular texture for the sunrise texture.
7303 (default: `"sunrisebg.png"`)
7304 * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
7306 * `scale`: Float controlling the overall size of the sun. (default: `1`)
7307 Note: For legacy reasons, the sun is bigger than the moon by a factor
7308 of about `1.57` for equal `scale` values.
7309 * `get_sun()`: returns a table with the current sun parameters as in
7311 * `set_moon(moon_parameters)`:
7312 * Passing no arguments resets the moon to its default values.
7313 * `moon_parameters` is a table with the following optional fields:
7314 * `visible`: Boolean for whether the moon is visible.
7316 * `texture`: A regular texture for the moon. Setting to `""`
7317 will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
7318 The texture appears non-rotated at sunrise / moonset and rotated 180
7319 degrees (upside down) at sunset / moonrise.
7320 Note: Relative to the sun, the moon texture is hence rotated by 180°.
7321 You can use the `^[transformR180` texture modifier to achieve the same orientation.
7322 * `tonemap`: A 512x1 texture containing the tonemap for the moon
7323 (default: `"moon_tonemap.png"`)
7324 * `scale`: Float controlling the overall size of the moon (default: `1`)
7325 Note: For legacy reasons, the sun is bigger than the moon by a factor
7326 of about `1.57` for equal `scale` values.
7327 * `get_moon()`: returns a table with the current moon parameters as in
7329 * `set_stars(star_parameters)`:
7330 * Passing no arguments resets stars to their default values.
7331 * `star_parameters` is a table with the following optional fields:
7332 * `visible`: Boolean for whether the stars are visible.
7334 * `day_opacity`: Float for maximum opacity of stars at day.
7335 No effect if `visible` is false.
7336 (default: 0.0; maximum: 1.0; minimum: 0.0)
7337 * `count`: Integer number to set the number of stars in
7338 the skybox. Only applies to `"skybox"` and `"regular"` sky types.
7340 * `star_color`: ColorSpec, sets the colors of the stars,
7341 alpha channel is used to set overall star brightness.
7342 (default: `#ebebff69`)
7343 * `scale`: Float controlling the overall size of the stars (default: `1`)
7344 * `get_stars()`: returns a table with the current stars parameters as in
7346 * `set_clouds(cloud_parameters)`: set cloud parameters
7347 * Passing no arguments resets clouds to their default values.
7348 * `cloud_parameters` is a table with the following optional fields:
7349 * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
7350 * `color`: basic cloud color with alpha channel, ColorSpec
7351 (default `#fff0f0e5`).
7352 * `ambient`: cloud color lower bound, use for a "glow at night" effect.
7353 ColorSpec (alpha ignored, default `#000000`)
7354 * `height`: cloud height, i.e. y of cloud base (default per conf,
7356 * `thickness`: cloud thickness in nodes (default `16`)
7357 * `speed`: 2D cloud speed + direction in nodes per second
7358 (default `{x=0, z=-2}`).
7359 * `get_clouds()`: returns a table with the current cloud parameters as in
7361 * `override_day_night_ratio(ratio or nil)`
7362 * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
7364 * `nil`: Disables override, defaulting to sunlight based on day-night cycle
7365 * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
7366 * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
7367 set animation for player model in third person view.
7368 * Every animation equals to a `{x=starting frame, y=ending frame}` table.
7369 * `frame_speed` sets the animations frame speed. Default is 30.
7370 * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
7372 * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
7373 camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
7374 * in first person view
7375 * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
7376 * `get_eye_offset()`: returns first and third person offsets.
7377 * `send_mapblock(blockpos)`:
7378 * Sends an already loaded mapblock to the player.
7379 * Returns `false` if nothing was sent (note that this can also mean that
7380 the client already has the block)
7381 * Resource intensive - use sparsely
7382 * `set_lighting(light_definition)`: sets lighting for the player
7383 * `light_definition` is a table with the following optional fields:
7384 * `shadows` is a table that controls ambient shadows
7385 * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
7386 * `get_lighting()`: returns the current state of lighting for the player.
7387 * Result is a table with the same fields as `light_definition` in `set_lighting`.
7388 * `respawn()`: Respawns the player using the same mechanism as the death screen,
7389 including calling on_respawnplayer callbacks.
7394 A 32-bit pseudorandom number generator.
7395 Uses PCG32, an algorithm of the permuted congruential generator family,
7396 offering very strong randomness.
7398 It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
7402 * `next()`: return next integer random number [`-2147483648`...`2147483647`]
7403 * `next(min, max)`: return next integer random number [`min`...`max`]
7404 * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
7405 random number [`min`...`max`].
7406 * This is only a rough approximation of a normal distribution with:
7407 * `mean = (max - min) / 2`, and
7408 * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
7409 * Increasing `num_trials` improves accuracy of the approximation
7414 A perlin noise generator.
7415 It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
7416 For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
7417 plus the world seed, to create world-specific noise.
7419 `PerlinNoise(noiseparams)`
7420 `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
7422 `minetest.get_perlin(noiseparams)`
7423 `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
7427 * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
7428 * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
7433 A fast, bulk perlin noise generator.
7435 It can be created via `PerlinNoiseMap(noiseparams, size)` or
7436 `minetest.get_perlin_map(noiseparams, size)`.
7437 For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
7438 plus the world seed, to create world-specific noise.
7440 Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
7441 for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
7444 For each of the functions with an optional `buffer` parameter: If `buffer` is
7445 not nil, this table will be used to store the result instead of creating a new
7450 * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
7451 with values starting at `pos={x=,y=}`
7452 * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
7453 3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
7454 * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
7455 array of 2D noise with values starting at `pos={x=,y=}`
7456 * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
7457 * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
7458 is stored internally.
7459 * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
7460 is stored internally.
7461 * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
7462 returns a slice of the most recently computed noise results. The result slice
7463 begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
7464 E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
7466 `noisevals = noise:get_map_slice({y=20}, {y=2})`
7467 It is important to note that `slice_offset` offset coordinates begin at 1,
7468 and are relative to the starting position of the most recently calculated
7470 To grab a single vertical column of noise starting at map coordinates
7471 x = 1023, y=1000, z = 1000:
7472 `noise:calc_3d_map({x=1000, y=1000, z=1000})`
7473 `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
7479 Uses the same method of storage as the deprecated player attribute API, so
7480 data there will also be in player meta.
7481 Can be obtained using `player:get_meta()`.
7485 * All methods in MetaDataRef
7490 A 16-bit pseudorandom number generator.
7491 Uses a well-known LCG algorithm introduced by K&R.
7493 It can be created via `PseudoRandom(seed)`.
7497 * `next()`: return next integer random number [`0`...`32767`]
7498 * `next(min, max)`: return next integer random number [`min`...`max`]
7499 * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
7500 due to the simple implementation making bad distribution otherwise.
7505 A raycast on the map. It works with selection boxes.
7506 Can be used as an iterator in a for loop as:
7508 local ray = Raycast(...)
7509 for pointed_thing in ray do
7513 The map is loaded as the ray advances. If the map is modified after the
7514 `Raycast` is created, the changes may or may not have an effect on the object.
7516 It can be created via `Raycast(pos1, pos2, objects, liquids)` or
7517 `minetest.raycast(pos1, pos2, objects, liquids)` where:
7519 * `pos1`: start of the ray
7520 * `pos2`: end of the ray
7521 * `objects`: if false, only nodes will be returned. Default is true.
7522 * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
7523 returned. Default is false.
7527 * `next()`: returns a `pointed_thing` with exact pointing location
7528 * Returns the next thing pointed by the ray or nil.
7533 Interface for the operating system's crypto-secure PRNG.
7535 It can be created via `SecureRandom()`. The constructor returns nil if a
7536 secure random device cannot be found on the system.
7540 * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
7541 random bytes, as a string.
7546 An interface to read config files in the format of `minetest.conf`.
7548 It can be created via `Settings(filename)`.
7552 * `get(key)`: returns a value
7553 * `get_bool(key, [default])`: returns a boolean
7554 * `default` is the value returned if `key` is not found.
7555 * Returns `nil` if `key` is not found and `default` not specified.
7556 * `get_np_group(key)`: returns a NoiseParams table
7558 * Returns `{flag = true/false, ...}` according to the set flags.
7559 * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
7560 flags like `mgv5_spflags`.
7562 * Setting names can't contain whitespace or any of `="{}#`.
7563 * Setting values can't contain the sequence `\n"""`.
7564 * Setting names starting with "secure." can't be set on the main settings
7565 object (`minetest.settings`).
7566 * `set_bool(key, value)`
7567 * See documentation for set() above.
7568 * `set_np_group(key, value)`
7569 * `value` is a NoiseParams table.
7570 * Also, see documentation for set() above.
7571 * `remove(key)`: returns a boolean (`true` for success)
7572 * `get_names()`: returns `{key1,...}`
7573 * `write()`: returns a boolean (`true` for success)
7574 * Writes changes to file.
7575 * `to_table()`: returns `{[key1]=value1,...}`
7579 The settings have the format `key = value`. Example:
7591 Mod metadata: per mod metadata, saved automatically.
7592 Can be obtained via `minetest.get_mod_storage()` during load time.
7594 WARNING: This storage backend is incapable of saving raw binary data due
7595 to restrictions of JSON.
7599 * All methods in MetaDataRef
7610 Used by `ObjectRef` methods. Part of an Entity definition.
7611 These properties are not persistent, but are applied automatically to the
7612 corresponding Lua entity using the given registration fields.
7613 Player properties need to be saved manually.
7617 -- Defines the maximum and default HP of the entity
7618 -- For Lua entities the maximum is not enforced.
7619 -- For players this defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
7622 -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
7625 -- For players only. Zoom FOV in degrees.
7626 -- Note that zoom loads and/or generates world beyond the server's
7627 -- maximum send and generate distances, so acts like a telescope.
7628 -- Smaller zoom_fov values increase the distance loaded/generated.
7629 -- Defaults to 15 in creative mode, 0 in survival mode.
7630 -- zoom_fov = 0 disables zooming for the player.
7633 -- For players only. Camera height above feet position in nodes.
7636 -- Collide with `walkable` nodes.
7638 collide_with_objects = true,
7639 -- Collide with other objects if physical = true
7641 collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
7642 selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
7643 -- Selection box uses collision box dimensions when not set.
7644 -- For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
7648 -- Whether the object can be pointed at
7650 visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
7651 -- "cube" is a node-sized cube.
7652 -- "sprite" is a flat texture always facing the player.
7653 -- "upright_sprite" is a vertical flat texture.
7654 -- "mesh" uses the defined mesh model.
7655 -- "wielditem" is used for dropped items.
7656 -- (see builtin/game/item_entity.lua).
7657 -- For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
7658 -- If the item has a 'wield_image' the object will be an extrusion of
7660 -- If 'itemname' is a cubic node or nodebox the object will appear
7661 -- identical to 'itemname'.
7662 -- If 'itemname' is a plantlike node the object will be an extrusion
7664 -- Otherwise for non-node items, the object will be an extrusion of
7665 -- 'inventory_image'.
7666 -- If 'itemname' contains a ColorString or palette index (e.g. from
7667 -- `minetest.itemstring_with_palette()`), the entity will inherit the color.
7668 -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
7670 visual_size = {x = 1, y = 1, z = 1},
7671 -- Multipliers for the visual size. If `z` is not specified, `x` will be used
7672 -- to scale the entity along both horizontal axes.
7675 -- File name of mesh when using "mesh" visual
7678 -- Number of required textures depends on visual.
7679 -- "cube" uses 6 textures just like a node, but all 6 must be defined.
7680 -- "sprite" uses 1 texture.
7681 -- "upright_sprite" uses 2 textures: {front, back}.
7682 -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
7683 -- "mesh" requires one texture for each mesh buffer/material (in order)
7686 -- Number of required colors depends on visual
7688 use_texture_alpha = false,
7689 -- Use texture's alpha channel.
7690 -- Excludes "upright_sprite" and "wielditem".
7691 -- Note: currently causes visual issues when viewed through other
7692 -- semi-transparent materials such as water.
7694 spritediv = {x = 1, y = 1},
7695 -- Used with spritesheet textures for animation and/or frame selection
7696 -- according to position relative to player.
7697 -- Defines the number of columns and rows in the spritesheet:
7700 initial_sprite_basepos = {x = 0, y = 0},
7701 -- Used with spritesheet textures.
7702 -- Defines the {column, row} position of the initially used frame in the
7706 -- If false, object is invisible and can't be pointed.
7708 makes_footstep_sound = false,
7709 -- If true, is able to make footstep sounds of nodes
7710 -- (see node sound definition for details).
7712 automatic_rotate = 0,
7713 -- Set constant rotation in radians per second, positive or negative.
7714 -- Object rotates along the local Y-axis, and works with set_rotation.
7715 -- Set to 0 to disable constant rotation.
7718 -- If positive number, object will climb upwards when it moves
7719 -- horizontally against a `walkable` node, if the height difference
7720 -- is within `stepheight`.
7722 automatic_face_movement_dir = 0.0,
7723 -- Automatically set yaw to movement direction, offset in degrees.
7724 -- 'false' to disable.
7726 automatic_face_movement_max_rotation_per_sec = -1,
7727 -- Limit automatic rotation to this value in degrees per second.
7728 -- No limit if value <= 0.
7730 backface_culling = true,
7731 -- Set to false to disable backface_culling for model
7734 -- Add this much extra lighting when calculating texture color.
7735 -- Value < 0 disables light's effect on texture color.
7736 -- For faking self-lighting, UI style entities, or programmatic coloring
7740 -- The name to display on the head of the object. By default empty.
7741 -- If the object is a player, a nil or empty nametag is replaced by the player's name.
7742 -- For all other objects, a nil or empty string removes the nametag.
7743 -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
7745 nametag_color = <ColorSpec>,
7746 -- Sets text color of nametag
7748 nametag_bgcolor = <ColorSpec>,
7749 -- Sets background color of nametag
7750 -- `false` will cause the background to be set automatically based on user settings.
7754 -- Same as infotext for nodes. Empty by default
7757 -- If false, never save this object statically. It will simply be
7758 -- deleted when the block gets unloaded.
7759 -- The get_staticdata() callback is never called then.
7760 -- Defaults to 'true'.
7762 damage_texture_modifier = "^[brighten",
7763 -- Texture modifier to be applied for a short duration when object is hit
7766 -- Setting this to 'false' disables diffuse lighting of entity
7768 show_on_minimap = false,
7769 -- Defaults to true for players, false for other entities.
7770 -- If set to true the entity will show as a marker on the minimap.
7776 Used by `minetest.register_entity`.
7779 initial_properties = {
7781 mesh = "boats_boat.obj",
7784 -- A table of object properties, see the `Object properties` section.
7785 -- The properties in this table are applied to the object
7786 -- once when it is spawned.
7788 -- Refer to the "Registered entities" section for explanations
7789 on_activate = function(self, staticdata, dtime_s),
7790 on_deactivate = function(self, removal),
7791 on_step = function(self, dtime, moveresult),
7792 on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage),
7793 on_death = function(self, killer),
7794 on_rightclick = function(self, clicker),
7795 on_attach_child = function(self, child),
7796 on_detach_child = function(self, child),
7797 on_detach = function(self, parent),
7798 get_staticdata = function(self),
7800 _custom_field = whatever,
7801 -- You can define arbitrary member variables here (see Item definition
7802 -- for more info) by using a '_' prefix
7806 ABM (ActiveBlockModifier) definition
7807 ------------------------------------
7809 Used by `minetest.register_abm`.
7812 label = "Lava cooling",
7813 -- Descriptive label for profiling purposes (optional).
7814 -- Definitions with identical labels will be listed as one.
7816 nodenames = {"default:lava_source"},
7817 -- Apply `action` function to these nodes.
7818 -- `group:groupname` can also be used here.
7820 neighbors = {"default:water_source", "default:water_flowing"},
7821 -- Only apply `action` to nodes that have one of, or any
7822 -- combination of, these neighbors.
7823 -- If left out or empty, any neighbor will do.
7824 -- `group:groupname` can also be used here.
7827 -- Operation interval in seconds
7830 -- Chance of triggering `action` per-node per-interval is 1.0 / this
7835 -- min and max height levels where ABM will be processed (inclusive)
7836 -- can be used to reduce CPU usage
7839 -- If true, catch-up behaviour is enabled: The `chance` value is
7840 -- temporarily reduced when returning to an area to simulate time lost
7841 -- by the area being unattended. Note that the `chance` value can often
7844 action = function(pos, node, active_object_count, active_object_count_wider),
7845 -- Function triggered for each qualifying node.
7846 -- `active_object_count` is number of active objects in the node's
7848 -- `active_object_count_wider` is number of active objects in the node's
7849 -- mapblock plus all 26 neighboring mapblocks. If any neighboring
7850 -- mapblocks are unloaded an estmate is calculated for them based on
7851 -- loaded mapblocks.
7854 LBM (LoadingBlockModifier) definition
7855 -------------------------------------
7857 Used by `minetest.register_lbm`.
7859 A loading block modifier (LBM) is used to define a function that is called for
7860 specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
7861 gets activated (not loaded!)
7864 label = "Upgrade legacy doors",
7865 -- Descriptive label for profiling purposes (optional).
7866 -- Definitions with identical labels will be listed as one.
7868 name = "modname:replace_legacy_door",
7869 -- Identifier of the LBM, should follow the modname:<whatever> convention
7871 nodenames = {"default:lava_source"},
7872 -- List of node names to trigger the LBM on.
7873 -- Names of non-registered nodes and groups (as group:groupname)
7874 -- will work as well.
7876 run_at_every_load = false,
7877 -- Whether to run the LBM's action every time a block gets activated,
7878 -- and not only the first time the block gets activated after the LBM
7881 action = function(pos, node),
7882 -- Function triggered for each qualifying node.
7889 * `{name="image.png", animation={Tile Animation definition}}`
7890 * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
7891 * backface culling enabled by default for most nodes
7892 * align style determines whether the texture will be rotated with the node
7893 or kept aligned with its surroundings. "user" means that client
7894 setting will be used, similar to `glasslike_framed_optional`.
7895 Note: supported by solid nodes and nodeboxes only.
7896 * scale is used to make texture span several (exactly `scale`) nodes,
7897 instead of just one, in each direction. Works for world-aligned
7899 Note that as the effect is applied on per-mapblock basis, `16` should
7900 be equally divisible by `scale` or you may get wrong results.
7901 * `{name="image.png", color=ColorSpec}`
7902 * the texture's color will be multiplied with this color.
7903 * the tile's color overrides the owning node's color in all cases.
7904 * deprecated, yet still supported field names:
7907 Tile animation definition
7908 -------------------------
7911 type = "vertical_frames",
7914 -- Width of a frame in pixels
7917 -- Height of a frame in pixels
7927 -- Width in number of frames
7930 -- Height in number of frames
7933 -- Length of a single frame
7939 Used by `minetest.register_node`, `minetest.register_craftitem`, and
7940 `minetest.register_tool`.
7944 -- Can contain new lines. "\n" has to be used as new line character.
7945 -- See also: `get_description` in [`ItemStack`]
7947 short_description = "",
7948 -- Must not contain new lines.
7950 -- Use an [`ItemStack`] to get the short description, e.g.:
7951 -- ItemStack(itemname):get_short_description()
7954 -- key = name, value = rating; rating = <number>.
7955 -- If rating not applicable, use 1.
7956 -- e.g. {wool = 1, fluffy = 3}
7957 -- {soil = 2, outerspace = 1, crumbly = 1}
7958 -- {bendy = 2, snappy = 1},
7959 -- {hard = 1, metal = 1, spikes = 1}
7961 inventory_image = "",
7962 -- Texture shown in the inventory GUI
7963 -- Defaults to a 3D rendering of the node if left empty.
7965 inventory_overlay = "",
7966 -- An overlay texture which is not affected by colorization
7969 -- Texture shown when item is held in hand
7970 -- Defaults to a 3D rendering of the node if left empty.
7973 -- Like inventory_overlay but only used in the same situation as wield_image
7975 wield_scale = {x = 1, y = 1, z = 1},
7976 -- Scale for the item when held in hand
7979 -- An image file containing the palette of a node.
7980 -- You can set the currently used color as the "palette_index" field of
7981 -- the item stack metadata.
7982 -- The palette is always stretched to fit indices between 0 and 255, to
7983 -- ensure compatibility with "colorfacedir" (and similar) nodes.
7985 color = "#ffffffff",
7986 -- Color the item is colorized with. The palette overrides this.
7989 -- Maximum amount of items that can be in a single stack.
7990 -- The default can be changed by the setting `default_stack_max`
7993 -- Range of node and object pointing that is possible with this item held
7995 liquids_pointable = false,
7996 -- If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
7997 -- even those for which `pointable = false`
8000 -- When used for nodes: Defines amount of light emitted by node.
8001 -- Otherwise: Defines texture glow when viewed as a dropped item
8002 -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
8003 -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
8006 -- See "Tool Capabilities" section for an example including explanation
8007 tool_capabilities = {
8008 full_punch_interval = 1.0,
8012 choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
8014 damage_groups = {groupname = damage},
8015 -- Damage values must be between -32768 and 32767 (2^15)
8017 punch_attack_uses = nil,
8018 -- Amount of uses this tool has for attacking players and entities
8019 -- by punching them (0 = infinite uses).
8020 -- For compatibility, this is automatically set from the first
8021 -- suitable groupcap using the forumla "uses * 3^(maxlevel - 1)".
8022 -- It is recommend to set this explicitly instead of relying on the
8023 -- fallback behavior.
8026 node_placement_prediction = nil,
8027 -- If nil and item is node, prediction is made automatically.
8028 -- If nil and item is not a node, no prediction is made.
8029 -- If "" and item is anything, no prediction is made.
8030 -- Otherwise should be name of node which the client immediately places
8031 -- on ground when the player places the item. Server will always update
8032 -- with actual result shortly.
8034 node_dig_prediction = "air",
8035 -- if "", no prediction is made.
8036 -- if "air", node is removed.
8037 -- Otherwise should be name of node which the client immediately places
8038 -- upon digging. Server will always update with actual result shortly.
8041 -- Definition of item sounds to be played at various events.
8042 -- All fields in this table are optional.
8044 breaks = <SimpleSoundSpec>,
8045 -- When tool breaks due to wear. Ignored for non-tools
8047 eat = <SimpleSoundSpec>,
8048 -- When item is eaten with `minetest.do_item_eat`
8050 punch_use = <SimpleSoundSpec>,
8051 -- When item is used with the 'punch/mine' key pointing at a node or entity
8053 punch_use_air = <SimpleSoundSpec>,
8054 -- When item is used with the 'punch/mine' key pointing at nothing (air)
8057 on_place = function(itemstack, placer, pointed_thing),
8058 -- When the 'place' key was pressed with the item in hand
8059 -- and a node was pointed at.
8060 -- Shall place item and return the leftover itemstack
8061 -- or nil to not modify the inventory.
8062 -- The placer may be any ObjectRef or nil.
8063 -- default: minetest.item_place
8065 on_secondary_use = function(itemstack, user, pointed_thing),
8066 -- Same as on_place but called when not pointing at a node.
8067 -- Function must return either nil if inventory shall not be modified,
8068 -- or an itemstack to replace the original itemstack.
8069 -- The user may be any ObjectRef or nil.
8072 on_drop = function(itemstack, dropper, pos),
8073 -- Shall drop item and return the leftover itemstack.
8074 -- The dropper may be any ObjectRef or nil.
8075 -- default: minetest.item_drop
8077 on_use = function(itemstack, user, pointed_thing),
8079 -- When user pressed the 'punch/mine' key with the item in hand.
8080 -- Function must return either nil if inventory shall not be modified,
8081 -- or an itemstack to replace the original itemstack.
8082 -- e.g. itemstack:take_item(); return itemstack
8083 -- Otherwise, the function is free to do what it wants.
8084 -- The user may be any ObjectRef or nil.
8085 -- The default functions handle regular use cases.
8087 after_use = function(itemstack, user, node, digparams),
8089 -- If defined, should return an itemstack and will be called instead of
8090 -- wearing out the item (if tool). If returns nil, does nothing.
8091 -- If after_use doesn't exist, it is the same as:
8092 -- function(itemstack, user, node, digparams)
8093 -- itemstack:add_wear(digparams.wear)
8096 -- The user may be any ObjectRef or nil.
8098 _custom_field = whatever,
8099 -- Add your own custom fields. By convention, all custom field names
8100 -- should start with `_` to avoid naming collisions with future engine
8107 Used by `minetest.register_node`.
8110 -- <all fields allowed in item definitions>
8112 drawtype = "normal", -- See "Node drawtypes"
8115 -- Supported for drawtypes "plantlike", "signlike", "torchlike",
8116 -- "firelike", "mesh", "nodebox", "allfaces".
8117 -- For plantlike and firelike, the image will start at the bottom of the
8118 -- node. For torchlike, the image will start at the surface to which the
8119 -- node "attaches". For the other drawtypes the image will be centered
8122 tiles = {tile definition 1, def2, def3, def4, def5, def6},
8123 -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
8124 -- List can be shortened to needed length.
8126 overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
8127 -- Same as `tiles`, but these textures are drawn on top of the base
8128 -- tiles. You can use this to colorize only specific parts of your
8129 -- texture. If the texture name is an empty string, that overlay is not
8130 -- drawn. Since such tiles are drawn twice, it is not recommended to use
8131 -- overlays on very common nodes.
8133 special_tiles = {tile definition 1, Tile definition 2},
8134 -- Special textures of node; used rarely.
8135 -- List can be shortened to needed length.
8138 -- The node's original color will be multiplied with this color.
8139 -- If the node has a palette, then this setting only has an effect in
8140 -- the inventory and on the wield item.
8142 use_texture_alpha = ...,
8143 -- Specifies how the texture's alpha channel will be used for rendering.
8145 -- * "opaque": Node is rendered opaque regardless of alpha channel
8146 -- * "clip": A given pixel is either fully see-through or opaque
8147 -- depending on the alpha channel being below/above 50% in value
8148 -- * "blend": The alpha channel specifies how transparent a given pixel
8149 -- of the rendered node is
8150 -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
8151 -- "clip" otherwise.
8152 -- If set to a boolean value (deprecated): true either sets it to blend
8153 -- or clip, false sets it to clip or opaque mode depending on the drawtype.
8156 -- The node's `param2` is used to select a pixel from the image.
8157 -- Pixels are arranged from left to right and from top to bottom.
8158 -- The node's color will be multiplied with the selected pixel's color.
8159 -- Tiles can override this behavior.
8160 -- Only when `paramtype2` supports palettes.
8162 post_effect_color = "#00000000",
8163 -- Screen tint if player is inside node, see "ColorSpec"
8165 paramtype = "none", -- See "Nodes"
8167 paramtype2 = "none", -- See "Nodes"
8170 -- Value for param2 that is set when player places node
8172 is_ground_content = true,
8173 -- If false, the cave generator and dungeon generator will not carve
8174 -- through this node.
8175 -- Specifically, this stops mod-added nodes being removed by caves and
8176 -- dungeons when those generate in a neighbor mapchunk and extend out
8177 -- beyond the edge of that mapchunk.
8179 sunlight_propagates = false,
8180 -- If true, sunlight will go infinitely through this node
8182 walkable = true, -- If true, objects collide with node
8184 pointable = true, -- If true, can be pointed at
8186 diggable = true, -- If false, can never be dug
8188 climbable = false, -- If true, can be climbed on like a ladder
8190 move_resistance = 0,
8191 -- Slows down movement of players through this node (max. 7).
8192 -- If this is nil, it will be equal to liquid_viscosity.
8193 -- Note: If liquid movement physics apply to the node
8194 -- (see `liquid_move_physics`), the movement speed will also be
8195 -- affected by the `movement_liquid_*` settings.
8197 buildable_to = false, -- If true, placed nodes can replace this node
8200 -- If true, liquids flow into and replace this node.
8201 -- Warning: making a liquid node 'floodable' will cause problems.
8203 liquidtype = "none", -- specifies liquid flowing physics
8204 -- * "none": no liquid flowing physics
8205 -- * "source": spawns flowing liquid nodes at all 4 sides and below;
8206 -- recommended drawtype: "liquid".
8207 -- * "flowing": spawned from source, spawns more flowing liquid nodes
8208 -- around it until `liquid_range` is reached;
8209 -- will drain out without a source;
8210 -- recommended drawtype: "flowingliquid".
8211 -- If it's "source" or "flowing" and `liquid_range > 0`, then
8212 -- both `liquid_alternative_*` fields must be specified
8214 liquid_alternative_flowing = "",
8215 -- Node that represents the flowing version of the liquid
8217 liquid_alternative_source = "",
8218 -- Node that represents the source version of the liquid
8220 liquid_viscosity = 0,
8221 -- Controls speed at which the liquid spreads/flows (max. 7).
8222 -- 0 is fastest, 7 is slowest.
8223 -- By default, this also slows down movement of players inside the node
8224 -- (can be overridden using `move_resistance`)
8226 liquid_renewable = true,
8227 -- If true, a new liquid source can be created by placing two or more
8230 liquid_move_physics = nil, -- specifies movement physics if inside node
8231 -- * false: No liquid movement physics apply.
8232 -- * true: Enables liquid movement physics. Enables things like
8233 -- ability to "swim" up/down, sinking slowly if not moving,
8234 -- smoother speed change when falling into, etc. The `movement_liquid_*`
8236 -- * nil: Will be treated as true if `liquidype ~= "none"`
8237 -- and as false otherwise.
8240 -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
8241 -- Allows defining the nodebox height without using param2.
8242 -- The nodebox height is 'leveled' / 64 nodes.
8243 -- The maximum value of 'leveled' is `leveled_max`.
8246 -- Maximum value for `leveled` (0-127), enforced in
8247 -- `minetest.set_node_level` and `minetest.add_node_level`.
8248 -- Values above 124 might causes collision detection issues.
8251 -- Maximum distance that flowing liquid nodes can spread around
8252 -- source on flat land;
8253 -- maximum = 8; set to 0 to disable liquid flow
8256 -- Player will take this amount of damage if no bubbles are left
8258 damage_per_second = 0,
8259 -- If player is inside node, this damage is caused
8261 node_box = {type = "regular"}, -- See "Node boxes"
8264 -- Used for nodebox nodes with the type == "connected".
8265 -- Specifies to what neighboring nodes connections will be drawn.
8266 -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
8269 -- Tells connected nodebox nodes to connect only to these sides of this
8270 -- node. possible: "top", "bottom", "front", "left", "back", "right"
8273 -- File name of mesh when using "mesh" drawtype
8276 -- see [Node boxes] for possibilities
8278 -- Custom selection box definition. Multiple boxes can be defined.
8279 -- If "nodebox" drawtype is used and selection_box is nil, then node_box
8280 -- definition is used for the selection box.
8283 -- see [Node boxes] for possibilities
8285 -- Custom collision box definition. Multiple boxes can be defined.
8286 -- If "nodebox" drawtype is used and collision_box is nil, then node_box
8287 -- definition is used for the collision box.
8289 -- Support maps made in and before January 2012
8290 legacy_facedir_simple = false,
8291 legacy_wallmounted = false,
8294 -- Valid for drawtypes:
8295 -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
8296 -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
8297 -- 2 - wave node like leaves (whole node moves side-to-side)
8298 -- 3 - wave node like liquids (whole node moves up and down)
8299 -- Not all models will properly wave.
8300 -- plantlike drawtype can only wave like plants.
8301 -- allfaces_optional drawtype can only wave like leaves.
8302 -- liquid, flowingliquid drawtypes can only wave like liquids.
8305 -- Definition of node sounds to be played at various events.
8306 -- All fields in this table are optional.
8308 footstep = <SimpleSoundSpec>,
8309 -- If walkable, played when object walks on it. If node is
8310 -- climbable or a liquid, played when object moves through it
8312 dig = <SimpleSoundSpec> or "__group",
8313 -- While digging node.
8314 -- If `"__group"`, then the sound will be
8315 -- `default_dig_<groupname>`, where `<groupname>` is the
8316 -- name of the item's digging group with the fastest digging time.
8317 -- In case of a tie, one of the sounds will be played (but we
8318 -- cannot predict which one)
8319 -- Default value: `"__group"`
8321 dug = <SimpleSoundSpec>,
8324 place = <SimpleSoundSpec>,
8325 -- Node was placed. Also played after falling
8327 place_failed = <SimpleSoundSpec>,
8328 -- When node placement failed.
8329 -- Note: This happens if the _built-in_ node placement failed.
8330 -- This sound will still be played if the node is placed in the
8331 -- `on_place` callback manually.
8333 fall = <SimpleSoundSpec>,
8334 -- When node starts to fall or is detached
8338 -- Name of dropped item when dug.
8339 -- Default dropped item is the node itself.
8341 -- Using a table allows multiple items, drop chances and item filtering:
8344 -- Maximum number of item lists to drop.
8345 -- The entries in 'items' are processed in order. For each:
8346 -- Item filtering is applied, chance of drop is applied, if both are
8347 -- successful the entire item list is dropped.
8348 -- Entry processing continues until the number of dropped item lists
8349 -- equals 'max_items'.
8350 -- Therefore, entries should progress from low to high drop chance.
8354 -- 1 in 1000 chance of dropping a diamond.
8355 -- Default rarity is '1'.
8357 items = {"default:diamond"},
8360 -- Only drop if using an item whose name is identical to one
8362 tools = {"default:shovel_mese", "default:shovel_diamond"},
8364 items = {"default:dirt"},
8365 -- Whether all items in the dropped item list inherit the
8366 -- hardware coloring palette color from the dug node.
8367 -- Default is 'false'.
8368 inherit_color = true,
8371 -- Only drop if using an item whose name contains
8372 -- "default:shovel_" (this item filtering by string matching
8373 -- is deprecated, use tool_groups instead).
8374 tools = {"~default:shovel_"},
8376 -- The item list dropped.
8377 items = {"default:sand", "default:desert_sand"},
8380 -- Only drop if using an item in the "magicwand" group, or
8381 -- an item that is in both the "pickaxe" and the "lucky"
8385 {"pickaxe", "lucky"}
8387 items = {"default:coal_lump"},
8392 on_construct = function(pos),
8393 -- Node constructor; called after adding node.
8394 -- Can set up metadata and stuff like that.
8395 -- Not called for bulk node placement (i.e. schematics and VoxelManip).
8398 on_destruct = function(pos),
8399 -- Node destructor; called before removing node.
8400 -- Not called for bulk node placement.
8403 after_destruct = function(pos, oldnode),
8404 -- Node destructor; called after removing node.
8405 -- Not called for bulk node placement.
8408 on_flood = function(pos, oldnode, newnode),
8409 -- Called when a liquid (newnode) is about to flood oldnode, if it has
8410 -- `floodable = true` in the nodedef. Not called for bulk node placement
8411 -- (i.e. schematics and VoxelManip) or air nodes. If return true the
8412 -- node is not flooded, but on_flood callback will most likely be called
8413 -- over and over again every liquid update interval.
8415 -- Warning: making a liquid node 'floodable' will cause problems.
8417 preserve_metadata = function(pos, oldnode, oldmeta, drops),
8418 -- Called when oldnode is about be converted to an item, but before the
8419 -- node is deleted from the world or the drops are added. This is
8420 -- generally the result of either the node being dug or an attached node
8421 -- becoming detached.
8422 -- oldmeta are the metadata fields (table) of the node before deletion.
8423 -- drops is a table of ItemStacks, so any metadata to be preserved can
8424 -- be added directly to one or more of the dropped items. See
8425 -- "ItemStackMetaRef".
8428 after_place_node = function(pos, placer, itemstack, pointed_thing),
8429 -- Called after constructing node when node was placed using
8430 -- minetest.item_place_node / minetest.place_node.
8431 -- If return true no item is taken from itemstack.
8432 -- `placer` may be any valid ObjectRef or nil.
8435 after_dig_node = function(pos, oldnode, oldmetadata, digger),
8436 -- oldmetadata is in table format.
8437 -- Called after destructing node when node was dug using
8438 -- minetest.node_dig / minetest.dig_node.
8441 can_dig = function(pos, [player]),
8442 -- Returns true if node can be dug, or false if not.
8445 on_punch = function(pos, node, puncher, pointed_thing),
8446 -- default: minetest.node_punch
8447 -- Called when puncher (an ObjectRef) punches the node at pos.
8448 -- By default calls minetest.register_on_punchnode callbacks.
8450 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
8452 -- Called when clicker (an ObjectRef) used the 'place/build' key
8453 -- (not neccessarily an actual rightclick)
8454 -- while pointing at the node at pos with 'node' being the node table.
8455 -- itemstack will hold clicker's wielded item.
8456 -- Shall return the leftover itemstack.
8457 -- Note: pointed_thing can be nil, if a mod calls this function.
8458 -- This function does not get triggered by clients <=0.4.16 if the
8459 -- "formspec" node metadata field is set.
8461 on_dig = function(pos, node, digger),
8462 -- default: minetest.node_dig
8463 -- By default checks privileges, wears out item (if tool) and removes node.
8464 -- return true if the node was dug successfully, false otherwise.
8465 -- Deprecated: returning nil is the same as returning true.
8467 on_timer = function(pos, elapsed),
8469 -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
8470 -- elapsed is the total time passed since the timer was started.
8471 -- return true to run the timer for another cycle with the same timeout
8474 on_receive_fields = function(pos, formname, fields, sender),
8475 -- fields = {name1 = value1, name2 = value2, ...}
8476 -- Called when an UI form (e.g. sign text input) returns data.
8477 -- See minetest.register_on_player_receive_fields for more info.
8480 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8481 -- Called when a player wants to move items inside the inventory.
8482 -- Return value: number of items allowed to move.
8484 allow_metadata_inventory_put = function(pos, listname, index, stack, player),
8485 -- Called when a player wants to put something into the inventory.
8486 -- Return value: number of items allowed to put.
8487 -- Return value -1: Allow and don't modify item count in inventory.
8489 allow_metadata_inventory_take = function(pos, listname, index, stack, player),
8490 -- Called when a player wants to take something out of the inventory.
8491 -- Return value: number of items allowed to take.
8492 -- Return value -1: Allow and don't modify item count in inventory.
8494 on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8495 on_metadata_inventory_put = function(pos, listname, index, stack, player),
8496 on_metadata_inventory_take = function(pos, listname, index, stack, player),
8497 -- Called after the actual action has happened, according to what was
8501 on_blast = function(pos, intensity),
8502 -- intensity: 1.0 = mid range of regular TNT.
8503 -- If defined, called when an explosion touches the node, instead of
8504 -- removing the node.
8506 mod_origin = "modname",
8507 -- stores which mod actually registered a node
8508 -- If the source could not be determined it contains "??"
8509 -- Useful for getting which mod truly registered something
8510 -- example: if a node is registered as ":othermodname:nodename",
8511 -- nodename will show "othermodname", but mod_orgin will say "modname"
8517 Crafting converts one or more inputs to one output itemstack of arbitrary
8518 count (except for fuels, which don't have an output). The conversion reduces
8519 each input ItemStack by 1.
8521 Craft recipes are registered by `minetest.register_craft` and use a
8522 table format. The accepted parameters are listed below.
8524 Recipe input items can either be specified by item name (item count = 1)
8525 or by group (see "Groups in crafting recipes" for details).
8527 The following sections describe the types and syntaxes of recipes.
8531 This is the default recipe type (when no `type` is specified).
8533 A shaped recipe takes one or multiple items as input and has
8534 a single item stack as output. The input items must be specified
8535 in a 2-dimensional matrix (see parameters below) to specify the
8536 exact arrangement (the "shape") in which the player must place them
8537 in the crafting grid.
8539 For example, for a 3x3 recipe, the `recipes` table must have
8540 3 rows and 3 columns.
8542 In order to craft the recipe, the players' crafting grid must
8543 have equal or larger dimensions (both width and height).
8547 * `type = "shaped"`: (optional) specifies recipe type as shaped
8548 * `output`: Itemstring of output itemstack (item counts >= 1 are allowed)
8549 * `recipe`: A 2-dimensional matrix of items, with a width *w* and height *h*.
8550 * *w* and *h* are chosen by you, they don't have to be equal but must be at least 1
8551 * The matrix is specified as a table containing tables containing itemnames
8552 * The inner tables are the rows. There must be *h* tables, specified from the top to the bottom row
8553 * Values inside of the inner table are the columns.
8554 Each inner table must contain a list of *w* items, specified from left to right
8555 * Empty slots *must* be filled with the empty string
8556 * `replacements`: (optional) Allows you to replace input items with some other items
8557 when something is crafted
8558 * Provided as a list of item pairs of the form `{ old_item, new_item }` where
8559 `old_item` is the input item to replace (same syntax as for a regular input
8560 slot; groups are allowed) and `new_item` is an itemstring for the item stack
8562 * When the output is crafted, Minetest iterates through the list
8563 of input items if the crafting grid. For each input item stack, it checks if
8564 it matches with an `old_item` in the item pair list.
8565 * If it matches, the item will be replaced. Also, this item pair
8566 will *not* be applied again for the remaining items
8567 * If it does not match, the item is consumed (reduced by 1) normally
8568 * The `new_item` will appear in one of 3 places:
8569 * Crafting grid, if the input stack size was exactly 1
8570 * Player inventory, if input stack size was larger
8571 * Drops as item entity, if it fits neither in craft grid or inventory
8575 A typical shaped recipe:
8579 output = "example:stone_pickaxe",
8580 -- A 3x3 recipe which needs 3 stone in the 1st row,
8581 -- and 1 stick in the horizontal middle in each of the 2nd and 3nd row.
8582 -- The 4 remaining slots have to be empty.
8584 {"example:stone", "example:stone", "example:stone"}, -- row 1
8585 {"", "example:stick", "" }, -- row 2
8586 {"", "example:stick", "" }, -- row 3
8587 -- ^ column 1 ^ column 2 ^ column 3
8589 -- There is no replacements table, so every input item
8590 -- will be consumed.
8593 Simple replacement example:
8597 output = "example:wet_sponge",
8598 -- 1x2 recipe with a water bucket above a dry sponge
8600 {"example:water_bucket"},
8601 {"example:dry_sponge"},
8603 -- When the wet sponge is crafted, the water bucket
8604 -- in the input slot is replaced with an empty
8607 {"example:water_bucket", "example:empty_bucket"},
8611 Complex replacement example 1:
8615 output = "example:very_wet_sponge",
8616 -- 3x3 recipe with a wet sponge in the center
8617 -- and 4 water buckets around it
8619 {"","example:water_bucket",""},
8620 {"example:water_bucket","example:wet_sponge","example:water_bucket"},
8621 {"","example:water_bucket",""},
8623 -- When the wet sponge is crafted, all water buckets
8624 -- in the input slot become empty
8626 -- Without these repetitions, only the first
8627 -- water bucket would be replaced.
8628 {"example:water_bucket", "example:empty_bucket"},
8629 {"example:water_bucket", "example:empty_bucket"},
8630 {"example:water_bucket", "example:empty_bucket"},
8631 {"example:water_bucket", "example:empty_bucket"},
8635 Complex replacement example 2:
8638 -- 3 magic orbs + 1 book crafts a magic book,
8639 -- and the orbs will be replaced with 3 different runes.
8641 output = "example:magic_book",
8644 -- 3 items in the group `magic_orb` on top of a book in the middle
8645 {"group:magic_orb", "group:magic_orb", "group:magic_orb"},
8646 {"", "example:book", ""},
8648 -- When the book is crafted, the 3 magic orbs will be turned into
8649 -- 3 runes: ice rune, earth rune and fire rune (from left to right)
8651 {"group:magic_orb", "example:ice_rune"},
8652 {"group:magic_orb", "example:earth_rune"},
8653 {"group:magic_orb", "example:fire_rune"},
8659 Takes a list of input items (at least 1). The order or arrangement
8660 of input items does not matter.
8662 In order to craft the recipe, the players' crafting grid must have matching or
8663 larger *count* of slots. The grid dimensions do not matter.
8667 * `type = "shapeless"`: Mandatory
8668 * `output`: Same as for shaped recipe
8669 * `recipe`: List of item names
8670 * `replacements`: Same as for shaped recipe
8675 -- Craft a mushroom stew from a bowl, a brown mushroom and a red mushroom
8676 -- (no matter where in the input grid the items are placed)
8678 output = "example:mushroom_stew",
8681 "example:mushroom_brown",
8682 "example:mushroom_red",
8691 type = "toolrepair",
8692 additional_wear = -0.02, -- multiplier of 65536
8695 Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
8696 group. If this recipe is used, repairing is possible with any crafting grid
8697 with at least 2 slots.
8698 The player can put 2 equal tools in the craft grid to get one "repaired" tool
8700 The wear of the output is determined by the wear of both tools, plus a
8701 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
8702 you want `additional_wear` to be negative.
8704 The formula used to calculate the resulting wear is:
8706 65536 * (1 - ( (1 - tool_1_wear) + (1 - tool_2_wear) + additional_wear ))
8708 The result is rounded and can't be lower than 0. If the result is 65536 or higher,
8709 no crafting is possible.
8713 A cooking recipe has a single input item, a single output item stack
8714 and a cooking time. It represents cooking/baking/smelting/etc. items in
8715 an oven, furnace, or something similar; the exact meaning is up for games
8716 to decide, if they choose to use cooking at all.
8718 The engine does not implement anything specific to cooking recipes, but
8719 the recipes can be retrieved later using `minetest.get_craft_result` to
8720 have a consistent interface across different games/mods.
8724 * `type = "cooking"`: Mandatory
8725 * `output`: Same as for shaped recipe
8726 * `recipe`: An itemname of the single input item
8727 * `cooktime`: (optional) Time it takes to cook this item, in seconds.
8728 A floating-point number. (default: 3.0)
8729 * `replacements`: Same meaning as for shaped recipes, but the mods
8730 that utilize cooking recipes (e.g. for adding a furnace
8731 node) need to implement replacements on their own
8733 Note: Games and mods are free to re-interpret the cooktime in special
8734 cases, e.g. for a super furnace that cooks items twice as fast.
8738 Cooking sand to glass in 3 seconds:
8742 output = "example:glass",
8743 recipe = "example:sand",
8749 A fuel recipe is an item associated with a "burning time" and an optional
8750 item replacement. There is no output. This is usually used as fuel for
8751 furnaces, ovens, stoves, etc.
8753 Like with cooking recipes, the engine does not do anything specific with
8754 fuel recipes and it's up to games and mods to use them by retrieving
8755 them via `minetest.get_craft_result`.
8759 * `type = "fuel"`: Mandatory
8760 * `recipe`: Itemname of the item to be used as fuel
8761 * `burntime`: (optional) Burning time this item provides, in seconds.
8762 A floating-point number. (default: 1.0)
8763 * `replacements`: Same meaning as for shaped recipes, but the mods
8764 that utilize fuels need to implement replacements
8767 Note: Games and mods are free to re-interpret the burntime in special
8768 cases, e.g. for an efficient furnace in which fuels burn twice as
8773 Coal lump with a burntime of 20 seconds. Will be consumed when used.
8777 recipe = "example:coal_lump",
8781 Lava bucket with a burn time of 60 seconds. Will become an empty bucket
8786 recipe = "example:lava_bucket",
8788 replacements = {{"example:lava_bucket", "example:empty_bucket"}},
8794 Used by `minetest.register_ore`.
8796 See [Ores] section above for essential information.
8800 -- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
8803 -- Ore node to place
8806 -- Param2 to set for ore (e.g. facedir rotation)
8809 -- Node to place ore in. Multiple are possible by passing a list.
8811 clust_scarcity = 8 * 8 * 8,
8812 -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
8813 -- If the desired average distance between ores is 'd', set this to
8817 -- Number of ores in a cluster
8820 -- Size of the bounding box of the cluster.
8821 -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
8822 -- nodes are coal ore.
8826 -- Lower and upper limits for ore (inclusive)
8829 -- Attributes for the ore generation, see 'Ore attributes' section above
8831 noise_threshold = 0,
8832 -- If noise is above this threshold, ore is placed. Not needed for a
8833 -- uniform distribution.
8838 spread = {x = 100, y = 100, z = 100},
8843 -- NoiseParams structure describing one of the perlin noises used for
8844 -- ore distribution.
8845 -- Needed by "sheet", "puff", "blob" and "vein" ores.
8846 -- Omit from "scatter" ore for a uniform ore distribution.
8847 -- Omit from "stratum" ore for a simple horizontal strata from y_min to
8850 biomes = {"desert", "rainforest"},
8851 -- List of biomes in which this ore occurs.
8852 -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
8853 -- being used does not support biomes.
8854 -- Can be a list of (or a single) biome names, IDs, or definitions.
8856 -- Type-specific parameters
8859 column_height_min = 1,
8860 column_height_max = 16,
8861 column_midpoint_factor = 0.5,
8867 spread = {x = 100, y = 100, z = 100},
8875 spread = {x = 100, y = 100, z = 100},
8882 random_factor = 1.0,
8885 np_stratum_thickness = {
8888 spread = {x = 100, y = 100, z = 100},
8893 stratum_thickness = 8, -- only used if no noise defined
8899 Used by `minetest.register_biome`.
8901 The maximum number of biomes that can be used is 65535. However, using an
8902 excessive number of biomes will slow down map generation. Depending on desired
8903 performance and computing power the practical limit is much lower.
8908 node_dust = "default:snow",
8909 -- Node dropped onto upper surface after all else is generated
8911 node_top = "default:dirt_with_snow",
8913 -- Node forming surface layer of biome and thickness of this layer
8915 node_filler = "default:permafrost",
8917 -- Node forming lower layer of biome and thickness of this layer
8919 node_stone = "default:bluestone",
8920 -- Node that replaces all stone nodes between roughly y_min and y_max.
8922 node_water_top = "default:ice",
8923 depth_water_top = 10,
8924 -- Node forming a surface layer in seawater with the defined thickness
8927 -- Node that replaces all seawater nodes not in the surface layer
8929 node_river_water = "default:ice",
8930 -- Node that replaces river water in mapgens that use
8931 -- default:river_water
8933 node_riverbed = "default:gravel",
8935 -- Node placed under river water and thickness of this layer
8937 node_cave_liquid = "default:lava_source",
8938 node_cave_liquid = {"default:water_source", "default:lava_source"},
8939 -- Nodes placed inside 50% of the medium size caves.
8940 -- Multiple nodes can be specified, each cave will use a randomly
8941 -- chosen node from the list.
8942 -- If this field is left out or 'nil', cave liquids fall back to
8943 -- classic behaviour of lava and water distributed using 3D noise.
8944 -- For no cave liquid, specify "air".
8946 node_dungeon = "default:cobble",
8947 -- Node used for primary dungeon structure.
8948 -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
8949 -- alias, if that is also absent, dungeon nodes fall back to the biome
8951 -- If present, the following two nodes are also used.
8953 node_dungeon_alt = "default:mossycobble",
8954 -- Node used for randomly-distributed alternative structure nodes.
8955 -- If alternative structure nodes are not wanted leave this absent.
8957 node_dungeon_stair = "stairs:stair_cobble",
8958 -- Node used for dungeon stairs.
8959 -- If absent, stairs fall back to 'node_dungeon'.
8963 -- Upper and lower limits for biome.
8964 -- Alternatively you can use xyz limits as shown below.
8966 max_pos = {x = 31000, y = 128, z = 31000},
8967 min_pos = {x = -31000, y = 9, z = -31000},
8968 -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
8969 -- Biome is limited to a cuboid defined by these positions.
8970 -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
8971 -- 31000 in 'max_pos'.
8974 -- Vertical distance in nodes above 'y_max' over which the biome will
8975 -- blend with the biome above.
8976 -- Set to 0 for no vertical blend. Defaults to 0.
8979 humidity_point = 50,
8980 -- Characteristic temperature and humidity for the biome.
8981 -- These values create 'biome points' on a voronoi diagram with heat and
8982 -- humidity as axes. The resulting voronoi cells determine the
8983 -- distribution of the biomes.
8984 -- Heat and humidity have average values of 50, vary mostly between
8985 -- 0 and 100 but can exceed these values.
8988 Decoration definition
8989 ---------------------
8991 See [Decoration types]. Used by `minetest.register_decoration`.
8994 deco_type = "simple",
8995 -- Type. "simple" or "schematic" supported
8997 place_on = "default:dirt_with_grass",
8998 -- Node (or list of nodes) that the decoration can be placed on
9001 -- Size of the square (X / Z) divisions of the mapchunk being generated.
9002 -- Determines the resolution of noise variation if used.
9003 -- If the chunk size is not evenly divisible by sidelen, sidelen is made
9004 -- equal to the chunk size.
9007 -- The value determines 'decorations per surface node'.
9008 -- Used only if noise_params is not specified.
9009 -- If >= 10.0 complete coverage is enabled and decoration placement uses
9010 -- a different and much faster method.
9015 spread = {x = 100, y = 100, z = 100},
9022 -- NoiseParams structure describing the perlin noise used for decoration
9024 -- A noise value is calculated for each square division and determines
9025 -- 'decorations per surface node' within each division.
9026 -- If the noise value >= 10.0 complete coverage is enabled and
9027 -- decoration placement uses a different and much faster method.
9029 biomes = {"Oceanside", "Hills", "Plains"},
9030 -- List of biomes in which this decoration occurs. Occurs in all biomes
9031 -- if this is omitted, and ignored if the Mapgen being used does not
9033 -- Can be a list of (or a single) biome names, IDs, or definitions.
9037 -- Lower and upper limits for decoration (inclusive).
9038 -- These parameters refer to the Y co-ordinate of the 'place_on' node.
9040 spawn_by = "default:water",
9041 -- Node (or list of nodes) that the decoration only spawns next to.
9042 -- Checks the 8 neighbouring nodes on the same Y, and also the ones
9043 -- at Y+1, excluding both center nodes.
9046 -- Number of spawn_by nodes that must be surrounding the decoration
9047 -- position to occur.
9048 -- If absent or -1, decorations occur next to any nodes.
9050 flags = "liquid_surface, force_placement, all_floors, all_ceilings",
9051 -- Flags for all decoration types.
9052 -- "liquid_surface": Instead of placement on the highest solid surface
9053 -- in a mapchunk column, placement is on the highest liquid surface.
9054 -- Placement is disabled if solid nodes are found above the liquid
9056 -- "force_placement": Nodes other than "air" and "ignore" are replaced
9057 -- by the decoration.
9058 -- "all_floors", "all_ceilings": Instead of placement on the highest
9059 -- surface in a mapchunk the decoration is placed on all floor and/or
9060 -- ceiling surfaces, for example in caves and dungeons.
9061 -- Ceiling decorations act as an inversion of floor decorations so the
9062 -- effect of 'place_offset_y' is inverted.
9063 -- Y-slice probabilities do not function correctly for ceiling
9064 -- schematic decorations as the behaviour is unchanged.
9065 -- If a single decoration registration has both flags the floor and
9066 -- ceiling decorations will be aligned vertically.
9068 ----- Simple-type parameters
9070 decoration = "default:grass",
9071 -- The node name used as the decoration.
9072 -- If instead a list of strings, a randomly selected node from the list
9073 -- is placed as the decoration.
9076 -- Decoration height in nodes.
9077 -- If height_max is not 0, this is the lower limit of a randomly
9081 -- Upper limit of the randomly selected height.
9082 -- If absent, the parameter 'height' is used as a constant.
9085 -- Param2 value of decoration nodes.
9086 -- If param2_max is not 0, this is the lower limit of a randomly
9090 -- Upper limit of the randomly selected param2.
9091 -- If absent, the parameter 'param2' is used as a constant.
9094 -- Y offset of the decoration base node relative to the standard base
9096 -- Can be positive or negative. Default is 0.
9097 -- Effect is inverted for "all_ceilings" decorations.
9098 -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
9099 -- to the 'place_on' node.
9101 ----- Schematic-type parameters
9103 schematic = "foobar.mts",
9104 -- If schematic is a string, it is the filepath relative to the current
9105 -- working directory of the specified Minetest schematic file.
9106 -- Could also be the ID of a previously registered schematic.
9109 size = {x = 4, y = 6, z = 4},
9111 {name = "default:cobble", param1 = 255, param2 = 0},
9112 {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
9113 {name = "air", param1 = 255, param2 = 0},
9117 {ypos = 2, prob = 128},
9118 {ypos = 5, prob = 64},
9122 -- Alternative schematic specification by supplying a table. The fields
9123 -- size and data are mandatory whereas yslice_prob is optional.
9124 -- See 'Schematic specifier' for details.
9126 replacements = {["oldname"] = "convert_to", ...},
9127 -- Map of node names to replace in the schematic after reading it.
9129 flags = "place_center_x, place_center_y, place_center_z",
9130 -- Flags for schematic decorations. See 'Schematic attributes'.
9133 -- Rotation can be "0", "90", "180", "270", or "random"
9136 -- If the flag 'place_center_y' is set this parameter is ignored.
9137 -- Y offset of the schematic base node layer relative to the 'place_on'
9139 -- Can be positive or negative. Default is 0.
9140 -- Effect is inverted for "all_ceilings" decorations.
9141 -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
9142 -- to the 'place_on' node.
9145 Chat command definition
9146 -----------------------
9148 Used by `minetest.register_chatcommand`.
9151 params = "<name> <privilege>", -- Short parameter description
9153 description = "Remove privilege from player", -- Full description
9155 privs = {privs=true}, -- Require the "privs" privilege to run
9157 func = function(name, param),
9158 -- Called when command is run. Returns boolean success and text output.
9159 -- Special case: The help message is shown to the player if `func`
9160 -- returns false without a text output.
9163 Note that in params, use of symbols is as follows:
9165 * `<>` signifies a placeholder to be replaced when the command is used. For
9166 example, when a player name is needed: `<name>`
9167 * `[]` signifies param is optional and not required when the command is used.
9168 For example, if you require param1 but param2 is optional:
9169 `<param1> [<param2>]`
9170 * `|` signifies exclusive or. The command requires one param from the options
9171 provided. For example: `<param1> | <param2>`
9172 * `()` signifies grouping. For example, when param1 and param2 are both
9173 required, or only param3 is required: `(<param1> <param2>) | <param3>`
9175 Privilege definition
9176 --------------------
9178 Used by `minetest.register_privilege`.
9182 -- Privilege description
9184 give_to_singleplayer = true,
9185 -- Whether to grant the privilege to singleplayer.
9187 give_to_admin = true,
9188 -- Whether to grant the privilege to the server admin.
9189 -- Uses value of 'give_to_singleplayer' by default.
9191 on_grant = function(name, granter_name),
9192 -- Called when given to player 'name' by 'granter_name'.
9193 -- 'granter_name' will be nil if the priv was granted by a mod.
9195 on_revoke = function(name, revoker_name),
9196 -- Called when taken from player 'name' by 'revoker_name'.
9197 -- 'revoker_name' will be nil if the priv was revoked by a mod.
9199 -- Note that the above two callbacks will be called twice if a player is
9200 -- responsible, once with the player name, and then with a nil player
9202 -- Return true in the above callbacks to stop register_on_priv_grant or
9203 -- revoke being called.
9206 Detached inventory callbacks
9207 ----------------------------
9209 Used by `minetest.create_detached_inventory`.
9212 allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
9213 -- Called when a player wants to move items inside the inventory.
9214 -- Return value: number of items allowed to move.
9216 allow_put = function(inv, listname, index, stack, player),
9217 -- Called when a player wants to put something into the inventory.
9218 -- Return value: number of items allowed to put.
9219 -- Return value -1: Allow and don't modify item count in inventory.
9221 allow_take = function(inv, listname, index, stack, player),
9222 -- Called when a player wants to take something out of the inventory.
9223 -- Return value: number of items allowed to take.
9224 -- Return value -1: Allow and don't modify item count in inventory.
9226 on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
9227 on_put = function(inv, listname, index, stack, player),
9228 on_take = function(inv, listname, index, stack, player),
9229 -- Called after the actual action has happened, according to what was
9237 Since most values have multiple different functions, please see the
9238 documentation in [HUD] section.
9240 Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
9243 hud_elem_type = "image",
9244 -- Type of element, can be "image", "text", "statbar", "inventory",
9245 -- "waypoint", "image_waypoint", "compass" or "minimap"
9247 position = {x=0.5, y=0.5},
9248 -- Top left corner position of element
9252 scale = {x = 1, y = 1},
9263 -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
9265 alignment = {x=0, y=0},
9267 offset = {x=0, y=0},
9269 world_pos = {x=0, y=0, z=0},
9274 -- Z index: lower z-index HUDs are displayed behind higher z-index HUDs
9282 Used by `minetest.add_particle`.
9285 pos = {x=0, y=0, z=0},
9286 velocity = {x=0, y=0, z=0},
9287 acceleration = {x=0, y=0, z=0},
9288 -- Spawn particle at pos with velocity and acceleration
9291 -- Disappears after expirationtime seconds
9294 -- Scales the visual size of the particle texture.
9295 -- If `node` is set, size can be set to 0 to spawn a randomly-sized
9296 -- particle (just like actual node dig particles).
9298 collisiondetection = false,
9299 -- If true collides with `walkable` nodes and, depending on the
9300 -- `object_collision` field, objects too.
9302 collision_removal = false,
9303 -- If true particle is removed when it collides.
9304 -- Requires collisiondetection = true to have any effect.
9306 object_collision = false,
9307 -- If true particle collides with objects that are defined as
9308 -- `physical = true,` and `collide_with_objects = true,`.
9309 -- Requires collisiondetection = true to have any effect.
9312 -- If true faces player using y axis only
9314 texture = "image.png",
9315 -- The texture of the particle
9316 -- v5.6.0 and later: also supports the table format described in the
9317 -- following section
9319 playername = "singleplayer",
9320 -- Optional, if specified spawns particle only on the player's client
9322 animation = {Tile Animation definition},
9323 -- Optional, specifies how to animate the particle texture
9326 -- Optional, specify particle self-luminescence in darkness.
9329 node = {name = "ignore", param2 = 0},
9330 -- Optional, if specified the particle will have the same appearance as
9331 -- node dig particles for the given node.
9332 -- `texture` and `animation` will be ignored if this is set.
9335 -- Optional, only valid in combination with `node`
9336 -- If set to a valid number 1-6, specifies the tile from which the
9337 -- particle texture is picked.
9338 -- Otherwise, the default behavior is used. (currently: any random tile)
9340 drag = {x=0, y=0, z=0},
9341 -- v5.6.0 and later: Optional drag value, consult the following section
9343 bounce = {min = ..., max = ..., bias = 0},
9344 -- v5.6.0 and later: Optional bounce range, consult the following section
9348 `ParticleSpawner` definition
9349 ----------------------------
9351 Used by `minetest.add_particlespawner`.
9353 Before v5.6.0, particlespawners used a different syntax and had a more limited set
9354 of features. Definition fields that are the same in both legacy and modern versions
9355 are shown in the next listing, and the fields that are used by legacy versions are
9356 shown separated by a comment; the modern fields are too complex to compactly
9357 describe in this manner and are documented after the listing.
9359 The older syntax can be used in combination with the newer syntax (e.g. having
9360 `minpos`, `maxpos`, and `pos` all set) to support older servers. On newer servers,
9361 the new syntax will override the older syntax; on older servers, the newer syntax
9365 -- Common fields (same name and meaning in both new and legacy syntax)
9368 -- Number of particles spawned over the time period `time`.
9371 -- Lifespan of spawner in seconds.
9372 -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
9373 -- a per-second basis.
9375 collisiondetection = false,
9376 -- If true collide with `walkable` nodes and, depending on the
9377 -- `object_collision` field, objects too.
9379 collision_removal = false,
9380 -- If true particles are removed when they collide.
9381 -- Requires collisiondetection = true to have any effect.
9383 object_collision = false,
9384 -- If true particles collide with objects that are defined as
9385 -- `physical = true,` and `collide_with_objects = true,`.
9386 -- Requires collisiondetection = true to have any effect.
9388 attached = ObjectRef,
9389 -- If defined, particle positions, velocities and accelerations are
9390 -- relative to this object's position and yaw
9393 -- If true face player using y axis only
9395 texture = "image.png",
9396 -- The texture of the particle
9398 playername = "singleplayer",
9399 -- Optional, if specified spawns particles only on the player's client
9401 animation = {Tile Animation definition},
9402 -- Optional, specifies how to animate the particles' texture
9403 -- v5.6.0 and later: set length to -1 to sychronize the length
9404 -- of the animation with the expiration time of individual particles.
9405 -- (-2 causes the animation to be played twice, and so on)
9408 -- Optional, specify particle self-luminescence in darkness.
9411 node = {name = "ignore", param2 = 0},
9412 -- Optional, if specified the particles will have the same appearance as
9413 -- node dig particles for the given node.
9414 -- `texture` and `animation` will be ignored if this is set.
9417 -- Optional, only valid in combination with `node`
9418 -- If set to a valid number 1-6, specifies the tile from which the
9419 -- particle texture is picked.
9420 -- Otherwise, the default behavior is used. (currently: any random tile)
9422 -- Legacy definition fields
9424 minpos = {x=0, y=0, z=0},
9425 maxpos = {x=0, y=0, z=0},
9426 minvel = {x=0, y=0, z=0},
9427 maxvel = {x=0, y=0, z=0},
9428 minacc = {x=0, y=0, z=0},
9429 maxacc = {x=0, y=0, z=0},
9434 -- The particles' properties are random values between the min and max
9436 -- applies to: pos, velocity, acceleration, expirationtime, size
9437 -- If `node` is set, min and maxsize can be set to 0 to spawn
9438 -- randomly-sized particles (just like actual node dig particles).
9441 ### Modern definition fields
9443 After v5.6.0, spawner properties can be defined in several different ways depending
9444 on the level of control you need. `pos` for instance can be set as a single vector,
9445 in which case all particles will appear at that exact point throughout the lifetime
9446 of the spawner. Alternately, it can be specified as a min-max pair, specifying a
9447 cubic range the particles can appear randomly within. Finally, some properties can
9448 be animated by suffixing their key with `_tween` (e.g. `pos_tween`) and supplying
9451 The following definitions are all equivalent, listed in order of precedence from
9452 lowest (the legacy syntax) to highest (tween tables). If multiple forms of a
9453 property definition are present, the highest-precidence form will be selected
9454 and all lower-precedence fields will be ignored, allowing for graceful
9455 degradation in older clients).
9459 maxpos = {x = 0, y = 0, z = 0},
9460 minpos = {x = 0, y = 0, z = 0},
9464 -- all components of every particle's position vector will be set to this
9468 pos = vector.new(0,0,0),
9469 -- all particles will appear at this exact position throughout the lifetime
9470 -- of the particlespawner
9474 -- the particle will appear at a position that is picked at random from
9475 -- within a cubic range
9477 min = vector.new(0,0,0),
9478 -- `min` is the minimum value this property will be set to in particles
9479 -- spawned by the generator
9481 max = vector.new(0,0,0),
9482 -- `max` is the minimum value this property will be set to in particles
9483 -- spawned by the generator
9486 -- when `bias` is 0, all random values are exactly as likely as any
9487 -- other. when it is positive, the higher it is, the more likely values
9488 -- will appear towards the minimum end of the allowed spectrum. when
9489 -- it is negative, the lower it is, the more likely values will appear
9490 -- towards the maximum end of the allowed spectrum. the curve is
9491 -- exponential and there is no particular maximum or minimum value
9496 -- a tween table should consist of a list of frames in the same form as the
9497 -- untweened pos property above, which the engine will interpolate between,
9498 -- and optionally a number of properties that control how the interpolation
9499 -- takes place. currently **only two frames**, the first and the last, are
9500 -- used, but extra frames are accepted for the sake of forward compatibility.
9501 -- any of the above definition styles can be used here as well in any combination
9502 -- supported by the property type
9506 -- linear animation from first to last frame (default)
9508 -- linear animation from last to first frame
9510 -- linear animation from first to last then back to first again
9512 -- like "pulse", but slightly randomized to add a bit of stutter
9515 -- number of times the animation is played over the particle's lifespan
9518 -- point in the spawner's lifespan at which the animation begins. 0 is
9519 -- the very beginning, 1 is the very end
9521 -- frames can be defined in a number of different ways, depending on the
9522 -- underlying type of the property. for now, all but the first and last
9523 -- frame are ignored
9535 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9536 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9539 0, { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9543 All of the properties that can be defined in this way are listed in the next
9544 section, along with the datatypes they accept.
9546 #### List of particlespawner properties
9547 All of the properties in this list can be animated with `*_tween` tables
9548 unless otherwise specified. For example, `jitter` can be tweened by setting
9549 a `jitter_tween` table instead of (or in addition to) a `jitter` table/value.
9550 Types used are defined in the previous section.
9552 * vec3 range `pos`: the position at which particles can appear
9553 * vec3 range `vel`: the initial velocity of the particle
9554 * vec3 range `acc`: the direction and speed with which the particle
9556 * vec3 range `jitter`: offsets the velocity of each particle by a random
9557 amount within the specified range each frame. used to create Brownian motion.
9558 * vec3 range `drag`: the amount by which absolute particle velocity along
9559 each axis is decreased per second. a value of 1.0 means that the particle
9560 will be slowed to a stop over the space of a second; a value of -1.0 means
9561 that the particle speed will be doubled every second. to avoid interfering
9562 with gravity provided by `acc`, a drag vector like `vector.new(1,0,1)` can
9563 be used instead of a uniform value.
9564 * float range `bounce`: how bouncy the particles are when `collisiondetection`
9565 is turned on. values less than or equal to `0` turn off particle bounce;
9566 `1` makes the particles bounce without losing any velocity, and `2` makes
9567 them double their velocity with every bounce. `bounce` is not bounded but
9568 values much larger than `1.0` probably aren't very useful.
9569 * float range `exptime`: the number of seconds after which the particle
9571 * table `attract`: sets the birth orientation of particles relative to various
9572 shapes defined in world coordinate space. this is an alternative means of
9573 setting the velocity which allows particles to emerge from or enter into
9574 some entity or node on the map, rather than simply being assigned random
9575 velocity values within a range. the velocity calculated by this method will
9576 be **added** to that specified by `vel` if `vel` is also set, so in most
9577 cases **`vel` should be set to 0**. `attract` has the fields:
9578 * string `kind`: selects the kind of shape towards which the particles will
9579 be oriented. it must have one of the following values:
9580 * `"none"`: no attractor is set and the `attractor` table is ignored
9581 * `"point"`: the particles are attracted to a specific point in space.
9582 use this also if you want a sphere-like effect, in combination with
9583 the `radius` property.
9584 * `"line"`: the particles are attracted to an (infinite) line passing
9585 through the points `origin` and `angle`. use this for e.g. beacon
9586 effects, energy beam effects, etc.
9587 * `"plane"`: the particles are attracted to an (infinite) plane on whose
9588 surface `origin` designates a point in world coordinate space. use this
9589 for e.g. particles entering or emerging from a portal.
9590 * float range `strength`: the speed with which particles will move towards
9591 `attractor`. If negative, the particles will instead move away from that
9593 * vec3 `origin`: the origin point of the shape towards which particles will
9594 initially be oriented. functions as an offset if `origin_attached` is also
9596 * vec3 `direction`: sets the direction in which the attractor shape faces. for
9597 lines, this sets the angle of the line; e.g. a vector of (0,1,0) will
9598 create a vertical line that passes through `origin`. for planes, `direction`
9599 is the surface normal of an infinite plane on whose surface `origin` is
9600 a point. functions as an offset if `direction_attached` is also set.
9601 * entity `origin_attached`: allows the origin to be specified as an offset
9602 from the position of an entity rather than a coordinate in world space.
9603 * entity `direction_attached`: allows the direction to be specified as an offset
9604 from the position of an entity rather than a coordinate in world space.
9605 * bool `die_on_contact`: if true, the particles' lifetimes are adjusted so
9606 that they will die as they cross the attractor threshold. this behavior
9607 is the default but is undesirable for some kinds of animations; set it to
9608 false to allow particles to live out their natural lives.
9609 * vec3 range `radius`: if set, particles will be arranged in a sphere around
9610 `pos`. A constant can be used to create a spherical shell of particles, a
9611 vector to create an ovoid shell, and a range to create a volume; e.g.
9612 `{min = 0.5, max = 1, bias = 1}` will allow particles to appear between 0.5
9613 and 1 nodes away from `pos` but will cluster them towards the center of the
9614 sphere. Usually if `radius` is used, `pos` should be a single point, but it
9615 can still be a range if you really know what you're doing (e.g. to create a
9616 "roundcube" emitter volume).
9620 In versions before v5.6.0, particlespawner textures could only be specified as a single
9621 texture string. After v5.6.0, textures can now be specified as a table as well. This
9622 table contains options that allow simple animations to be applied to the texture.
9625 name = "mymod_particle_texture.png",
9626 -- the texture specification string
9629 -- controls how visible the particle is; at 1.0 the particle is fully
9630 -- visible, at 0, it is completely invisible.
9632 alpha_tween = {1, 0},
9633 -- can be used instead of `alpha` to animate the alpha value over the
9634 -- particle's lifetime. these tween tables work identically to the tween
9635 -- tables used in particlespawner properties, except that time references
9636 -- are understood with respect to the particle's lifetime, not the
9637 -- spawner's. {1,0} fades the particle out over its lifetime.
9640 scale = {x = 1, y = 1},
9641 -- scales the texture onscreen
9647 -- animates the scale over the particle's lifetime. works like the
9648 -- alpha_tween table, but can accept two-dimensional vectors as well as
9649 -- integer values. the example value would cause the particle to shrink
9650 -- in one dimension over the course of its life until it disappears
9653 -- (default) blends transparent pixels with those they are drawn atop
9654 -- according to the alpha channel of the source texture. useful for
9655 -- e.g. material objects like rocks, dirt, smoke, or node chunks
9657 -- adds the value of pixels to those underneath them, modulo the sources
9658 -- alpha channel. useful for e.g. bright light effects like sparks or fire
9660 -- like "add" but less bright. useful for subtler light effecs. note that
9661 -- this is NOT formally equivalent to the "screen" effect used in image
9662 -- editors and compositors, as it does not respect the alpha channel of
9663 -- of the image being blended
9665 -- the inverse of "add"; the value of the source pixel is subtracted from
9666 -- the pixel underneath it. a white pixel will turn whatever is underneath
9667 -- it black; a black pixel will be "transparent". useful for creating
9668 -- darkening effects
9670 animation = {Tile Animation definition},
9671 -- overrides the particlespawner's global animation property for a single
9675 Instead of setting a single texture definition, it is also possible to set a
9676 `texpool` property. A `texpool` consists of a list of possible particle textures.
9677 Every time a particle is spawned, the engine will pick a texture at random from
9678 the `texpool` and assign it as that particle's texture. You can also specify a
9679 `texture` in addition to a `texpool`; the `texture` value will be ignored on newer
9680 clients but will be sent to older (pre-v5.6.0) clients that do not implement
9684 "mymod_particle_texture.png";
9685 { name = "mymod_spark.png", fade = "out" },
9687 name = "mymod_dust.png",
9691 type = "vertical_frames",
9692 aspect_w = 16, aspect_h = 16,
9695 -- the animation lasts for 3s and then repeats
9697 -- repeat the animation three times over the particle's lifetime
9698 -- (post-v5.6.0 clients only)
9703 #### List of animatable texture properties
9705 While animated particlespawner values vary over the course of the particlespawner's
9706 lifetime, animated texture properties vary over the lifespans of the individual
9707 particles spawned with that texture. So a particle with the texture property
9715 would be invisible at its spawning, pulse visible four times throughout its
9716 lifespan, and then vanish again before expiring.
9718 * float `alpha` (0.0 - 1.0): controls the visibility of the texture
9719 * vec2 `scale`: controls the size of the displayed billboard onscreen. Its units
9720 are multiples of the parent particle's assigned size (see the `size` property above)
9722 `HTTPRequest` definition
9723 ------------------------
9725 Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
9728 url = "http://example.org",
9731 -- Timeout for request to be completed in seconds. Default depends on engine settings.
9733 method = "GET", "POST", "PUT" or "DELETE"
9734 -- The http method to use. Defaults to "GET".
9736 data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
9737 -- Data for the POST, PUT or DELETE request.
9738 -- Accepts both a string and a table. If a table is specified, encodes
9739 -- table as x-www-form-urlencoded key-value pairs.
9741 user_agent = "ExampleUserAgent",
9742 -- Optional, if specified replaces the default minetest user agent with
9745 extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
9746 -- Optional, if specified adds additional headers to the HTTP request.
9747 -- You must make sure that the header strings follow HTTP specification
9751 -- Optional, if true performs a multipart HTTP request.
9752 -- Default is false.
9753 -- Post only, data must be array
9755 post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
9756 -- Deprecated, use `data` instead. Forces `method = "POST"`.
9759 `HTTPRequestResult` definition
9760 ------------------------------
9762 Passed to `HTTPApiTable.fetch` callback. Returned by
9763 `HTTPApiTable.fetch_async_get`.
9767 -- If true, the request has finished (either succeeded, failed or timed
9771 -- If true, the request was successful
9774 -- If true, the request timed out
9782 Authentication handler definition
9783 ---------------------------------
9785 Used by `minetest.register_authentication_handler`.
9788 get_auth = function(name),
9789 -- Get authentication data for existing player `name` (`nil` if player
9791 -- Returns following structure:
9792 -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
9794 create_auth = function(name, password),
9795 -- Create new auth data for player `name`.
9796 -- Note that `password` is not plain-text but an arbitrary
9797 -- representation decided by the engine.
9799 delete_auth = function(name),
9800 -- Delete auth data of player `name`.
9801 -- Returns boolean indicating success (false if player is nonexistent).
9803 set_password = function(name, password),
9804 -- Set password of player `name` to `password`.
9805 -- Auth data should be created if not present.
9807 set_privileges = function(name, privileges),
9808 -- Set privileges of player `name`.
9809 -- `privileges` is in table form, auth data should be created if not
9812 reload = function(),
9813 -- Reload authentication data from the storage location.
9814 -- Returns boolean indicating success.
9816 record_login = function(name),
9817 -- Called when player joins, used for keeping track of last_login
9819 iterate = function(),
9820 -- Returns an iterator (use with `for` loops) for all player names
9821 -- currently in the auth database
9827 Functions: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap
9829 See http://bitop.luajit.org/ for advanced information.