]> git.lizzy.rs Git - minetest.git/blob - doc/lua_api.txt
Fix trivial get_armor_groups documentation issue (#12760)
[minetest.git] / doc / lua_api.txt
1 Minetest Lua Modding API Reference
2 ==================================
3
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/>
7
8 Introduction
9 ------------
10
11 Content and functionality can be added to Minetest using Lua scripting
12 in run-time loaded mods.
13
14 A mod is a self-contained bunch of scripts, textures and other related
15 things, which is loaded by and interfaces with Minetest.
16
17 Mods are contained and ran solely on the server side. Definitions and media
18 files are automatically transferred to the client.
19
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.
22
23 Programming in Lua
24 ------------------
25
26 If you have any difficulty in understanding this, please read
27 [Programming in Lua](http://www.lua.org/pil/).
28
29 Startup
30 -------
31
32 Mods are loaded during server startup from the mod load paths by running
33 the `init.lua` scripts in a shared environment.
34
35 Paths
36 -----
37
38 Minetest keeps and looks for files mostly in two paths. `path_share` or `path_user`.
39
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
42 worlds or settings.
43
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.
48
49 Games
50 =====
51
52 Games are looked up from:
53
54 * `$path_share/games/<gameid>/`
55 * `$path_user/games/<gameid>/`
56
57 Where `<gameid>` is unique to each game.
58
59 The game directory can contain the following files:
60
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
68       game.
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
75       `disallowed_mapgens`.
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
89                 ContentDB.
90     * `release`: Ignore this: Should only ever be set by ContentDB, as it is
91                  an internal ID used to track versions.
92 * `minetest.conf`:
93   Used to set default settings when running this game.
94 * `settingtypes.txt`:
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.
101
102 Menu images
103 -----------
104
105 Games can provide custom main menu images. They are put inside a `menu`
106 directory inside the game directory.
107
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.
113
114 Menu music
115 -----------
116
117 Games can provide custom main menu music. They are put inside a `menu`
118 directory inside the game directory.
119
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.
124
125 Mods
126 ====
127
128 Mod load path
129 -------------
130
131 Paths are relative to the directories listed in the [Paths] section above.
132
133 * `games/<gameid>/mods/`
134 * `mods/`
135 * `worlds/<worldname>/worldmods/`
136
137 World-specific games
138 --------------------
139
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.
142
143 This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
144 directory exists.
145
146 Mods should then be placed in `<worldname>/game/mods/`.
147
148 Modpacks
149 --------
150
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.
154
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
158                  menu.
159 * `author`: The author of the modpack. It only appears when downloaded from
160             ContentDB.
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.
164
165 Note: to support 0.4.x, please also create an empty modpack.txt file.
166
167 Mod directory structure
168 -----------------------
169
170     mods
171     ├── modname
172     │   ├── mod.conf
173     │   ├── screenshot.png
174     │   ├── settingtypes.txt
175     │   ├── init.lua
176     │   ├── models
177     │   ├── textures
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
185     │   ├── sounds
186     │   ├── media
187     │   ├── locale
188     │   └── <custom data>
189     └── another
190
191 ### modname
192
193 The location of this directory can be fetched by using
194 `minetest.get_modpath(modname)`.
195
196 ### mod.conf
197
198 A `Settings` file that provides meta information about the mod.
199
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
203                  menu.
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
209             ContentDB.
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.
213
214 ### `screenshot.png`
215
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.
218
219 ### `depends.txt`
220
221 **Deprecated:** you should use mod.conf instead.
222
223 This file is used if there are no dependencies in mod.conf.
224
225 List of mods that have to be loaded before loading this mod.
226
227 A single line contains a single modname.
228
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.
232
233 ### `description.txt`
234
235 **Deprecated:** you should use mod.conf instead.
236
237 This file is used if there is no description in mod.conf.
238
239 A file containing a description to be shown in the Mods tab of the main menu.
240
241 ### `settingtypes.txt`
242
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.
246
247 ### `init.lua`
248
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.
252
253 `minetest.settings` can be used to read custom or existing settings at load
254 time, if necessary. (See [`Settings`])
255
256 ### `textures`, `sounds`, `media`, `models`, `locale`
257
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]).
261
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.
265
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.
270
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.
273
274 Naming conventions
275 ------------------
276
277 Registered names should generally be in this format:
278
279     modname:<whatever>
280
281 `<whatever>` can have these characters:
282
283     a-zA-Z0-9_
284
285 This is to prevent conflicting names from corrupting maps and is
286 enforced by the mod loader.
287
288 Registered names can be overridden by prefixing the name with `:`. This can
289 be used for overriding the registrations of some other mod.
290
291 The `:` prefix can also be used for maintaining backwards compatibility.
292
293 ### Example
294
295 In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
296 So the name should be `experimental:tnt`.
297
298 Any mod can redefine `experimental:tnt` by using the name
299
300     :experimental:tnt
301
302 when registering it. For this to work correctly, that mod must have
303 `experimental` as a dependency.
304
305
306
307
308 Aliases
309 =======
310
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)`.
314
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`.
317
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.
322
323 This can be used for maintaining backwards compatibility.
324
325 This can also set quick access names for things, e.g. if
326 you have an item called `epiclylongmodname:stuff`, you could do
327
328     minetest.register_alias("stuff", "epiclylongmodname:stuff")
329
330 and be able to use `/giveme stuff`.
331
332 Mapgen aliases
333 --------------
334
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:
337
338     minetest.register_alias("mapgen_stone", "default:stone")
339
340 ### Aliases for non-V6 mapgens
341
342 #### Essential aliases
343
344 * `mapgen_stone`
345 * `mapgen_water_source`
346 * `mapgen_river_water_source`
347
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.
351
352 #### Optional aliases
353
354 * `mapgen_lava_source`
355
356 Fallback lava node used if cave liquids are not defined in biome definitions.
357 Deprecated, define cave liquids in biome definitions instead.
358
359 * `mapgen_cobble`
360
361 Fallback node used if dungeon nodes are not defined in biome definitions.
362 Deprecated, define dungeon nodes in biome definitions instead.
363
364 ### Aliases for Mapgen V6
365
366 #### Essential
367
368 * `mapgen_stone`
369 * `mapgen_water_source`
370 * `mapgen_lava_source`
371 * `mapgen_dirt`
372 * `mapgen_dirt_with_grass`
373 * `mapgen_sand`
374
375 * `mapgen_tree`
376 * `mapgen_leaves`
377 * `mapgen_apple`
378
379 * `mapgen_cobble`
380
381 #### Optional
382
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)
390
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)
396
397 * `mapgen_stair_cobble` (falls back to cobble)
398 * `mapgen_mossycobble` (falls back to cobble)
399 * `mapgen_stair_desert_stone` (falls backto desert_stone)
400
401 ### Setting the node used in Mapgen Singlenode
402
403 By default the world is filled with air nodes. To set a different node use e.g.:
404
405     minetest.register_alias("mapgen_singlenode", "default:stone")
406
407
408
409
410 Textures
411 ========
412
413 Mods should generally prefix their textures with `modname_`, e.g. given
414 the mod name `foomod`, a texture could be called:
415
416     foomod_foothing.png
417
418 Textures are referred to by their complete name, or alternatively by
419 stripping out the file extension:
420
421 * e.g. `foomod_foothing.png`
422 * e.g. `foomod_foothing`
423
424 Supported texture formats are PNG (`.png`), JPEG (`.jpg`), Bitmap (`.bmp`)
425 and Targa (`.tga`).
426 Since better alternatives exist, the latter two may be removed in the future.
427
428 Texture modifiers
429 -----------------
430
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.
435
436 ### Texture overlaying
437
438 Textures can be overlaid by putting a `^` between them.
439
440 Example:
441
442     default_dirt.png^default_grass_side.png
443
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.
447
448 ### Texture grouping
449
450 Textures can be grouped together by enclosing them in `(` and `)`.
451
452 Example: `cobble.png^(thing1.png^thing2.png)`
453
454 A texture for `thing1.png^thing2.png` is created and the resulting
455 texture is overlaid on top of `cobble.png`.
456
457 ### Escaping
458
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 `:`.
462
463 Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
464
465 The lower 50 percent of `color.png^[mask:trans.png` are overlaid
466 on top of `cobble.png`.
467
468 ### Advanced texture modifiers
469
470 #### Crack
471
472 * `[crack:<n>:<p>`
473 * `[cracko:<n>:<p>`
474 * `[crack:<t>:<n>:<p>`
475 * `[cracko:<t>:<n>:<p>`
476
477 Parameters:
478
479 * `<t>`: tile count (in each direction)
480 * `<n>`: animation frame count
481 * `<p>`: current animation frame
482
483 Draw a step of the crack animation on the texture.
484 `crack` draws it normally, while `cracko` lays it over, keeping transparent
485 pixels intact.
486
487 Example:
488
489     default_cobble.png^[crack:10:1
490
491 #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
492
493 * `<w>`: width
494 * `<h>`: height
495 * `<x>`: x position
496 * `<y>`: y position
497 * `<file>`: texture to combine
498
499 Creates a texture of size `<w>` times `<h>` and blits the listed files to their
500 specified coordinates.
501
502 Example:
503
504     [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
505
506 #### `[resize:<w>x<h>`
507
508 Resizes the texture to the given dimensions.
509
510 Example:
511
512     default_sandstone.png^[resize:16x16
513
514 #### `[opacity:<r>`
515
516 Makes the base image transparent according to the given ratio.
517
518 `r` must be between 0 (transparent) and 255 (opaque).
519
520 Example:
521
522     default_sandstone.png^[opacity:127
523
524 #### `[invert:<mode>`
525
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.
529
530 Example:
531
532     default_apple.png^[invert:rgb
533
534 #### `[brighten`
535
536 Brightens the texture.
537
538 Example:
539
540     tnt_tnt_side.png^[brighten
541
542 #### `[noalpha`
543
544 Makes the texture completely opaque.
545
546 Example:
547
548     default_leaves.png^[noalpha
549
550 #### `[makealpha:<r>,<g>,<b>`
551
552 Convert one color to transparency.
553
554 Example:
555
556     default_cobble.png^[makealpha:128,128,128
557
558 #### `[transform<t>`
559
560 * `<t>`: transformation(s) to apply
561
562 Rotates and/or flips the image.
563
564 `<t>` can be a number (between 0 and 7) or a transform name.
565 Rotations are counter-clockwise.
566
567     0  I      identity
568     1  R90    rotate by 90 degrees
569     2  R180   rotate by 180 degrees
570     3  R270   rotate by 270 degrees
571     4  FX     flip X
572     5  FXR90  flip X then rotate by 90 degrees
573     6  FY     flip Y
574     7  FYR90  flip Y then rotate by 90 degrees
575
576 Example:
577
578     default_stone.png^[transformFXR90
579
580 #### `[inventorycube{<top>{<left>{<right>`
581
582 Escaping does not apply here and `^` is replaced by `&` in texture names
583 instead.
584
585 Create an inventory cube texture using the side textures.
586
587 Example:
588
589     [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
590
591 Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
592 `dirt.png^grass_side.png` textures
593
594 #### `[lowpart:<percent>:<file>`
595
596 Blit the lower `<percent>`% part of `<file>` on the texture.
597
598 Example:
599
600     base.png^[lowpart:25:overlay.png
601
602 #### `[verticalframe:<t>:<n>`
603
604 * `<t>`: animation frame count
605 * `<n>`: current animation frame
606
607 Crops the texture to a frame of a vertical animation.
608
609 Example:
610
611     default_torch_animated.png^[verticalframe:16:8
612
613 #### `[mask:<file>`
614
615 Apply a mask to the base image.
616
617 The mask is applied using binary AND.
618
619 #### `[sheet:<w>x<h>:<x>,<y>`
620
621 Retrieves a tile at position x,y from the base image
622 which it assumes to be a tilesheet with dimensions w,h.
623
624 #### `[colorize:<color>:<ratio>`
625
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
634 texture pixel.
635
636 #### `[multiply:<color>`
637
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.
643
644 #### `[png:<base64>`
645
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:`.
653
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.
660
661 Hardware coloring
662 -----------------
663
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).
670
671 ### Static coloring
672
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.
675
676 #### Global color
677
678 When you register an item or node, set its `color` field (which accepts a
679 `ColorSpec`) to the desired color.
680
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.
683
684 #### Tile color
685
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.
691
692 ### Palettes
693
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.
698
699 #### Palette indexing
700
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.
706
707 Examples:
708
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
719
720 #### Using palettes with items
721
722 When registering an item, set the item definition's `palette` field to
723 a texture. You can also use texture modifiers.
724
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.
728
729 #### Linking palettes with nodes
730
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`:
735
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.
745   Examples:
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.
756   Examples:
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
762 To colorize a node on the map, set its `param2` value (according
763 to the node's paramtype2).
764
765 ### Conversion between nodes in the inventory and on the map
766
767 Static coloring is the same for both cases, there is no need
768 for conversion.
769
770 If the `ItemStack`'s metadata contains the `color` field, it will be
771 lost on placement, because nodes on the map can only use palettes.
772
773 If the `ItemStack`'s metadata contains the `palette_index` field, it is
774 automatically transferred between node and item forms by the engine,
775 when a player digs or places a colored node.
776 You can disable this feature by setting the `drop` field of the node
777 to itself (without metadata).
778 To transfer the color to a special drop, you need a drop table.
779
780 Example:
781
782     minetest.register_node("mod:stone", {
783         description = "Stone",
784         tiles = {"default_stone.png"},
785         paramtype2 = "color",
786         palette = "palette.png",
787         drop = {
788             items = {
789                 -- assume that mod:cobblestone also has the same palette
790                 {items = {"mod:cobblestone"}, inherit_color = true },
791             }
792         }
793     })
794
795 ### Colored items in craft recipes
796
797 Craft recipes only support item strings, but fortunately item strings
798 can also contain metadata. Example craft recipe registration:
799
800     minetest.register_craft({
801         output = minetest.itemstring_with_palette("wool:block", 3),
802         type = "shapeless",
803         recipe = {
804             "wool:block",
805             "dye:red",
806         },
807     })
808
809 To set the `color` field, you can use `minetest.itemstring_with_color`.
810
811 Metadata field filtering in the `recipe` field are not supported yet,
812 so the craft output is independent of the color of the ingredients.
813
814 Soft texture overlay
815 --------------------
816
817 Sometimes hardware coloring is not enough, because it affects the
818 whole tile. Soft texture overlays were added to Minetest to allow
819 the dynamic coloring of only specific parts of the node's texture.
820 For example a grass block may have colored grass, while keeping the
821 dirt brown.
822
823 These overlays are 'soft', because unlike texture modifiers, the layers
824 are not merged in the memory, but they are simply drawn on top of each
825 other. This allows different hardware coloring, but also means that
826 tiles with overlays are drawn slower. Using too much overlays might
827 cause FPS loss.
828
829 For inventory and wield images you can specify overlays which
830 hardware coloring does not modify. You have to set `inventory_overlay`
831 and `wield_overlay` fields to an image name.
832
833 To define a node overlay, simply set the `overlay_tiles` field of the node
834 definition. These tiles are defined in the same way as plain tiles:
835 they can have a texture name, color etc.
836 To skip one face, set that overlay tile to an empty string.
837
838 Example (colored grass block):
839
840     minetest.register_node("default:dirt_with_grass", {
841         description = "Dirt with Grass",
842         -- Regular tiles, as usual
843         -- The dirt tile disables palette coloring
844         tiles = {{name = "default_grass.png"},
845             {name = "default_dirt.png", color = "white"}},
846         -- Overlay tiles: define them in the same style
847         -- The top and bottom tile does not have overlay
848         overlay_tiles = {"", "",
849             {name = "default_grass_side.png"}},
850         -- Global color, used in inventory
851         color = "green",
852         -- Palette in the world
853         paramtype2 = "color",
854         palette = "default_foilage.png",
855     })
856
857
858
859
860 Sounds
861 ======
862
863 Only Ogg Vorbis files are supported.
864
865 For positional playing of sounds, only single-channel (mono) files are
866 supported. Otherwise OpenAL will play them non-positionally.
867
868 Mods should generally prefix their sounds with `modname_`, e.g. given
869 the mod name "`foomod`", a sound could be called:
870
871     foomod_foosound.ogg
872
873 Sounds are referred to by their name with a dot, a single digit and the
874 file extension stripped out. When a sound is played, the actual sound file
875 is chosen randomly from the matching sounds.
876
877 When playing the sound `foomod_foosound`, the sound is chosen randomly
878 from the available ones of the following files:
879
880 * `foomod_foosound.ogg`
881 * `foomod_foosound.0.ogg`
882 * `foomod_foosound.1.ogg`
883 * (...)
884 * `foomod_foosound.9.ogg`
885
886 Examples of sound parameter tables:
887
888     -- Play locationless on all clients
889     {
890         gain = 1.0,   -- default
891         fade = 0.0,   -- default, change to a value > 0 to fade the sound in
892         pitch = 1.0,  -- default
893     }
894     -- Play locationless to one player
895     {
896         to_player = name,
897         gain = 1.0,   -- default
898         fade = 0.0,   -- default, change to a value > 0 to fade the sound in
899         pitch = 1.0,  -- default
900     }
901     -- Play locationless to one player, looped
902     {
903         to_player = name,
904         gain = 1.0,  -- default
905         loop = true,
906     }
907     -- Play at a location
908     {
909         pos = {x = 1, y = 2, z = 3},
910         gain = 1.0,  -- default
911         max_hear_distance = 32,  -- default, uses an euclidean metric
912     }
913     -- Play connected to an object, looped
914     {
915         object = <an ObjectRef>,
916         gain = 1.0,  -- default
917         max_hear_distance = 32,  -- default, uses an euclidean metric
918         loop = true,
919     }
920     -- Play at a location, heard by anyone *but* the given player
921     {
922         pos = {x = 32, y = 0, z = 100},
923         max_hear_distance = 40,
924         exclude_player = name,
925     }
926
927 Looped sounds must either be connected to an object or played locationless to
928 one player using `to_player = name`.
929
930 A positional sound will only be heard by players that are within
931 `max_hear_distance` of the sound position, at the start of the sound.
932
933 `exclude_player = name` can be applied to locationless, positional and object-
934 bound sounds to exclude a single player from hearing them.
935
936 `SimpleSoundSpec`
937 -----------------
938
939 Specifies a sound name, gain (=volume) and pitch.
940 This is either a string or a table.
941
942 In string form, you just specify the sound name or
943 the empty string for no sound.
944
945 Table form has the following fields:
946
947 * `name`: Sound name
948 * `gain`: Volume (`1.0` = 100%)
949 * `pitch`: Pitch (`1.0` = 100%)
950
951 `gain` and `pitch` are optional and default to `1.0`.
952
953 Examples:
954
955 * `""`: No sound
956 * `{}`: No sound
957 * `"default_place_node"`: Play e.g. `default_place_node.ogg`
958 * `{name = "default_place_node"}`: Same as above
959 * `{name = "default_place_node", gain = 0.5}`: 50% volume
960 * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
961
962 Special sound files
963 -------------------
964
965 These sound files are played back by the engine if provided.
966
967  * `player_damage`: Played when the local player takes damage (gain = 0.5)
968  * `player_falling_damage`: Played when the local player takes
969    damage by falling (gain = 0.5)
970  * `player_jump`: Played when the local player jumps
971  * `default_dig_<groupname>`: Default node digging sound
972    (see node sound definition for details)
973
974 Registered definitions
975 ======================
976
977 Anything added using certain [Registration functions] gets added to one or more
978 of the global [Registered definition tables].
979
980 Note that in some cases you will stumble upon things that are not contained
981 in these tables (e.g. when a mod has been removed). Always check for
982 existence before trying to access the fields.
983
984 Example:
985
986 All nodes register with `minetest.register_node` get added to the table
987 `minetest.registered_nodes`.
988
989 If you want to check the drawtype of a node, you could do it like this:
990
991     local def = minetest.registered_nodes[nodename]
992     local drawtype = def and def.drawtype
993
994
995
996
997 Nodes
998 =====
999
1000 Nodes are the bulk data of the world: cubes and other things that take the
1001 space of a cube. Huge amounts of them are handled efficiently, but they
1002 are quite static.
1003
1004 The definition of a node is stored and can be accessed by using
1005
1006     minetest.registered_nodes[node.name]
1007
1008 See [Registered definitions].
1009
1010 Nodes are passed by value between Lua and the engine.
1011 They are represented by a table:
1012
1013     {name="name", param1=num, param2=num}
1014
1015 `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
1016 them for certain automated functions. If you don't use these functions, you can
1017 use them to store arbitrary values.
1018
1019 Node paramtypes
1020 ---------------
1021
1022 The functions of `param1` and `param2` are determined by certain fields in the
1023 node definition.
1024
1025 The function of `param1` is determined by `paramtype` in node definition.
1026 `param1` is reserved for the engine when `paramtype != "none"`.
1027
1028 * `paramtype = "light"`
1029     * The value stores light with and without sun in its lower and upper 4 bits
1030       respectively.
1031     * Required by a light source node to enable spreading its light.
1032     * Required by the following drawtypes as they determine their visual
1033       brightness from their internal light value:
1034         * torchlike
1035         * signlike
1036         * firelike
1037         * fencelike
1038         * raillike
1039         * nodebox
1040         * mesh
1041         * plantlike
1042         * plantlike_rooted
1043 * `paramtype = "none"`
1044     * `param1` will not be used by the engine and can be used to store
1045       an arbitrary value
1046
1047 The function of `param2` is determined by `paramtype2` in node definition.
1048 `param2` is reserved for the engine when `paramtype2 != "none"`.
1049
1050 * `paramtype2 = "flowingliquid"`
1051     * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
1052     * The liquid level and a flag of the liquid are stored in `param2`
1053     * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
1054       see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
1055       to access/manipulate the content of this field
1056     * Bit 3: If set, liquid is flowing downwards (no graphical effect)
1057 * `paramtype2 = "wallmounted"`
1058     * Supported drawtypes: "torchlike", "signlike", "plantlike",
1059       "plantlike_rooted", "normal", "nodebox", "mesh"
1060     * The rotation of the node is stored in `param2`
1061     * You can make this value by using `minetest.dir_to_wallmounted()`
1062     * Values range 0 - 5
1063     * The value denotes at which direction the node is "mounted":
1064       0 = y+,   1 = y-,   2 = x+,   3 = x-,   4 = z+,   5 = z-
1065 * `paramtype2 = "facedir"`
1066     * Supported drawtypes: "normal", "nodebox", "mesh"
1067     * The rotation of the node is stored in `param2`. Furnaces and chests are
1068       rotated this way. Can be made by using `minetest.dir_to_facedir()`.
1069     * Values range 0 - 23
1070     * facedir / 4 = axis direction:
1071       0 = y+,   1 = z+,   2 = z-,   3 = x+,   4 = x-,   5 = y-
1072     * facedir modulo 4 = rotation around that axis
1073 * `paramtype2 = "leveled"`
1074     * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
1075         * Leveled nodebox:
1076             * The level of the top face of the nodebox is stored in `param2`.
1077             * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
1078               nodeboxes.
1079             * The nodebox height is (`param2` / 64) nodes.
1080             * The maximum accepted value of `param2` is 127.
1081         * Rooted plantlike:
1082             * The height of the 'plantlike' section is stored in `param2`.
1083             * The height is (`param2` / 16) nodes.
1084 * `paramtype2 = "degrotate"`
1085     * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
1086       stored in `param2`.
1087     * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
1088       get the actual rotation in degrees of the node.
1089 * `paramtype2 = "meshoptions"`
1090     * Only valid for "plantlike" drawtype. `param2` encodes the shape and
1091       optional modifiers of the "plant". `param2` is a bitfield.
1092     * Bits 0 to 2 select the shape.
1093       Use only one of the values below:
1094         * 0 = a "x" shaped plant (ordinary plant)
1095         * 1 = a "+" shaped plant (just rotated 45 degrees)
1096         * 2 = a "*" shaped plant with 3 faces instead of 2
1097         * 3 = a "#" shaped plant with 4 faces instead of 2
1098         * 4 = a "#" shaped plant with 4 faces that lean outwards
1099         * 5-7 are unused and reserved for future meshes.
1100     * Bits 3 to 7 are used to enable any number of optional modifiers.
1101       Just add the corresponding value(s) below to `param2`:
1102         * 8  - Makes the plant slightly vary placement horizontally
1103         * 16 - Makes the plant mesh 1.4x larger
1104         * 32 - Moves each face randomly a small bit down (1/8 max)
1105         * values 64 and 128 (bits 6-7) are reserved for future use.
1106     * Example: `param2 = 0` selects a normal "x" shaped plant
1107     * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
1108 * `paramtype2 = "color"`
1109     * `param2` tells which color is picked from the palette.
1110       The palette should have 256 pixels.
1111 * `paramtype2 = "colorfacedir"`
1112     * Same as `facedir`, but with colors.
1113     * The first three bits of `param2` tells which color is picked from the
1114       palette. The palette should have 8 pixels.
1115 * `paramtype2 = "colorwallmounted"`
1116     * Same as `wallmounted`, but with colors.
1117     * The first five bits of `param2` tells which color is picked from the
1118       palette. The palette should have 32 pixels.
1119 * `paramtype2 = "glasslikeliquidlevel"`
1120     * Only valid for "glasslike_framed" or "glasslike_framed_optional"
1121       drawtypes. "glasslike_framed_optional" nodes are only affected if the
1122       "Connected Glass" setting is enabled.
1123     * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
1124       full.
1125     * Bits 6 and 7 modify the appearance of the frame and node faces. One or
1126       both of these values may be added to `param2`:
1127         * 64  - Makes the node not connect with neighbors above or below it.
1128         * 128 - Makes the node not connect with neighbors to its sides.
1129     * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
1130 * `paramtype2 = "colordegrotate"`
1131     * Same as `degrotate`, but with colors.
1132     * The first (most-significant) three bits of `param2` tells which color
1133       is picked from the palette. The palette should have 8 pixels.
1134     * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
1135 * `paramtype2 = "none"`
1136     * `param2` will not be used by the engine and can be used to store
1137       an arbitrary value
1138
1139 Nodes can also contain extra data. See [Node Metadata].
1140
1141 Node drawtypes
1142 --------------
1143
1144 There are a bunch of different looking node types.
1145
1146 Look for examples in `games/devtest` or `games/minetest_game`.
1147
1148 * `normal`
1149     * A node-sized cube.
1150 * `airlike`
1151     * Invisible, uses no texture.
1152 * `liquid`
1153     * The cubic source node for a liquid.
1154     * Faces bordering to the same node are never rendered.
1155     * Connects to node specified in `liquid_alternative_flowing`.
1156     * Use `backface_culling = false` for the tiles you want to make
1157       visible when inside the node.
1158 * `flowingliquid`
1159     * The flowing version of a liquid, appears with various heights and slopes.
1160     * Faces bordering to the same node are never rendered.
1161     * Connects to node specified in `liquid_alternative_source`.
1162     * Node textures are defined with `special_tiles` where the first tile
1163       is for the top and bottom faces and the second tile is for the side
1164       faces.
1165     * `tiles` is used for the item/inventory/wield image rendering.
1166     * Use `backface_culling = false` for the special tiles you want to make
1167       visible when inside the node
1168 * `glasslike`
1169     * Often used for partially-transparent nodes.
1170     * Only external sides of textures are visible.
1171 * `glasslike_framed`
1172     * All face-connected nodes are drawn as one volume within a surrounding
1173       frame.
1174     * The frame appearance is generated from the edges of the first texture
1175       specified in `tiles`. The width of the edges used are 1/16th of texture
1176       size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
1177     * The glass 'shine' (or other desired detail) on each node face is supplied
1178       by the second texture specified in `tiles`.
1179 * `glasslike_framed_optional`
1180     * This switches between the above 2 drawtypes according to the menu setting
1181       'Connected Glass'.
1182 * `allfaces`
1183     * Often used for partially-transparent nodes.
1184     * External and internal sides of textures are visible.
1185 * `allfaces_optional`
1186     * Often used for leaves nodes.
1187     * This switches between `normal`, `glasslike` and `allfaces` according to
1188       the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
1189     * With 'Simple Leaves' selected, the texture specified in `special_tiles`
1190       is used instead, if present. This allows a visually thicker texture to be
1191       used to compensate for how `glasslike` reduces visual thickness.
1192 * `torchlike`
1193     * A single vertical texture.
1194     * If `paramtype2="[color]wallmounted"`:
1195         * If placed on top of a node, uses the first texture specified in `tiles`.
1196         * If placed against the underside of a node, uses the second texture
1197           specified in `tiles`.
1198         * If placed on the side of a node, uses the third texture specified in
1199           `tiles` and is perpendicular to that node.
1200     * If `paramtype2="none"`:
1201         * Will be rendered as if placed on top of a node (see
1202           above) and only the first texture is used.
1203 * `signlike`
1204     * A single texture parallel to, and mounted against, the top, underside or
1205       side of a node.
1206     * If `paramtype2="[color]wallmounted"`, it rotates according to `param2`
1207     * If `paramtype2="none"`, it will always be on the floor.
1208 * `plantlike`
1209     * Two vertical and diagonal textures at right-angles to each other.
1210     * See `paramtype2 = "meshoptions"` above for other options.
1211 * `firelike`
1212     * When above a flat surface, appears as 6 textures, the central 2 as
1213       `plantlike` plus 4 more surrounding those.
1214     * If not above a surface the central 2 do not appear, but the texture
1215       appears against the faces of surrounding nodes if they are present.
1216 * `fencelike`
1217     * A 3D model suitable for a wooden fence.
1218     * One placed node appears as a single vertical post.
1219     * Adjacently-placed nodes cause horizontal bars to appear between them.
1220 * `raillike`
1221     * Often used for tracks for mining carts.
1222     * Requires 4 textures to be specified in `tiles`, in order: Straight,
1223       curved, t-junction, crossing.
1224     * Each placed node automatically switches to a suitable rotated texture
1225       determined by the adjacent `raillike` nodes, in order to create a
1226       continuous track network.
1227     * Becomes a sloping node if placed against stepped nodes.
1228 * `nodebox`
1229     * Often used for stairs and slabs.
1230     * Allows defining nodes consisting of an arbitrary number of boxes.
1231     * See [Node boxes] below for more information.
1232 * `mesh`
1233     * Uses models for nodes.
1234     * Tiles should hold model materials textures.
1235     * Only static meshes are implemented.
1236     * For supported model formats see Irrlicht engine documentation.
1237 * `plantlike_rooted`
1238     * Enables underwater `plantlike` without air bubbles around the nodes.
1239     * Consists of a base cube at the co-ordinates of the node plus a
1240       `plantlike` extension above
1241     * If `paramtype2="leveled", the `plantlike` extension has a height
1242       of `param2 / 16` nodes, otherwise it's the height of 1 node
1243     * If `paramtype2="wallmounted"`, the `plantlike` extension
1244       will be at one of the corresponding 6 sides of the base cube.
1245       Also, the base cube rotates like a `normal` cube would
1246     * The `plantlike` extension visually passes through any nodes above the
1247       base cube without affecting them.
1248     * The base cube texture tiles are defined as normal, the `plantlike`
1249       extension uses the defined special tile, for example:
1250       `special_tiles = {{name = "default_papyrus.png"}},`
1251
1252 `*_optional` drawtypes need less rendering time if deactivated
1253 (always client-side).
1254
1255 Node boxes
1256 ----------
1257
1258 Node selection boxes are defined using "node boxes".
1259
1260 A nodebox is defined as any of:
1261
1262     {
1263         -- A normal cube; the default in most things
1264         type = "regular"
1265     }
1266     {
1267         -- A fixed box (or boxes) (facedir param2 is used, if applicable)
1268         type = "fixed",
1269         fixed = box OR {box1, box2, ...}
1270     }
1271     {
1272         -- A variable height box (or boxes) with the top face position defined
1273         -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
1274         -- by param2.
1275         -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
1276         type = "leveled",
1277         fixed = box OR {box1, box2, ...}
1278     }
1279     {
1280         -- A box like the selection box for torches
1281         -- (wallmounted param2 is used, if applicable)
1282         type = "wallmounted",
1283         wall_top = box,
1284         wall_bottom = box,
1285         wall_side = box
1286     }
1287     {
1288         -- A node that has optional boxes depending on neighbouring nodes'
1289         -- presence and type. See also `connects_to`.
1290         type = "connected",
1291         fixed = box OR {box1, box2, ...}
1292         connect_top = box OR {box1, box2, ...}
1293         connect_bottom = box OR {box1, box2, ...}
1294         connect_front = box OR {box1, box2, ...}
1295         connect_left = box OR {box1, box2, ...}
1296         connect_back = box OR {box1, box2, ...}
1297         connect_right = box OR {box1, box2, ...}
1298         -- The following `disconnected_*` boxes are the opposites of the
1299         -- `connect_*` ones above, i.e. when a node has no suitable neighbour
1300         -- on the respective side, the corresponding disconnected box is drawn.
1301         disconnected_top = box OR {box1, box2, ...}
1302         disconnected_bottom = box OR {box1, box2, ...}
1303         disconnected_front = box OR {box1, box2, ...}
1304         disconnected_left = box OR {box1, box2, ...}
1305         disconnected_back = box OR {box1, box2, ...}
1306         disconnected_right = box OR {box1, box2, ...}
1307         disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour
1308         disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
1309                                                       -- neighbours to the sides
1310     }
1311
1312 A `box` is defined as:
1313
1314     {x1, y1, z1, x2, y2, z2}
1315
1316 A box of a regular node would look like:
1317
1318     {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
1319
1320 To avoid collision issues, keep each value within the range of +/- 1.45.
1321 This also applies to leveled nodeboxes, where the final height shall not
1322 exceed this soft limit.
1323
1324
1325
1326 Map terminology and coordinates
1327 ===============================
1328
1329 Nodes, mapblocks, mapchunks
1330 ---------------------------
1331
1332 A 'node' is the fundamental cubic unit of a world and appears to a player as
1333 roughly 1x1x1 meters in size.
1334
1335 A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
1336 fundamental region of a world that is stored in the world database, sent to
1337 clients and handled by many parts of the engine.
1338 'mapblock' is preferred terminology to 'block' to help avoid confusion with
1339 'node', however 'block' often appears in the API.
1340
1341 A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
1342 (80x80x80 nodes) and is the volume of world generated in one operation by
1343 the map generator.
1344 The size in mapblocks has been chosen to optimise map generation.
1345
1346 Coordinates
1347 -----------
1348
1349 ### Orientation of axes
1350
1351 For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
1352
1353 ### Node coordinates
1354
1355 Almost all positions used in the API use node coordinates.
1356
1357 ### Mapblock coordinates
1358
1359 Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
1360 specify a particular mapblock.
1361 For example blockpos (0,0,0) specifies the mapblock that extends from
1362 node position (0,0,0) to node position (15,15,15).
1363
1364 #### Converting node position to the containing blockpos
1365
1366 To calculate the blockpos of the mapblock that contains the node at 'nodepos',
1367 for each axis:
1368
1369 * blockpos = math.floor(nodepos / 16)
1370
1371 #### Converting blockpos to min/max node positions
1372
1373 To calculate the min/max node positions contained in the mapblock at 'blockpos',
1374 for each axis:
1375
1376 * Minimum:
1377   nodepos = blockpos * 16
1378 * Maximum:
1379   nodepos = blockpos * 16 + 15
1380
1381
1382
1383
1384 HUD
1385 ===
1386
1387 HUD element types
1388 -----------------
1389
1390 The position field is used for all element types.
1391 To account for differing resolutions, the position coordinates are the
1392 percentage of the screen, ranging in value from `0` to `1`.
1393
1394 The `name` field is not yet used, but should contain a description of what the
1395 HUD element represents.
1396
1397 The `direction` field is the direction in which something is drawn.
1398 `0` draws from left to right, `1` draws from right to left, `2` draws from
1399 top to bottom, and `3` draws from bottom to top.
1400
1401 The `alignment` field specifies how the item will be aligned. It is a table
1402 where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
1403 moved to the left/up, and `1` is to the right/down. Fractional values can be
1404 used.
1405
1406 The `offset` field specifies a pixel offset from the position. Contrary to
1407 position, the offset is not scaled to screen size. This allows for some
1408 precisely positioned items in the HUD.
1409
1410 **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
1411 factor!
1412
1413 The `z_index` field specifies the order of HUD elements from back to front.
1414 Lower z-index elements are displayed behind higher z-index elements. Elements
1415 with same z-index are displayed in an arbitrary order. Default 0.
1416 Supports negative values. By convention, the following values are recommended:
1417
1418 *  -400: Graphical effects, such as vignette
1419 *  -300: Name tags, waypoints
1420 *  -200: Wieldhand
1421 *  -100: Things that block the player's view, e.g. masks
1422 *     0: Default. For standard in-game HUD elements like crosshair, hotbar,
1423          minimap, builtin statbars, etc.
1424 *   100: Temporary text messages or notification icons
1425 *  1000: Full-screen effects such as full-black screen or credits.
1426          This includes effects that cover the entire screen
1427
1428 If your HUD element doesn't fit into any category, pick a number
1429 between the suggested values
1430
1431 Below are the specific uses for fields in each type; fields not listed for that
1432 type are ignored.
1433
1434 ### `image`
1435
1436 Displays an image on the HUD.
1437
1438 * `scale`: The scale of the image, with 1 being the original texture size.
1439   Only the X coordinate scale is used (positive values).
1440   Negative values represent that percentage of the screen it
1441   should take; e.g. `x=-100` means 100% (width).
1442 * `text`: The name of the texture that is displayed.
1443 * `alignment`: The alignment of the image.
1444 * `offset`: offset in pixels from position.
1445
1446 ### `text`
1447
1448 Displays text on the HUD.
1449
1450 * `scale`: Defines the bounding rectangle of the text.
1451   A value such as `{x=100, y=100}` should work.
1452 * `text`: The text to be displayed in the HUD element.
1453 * `number`: An integer containing the RGB value of the color used to draw the
1454   text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
1455 * `alignment`: The alignment of the text.
1456 * `offset`: offset in pixels from position.
1457 * `size`: size of the text.
1458   The player-set font size is multiplied by size.x (y value isn't used).
1459 * `style`: determines font style
1460   Bitfield with 1 = bold, 2 = italic, 4 = monospace
1461
1462 ### `statbar`
1463
1464 Displays a horizontal bar made up of half-images with an optional background.
1465
1466 * `text`: The name of the texture to use.
1467 * `text2`: Optional texture name to enable a background / "off state"
1468   texture (useful to visualize the maximal value). Both textures
1469   must have the same size.
1470 * `number`: The number of half-textures that are displayed.
1471   If odd, will end with a vertically center-split texture.
1472 * `item`: Same as `number` but for the "off state" texture
1473 * `direction`: To which direction the images will extend to
1474 * `offset`: offset in pixels from position.
1475 * `size`: If used, will force full-image size to this value (override texture
1476   pack image size)
1477
1478 ### `inventory`
1479
1480 * `text`: The name of the inventory list to be displayed.
1481 * `number`: Number of items in the inventory to be displayed.
1482 * `item`: Position of item that is selected.
1483 * `direction`: Direction the list will be displayed in
1484 * `offset`: offset in pixels from position.
1485
1486 ### `waypoint`
1487
1488 Displays distance to selected world position.
1489
1490 * `name`: The name of the waypoint.
1491 * `text`: Distance suffix. Can be blank.
1492 * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
1493   If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
1494   When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
1495   `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
1496   `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
1497   `precision = n` will show multiples of `1/n`
1498 * `number:` An integer containing the RGB value of the color used to draw the
1499   text.
1500 * `world_pos`: World position of the waypoint.
1501 * `offset`: offset in pixels from position.
1502 * `alignment`: The alignment of the waypoint.
1503
1504 ### `image_waypoint`
1505
1506 Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
1507
1508 * `scale`: The scale of the image, with 1 being the original texture size.
1509   Only the X coordinate scale is used (positive values).
1510   Negative values represent that percentage of the screen it
1511   should take; e.g. `x=-100` means 100% (width).
1512 * `text`: The name of the texture that is displayed.
1513 * `alignment`: The alignment of the image.
1514 * `world_pos`: World position of the waypoint.
1515 * `offset`: offset in pixels from position.
1516
1517 ### `compass`
1518
1519 Displays an image oriented or translated according to current heading direction.
1520
1521 * `size`: The size of this element. Negative values represent percentage
1522   of the screen; e.g. `x=-100` means 100% (width).
1523 * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
1524 * `text`: The name of the texture to use.
1525 * `alignment`: The alignment of the image.
1526 * `offset`: Offset in pixels from position.
1527 * `direction`: How the image is rotated/translated:
1528   * 0 - Rotate as heading direction
1529   * 1 - Rotate in reverse direction
1530   * 2 - Translate as landscape direction
1531   * 3 - Translate in reverse direction
1532
1533 If translation is chosen, texture is repeated horizontally to fill the whole element.
1534
1535 ### `minimap`
1536
1537 Displays a minimap on the HUD.
1538
1539 * `size`: Size of the minimap to display. Minimap should be a square to avoid
1540   distortion.
1541 * `alignment`: The alignment of the minimap.
1542 * `offset`: offset in pixels from position.
1543
1544 Representations of simple things
1545 ================================
1546
1547 Vector (ie. a position)
1548 -----------------------
1549
1550     vector.new(x, y, z)
1551
1552 See [Spatial Vectors] for details.
1553
1554 `pointed_thing`
1555 ---------------
1556
1557 * `{type="nothing"}`
1558 * `{type="node", under=pos, above=pos}`
1559     * Indicates a pointed node selection box.
1560     * `under` refers to the node position behind the pointed face.
1561     * `above` refers to the node position in front of the pointed face.
1562 * `{type="object", ref=ObjectRef}`
1563
1564 Exact pointing location (currently only `Raycast` supports these fields):
1565
1566 * `pointed_thing.intersection_point`: The absolute world coordinates of the
1567   point on the selection box which is pointed at. May be in the selection box
1568   if the pointer is in the box too.
1569 * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
1570   from 1).
1571 * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
1572   selected selection box. This specifies which face is pointed at.
1573   Is a null vector `vector.zero()` when the pointer is inside the selection box.
1574
1575
1576
1577
1578 Flag Specifier Format
1579 =====================
1580
1581 Flags using the standardized flag specifier format can be specified in either
1582 of two ways, by string or table.
1583
1584 The string format is a comma-delimited set of flag names; whitespace and
1585 unrecognized flag fields are ignored. Specifying a flag in the string sets the
1586 flag, and specifying a flag prefixed by the string `"no"` explicitly
1587 clears the flag from whatever the default may be.
1588
1589 In addition to the standard string flag format, the schematic flags field can
1590 also be a table of flag names to boolean values representing whether or not the
1591 flag is set. Additionally, if a field with the flag name prefixed with `"no"`
1592 is present, mapped to a boolean of any value, the specified flag is unset.
1593
1594 E.g. A flag field of value
1595
1596     {place_center_x = true, place_center_y=false, place_center_z=true}
1597
1598 is equivalent to
1599
1600     {place_center_x = true, noplace_center_y=true, place_center_z=true}
1601
1602 which is equivalent to
1603
1604     "place_center_x, noplace_center_y, place_center_z"
1605
1606 or even
1607
1608     "place_center_x, place_center_z"
1609
1610 since, by default, no schematic attributes are set.
1611
1612
1613
1614
1615 Items
1616 =====
1617
1618 Items are things that can be held by players, dropped in the map and
1619 stored in inventories.
1620 Items come in the form of item stacks, which are collections of equal
1621 items that occupy a single inventory slot.
1622
1623 Item types
1624 ----------
1625
1626 There are three kinds of items: nodes, tools and craftitems.
1627
1628 * Node: Placeable item form of a node in the world's voxel grid
1629 * Tool: Has a changable wear property but cannot be stacked
1630 * Craftitem: Has no special properties
1631
1632 Every registered node (the voxel in the world) has a corresponding
1633 item form (the thing in your inventory) that comes along with it.
1634 This item form can be placed which will create a node in the
1635 world (by default).
1636 Both the 'actual' node and its item form share the same identifier.
1637 For all practical purposes, you can treat the node and its item form
1638 interchangeably. We usually just say 'node' to the item form of
1639 the node as well.
1640
1641 Note the definition of tools is purely technical. The only really
1642 unique thing about tools is their wear, and that's basically it.
1643 Beyond that, you can't make any gameplay-relevant assumptions
1644 about tools or non-tools. It is perfectly valid to register something
1645 that acts as tool in a gameplay sense as a craftitem, and vice-versa.
1646
1647 Craftitems can be used for items that neither need to be a node
1648 nor a tool.
1649
1650 Amount and wear
1651 ---------------
1652
1653 All item stacks have an amount between 0 and 65535. It is 1 by
1654 default. Tool item stacks can not have an amount greater than 1.
1655
1656 Tools use a wear (damage) value ranging from 0 to 65535. The
1657 value 0 is the default and is used for unworn tools. The values
1658 1 to 65535 are used for worn tools, where a higher value stands for
1659 a higher wear. Non-tools technically also have a wear property,
1660 but it is always 0. There is also a special 'toolrepair' crafting
1661 recipe that is only available to tools.
1662
1663 Item formats
1664 ------------
1665
1666 Items and item stacks can exist in three formats: Serializes, table format
1667 and `ItemStack`.
1668
1669 When an item must be passed to a function, it can usually be in any of
1670 these formats.
1671
1672 ### Serialized
1673
1674 This is called "stackstring" or "itemstring". It is a simple string with
1675 1-4 components:
1676
1677 1. Full item identifier ("item name")
1678 2. Optional amount
1679 3. Optional wear value
1680 4. Optional item metadata
1681
1682 Syntax:
1683
1684     <identifier> [<amount>[ <wear>[ <metadata>]]]
1685
1686 Examples:
1687
1688 * `"default:apple"`: 1 apple
1689 * `"default:dirt 5"`: 5 dirt
1690 * `"default:pick_stone"`: a new stone pickaxe
1691 * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
1692 * `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`:
1693   * a wooden pickaxe from the `default` mod,
1694   * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool),
1695   * with the `description` field set to `"My worn out pick"` in its metadata
1696 * `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`:
1697   * analogeous to the above example
1698   * note how the wear is set to `0` as dirt is not a tool
1699
1700 You should ideally use the `ItemStack` format to build complex item strings
1701 (especially if they use item metadata)
1702 without relying on the serialization format. Example:
1703
1704     local stack = ItemStack("default:pick_wood")
1705     stack:set_wear(21323)
1706     stack:get_meta():set_string("description", "My worn out pick")
1707     local itemstring = stack:to_string()
1708
1709 Additionally the methods `minetest.itemstring_with_palette(item, palette_index)`
1710 and `minetest.itemstring_with_color(item, colorstring)` may be used to create
1711 item strings encoding color information in their metadata.
1712
1713 ### Table format
1714
1715 Examples:
1716
1717 5 dirt nodes:
1718
1719     {name="default:dirt", count=5, wear=0, metadata=""}
1720
1721 A wooden pick about 1/3 worn out:
1722
1723     {name="default:pick_wood", count=1, wear=21323, metadata=""}
1724
1725 An apple:
1726
1727     {name="default:apple", count=1, wear=0, metadata=""}
1728
1729 ### `ItemStack`
1730
1731 A native C++ format with many helper methods. Useful for converting
1732 between formats. See the [Class reference] section for details.
1733
1734
1735
1736
1737 Groups
1738 ======
1739
1740 In a number of places, there is a group table. Groups define the
1741 properties of a thing (item, node, armor of entity, tool capabilities)
1742 in such a way that the engine and other mods can can interact with
1743 the thing without actually knowing what the thing is.
1744
1745 Usage
1746 -----
1747
1748 Groups are stored in a table, having the group names with keys and the
1749 group ratings as values. Group ratings are integer values within the
1750 range [-32767, 32767]. For example:
1751
1752     -- Default dirt
1753     groups = {crumbly=3, soil=1}
1754
1755     -- A more special dirt-kind of thing
1756     groups = {crumbly=2, soil=1, level=2, outerspace=1}
1757
1758 Groups always have a rating associated with them. If there is no
1759 useful meaning for a rating for an enabled group, it shall be `1`.
1760
1761 When not defined, the rating of a group defaults to `0`. Thus when you
1762 read groups, you must interpret `nil` and `0` as the same value, `0`.
1763
1764 You can read the rating of a group for an item or a node by using
1765
1766     minetest.get_item_group(itemname, groupname)
1767
1768 Groups of items
1769 ---------------
1770
1771 Groups of items can define what kind of an item it is (e.g. wool).
1772
1773 Groups of nodes
1774 ---------------
1775
1776 In addition to the general item things, groups are used to define whether
1777 a node is destroyable and how long it takes to destroy by a tool.
1778
1779 Groups of entities
1780 ------------------
1781
1782 For entities, groups are, as of now, used only for calculating damage.
1783 The rating is the percentage of damage caused by items with this damage group.
1784 See [Entity damage mechanism].
1785
1786     object:get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
1787     object:set_armor_groups({fleshy=30, cracky=80})
1788
1789 Groups of tool capabilities
1790 ---------------------------
1791
1792 Groups in tool capabilities define which groups of nodes and entities they
1793 are effective towards.
1794
1795 Groups in crafting recipes
1796 --------------------------
1797
1798 An example: Make meat soup from any meat, any water and any bowl:
1799
1800     {
1801         output = "food:meat_soup_raw",
1802         recipe = {
1803             {"group:meat"},
1804             {"group:water"},
1805             {"group:bowl"},
1806         },
1807     }
1808
1809 Another example: Make red wool from white wool and red dye:
1810
1811     {
1812         type = "shapeless",
1813         output = "wool:red",
1814         recipe = {"wool:white", "group:dye,basecolor_red"},
1815     }
1816
1817 Special groups
1818 --------------
1819
1820 The asterisk `(*)` after a group name describes that there is no engine
1821 functionality bound to it, and implementation is left up as a suggestion
1822 to games.
1823
1824 ### Node and item groups
1825
1826 * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
1827   that the item should be hidden in item lists.
1828
1829
1830 ### Node-only groups
1831
1832 * `attached_node`: if the node under it is not a walkable block the node will be
1833   dropped as an item. If the node is wallmounted the wallmounted direction is
1834   checked.
1835 * `bouncy`: value is bounce speed in percent
1836 * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1837   connect to each other
1838 * `dig_immediate`: Player can always pick up node without reducing tool wear
1839     * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
1840     * `3`: the node always gets the digging time 0 seconds (torch)
1841 * `disable_jump`: Player (and possibly other things) cannot jump from node
1842   or if their feet are in the node. Note: not supported for `new_move = false`
1843 * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
1844   the top of this node. There's also an armor group with the same name.
1845   The final player damage is determined by the following formula:
1846     damage =
1847       collision speed
1848       * ((node_fall_damage_add_percent   + 100) / 100) -- node group
1849       * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
1850       - (14)                                           -- constant tolerance
1851   Negative damage values are discarded as no damage.
1852 * `falling_node`: if there is no walkable block under the node it will fall
1853 * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
1854 * `level`: Can be used to give an additional sense of progression in the game.
1855      * A larger level will cause e.g. a weapon of a lower level make much less
1856        damage, and get worn out much faster, or not be able to get drops
1857        from destroyed nodes.
1858      * `0` is something that is directly accessible at the start of gameplay
1859      * There is no upper limit
1860      * See also: `leveldiff` in [Tool Capabilities]
1861 * `slippery`: Players and items will slide on the node.
1862   Slipperiness rises steadily with `slippery` value, starting at 1.
1863
1864
1865 ### Tool-only groups
1866
1867 * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
1868   `"toolrepair"` crafting recipe
1869
1870
1871 ### `ObjectRef` armor groups
1872
1873 * `immortal`: Skips all damage and breath handling for an object. This group
1874   will also hide the integrated HUD status bars for players. It is
1875   automatically set to all players when damage is disabled on the server and
1876   cannot be reset (subject to change).
1877 * `fall_damage_add_percent`: Modifies the fall damage suffered by players
1878   when they hit the ground. It is analog to the node group with the same
1879   name. See the node group above for the exact calculation.
1880 * `punch_operable`: For entities; disables the regular damage mechanism for
1881   players punching it by hand or a non-tool item, so that it can do something
1882   else than take damage.
1883
1884
1885
1886 Known damage and digging time defining groups
1887 ---------------------------------------------
1888
1889 * `crumbly`: dirt, sand
1890 * `cracky`: tough but crackable stuff like stone.
1891 * `snappy`: something that can be cut using things like scissors, shears,
1892   bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
1893 * `choppy`: something that can be cut using force; e.g. trees, wooden planks
1894 * `fleshy`: Living things like animals and the player. This could imply
1895   some blood effects when hitting.
1896 * `explody`: Especially prone to explosions
1897 * `oddly_breakable_by_hand`:
1898    Can be added to nodes that shouldn't logically be breakable by the
1899    hand but are. Somewhat similar to `dig_immediate`, but times are more
1900    like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
1901    digging speed of an item if it can dig at a faster speed than this
1902    suggests for the hand.
1903
1904 Examples of custom groups
1905 -------------------------
1906
1907 Item groups are often used for defining, well, _groups of items_.
1908
1909 * `meat`: any meat-kind of a thing (rating might define the size or healing
1910   ability or be irrelevant -- it is not defined as of yet)
1911 * `eatable`: anything that can be eaten. Rating might define HP gain in half
1912   hearts.
1913 * `flammable`: can be set on fire. Rating might define the intensity of the
1914   fire, affecting e.g. the speed of the spreading of an open fire.
1915 * `wool`: any wool (any origin, any color)
1916 * `metal`: any metal
1917 * `weapon`: any weapon
1918 * `heavy`: anything considerably heavy
1919
1920 Digging time calculation specifics
1921 ----------------------------------
1922
1923 Groups such as `crumbly`, `cracky` and `snappy` are used for this
1924 purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
1925 faster digging time.
1926
1927 The `level` group is used to limit the toughness of nodes an item capable
1928 of digging can dig and to scale the digging times / damage to a greater extent.
1929
1930 **Please do understand this**, otherwise you cannot use the system to it's
1931 full potential.
1932
1933 Items define their properties by a list of parameters for groups. They
1934 cannot dig other groups; thus it is important to use a standard bunch of
1935 groups to enable interaction with items.
1936
1937
1938
1939
1940 Tool Capabilities
1941 =================
1942
1943 'Tool capabilities' is a property of items that defines two things:
1944
1945 1) Which nodes it can dig and how fast
1946 2) Which objects it can hurt by punching and by how much
1947
1948 Tool capabilities are available for all items, not just tools.
1949 But only tools can receive wear from digging and punching.
1950
1951 Missing or incomplete tool capabilities will default to the
1952 player's hand.
1953
1954 Tool capabilities definition
1955 ----------------------------
1956
1957 Tool capabilities define:
1958
1959 * Full punch interval
1960 * Maximum drop level
1961 * For an arbitrary list of node groups:
1962     * Uses (until the tool breaks)
1963     * Maximum level (usually `0`, `1`, `2` or `3`)
1964     * Digging times
1965 * Damage groups
1966 * Punch attack uses (until the tool breaks)
1967
1968 ### Full punch interval `full_punch_interval`
1969
1970 When used as a weapon, the item will do full damage if this time is spent
1971 between punches. If e.g. half the time is spent, the item will do half
1972 damage.
1973
1974 ### Maximum drop level `max_drop_level`
1975
1976 Suggests the maximum level of node, when dug with the item, that will drop
1977 its useful item. (e.g. iron ore to drop a lump of iron).
1978
1979 This value is not used in the engine; it is the responsibility of the game/mod
1980 code to implement this.
1981
1982 ### Uses `uses` (tools only)
1983
1984 Determines how many uses the tool has when it is used for digging a node,
1985 of this group, of the maximum level. The maximum supported number of
1986 uses is 65535. The special number 0 is used for infinite uses.
1987 For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
1988 `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
1989 node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
1990
1991 * `uses=10, leveldiff=0`: actual uses: 10
1992 * `uses=10, leveldiff=1`: actual uses: 30
1993 * `uses=10, leveldiff=2`: actual uses: 90
1994
1995 For non-tools, this has no effect.
1996
1997 ### Maximum level `maxlevel`
1998
1999 Tells what is the maximum level of a node of this group that the item will
2000 be able to dig.
2001
2002 ### Digging times `times`
2003
2004 List of digging times for different ratings of the group, for nodes of the
2005 maximum level.
2006
2007 For example, as a Lua table, `times={[2]=2.00, [3]=0.70}`. This would
2008 result in the item to be able to dig nodes that have a rating of `2` or `3`
2009 for this group, and unable to dig the rating `1`, which is the toughest.
2010 Unless there is a matching group that enables digging otherwise.
2011
2012 If the result digging time is 0, a delay of 0.15 seconds is added between
2013 digging nodes; If the player releases LMB after digging, this delay is set to 0,
2014 i.e. players can more quickly click the nodes away instead of holding LMB.
2015
2016 ### Damage groups
2017
2018 List of damage for groups of entities. See [Entity damage mechanism].
2019
2020 ### Punch attack uses (tools only)
2021
2022 Determines how many uses (before breaking) the tool has when dealing damage
2023 to an object, when the full punch interval (see above) was always
2024 waited out fully.
2025
2026 Wear received by the tool is proportional to the time spent, scaled by
2027 the full punch interval.
2028
2029 For non-tools, this has no effect.
2030
2031 Example definition of the capabilities of an item
2032 -------------------------------------------------
2033
2034     tool_capabilities = {
2035         groupcaps={
2036             crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
2037         },
2038     }
2039
2040 This makes the item capable of digging nodes that fulfil both of these:
2041
2042 * Have the `crumbly` group
2043 * Have a `level` group less or equal to `2`
2044
2045 Table of resulting digging times:
2046
2047     crumbly        0     1     2     3     4  <- level
2048          ->  0     -     -     -     -     -
2049              1  0.80  1.60  1.60     -     -
2050              2  0.60  1.20  1.20     -     -
2051              3  0.40  0.80  0.80     -     -
2052
2053     level diff:    2     1     0    -1    -2
2054
2055 Table of resulting tool uses:
2056
2057     ->  0     -     -     -     -     -
2058         1   180    60    20     -     -
2059         2   180    60    20     -     -
2060         3   180    60    20     -     -
2061
2062 **Notes**:
2063
2064 * At `crumbly==0`, the node is not diggable.
2065 * At `crumbly==3`, the level difference digging time divider kicks in and makes
2066   easy nodes to be quickly breakable.
2067 * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
2068
2069
2070
2071
2072 Entity damage mechanism
2073 =======================
2074
2075 Damage calculation:
2076
2077     damage = 0
2078     foreach group in cap.damage_groups:
2079         damage += cap.damage_groups[group]
2080             * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
2081             * (object.armor_groups[group] / 100.0)
2082             -- Where object.armor_groups[group] is 0 for inexistent values
2083     return damage
2084
2085 Client predicts damage based on damage groups. Because of this, it is able to
2086 give an immediate response when an entity is damaged or dies; the response is
2087 pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
2088 TODO).
2089 Currently a smoke puff will appear when an entity dies.
2090
2091 The group `immortal` completely disables normal damage.
2092
2093 Entities can define a special armor group, which is `punch_operable`. This
2094 group disables the regular damage mechanism for players punching it by hand or
2095 a non-tool item, so that it can do something else than take damage.
2096
2097 On the Lua side, every punch calls:
2098
2099     entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
2100                     damage)
2101
2102 This should never be called directly, because damage is usually not handled by
2103 the entity itself.
2104
2105 * `puncher` is the object performing the punch. Can be `nil`. Should never be
2106   accessed unless absolutely required, to encourage interoperability.
2107 * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
2108 * `tool_capabilities` can be `nil`.
2109 * `direction` is a unit vector, pointing from the source of the punch to
2110    the punched object.
2111 * `damage` damage that will be done to entity
2112 Return value of this function will determine if damage is done by this function
2113 (retval true) or shall be done by engine (retval false)
2114
2115 To punch an entity/object in Lua, call:
2116
2117   object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
2118
2119 * Return value is tool wear.
2120 * Parameters are equal to the above callback.
2121 * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
2122   will be automatically filled in based on the location of `puncher`.
2123
2124
2125
2126
2127 Metadata
2128 ========
2129
2130 Node Metadata
2131 -------------
2132
2133 The instance of a node in the world normally only contains the three values
2134 mentioned in [Nodes]. However, it is possible to insert extra data into a node.
2135 It is called "node metadata"; See `NodeMetaRef`.
2136
2137 Node metadata contains two things:
2138
2139 * A key-value store
2140 * An inventory
2141
2142 Some of the values in the key-value store are handled specially:
2143
2144 * `formspec`: Defines an inventory menu that is opened with the
2145               'place/use' key. Only works if no `on_rightclick` was
2146               defined for the node. See also [Formspec].
2147 * `infotext`: Text shown on the screen when the node is pointed at.
2148               Line-breaks will be applied automatically.
2149               If the infotext is very long, it will be truncated.
2150
2151 Example:
2152
2153     local meta = minetest.get_meta(pos)
2154     meta:set_string("formspec",
2155             "size[8,9]"..
2156             "list[context;main;0,0;8,4;]"..
2157             "list[current_player;main;0,5;8,4;]")
2158     meta:set_string("infotext", "Chest");
2159     local inv = meta:get_inventory()
2160     inv:set_size("main", 8*4)
2161     print(dump(meta:to_table()))
2162     meta:from_table({
2163         inventory = {
2164             main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
2165                     [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
2166                     [10] = "", [11] = "", [12] = "", [13] = "",
2167                     [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
2168                     [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
2169                     [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
2170                     [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
2171                     [32] = ""}
2172         },
2173         fields = {
2174             formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
2175             infotext = "Chest"
2176         }
2177     })
2178
2179 Item Metadata
2180 -------------
2181
2182 Item stacks can store metadata too. See [`ItemStackMetaRef`].
2183
2184 Item metadata only contains a key-value store.
2185
2186 Some of the values in the key-value store are handled specially:
2187
2188 * `description`: Set the item stack's description.
2189   See also: `get_description` in [`ItemStack`]
2190 * `short_description`: Set the item stack's short description.
2191   See also: `get_short_description` in [`ItemStack`]
2192 * `color`: A `ColorString`, which sets the stack's color.
2193 * `palette_index`: If the item has a palette, this is used to get the
2194   current color from the palette.
2195 * `count_meta`: Replace the displayed count with any string.
2196 * `count_alignment`: Set the alignment of the displayed count value. This is an
2197   int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
2198   4th bit specify the alignment in y-direction:
2199   0 = default, 1 = left / up, 2 = middle, 3 = right / down
2200   The default currently is the same as right/down.
2201   Example: 6 = 2 + 1*4 = middle,up
2202
2203 Example:
2204
2205     local meta = stack:get_meta()
2206     meta:set_string("key", "value")
2207     print(dump(meta:to_table()))
2208
2209 Example manipulations of "description" and expected output behaviors:
2210
2211     print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
2212     print(ItemStack("foobar"):get_description()) --> Unknown Item
2213
2214     local stack = ItemStack("default:stone")
2215     stack:get_meta():set_string("description", "Custom description\nAnother line")
2216     print(stack:get_description()) --> Custom description\nAnother line
2217     print(stack:get_short_description()) --> Custom description
2218
2219     stack:get_meta():set_string("short_description", "Short")
2220     print(stack:get_description()) --> Custom description\nAnother line
2221     print(stack:get_short_description()) --> Short
2222
2223     print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
2224
2225
2226
2227 Formspec
2228 ========
2229
2230 Formspec defines a menu. This supports inventories and some of the
2231 typical widgets like buttons, checkboxes, text input fields, etc.
2232 It is a string, with a somewhat strange format.
2233
2234 A formspec is made out of formspec elements, which includes widgets
2235 like buttons but also can be used to set stuff like background color.
2236
2237 Many formspec elements have a `name`, which is a unique identifier which
2238 is used when the server receives user input. You must not use the name
2239 "quit" for formspec elements.
2240
2241 Spaces and newlines can be inserted between the blocks, as is used in the
2242 examples.
2243
2244 Position and size units are inventory slots unless the new coordinate system
2245 is enabled. `X` and `Y` position the formspec element relative to the top left
2246 of the menu or container. `W` and `H` are its width and height values.
2247
2248 If the new system is enabled, all elements have unified coordinates for all
2249 elements with no padding or spacing in between. This is highly recommended
2250 for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
2251 Coordinates`.
2252
2253 Inventories with a `player:<name>` inventory location are only sent to the
2254 player named `<name>`.
2255
2256 When displaying text which can contain formspec code, e.g. text set by a player,
2257 use `minetest.formspec_escape`.
2258 For colored text you can use `minetest.colorize`.
2259
2260 Since formspec version 3, elements drawn in the order they are defined. All
2261 background elements are drawn before all other elements.
2262
2263 **WARNING**: do _not_ use a element name starting with `key_`; those names are
2264 reserved to pass key press events to formspec!
2265
2266 **WARNING**: Minetest allows you to add elements to every single formspec instance
2267 using `player:set_formspec_prepend()`, which may be the reason backgrounds are
2268 appearing when you don't expect them to, or why things are styled differently
2269 to normal. See [`no_prepend[]`] and [Styling Formspecs].
2270
2271 Examples
2272 --------
2273
2274 ### Chest
2275
2276     size[8,9]
2277     list[context;main;0,0;8,4;]
2278     list[current_player;main;0,5;8,4;]
2279
2280 ### Furnace
2281
2282     size[8,9]
2283     list[context;fuel;2,3;1,1;]
2284     list[context;src;2,1;1,1;]
2285     list[context;dst;5,1;2,2;]
2286     list[current_player;main;0,5;8,4;]
2287
2288 ### Minecraft-like player inventory
2289
2290     size[8,7.5]
2291     image[1,0.6;1,2;player.png]
2292     list[current_player;main;0,3.5;8,4;]
2293     list[current_player;craft;3,0;3,3;]
2294     list[current_player;craftpreview;7,1;1,1;]
2295
2296 Version History
2297 ---------------
2298
2299 * Formspec version 1 (pre-5.1.0):
2300   * (too much)
2301 * Formspec version 2 (5.1.0):
2302   * Forced real coordinates
2303   * background9[]: 9-slice scaling parameters
2304 * Formspec version 3 (5.2.0):
2305   * Formspec elements are drawn in the order of definition
2306   * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
2307   * box[] and image[] elements enable clipping by default
2308   * new element: scroll_container[]
2309 * Formspec version 4 (5.4.0):
2310   * Allow dropdown indexing events
2311 * Formspec version 5 (5.5.0):
2312   * Added padding[] element
2313 * Formspec version 6 (5.6.0):
2314   * Add nine-slice images, animated_image, and fgimg_middle
2315
2316 Elements
2317 --------
2318
2319 ### `formspec_version[<version>]`
2320
2321 * Set the formspec version to a certain number. If not specified,
2322   version 1 is assumed.
2323 * Must be specified before `size` element.
2324 * Clients older than this version can neither show newer elements nor display
2325   elements with new arguments correctly.
2326 * Available since feature `formspec_version_element`.
2327 * See also: [Version History]
2328
2329 ### `size[<W>,<H>,<fixed_size>]`
2330
2331 * Define the size of the menu in inventory slots
2332 * `fixed_size`: `true`/`false` (optional)
2333 * deprecated: `invsize[<W>,<H>;]`
2334
2335 ### `position[<X>,<Y>]`
2336
2337 * Must be used after `size` element.
2338 * Defines the position on the game window of the formspec's `anchor` point.
2339 * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
2340   for example:
2341     * [0.0, 0.0] sets the position to the top left corner of the game window.
2342     * [1.0, 1.0] sets the position to the bottom right of the game window.
2343 * Defaults to the center of the game window [0.5, 0.5].
2344
2345 ### `anchor[<X>,<Y>]`
2346
2347 * Must be used after both `size` and `position` (if present) elements.
2348 * Defines the location of the anchor point within the formspec.
2349 * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
2350   for example:
2351     * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
2352     * [1.0, 0.0] sets the anchor to the top right of the formspec.
2353 * Defaults to the center of the formspec [0.5, 0.5].
2354
2355 * `position` and `anchor` elements need suitable values to avoid a formspec
2356   extending off the game window due to particular game window sizes.
2357
2358 ### `padding[<X>,<Y>]`
2359
2360 * Must be used after the `size`, `position`, and `anchor` elements (if present).
2361 * Defines how much space is padded around the formspec if the formspec tries to
2362   increase past the size of the screen and coordinates have to be shrunk.
2363 * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
2364   screen), and 0.5 represents half the screen (which forces the coordinate size
2365   to 0). If negative, the formspec can extend off the edge of the screen.
2366 * Defaults to [0.05, 0.05].
2367
2368 ### `no_prepend[]`
2369
2370 * Must be used after the `size`, `position`, `anchor`, and `padding` elements
2371   (if present).
2372 * Disables player:set_formspec_prepend() from applying to this formspec.
2373
2374 ### `real_coordinates[<bool>]`
2375
2376 * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
2377 * When set to true, all following formspec elements will use the new coordinate system.
2378 * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
2379   (if present), the form size will use the new coordinate system.
2380 * **Note**: Formspec prepends are not affected by the coordinates in the main form.
2381   They must enable it explicitly.
2382 * For information on converting forms to the new coordinate system, see `Migrating
2383   to Real Coordinates`.
2384
2385 ### `container[<X>,<Y>]`
2386
2387 * Start of a container block, moves all physical elements in the container by
2388   (X, Y).
2389 * Must have matching `container_end`
2390 * Containers can be nested, in which case the offsets are added
2391   (child containers are relative to parent containers)
2392
2393 ### `container_end[]`
2394
2395 * End of a container, following elements are no longer relative to this
2396   container.
2397
2398 ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
2399
2400 * Start of a scroll_container block. All contained elements will ...
2401   * take the scroll_container coordinate as position origin,
2402   * be additionally moved by the current value of the scrollbar with the name
2403     `scrollbar name` times `scroll factor` along the orientation `orientation` and
2404   * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
2405 * `orientation`: possible values are `vertical` and `horizontal`.
2406 * `scroll factor`: optional, defaults to `0.1`.
2407 * Nesting is possible.
2408 * Some elements might work a little different if they are in a scroll_container.
2409 * Note: If you want the scroll_container to actually work, you also need to add a
2410   scrollbar element with the specified name. Furthermore, it is highly recommended
2411   to use a scrollbaroptions element on this scrollbar.
2412
2413 ### `scroll_container_end[]`
2414
2415 * End of a scroll_container, following elements are no longer bound to this
2416   container.
2417
2418 ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
2419
2420 * Show an inventory list if it has been sent to the client.
2421 * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
2422   are moved) while the formspec is open, the formspec element may (but is not guaranteed
2423   to) adapt to the new inventory list.
2424 * Item slots are drawn in a grid from left to right, then up to down, ordered
2425   according to the slot index.
2426 * `W` and `H` are in inventory slots, not in coordinates.
2427 * `starting item index` (Optional): The index of the first (upper-left) item to draw.
2428   Indices start at `0`. Default is `0`.
2429 * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
2430   `starting item index`.
2431 * **Note**: With the new coordinate system, the spacing between inventory
2432   slots is one-fourth the size of an inventory slot by default. Also see
2433   [Styling Formspecs] for changing the size of slots and spacing.
2434
2435 ### `listring[<inventory location>;<list name>]`
2436
2437 * Appends to an internal ring of inventory lists.
2438 * Shift-clicking on items in one element of the ring
2439   will send them to the next inventory list inside the ring
2440 * The first occurrence of an element inside the ring will
2441   determine the inventory where items will be sent to
2442
2443 ### `listring[]`
2444
2445 * Shorthand for doing `listring[<inventory location>;<list name>]`
2446   for the last two inventory lists added by list[...]
2447
2448 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
2449
2450 * Sets background color of slots as `ColorString`
2451 * Sets background color of slots on mouse hovering
2452
2453 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
2454
2455 * Sets background color of slots as `ColorString`
2456 * Sets background color of slots on mouse hovering
2457 * Sets color of slots border
2458
2459 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
2460
2461 * Sets background color of slots as `ColorString`
2462 * Sets background color of slots on mouse hovering
2463 * Sets color of slots border
2464 * Sets default background color of tooltips
2465 * Sets default font color of tooltips
2466
2467 ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2468
2469 * Adds tooltip for an element
2470 * `bgcolor` tooltip background color as `ColorString` (optional)
2471 * `fontcolor` tooltip font color as `ColorString` (optional)
2472
2473 ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2474
2475 * Adds tooltip for an area. Other tooltips will take priority when present.
2476 * `bgcolor` tooltip background color as `ColorString` (optional)
2477 * `fontcolor` tooltip font color as `ColorString` (optional)
2478
2479 ### `image[<X>,<Y>;<W>,<H>;<texture name>;<middle>]`
2480
2481 * Show an image.
2482 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2483     * Requires formspec version >= 6.
2484     * See `background9[]` documentation for more information.
2485
2486 ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
2487
2488 * Show an animated image. The image is drawn like a "vertical_frames" tile
2489   animation (See [Tile animation definition]), but uses a frame count/duration for simplicity
2490 * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
2491 * `texture name`: The image to use.
2492 * `frame count`: The number of frames animating the image.
2493 * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
2494 * `frame start` (optional): The index of the frame to start on. Default `1`.
2495 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2496     * Requires formspec version >= 6.
2497     * See `background9[]` documentation for more information.
2498
2499 ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
2500
2501 * Show a mesh model.
2502 * `name`: Element name that can be used for styling
2503 * `mesh`: The mesh model to use.
2504 * `textures`: The mesh textures to use according to the mesh materials.
2505    Texture names must be separated by commas.
2506 * `rotation {X,Y}` (Optional): Initial rotation of the camera.
2507   The axes are euler angles in degrees.
2508 * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
2509 * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
2510 * `frame loop range` (Optional): Range of the animation frames.
2511     * Defaults to the full range of all available frames.
2512     * Syntax: `<begin>,<end>`
2513 * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
2514
2515 ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
2516
2517 * Show an inventory image of registered item/node
2518
2519 ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
2520
2521 * Sets background color of formspec.
2522 * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
2523   of the non-fullscreen and the fullscreen background.
2524 * `fullscreen` (optional) can be one of the following:
2525   * `false`: Only the non-fullscreen background color is drawn. (default)
2526   * `true`: Only the fullscreen background color is drawn.
2527   * `both`: The non-fullscreen and the fullscreen background color are drawn.
2528   * `neither`: No background color is drawn.
2529 * Note: Leave a parameter empty to not modify the value.
2530 * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
2531   are not bools are only available since formspec version 3.
2532
2533 ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
2534
2535 * Example for formspec 8x4 in 16x resolution: image shall be sized
2536   8 times 16px  times  4 times 16px.
2537
2538 ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
2539
2540 * Example for formspec 8x4 in 16x resolution:
2541   image shall be sized 8 times 16px  times  4 times 16px
2542 * If `auto_clip` is `true`, the background is clipped to the formspec size
2543   (`x` and `y` are used as offset values, `w` and `h` are ignored)
2544
2545 ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
2546
2547 * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
2548 * Middle is a rect which defines the middle of the 9-slice.
2549     * `x` - The middle will be x pixels from all sides.
2550     * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
2551     * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
2552         will be added to the width and height of the texture, allowing it to be used as the
2553         distance from the far end.
2554     * All numbers in middle are integers.
2555 * If `auto_clip` is `true`, the background is clipped to the formspec size
2556   (`x` and `y` are used as offset values, `w` and `h` are ignored)
2557 * Available since formspec version 2
2558
2559 ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
2560
2561 * Textual password style field; will be sent to server when a button is clicked
2562 * When enter is pressed in field, fields.key_enter_field will be sent with the
2563   name of this field.
2564 * With the old coordinate system, fields are a set height, but will be vertically
2565   centred on `H`. With the new coordinate system, `H` will modify the height.
2566 * `name` is the name of the field as returned in fields to `on_receive_fields`
2567 * `label`, if not blank, will be text printed on the top left above the field
2568 * See `field_close_on_enter` to stop enter closing the formspec
2569
2570 ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2571
2572 * Textual field; will be sent to server when a button is clicked
2573 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2574   the name of this field.
2575 * With the old coordinate system, fields are a set height, but will be vertically
2576   centred on `H`. With the new coordinate system, `H` will modify the height.
2577 * `name` is the name of the field as returned in fields to `on_receive_fields`
2578 * `label`, if not blank, will be text printed on the top left above the field
2579 * `default` is the default value of the field
2580     * `default` may contain variable references such as `${text}` which
2581       will fill the value from the metadata value `text`
2582     * **Note**: no extra text or more than a single variable is supported ATM.
2583 * See `field_close_on_enter` to stop enter closing the formspec
2584
2585 ### `field[<name>;<label>;<default>]`
2586
2587 * As above, but without position/size units
2588 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2589   the name of this field.
2590 * Special field for creating simple forms, such as sign text input
2591 * Must be used without a `size[]` element
2592 * A "Proceed" button will be added automatically
2593 * See `field_close_on_enter` to stop enter closing the formspec
2594
2595 ### `field_close_on_enter[<name>;<close_on_enter>]`
2596
2597 * <name> is the name of the field
2598 * if <close_on_enter> is false, pressing enter in the field will submit the
2599   form but not close it.
2600 * defaults to true when not specified (ie: no tag for a field)
2601
2602 ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2603
2604 * Same as fields above, but with multi-line input
2605 * If the text overflows, a vertical scrollbar is added.
2606 * If the name is empty, the textarea is read-only and
2607   the background is not shown, which corresponds to a multi-line label.
2608
2609 ### `label[<X>,<Y>;<label>]`
2610
2611 * The label formspec element displays the text set in `label`
2612   at the specified position.
2613 * **Note**: If the new coordinate system is enabled, labels are
2614   positioned from the center of the text, not the top.
2615 * The text is displayed directly without automatic line breaking,
2616   so label should not be used for big text chunks.  Newlines can be
2617   used to make labels multiline.
2618 * **Note**: With the new coordinate system, newlines are spaced with
2619   half a coordinate.  With the old system, newlines are spaced 2/5 of
2620   an inventory slot.
2621
2622 ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
2623 * Displays a static formatted text with hyperlinks.
2624 * **Note**: This element is currently unstable and subject to change.
2625 * `x`, `y`, `w` and `h` work as per field
2626 * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
2627 * `text` is the formatted text using `Markup Language` described below.
2628
2629 ### `vertlabel[<X>,<Y>;<label>]`
2630 * Textual label drawn vertically
2631 * `label` is the text on the label
2632 * **Note**: If the new coordinate system is enabled, vertlabels are
2633   positioned from the center of the text, not the left.
2634
2635 ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
2636
2637 * Clickable button. When clicked, fields will be sent.
2638 * With the old coordinate system, buttons are a set height, but will be vertically
2639   centred on `H`. With the new coordinate system, `H` will modify the height.
2640 * `label` is the text on the button
2641
2642 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2643
2644 * `texture name` is the filename of an image
2645 * **Note**: Height is supported on both the old and new coordinate systems
2646   for image_buttons.
2647
2648 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
2649
2650 * `texture name` is the filename of an image
2651 * `noclip=true` means the image button doesn't need to be within specified
2652   formsize.
2653 * `drawborder`: draw button border or not
2654 * `pressed texture name` is the filename of an image on pressed state
2655
2656 ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
2657
2658 * `item name` is the registered name of an item/node
2659 * The item description will be used as the tooltip. This can be overridden with
2660   a tooltip element.
2661
2662 ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
2663
2664 * When clicked, fields will be sent and the form will quit.
2665 * Same as `button` in all other respects.
2666
2667 ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2668
2669 * When clicked, fields will be sent and the form will quit.
2670 * Same as `image_button` in all other respects.
2671
2672 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
2673
2674 * Scrollable item list showing arbitrary text elements
2675 * `name` fieldname sent to server on doubleclick value is current selected
2676   element.
2677 * `listelements` can be prepended by #color in hexadecimal format RRGGBB
2678   (only).
2679     * if you want a listelement to start with "#" write "##".
2680
2681 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
2682
2683 * Scrollable itemlist showing arbitrary text elements
2684 * `name` fieldname sent to server on doubleclick value is current selected
2685   element.
2686 * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
2687     * if you want a listelement to start with "#" write "##"
2688 * Index to be selected within textlist
2689 * `true`/`false`: draw transparent background
2690 * See also `minetest.explode_textlist_event`
2691   (main menu: `core.explode_textlist_event`).
2692
2693 ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2694
2695 * Show a tab**header** at specific position (ignores formsize)
2696 * `X` and `Y`: position of the tabheader
2697 * *Note*: Width and height are automatically chosen with this syntax
2698 * `name` fieldname data is transferred to Lua
2699 * `caption 1`...: name shown on top of tab
2700 * `current_tab`: index of selected tab 1...
2701 * `transparent` (optional): if true, tabs are semi-transparent
2702 * `draw_border` (optional): if true, draw a thin line at tab base
2703
2704 ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2705
2706 * Show a tab**header** at specific position (ignores formsize)
2707 * **Important note**: This syntax for tabheaders can only be used with the
2708   new coordinate system.
2709 * `X` and `Y`: position of the tabheader
2710 * `H`: height of the tabheader. Width is automatically determined with this syntax.
2711 * `name` fieldname data is transferred to Lua
2712 * `caption 1`...: name shown on top of tab
2713 * `current_tab`: index of selected tab 1...
2714 * `transparent` (optional): show transparent
2715 * `draw_border` (optional): draw border
2716
2717 ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2718
2719 * Show a tab**header** at specific position (ignores formsize)
2720 * **Important note**: This syntax for tabheaders can only be used with the
2721   new coordinate system.
2722 * `X` and `Y`: position of the tabheader
2723 * `W` and `H`: width and height of the tabheader
2724 * `name` fieldname data is transferred to Lua
2725 * `caption 1`...: name shown on top of tab
2726 * `current_tab`: index of selected tab 1...
2727 * `transparent` (optional): show transparent
2728 * `draw_border` (optional): draw border
2729
2730 ### `box[<X>,<Y>;<W>,<H>;<color>]`
2731
2732 * Simple colored box
2733 * `color` is color specified as a `ColorString`.
2734   If the alpha component is left blank, the box will be semitransparent.
2735   If the color is not specified, the box will use the options specified by
2736   its style. If the color is specified, all styling options will be ignored.
2737
2738 ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2739
2740 * Show a dropdown field
2741 * **Important note**: There are two different operation modes:
2742     1. handle directly on change (only changed dropdown is submitted)
2743     2. read the value on pressing a button (all dropdown values are available)
2744 * `X` and `Y`: position of the dropdown
2745 * `W`: width of the dropdown. Height is automatically chosen with this syntax.
2746 * Fieldname data is transferred to Lua
2747 * Items to be shown in dropdown
2748 * Index of currently selected dropdown item
2749 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2750   event field value for selected items.
2751     * `true`: Selected item index
2752     * `false` (default): Selected item value
2753
2754 ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2755
2756 * Show a dropdown field
2757 * **Important note**: This syntax for dropdowns can only be used with the
2758   new coordinate system.
2759 * **Important note**: There are two different operation modes:
2760     1. handle directly on change (only changed dropdown is submitted)
2761     2. read the value on pressing a button (all dropdown values are available)
2762 * `X` and `Y`: position of the dropdown
2763 * `W` and `H`: width and height of the dropdown
2764 * Fieldname data is transferred to Lua
2765 * Items to be shown in dropdown
2766 * Index of currently selected dropdown item
2767 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2768   event field value for selected items.
2769     * `true`: Selected item index
2770     * `false` (default): Selected item value
2771
2772 ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
2773
2774 * Show a checkbox
2775 * `name` fieldname data is transferred to Lua
2776 * `label` to be shown left of checkbox
2777 * `selected` (optional): `true`/`false`
2778 * **Note**: If the new coordinate system is enabled, checkboxes are
2779   positioned from the center of the checkbox, not the top.
2780
2781 ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
2782
2783 * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
2784 * There are two ways to use it:
2785     1. handle the changed event (only changed scrollbar is available)
2786     2. read the value on pressing a button (all scrollbars are available)
2787 * `orientation`: `vertical`/`horizontal`. Default horizontal.
2788 * Fieldname data is transferred to Lua
2789 * Value of this trackbar is set to (`0`-`1000`) by default
2790 * See also `minetest.explode_scrollbar_event`
2791   (main menu: `core.explode_scrollbar_event`).
2792
2793 ### `scrollbaroptions[opt1;opt2;...]`
2794 * Sets options for all following `scrollbar[]` elements
2795 * `min=<int>`
2796     * Sets scrollbar minimum value, defaults to `0`.
2797 * `max=<int>`
2798     * Sets scrollbar maximum value, defaults to `1000`.
2799       If the max is equal to the min, the scrollbar will be disabled.
2800 * `smallstep=<int>`
2801     * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
2802       scrolled.
2803     * If this is set to a negative number, the value will be reset to `10`.
2804 * `largestep=<int>`
2805     * Sets scrollbar step value used by page up and page down.
2806     * If this is set to a negative number, the value will be reset to `100`.
2807 * `thumbsize=<int>`
2808     * Sets size of the thumb on the scrollbar. Size is calculated in the number of
2809       units the thumb spans out of the range of the scrollbar values.
2810     * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
2811       would span a tenth of the scrollbar space.
2812     * If this is set to zero or less, the value will be reset to `1`.
2813 * `arrows=<show/hide/default>`
2814     * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
2815       when the scrollbar gets too small, but shows them otherwise.
2816
2817 ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
2818
2819 * Show scrollable table using options defined by the previous `tableoptions[]`
2820 * Displays cells as defined by the previous `tablecolumns[]`
2821 * `name`: fieldname sent to server on row select or doubleclick
2822 * `cell 1`...`cell n`: cell contents given in row-major order
2823 * `selected idx`: index of row to be selected within table (first row = `1`)
2824 * See also `minetest.explode_table_event`
2825   (main menu: `core.explode_table_event`).
2826
2827 ### `tableoptions[<opt 1>;<opt 2>;...]`
2828
2829 * Sets options for `table[]`
2830 * `color=#RRGGBB`
2831     * default text color (`ColorString`), defaults to `#FFFFFF`
2832 * `background=#RRGGBB`
2833     * table background color (`ColorString`), defaults to `#000000`
2834 * `border=<true/false>`
2835     * should the table be drawn with a border? (default: `true`)
2836 * `highlight=#RRGGBB`
2837     * highlight background color (`ColorString`), defaults to `#466432`
2838 * `highlight_text=#RRGGBB`
2839     * highlight text color (`ColorString`), defaults to `#FFFFFF`
2840 * `opendepth=<value>`
2841     * all subtrees up to `depth < value` are open (default value = `0`)
2842     * only useful when there is a column of type "tree"
2843
2844 ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
2845
2846 * Sets columns for `table[]`
2847 * Types: `text`, `image`, `color`, `indent`, `tree`
2848     * `text`:   show cell contents as text
2849     * `image`:  cell contents are an image index, use column options to define
2850                 images.
2851     * `color`:  cell contents are a ColorString and define color of following
2852                 cell.
2853     * `indent`: cell contents are a number and define indentation of following
2854                 cell.
2855     * `tree`:   same as indent, but user can open and close subtrees
2856                 (treeview-like).
2857 * Column options:
2858     * `align=<value>`
2859         * for `text` and `image`: content alignment within cells.
2860           Available values: `left` (default), `center`, `right`, `inline`
2861     * `width=<value>`
2862         * for `text` and `image`: minimum width in em (default: `0`)
2863         * for `indent` and `tree`: indent width in em (default: `1.5`)
2864     * `padding=<value>`: padding left of the column, in em (default `0.5`).
2865       Exception: defaults to 0 for indent columns
2866     * `tooltip=<value>`: tooltip text (default: empty)
2867     * `image` column options:
2868         * `0=<value>` sets image for image index 0
2869         * `1=<value>` sets image for image index 1
2870         * `2=<value>` sets image for image index 2
2871         * and so on; defined indices need not be contiguous empty or
2872           non-numeric cells are treated as `0`.
2873     * `color` column options:
2874         * `span=<value>`: number of following columns to affect
2875           (default: infinite).
2876
2877 ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2878
2879 * Set the style for the element(s) matching `selector` by name.
2880 * `selector` can be one of:
2881     * `<name>` - An element name. Includes `*`, which represents every element.
2882     * `<name>:<state>` - An element name, a colon, and one or more states.
2883 * `state` is a list of states separated by the `+` character.
2884     * If a state is provided, the style will only take effect when the element is in that state.
2885     * All provided states must be active for the style to apply.
2886 * Note: this **must** be before the element is defined.
2887 * See [Styling Formspecs].
2888
2889
2890 ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2891
2892 * Set the style for the element(s) matching `selector` by type.
2893 * `selector` can be one of:
2894     * `<type>` - An element type. Includes `*`, which represents every element.
2895     * `<type>:<state>` - An element type, a colon, and one or more states.
2896 * `state` is a list of states separated by the `+` character.
2897     * If a state is provided, the style will only take effect when the element is in that state.
2898     * All provided states must be active for the style to apply.
2899 * See [Styling Formspecs].
2900
2901 ### `set_focus[<name>;<force>]`
2902
2903 * Sets the focus to the element with the same `name` parameter.
2904 * **Note**: This element must be placed before the element it focuses.
2905 * `force` (optional, default `false`): By default, focus is not applied for
2906   re-sent formspecs with the same name so that player-set focus is kept.
2907   `true` sets the focus to the specified element for every sent formspec.
2908 * The following elements have the ability to be focused:
2909     * checkbox
2910     * button
2911     * button_exit
2912     * image_button
2913     * image_button_exit
2914     * item_image_button
2915     * table
2916     * textlist
2917     * dropdown
2918     * field
2919     * pwdfield
2920     * textarea
2921     * scrollbar
2922
2923 Migrating to Real Coordinates
2924 -----------------------------
2925
2926 In the old system, positions included padding and spacing. Padding is a gap between
2927 the formspec window edges and content, and spacing is the gaps between items. For
2928 example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
2929 and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
2930 in the new coordinate system from scratch.
2931
2932 To recreate an old layout with padding, you'll need to pass the positions and sizes
2933 through the following formula to re-introduce padding:
2934
2935 ```
2936 pos = (oldpos + 1)*spacing + padding
2937 where
2938     padding = 3/8
2939     spacing = 5/4
2940 ```
2941
2942 You'll need to change the `size[]` tag like this:
2943
2944 ```
2945 size = (oldsize-1)*spacing + padding*2 + 1
2946 ```
2947
2948 A few elements had random offsets in the old system. Here is a table which shows these
2949 offsets when migrating:
2950
2951 | Element |  Position  |  Size   | Notes
2952 |---------|------------|---------|-------
2953 | box     | +0.3, +0.1 | 0, -0.4 |
2954 | button  |            |         | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
2955 | list    |            |         | Spacing is now 0.25 for both directions, meaning lists will be taller in height
2956 | label   | 0, +0.3    |         | The first line of text is now positioned centered exactly at the position specified
2957
2958 Styling Formspecs
2959 -----------------
2960
2961 Formspec elements can be themed using the style elements:
2962
2963     style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
2964     style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
2965     style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
2966     style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
2967
2968 Where a prop is:
2969
2970     property_name=property_value
2971
2972 For example:
2973
2974     style_type[button;bgcolor=#006699]
2975     style[world_delete;bgcolor=red;textcolor=yellow]
2976     button[4,3.95;2.6,1;world_delete;Delete]
2977
2978 A name/type can optionally be a comma separated list of names/types, like so:
2979
2980     world_delete,world_create,world_configure
2981     button,image_button
2982
2983 A `*` type can be used to select every element in the formspec.
2984
2985 Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
2986
2987     world_delete:hovered+pressed
2988     button:pressed
2989
2990 States allow you to apply styles in response to changes in the element, instead of applying at all times.
2991
2992 Setting a property to nothing will reset it to the default value. For example:
2993
2994     style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
2995     style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
2996
2997
2998 ### Supported Element Types
2999
3000 Some types may inherit styles from parent types.
3001
3002 * animated_image, inherits from image
3003 * box
3004 * button
3005 * button_exit, inherits from button
3006 * checkbox
3007 * dropdown
3008 * field
3009 * image
3010 * image_button
3011 * item_image_button
3012 * label
3013 * list
3014 * model
3015 * pwdfield, inherits from field
3016 * scrollbar
3017 * tabheader
3018 * table
3019 * textarea
3020 * textlist
3021 * vertlabel, inherits from label
3022
3023
3024 ### Valid Properties
3025
3026 * animated_image
3027     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3028 * box
3029     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3030         * Defaults to false in formspec_version version 3 or higher
3031     * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
3032         * Single value (e.g. `#FF0`): All corners/borders.
3033         * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
3034           top and bottom,left and right.
3035         * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
3036         * These work similarly to CSS borders.
3037     * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
3038     * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
3039     * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
3040       negative, the border will extend inside the box, whereas positive extends outside
3041       the box. A width of zero results in no border; this is default.
3042 * button, button_exit, image_button, item_image_button
3043     * alpha - boolean, whether to draw alpha in bgimg. Default true.
3044     * bgcolor - color, sets button tint.
3045     * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
3046         * This is deprecated, use states instead.
3047     * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
3048         * This is deprecated, use states instead.
3049     * bgimg - standard background image. Defaults to none.
3050     * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
3051         * This is deprecated, use states instead.
3052     * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
3053                      See background9[] documentation for more details. This property also pads the
3054                      button's content when set.
3055     * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
3056         * This is deprecated, use states instead.
3057     * font - Sets font type. This is a comma separated list of options. Valid options:
3058       * Main font type options. These cannot be combined with each other:
3059         * `normal`: Default font
3060         * `mono`: Monospaced font
3061       * Font modification options. If used without a main font type, `normal` is used:
3062         * `bold`: Makes font bold.
3063         * `italic`: Makes font italic.
3064       Default `normal`.
3065     * font_size - Sets font size. Default is user-set. Can have multiple values:
3066       * `<number>`: Sets absolute font size to `number`.
3067       * `+<number>`/`-<number>`: Offsets default font size by `number` points.
3068       * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
3069     * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
3070     * content_offset - 2d vector, shifts the position of the button's content without resizing it.
3071     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3072     * padding - rect, adds space between the edges of the button and the content. This value is
3073                 relative to bgimg_middle.
3074     * sound - a sound to be played when triggered.
3075     * textcolor - color, default white.
3076 * checkbox
3077     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3078     * sound - a sound to be played when triggered.
3079 * dropdown
3080     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3081     * sound - a sound to be played when the entry is changed.
3082 * field, pwdfield, textarea
3083     * border - set to false to hide the textbox background and border. Default true.
3084     * font - Sets font type. See button `font` property for more information.
3085     * font_size - Sets font size. See button `font_size` property for more information.
3086     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3087     * textcolor - color. Default white.
3088 * model
3089     * bgcolor - color, sets background color.
3090     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3091         * Default to false in formspec_version version 3 or higher
3092 * image
3093     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3094         * Default to false in formspec_version version 3 or higher
3095 * item_image
3096     * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
3097 * label, vertlabel
3098     * font - Sets font type. See button `font` property for more information.
3099     * font_size - Sets font size. See button `font_size` property for more information.
3100     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3101 * list
3102     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3103     * size - 2d vector, sets the size of inventory slots in coordinates.
3104     * spacing - 2d vector, sets the space between inventory slots in coordinates.
3105 * image_button (additional properties)
3106     * fgimg - standard image. Defaults to none.
3107     * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
3108         * This is deprecated, use states instead.
3109     * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
3110         * This is deprecated, use states instead.
3111     * fgimg_middle - Makes the fgimg textures render in 9-sliced mode and defines the middle rect.
3112                      See background9[] documentation for more details.
3113     * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
3114     * sound - a sound to be played when triggered.
3115 * scrollbar
3116     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3117 * tabheader
3118     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3119     * sound - a sound to be played when a different tab is selected.
3120     * textcolor - color. Default white.
3121 * table, textlist
3122     * font - Sets font type. See button `font` property for more information.
3123     * font_size - Sets font size. See button `font_size` property for more information.
3124     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3125
3126 ### Valid States
3127
3128 * *all elements*
3129     * default - Equivalent to providing no states
3130 * button, button_exit, image_button, item_image_button
3131     * hovered - Active when the mouse is hovering over the element
3132     * pressed - Active when the button is pressed
3133
3134 Markup Language
3135 ---------------
3136
3137 Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
3138 The markup language is currently unstable and subject to change. Use with caution.
3139 Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
3140 Tags can have attributes, in that case, attributes are in the opening tag in
3141 form of a key/value separated with equal signs. Attribute values should not be quoted.
3142
3143 If you want to insert a literal greater-than sign or a backslash into the text,
3144 you must escape it by preceding it with a backslash.
3145
3146 These are the technically basic tags but see below for usual tags. Base tags are:
3147
3148 `<style color=... font=... size=...>...</style>`
3149
3150 Changes the style of the text.
3151
3152 * `color`: Text color. Given color is a `colorspec`.
3153 * `size`: Text size.
3154 * `font`: Text font (`mono` or `normal`).
3155
3156 `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
3157
3158 Sets global style.
3159
3160 Global only styles:
3161 * `background`: Text background, a `colorspec` or `none`.
3162 * `margin`: Page margins in pixel.
3163 * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
3164
3165 Inheriting styles (affects child elements):
3166 * `color`: Default text color. Given color is a `colorspec`.
3167 * `hovercolor`: Color of <action> tags when mouse is over.
3168 * `size`: Default text size.
3169 * `font`: Default text font (`mono` or `normal`).
3170 * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
3171
3172 This tag needs to be placed only once as it changes the global settings of the
3173 text. Anyway, if several tags are placed, each changed will be made in the order
3174 tags appear.
3175
3176 `<tag name=... color=... hovercolor=... font=... size=...>`
3177
3178 Defines or redefines tag style. This can be used to define new tags.
3179 * `name`: Name of the tag to define or change.
3180 * `color`: Text color. Given color is a `colorspec`.
3181 * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
3182 * `size`: Text size.
3183 * `font`: Text font (`mono` or `normal`).
3184
3185 Following tags are the usual tags for text layout. They are defined by default.
3186 Other tags can be added using `<tag ...>` tag.
3187
3188 `<normal>...</normal>`: Normal size text
3189
3190 `<big>...</big>`: Big text
3191
3192 `<bigger>...</bigger>`: Bigger text
3193
3194 `<center>...</center>`: Centered text
3195
3196 `<left>...</left>`: Left-aligned text
3197
3198 `<right>...</right>`: Right-aligned text
3199
3200 `<justify>...</justify>`: Justified text
3201
3202 `<mono>...</mono>`: Monospaced font
3203
3204 `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
3205
3206 `<action name=...>...</action>`
3207
3208 Make that text a clickable text triggering an action.
3209
3210 * `name`: Name of the action (mandatory).
3211
3212 When clicked, the formspec is send to the server. The value of the text field
3213 sent to `on_player_receive_fields` will be "action:" concatenated to the action
3214 name.
3215
3216 `<img name=... float=... width=... height=...>`
3217
3218 Draws an image which is present in the client media cache.
3219
3220 * `name`: Name of the texture (mandatory).
3221 * `float`: If present, makes the image floating (`left` or `right`).
3222 * `width`: Force image width instead of taking texture width.
3223 * `height`: Force image height instead of taking texture height.
3224
3225 If only width or height given, texture aspect is kept.
3226
3227 `<item name=... float=... width=... height=... rotate=...>`
3228
3229 Draws an item image.
3230
3231 * `name`: Item string of the item to draw (mandatory).
3232 * `float`: If present, makes the image floating (`left` or `right`).
3233 * `width`: Item image width.
3234 * `height`: Item image height.
3235 * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
3236 rotation speeds in percent of standard speed (-1000 to 1000). Works only if
3237 `inventory_items_animations` is set to true.
3238 * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
3239 X, Y and Z being angles around each three axes. Works only if
3240 `inventory_items_animations` is set to true.
3241
3242 Inventory
3243 =========
3244
3245 Inventory locations
3246 -------------------
3247
3248 * `"context"`: Selected node metadata (deprecated: `"current_name"`)
3249 * `"current_player"`: Player to whom the menu is shown
3250 * `"player:<name>"`: Any player
3251 * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
3252 * `"detached:<name>"`: A detached inventory
3253
3254 Player Inventory lists
3255 ----------------------
3256
3257 * `main`: list containing the default inventory
3258 * `craft`: list containing the craft input
3259 * `craftpreview`: list containing the craft prediction
3260 * `craftresult`: list containing the crafted output
3261 * `hand`: list containing an override for the empty hand
3262     * Is not created automatically, use `InvRef:set_size`
3263     * Is only used to enhance the empty hand's tool capabilities
3264
3265 Colors
3266 ======
3267
3268 `ColorString`
3269 -------------
3270
3271 `#RGB` defines a color in hexadecimal format.
3272
3273 `#RGBA` defines a color in hexadecimal format and alpha channel.
3274
3275 `#RRGGBB` defines a color in hexadecimal format.
3276
3277 `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
3278
3279 Named colors are also supported and are equivalent to
3280 [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
3281 To specify the value of the alpha channel, append `#A` or `#AA` to the end of
3282 the color name (e.g. `colorname#08`).
3283
3284 `ColorSpec`
3285 -----------
3286
3287 A ColorSpec specifies a 32-bit color. It can be written in any of the following
3288 forms:
3289
3290 * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
3291     * `colorspec = {a=255, r=0, g=255, b=0}`
3292 * numerical form: The raw integer value of an ARGB8 quad:
3293     * `colorspec = 0xFF00FF00`
3294 * string form: A ColorString (defined above):
3295     * `colorspec = "green"`
3296
3297
3298
3299
3300 Escape sequences
3301 ================
3302
3303 Most text can contain escape sequences, that can for example color the text.
3304 There are a few exceptions: tab headers, dropdowns and vertical labels can't.
3305 The following functions provide escape sequences:
3306
3307 * `minetest.get_color_escape_sequence(color)`:
3308     * `color` is a ColorString
3309     * The escape sequence sets the text color to `color`
3310 * `minetest.colorize(color, message)`:
3311     * Equivalent to:
3312       `minetest.get_color_escape_sequence(color) ..
3313       message ..
3314       minetest.get_color_escape_sequence("#ffffff")`
3315 * `minetest.get_background_escape_sequence(color)`
3316     * `color` is a ColorString
3317     * The escape sequence sets the background of the whole text element to
3318       `color`. Only defined for item descriptions and tooltips.
3319 * `minetest.strip_foreground_colors(str)`
3320     * Removes foreground colors added by `get_color_escape_sequence`.
3321 * `minetest.strip_background_colors(str)`
3322     * Removes background colors added by `get_background_escape_sequence`.
3323 * `minetest.strip_colors(str)`
3324     * Removes all color escape sequences.
3325
3326
3327
3328
3329 Spatial Vectors
3330 ===============
3331
3332 Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
3333 and has a class to represent them (`vector.*`), which this chapter is about.
3334 For details on what a spatial vectors is, please refer to Wikipedia:
3335 https://en.wikipedia.org/wiki/Euclidean_vector.
3336
3337 Spatial vectors are used for various things, including, but not limited to:
3338
3339 * any 3D spatial vector (x/y/z-directions)
3340 * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
3341   meaning here. Therefore, most vector operations make no sense in this use case.)
3342
3343 Note that they are *not* used for:
3344
3345 * n-dimensional vectors where n is not 3 (ie. n=2)
3346 * arrays of the form `{num, num, num}`
3347
3348 The API documentation may refer to spatial vectors, as produced by `vector.new`,
3349 by any of the following notations:
3350
3351 * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
3352 * `vector.new(x, y, z)`
3353 * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
3354
3355 Compatibility notes
3356 -------------------
3357
3358 Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
3359 Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
3360 Note: Those old-style vectors can still be found in old mod code. Hence, mod and
3361 engine APIs still need to be able to cope with them in many places.
3362
3363 Manually constructed tables are deprecated and highly discouraged. This interface
3364 should be used to ensure seamless compatibility between mods and the Minetest API.
3365 This is especially important to callback function parameters and functions overwritten
3366 by mods.
3367 Also, though not likely, the internal implementation of a vector might change in
3368 the future.
3369 In your own code, or if you define your own API, you can, of course, still use
3370 other representations of vectors.
3371
3372 Vectors provided by API functions will provide an instance of this class if not
3373 stated otherwise. Mods should adapt this for convenience reasons.
3374
3375 Special properties of the class
3376 -------------------------------
3377
3378 Vectors can be indexed with numbers and allow method and operator syntax.
3379
3380 All these forms of addressing a vector `v` are valid:
3381 `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
3382 Note: Prefer letter over number indexing for performance and compatibility reasons.
3383
3384 Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
3385 the same as `vector.foo(v, ...)`, apart from deprecated functionality.
3386
3387 `tostring` is defined for vectors, see `vector.to_string`.
3388
3389 The metatable that is used for vectors can be accessed via `vector.metatable`.
3390 Do not modify it!
3391
3392 All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
3393 Returned vectors always have a metatable set.
3394
3395 Common functions and methods
3396 ----------------------------
3397
3398 For the following functions (and subchapters),
3399 `v`, `v1`, `v2` are vectors,
3400 `p1`, `p2` are position vectors,
3401 `s` is a scalar (a number),
3402 vectors are written like this: `(x, y, z)`:
3403
3404 * `vector.new([a[, b, c]])`:
3405     * Returns a new vector `(a, b, c)`.
3406     * Deprecated: `vector.new()` does the same as `vector.zero()` and
3407       `vector.new(v)` does the same as `vector.copy(v)`
3408 * `vector.zero()`:
3409     * Returns a new vector `(0, 0, 0)`.
3410 * `vector.copy(v)`:
3411     * Returns a copy of the vector `v`.
3412 * `vector.from_string(s[, init])`:
3413     * Returns `v, np`, where `v` is a vector read from the given string `s` and
3414       `np` is the next position in the string after the vector.
3415     * Returns `nil` on failure.
3416     * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
3417            spaces, leaving away commas and adding an additional comma to the end
3418            is allowed.
3419     * `init`: If given starts looking for the vector at this string index.
3420 * `vector.to_string(v)`:
3421     * Returns a string of the form `"(x, y, z)"`.
3422     *  `tostring(v)` does the same.
3423 * `vector.direction(p1, p2)`:
3424     * Returns a vector of length 1 with direction `p1` to `p2`.
3425     * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
3426 * `vector.distance(p1, p2)`:
3427     * Returns zero or a positive number, the distance between `p1` and `p2`.
3428 * `vector.length(v)`:
3429     * Returns zero or a positive number, the length of vector `v`.
3430 * `vector.normalize(v)`:
3431     * Returns a vector of length 1 with direction of vector `v`.
3432     * If `v` has zero length, returns `(0, 0, 0)`.
3433 * `vector.floor(v)`:
3434     * Returns a vector, each dimension rounded down.
3435 * `vector.round(v)`:
3436     * Returns a vector, each dimension rounded to nearest integer.
3437     * At a multiple of 0.5, rounds away from zero.
3438 * `vector.apply(v, func)`:
3439     * Returns a vector where the function `func` has been applied to each
3440       component.
3441 * `vector.combine(v, w, func)`:
3442         * Returns a vector where the function `func` has combined both components of `v` and `w`
3443           for each component
3444 * `vector.equals(v1, v2)`:
3445     * Returns a boolean, `true` if the vectors are identical.
3446 * `vector.sort(v1, v2)`:
3447     * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
3448 * `vector.angle(v1, v2)`:
3449     * Returns the angle between `v1` and `v2` in radians.
3450 * `vector.dot(v1, v2)`:
3451     * Returns the dot product of `v1` and `v2`.
3452 * `vector.cross(v1, v2)`:
3453     * Returns the cross product of `v1` and `v2`.
3454 * `vector.offset(v, x, y, z)`:
3455     * Returns the sum of the vectors `v` and `(x, y, z)`.
3456 * `vector.check(v)`:
3457     * Returns a boolean value indicating whether `v` is a real vector, eg. created
3458       by a `vector.*` function.
3459     * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
3460
3461 For the following functions `x` can be either a vector or a number:
3462
3463 * `vector.add(v, x)`:
3464     * Returns a vector.
3465     * If `x` is a vector: Returns the sum of `v` and `x`.
3466     * If `x` is a number: Adds `x` to each component of `v`.
3467 * `vector.subtract(v, x)`:
3468     * Returns a vector.
3469     * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
3470     * If `x` is a number: Subtracts `x` from each component of `v`.
3471 * `vector.multiply(v, s)`:
3472     * Returns a scaled vector.
3473     * Deprecated: If `s` is a vector: Returns the Schur product.
3474 * `vector.divide(v, s)`:
3475     * Returns a scaled vector.
3476     * Deprecated: If `s` is a vector: Returns the Schur quotient.
3477
3478 Operators
3479 ---------
3480
3481 Operators can be used if all of the involved vectors have metatables:
3482 * `v1 == v2`:
3483     * Returns whether `v1` and `v2` are identical.
3484 * `-v`:
3485     * Returns the additive inverse of v.
3486 * `v1 + v2`:
3487     * Returns the sum of both vectors.
3488     * Note: `+` can not be used together with scalars.
3489 * `v1 - v2`:
3490     * Returns the difference of `v1` subtracted by `v2`.
3491     * Note: `-` can not be used together with scalars.
3492 * `v * s` or `s * v`:
3493     * Returns `v` scaled by `s`.
3494 * `v / s`:
3495     * Returns `v` scaled by `1 / s`.
3496
3497 Rotation-related functions
3498 --------------------------
3499
3500 For the following functions `a` is an angle in radians and `r` is a rotation
3501 vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
3502 angles in radians.
3503
3504 * `vector.rotate(v, r)`:
3505     * Applies the rotation `r` to `v` and returns the result.
3506     * `vector.rotate(vector.new(0, 0, 1), r)` and
3507       `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
3508       forward and up relative to an entity's rotation `r`.
3509 * `vector.rotate_around_axis(v1, v2, a)`:
3510     * Returns `v1` rotated around axis `v2` by `a` radians according to
3511       the right hand rule.
3512 * `vector.dir_to_rotation(direction[, up])`:
3513     * Returns a rotation vector for `direction` pointing forward using `up`
3514       as the up vector.
3515     * If `up` is omitted, the roll of the returned vector defaults to zero.
3516     * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
3517
3518 Further helpers
3519 ---------------
3520
3521 There are more helper functions involving vectors, but they are listed elsewhere
3522 because they only work on specific sorts of vectors or involve things that are not
3523 vectors.
3524
3525 For example:
3526
3527 * `minetest.hash_node_position` (Only works on node positions.)
3528 * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
3529
3530
3531
3532
3533 Helper functions
3534 ================
3535
3536 * `dump2(obj, name, dumped)`: returns a string which makes `obj`
3537   human-readable, handles reference loops.
3538     * `obj`: arbitrary variable
3539     * `name`: string, default: `"_"`
3540     * `dumped`: table, default: `{}`
3541 * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
3542     * `obj`: arbitrary variable
3543     * `dumped`: table, default: `{}`
3544 * `math.hypot(x, y)`
3545     * Get the hypotenuse of a triangle with legs x and y.
3546       Useful for distance calculation.
3547 * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
3548     * Get the sign of a number.
3549     * tolerance: number, default: `0.0`
3550     * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
3551       `0` is returned.
3552 * `math.factorial(x)`: returns the factorial of `x`
3553 * `math.round(x)`: Returns `x` rounded to the nearest integer.
3554     * At a multiple of 0.5, rounds away from zero.
3555 * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
3556     * `separator`: string, default: `","`
3557     * `include_empty`: boolean, default: `false`
3558     * `max_splits`: number, if it's negative, splits aren't limited,
3559       default: `-1`
3560     * `sep_is_pattern`: boolean, it specifies whether separator is a plain
3561       string or a pattern (regex), default: `false`
3562     * e.g. `"a,b":split","` returns `{"a","b"}`
3563 * `string:trim()`: returns the string without whitespace pre- and suffixes
3564     * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
3565 * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
3566     * Adds newlines to the string to keep it within the specified character
3567       limit
3568     * Note that the returned lines may be longer than the limit since it only
3569       splits at word borders.
3570     * `limit`: number, maximal amount of characters in one line
3571     * `as_table`: boolean, if set to true, a table of lines instead of a string
3572       is returned, default: `false`
3573 * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
3574     * `pos`: table {x=X, y=Y, z=Z}
3575     * Converts the position `pos` to a human-readable, printable string
3576     * `decimal_places`: number, if specified, the x, y and z values of
3577       the position are rounded to the given decimal place.
3578 * `minetest.string_to_pos(string)`: returns a position or `nil`
3579     * Same but in reverse.
3580     * If the string can't be parsed to a position, nothing is returned.
3581 * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`:
3582     * returns two positions
3583     * Converts a string representing an area box into two positions
3584     * X1, Y1, ... Z2 are coordinates
3585     * `relative_to`: Optional. If set to a position, each coordinate
3586       can use the tilde notation for relative positions
3587     * Tilde notation: "~": Relative coordinate
3588                       "~<number>": Relative coordinate plus <number>
3589     * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
3590       returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
3591 * `minetest.formspec_escape(string)`: returns a string
3592     * escapes the characters "[", "]", "\", "," and ";", which can not be used
3593       in formspecs.
3594 * `minetest.is_yes(arg)`
3595     * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
3596 * `minetest.is_nan(arg)`
3597     * returns true when the passed number represents NaN.
3598 * `minetest.get_us_time()`
3599     * returns time with microsecond precision. May not return wall time.
3600 * `table.copy(table)`: returns a table
3601     * returns a deep copy of `table`
3602 * `table.indexof(list, val)`: returns the smallest numerical index containing
3603       the value `val` in the table `list`. Non-numerical indices are ignored.
3604       If `val` could not be found, `-1` is returned. `list` must not have
3605       negative indices.
3606 * `table.insert_all(table, other_table)`:
3607     * Appends all values in `other_table` to `table` - uses `#table + 1` to
3608       find new indices.
3609 * `table.key_value_swap(t)`: returns a table with keys and values swapped
3610     * If multiple keys in `t` map to the same value, it is unspecified which
3611       value maps to that key.
3612 * `table.shuffle(table, [from], [to], [random_func])`:
3613     * Shuffles elements `from` to `to` in `table` in place
3614     * `from` defaults to `1`
3615     * `to` defaults to `#table`
3616     * `random_func` defaults to `math.random`. This function receives two
3617       integers as arguments and should return a random integer inclusively
3618       between them.
3619 * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
3620   position.
3621     * returns the exact position on the surface of a pointed node
3622 * `minetest.get_tool_wear_after_use(uses [, initial_wear])`
3623     * Simulates a tool being used once and returns the added wear,
3624       such that, if only this function is used to calculate wear,
3625       the tool will break exactly after `uses` times of uses
3626     * `uses`: Number of times the tool can be used
3627     * `initial_wear`: The initial wear the tool starts with (default: 0)
3628 * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
3629     Simulates an item that digs a node.
3630     Returns a table with the following fields:
3631     * `diggable`: `true` if node can be dug, `false` otherwise.
3632     * `time`: Time it would take to dig the node.
3633     * `wear`: How much wear would be added to the tool (ignored for non-tools).
3634     `time` and `wear` are meaningless if node's not diggable
3635     Parameters:
3636     * `groups`: Table of the node groups of the node that would be dug
3637     * `tool_capabilities`: Tool capabilities table of the item
3638     * `wear`: Amount of wear the tool starts with (default: 0)
3639 * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
3640     Simulates an item that punches an object.
3641     Returns a table with the following fields:
3642     * `hp`: How much damage the punch would cause (between -65535 and 65535).
3643     * `wear`: How much wear would be added to the tool (ignored for non-tools).
3644     Parameters:
3645     * `groups`: Damage groups of the object
3646     * `tool_capabilities`: Tool capabilities table of the item
3647     * `time_from_last_punch`: time in seconds since last punch action
3648     * `wear`: Amount of wear the item starts with (default: 0)
3649
3650
3651
3652
3653 Translations
3654 ============
3655
3656 Texts can be translated client-side with the help of `minetest.translate` and
3657 translation files.
3658
3659 Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
3660 to generate and update translation files automatically from the Lua source.
3661
3662 Translating a string
3663 --------------------
3664
3665 Two functions are provided to translate strings: `minetest.translate` and
3666 `minetest.get_translator`.
3667
3668 * `minetest.get_translator(textdomain)` is a simple wrapper around
3669   `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
3670   equivalent to `minetest.translate(textdomain, str, ...)`.
3671   It is intended to be used in the following way, so that it avoids verbose
3672   repetitions of `minetest.translate`:
3673
3674       local S = minetest.get_translator(textdomain)
3675       S(str, ...)
3676
3677   As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
3678
3679 * `minetest.translate(textdomain, str, ...)` translates the string `str` with
3680   the given `textdomain` for disambiguation. The textdomain must match the
3681   textdomain specified in the translation file in order to get the string
3682   translated. This can be used so that a string is translated differently in
3683   different contexts.
3684   It is advised to use the name of the mod as textdomain whenever possible, to
3685   avoid clashes with other mods.
3686   This function must be given a number of arguments equal to the number of
3687   arguments the translated string expects.
3688   Arguments are literal strings -- they will not be translated, so if you want
3689   them to be, they need to come as outputs of `minetest.translate` as well.
3690
3691   For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
3692   by the translation of "Red". We can do the following:
3693
3694       local S = minetest.get_translator()
3695       S("@1 Wool", S("Red"))
3696
3697   This will be displayed as "Red Wool" on old clients and on clients that do
3698   not have localization enabled. However, if we have for instance a translation
3699   file named `wool.fr.tr` containing the following:
3700
3701       @1 Wool=Laine @1
3702       Red=Rouge
3703
3704   this will be displayed as "Laine Rouge" on clients with a French locale.
3705
3706 Operations on translated strings
3707 --------------------------------
3708
3709 The output of `minetest.translate` is a string, with escape sequences adding
3710 additional information to that string so that it can be translated on the
3711 different clients. In particular, you can't expect operations like string.length
3712 to work on them like you would expect them to, or string.gsub to work in the
3713 expected manner. However, string concatenation will still work as expected
3714 (note that you should only use this for things like formspecs; do not translate
3715 sentences by breaking them into parts; arguments should be used instead), and
3716 operations such as `minetest.colorize` which are also concatenation.
3717
3718 Translation file format
3719 -----------------------
3720
3721 A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
3722 it corresponds to. It must be put into the `locale` subdirectory of the mod.
3723 The file should be a text file, with the following format:
3724
3725 * Lines beginning with `# textdomain:` (the space is significant) can be used
3726   to specify the text domain of all following translations in the file.
3727 * All other empty lines or lines beginning with `#` are ignored.
3728 * Other lines should be in the format `original=translated`. Both `original`
3729   and `translated` can contain escape sequences beginning with `@` to insert
3730   arguments, literal `@`, `=` or newline (See [Escapes] below).
3731   There must be no extraneous whitespace around the `=` or at the beginning or
3732   the end of the line.
3733
3734 Escapes
3735 -------
3736
3737 Strings that need to be translated can contain several escapes, preceded by `@`.
3738
3739 * `@@` acts as a literal `@`.
3740 * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
3741   string that will be inlined when translated. Due to how translations are
3742   implemented, the original translation string **must** have its arguments in
3743   increasing order, without gaps or repetitions, starting from 1.
3744 * `@=` acts as a literal `=`. It is not required in strings given to
3745   `minetest.translate`, but is in translation files to avoid being confused
3746   with the `=` separating the original from the translation.
3747 * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
3748   As with `@=`, this escape is not required in strings given to
3749   `minetest.translate`, but is in translation files.
3750 * `@n` acts as a literal newline as well.
3751
3752 Server side translations
3753 ------------------------
3754
3755 On some specific cases, server translation could be useful. For example, filter
3756 a list on labels and send results to client. A method is supplied to achieve
3757 that:
3758
3759 `minetest.get_translated_string(lang_code, string)`: Translates `string` using
3760 translations for `lang_code` language. It gives the same result as if the string
3761 was translated by the client.
3762
3763 The `lang_code` to use for a given player can be retrieved from
3764 the table returned by `minetest.get_player_information(name)`.
3765
3766 IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
3767 You do not need to use this to get translated strings to show up on the client.
3768
3769 Perlin noise
3770 ============
3771
3772 Perlin noise creates a continuously-varying value depending on the input values.
3773 Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
3774 The result is used during map generation to create the terrain shape, vary heat
3775 and humidity to distribute biomes, vary the density of decorations or vary the
3776 structure of ores.
3777
3778 Structure of perlin noise
3779 -------------------------
3780
3781 An 'octave' is a simple noise generator that outputs a value between -1 and 1.
3782 The smooth wavy noise it generates has a single characteristic scale, almost
3783 like a 'wavelength', so on its own does not create fine detail.
3784 Due to this perlin noise combines several octaves to create variation on
3785 multiple scales. Each additional octave has a smaller 'wavelength' than the
3786 previous.
3787
3788 This combination results in noise varying very roughly between -2.0 and 2.0 and
3789 with an average value of 0.0, so `scale` and `offset` are then used to multiply
3790 and offset the noise variation.
3791
3792 The final perlin noise variation is created as follows:
3793
3794 noise = offset + scale * (octave1 +
3795                           octave2 * persistence +
3796                           octave3 * persistence ^ 2 +
3797                           octave4 * persistence ^ 3 +
3798                           ...)
3799
3800 Noise Parameters
3801 ----------------
3802
3803 Noise Parameters are commonly called `NoiseParams`.
3804
3805 ### `offset`
3806
3807 After the multiplication by `scale` this is added to the result and is the final
3808 step in creating the noise value.
3809 Can be positive or negative.
3810
3811 ### `scale`
3812
3813 Once all octaves have been combined, the result is multiplied by this.
3814 Can be positive or negative.
3815
3816 ### `spread`
3817
3818 For octave1, this is roughly the change of input value needed for a very large
3819 variation in the noise value generated by octave1. It is almost like a
3820 'wavelength' for the wavy noise variation.
3821 Each additional octave has a 'wavelength' that is smaller than the previous
3822 octave, to create finer detail. `spread` will therefore roughly be the typical
3823 size of the largest structures in the final noise variation.
3824
3825 `spread` is a vector with values for x, y, z to allow the noise variation to be
3826 stretched or compressed in the desired axes.
3827 Values are positive numbers.
3828
3829 ### `seed`
3830
3831 This is a whole number that determines the entire pattern of the noise
3832 variation. Altering it enables different noise patterns to be created.
3833 With other parameters equal, different seeds produce different noise patterns
3834 and identical seeds produce identical noise patterns.
3835
3836 For this parameter you can randomly choose any whole number. Usually it is
3837 preferable for this to be different from other seeds, but sometimes it is useful
3838 to be able to create identical noise patterns.
3839
3840 In some noise APIs the world seed is added to the seed specified in noise
3841 parameters. This is done to make the resulting noise pattern vary in different
3842 worlds, and be 'world-specific'.
3843
3844 ### `octaves`
3845
3846 The number of simple noise generators that are combined.
3847 A whole number, 1 or more.
3848 Each additional octave adds finer detail to the noise but also increases the
3849 noise calculation load.
3850 3 is a typical minimum for a high quality, complex and natural-looking noise
3851 variation. 1 octave has a slight 'gridlike' appearance.
3852
3853 Choose the number of octaves according to the `spread` and `lacunarity`, and the
3854 size of the finest detail you require. For example:
3855 if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
3856 nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
3857 512, 256, 128, 64, 32, 16 nodes.
3858 Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
3859
3860 ### `persistence`
3861
3862 Each additional octave has an amplitude that is the amplitude of the previous
3863 octave multiplied by `persistence`, to reduce the amplitude of finer details,
3864 as is often helpful and natural to do so.
3865 Since this controls the balance of fine detail to large-scale detail
3866 `persistence` can be thought of as the 'roughness' of the noise.
3867
3868 A positive or negative non-zero number, often between 0.3 and 1.0.
3869 A common medium value is 0.5, such that each octave has half the amplitude of
3870 the previous octave.
3871 This may need to be tuned when altering `lacunarity`; when doing so consider
3872 that a common medium value is 1 / lacunarity.
3873
3874 ### `lacunarity`
3875
3876 Each additional octave has a 'wavelength' that is the 'wavelength' of the
3877 previous octave multiplied by 1 / lacunarity, to create finer detail.
3878 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
3879
3880 A positive number no smaller than 1.0.
3881 Values below 2.0 create higher quality noise at the expense of requiring more
3882 octaves to cover a paticular range of 'wavelengths'.
3883
3884 ### `flags`
3885
3886 Leave this field unset for no special handling.
3887 Currently supported are `defaults`, `eased` and `absvalue`:
3888
3889 #### `defaults`
3890
3891 Specify this if you would like to keep auto-selection of eased/not-eased while
3892 specifying some other flags.
3893
3894 #### `eased`
3895
3896 Maps noise gradient values onto a quintic S-curve before performing
3897 interpolation. This results in smooth, rolling noise.
3898 Disable this (`noeased`) for sharp-looking noise with a slightly gridded
3899 appearence.
3900 If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
3901 not eased.
3902 Easing a 3D noise significantly increases the noise calculation load, so use
3903 with restraint.
3904
3905 #### `absvalue`
3906
3907 The absolute value of each octave's noise variation is used when combining the
3908 octaves. The final perlin noise variation is created as follows:
3909
3910 noise = offset + scale * (abs(octave1) +
3911                           abs(octave2) * persistence +
3912                           abs(octave3) * persistence ^ 2 +
3913                           abs(octave4) * persistence ^ 3 +
3914                           ...)
3915
3916 ### Format example
3917
3918 For 2D or 3D perlin noise or perlin noise maps:
3919
3920     np_terrain = {
3921         offset = 0,
3922         scale = 1,
3923         spread = {x = 500, y = 500, z = 500},
3924         seed = 571347,
3925         octaves = 5,
3926         persistence = 0.63,
3927         lacunarity = 2.0,
3928         flags = "defaults, absvalue",
3929     }
3930
3931 For 2D noise the Z component of `spread` is still defined but is ignored.
3932 A single noise parameter table can be used for 2D or 3D noise.
3933
3934
3935
3936
3937 Ores
3938 ====
3939
3940 Ore types
3941 ---------
3942
3943 These tell in what manner the ore is generated.
3944
3945 All default ores are of the uniformly-distributed scatter type.
3946
3947 ### `scatter`
3948
3949 Randomly chooses a location and generates a cluster of ore.
3950
3951 If `noise_params` is specified, the ore will be placed if the 3D perlin noise
3952 at that point is greater than the `noise_threshold`, giving the ability to
3953 create a non-equal distribution of ore.
3954
3955 ### `sheet`
3956
3957 Creates a sheet of ore in a blob shape according to the 2D perlin noise
3958 described by `noise_params` and `noise_threshold`. This is essentially an
3959 improved version of the so-called "stratus" ore seen in some unofficial mods.
3960
3961 This sheet consists of vertical columns of uniform randomly distributed height,
3962 varying between the inclusive range `column_height_min` and `column_height_max`.
3963 If `column_height_min` is not specified, this parameter defaults to 1.
3964 If `column_height_max` is not specified, this parameter defaults to `clust_size`
3965 for reverse compatibility. New code should prefer `column_height_max`.
3966
3967 The `column_midpoint_factor` parameter controls the position of the column at
3968 which ore emanates from.
3969 If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
3970 equally starting from each direction.
3971 `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
3972 this parameter is not specified, the default is 0.5.
3973
3974 The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
3975 ore type.
3976
3977 ### `puff`
3978
3979 Creates a sheet of ore in a cloud-like puff shape.
3980
3981 As with the `sheet` ore type, the size and shape of puffs are described by
3982 `noise_params` and `noise_threshold` and are placed at random vertical
3983 positions within the currently generated chunk.
3984
3985 The vertical top and bottom displacement of each puff are determined by the
3986 noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
3987
3988 ### `blob`
3989
3990 Creates a deformed sphere of ore according to 3d perlin noise described by
3991 `noise_params`. The maximum size of the blob is `clust_size`, and
3992 `clust_scarcity` has the same meaning as with the `scatter` type.
3993
3994 ### `vein`
3995
3996 Creates veins of ore varying in density by according to the intersection of two
3997 instances of 3d perlin noise with different seeds, both described by
3998 `noise_params`.
3999
4000 `random_factor` varies the influence random chance has on placement of an ore
4001 inside the vein, which is `1` by default. Note that modifying this parameter
4002 may require adjusting `noise_threshold`.
4003
4004 The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
4005 by this ore type.
4006
4007 This ore type is difficult to control since it is sensitive to small changes.
4008 The following is a decent set of parameters to work from:
4009
4010     noise_params = {
4011         offset  = 0,
4012         scale   = 3,
4013         spread  = {x=200, y=200, z=200},
4014         seed    = 5390,
4015         octaves = 4,
4016         persistence = 0.5,
4017         lacunarity = 2.0,
4018         flags = "eased",
4019     },
4020     noise_threshold = 1.6
4021
4022 **WARNING**: Use this ore type *very* sparingly since it is ~200x more
4023 computationally expensive than any other ore.
4024
4025 ### `stratum`
4026
4027 Creates a single undulating ore stratum that is continuous across mapchunk
4028 borders and horizontally spans the world.
4029
4030 The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
4031 the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
4032 defines the stratum's vertical thickness (in units of nodes). Due to being
4033 continuous across mapchunk borders the stratum's vertical thickness is
4034 unlimited.
4035
4036 If the noise parameter `noise_params` is omitted the ore will occur from y_min
4037 to y_max in a simple horizontal stratum.
4038
4039 A parameter `stratum_thickness` can be provided instead of the noise parameter
4040 `np_stratum_thickness`, to create a constant thickness.
4041
4042 Leaving out one or both noise parameters makes the ore generation less
4043 intensive, useful when adding multiple strata.
4044
4045 `y_min` and `y_max` define the limits of the ore generation and for performance
4046 reasons should be set as close together as possible but without clipping the
4047 stratum's Y variation.
4048
4049 Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
4050 solid-ore stratum would require a `clust_scarcity` of 1.
4051
4052 The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
4053 `random_factor` are ignored by this ore type.
4054
4055 Ore attributes
4056 --------------
4057
4058 See section [Flag Specifier Format].
4059
4060 Currently supported flags:
4061 `puff_cliffs`, `puff_additive_composition`.
4062
4063 ### `puff_cliffs`
4064
4065 If set, puff ore generation will not taper down large differences in
4066 displacement when approaching the edge of a puff. This flag has no effect for
4067 ore types other than `puff`.
4068
4069 ### `puff_additive_composition`
4070
4071 By default, when noise described by `np_puff_top` or `np_puff_bottom` results
4072 in a negative displacement, the sub-column at that point is not generated. With
4073 this attribute set, puff ore generation will instead generate the absolute
4074 difference in noise displacement values. This flag has no effect for ore types
4075 other than `puff`.
4076
4077
4078
4079
4080 Decoration types
4081 ================
4082
4083 The varying types of decorations that can be placed.
4084
4085 `simple`
4086 --------
4087
4088 Creates a 1 times `H` times 1 column of a specified node (or a random node from
4089 a list, if a decoration list is specified). Can specify a certain node it must
4090 spawn next to, such as water or lava, for example. Can also generate a
4091 decoration of random height between a specified lower and upper bound.
4092 This type of decoration is intended for placement of grass, flowers, cacti,
4093 papyri, waterlilies and so on.
4094
4095 `schematic`
4096 -----------
4097
4098 Copies a box of `MapNodes` from a specified schematic file (or raw description).
4099 Can specify a probability of a node randomly appearing when placed.
4100 This decoration type is intended to be used for multi-node sized discrete
4101 structures, such as trees, cave spikes, rocks, and so on.
4102
4103
4104
4105
4106 Schematics
4107 ==========
4108
4109 Schematic specifier
4110 --------------------
4111
4112 A schematic specifier identifies a schematic by either a filename to a
4113 Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
4114 in the form of a table.  This table specifies the following fields:
4115
4116 * The `size` field is a 3D vector containing the dimensions of the provided
4117   schematic. (required field)
4118 * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
4119   sets the probability of a particular horizontal slice of the schematic being
4120   placed. (optional field)
4121   `ypos` = 0 for the lowest horizontal slice of a schematic.
4122   The default of `prob` is 255.
4123 * The `data` field is a flat table of MapNode tables making up the schematic,
4124   in the order of `[z [y [x]]]`. (required field)
4125   Each MapNode table contains:
4126     * `name`: the name of the map node to place (required)
4127     * `prob` (alias `param1`): the probability of this node being placed
4128       (default: 255)
4129     * `param2`: the raw param2 value of the node being placed onto the map
4130       (default: 0)
4131     * `force_place`: boolean representing if the node should forcibly overwrite
4132       any previous contents (default: false)
4133
4134 About probability values:
4135
4136 * A probability value of `0` or `1` means that node will never appear
4137   (0% chance).
4138 * A probability value of `254` or `255` means the node will always appear
4139   (100% chance).
4140 * If the probability value `p` is greater than `1`, then there is a
4141   `(p / 256 * 100)` percent chance that node will appear when the schematic is
4142   placed on the map.
4143
4144 Schematic attributes
4145 --------------------
4146
4147 See section [Flag Specifier Format].
4148
4149 Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
4150                            `force_placement`.
4151
4152 * `place_center_x`: Placement of this decoration is centered along the X axis.
4153 * `place_center_y`: Placement of this decoration is centered along the Y axis.
4154 * `place_center_z`: Placement of this decoration is centered along the Z axis.
4155 * `force_placement`: Schematic nodes other than "ignore" will replace existing
4156   nodes.
4157
4158
4159
4160
4161 Lua Voxel Manipulator
4162 =====================
4163
4164 About VoxelManip
4165 ----------------
4166
4167 VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
4168 facility. The purpose of this object is for fast, low-level, bulk access to
4169 reading and writing Map content. As such, setting map nodes through VoxelManip
4170 will lack many of the higher level features and concepts you may be used to
4171 with other methods of setting nodes. For example, nodes will not have their
4172 construction and destruction callbacks run, and no rollback information is
4173 logged.
4174
4175 It is important to note that VoxelManip is designed for speed, and *not* ease
4176 of use or flexibility. If your mod requires a map manipulation facility that
4177 will handle 100% of all edge cases, or the use of high level node placement
4178 features, perhaps `minetest.set_node()` is better suited for the job.
4179
4180 In addition, VoxelManip might not be faster, or could even be slower, for your
4181 specific use case. VoxelManip is most effective when setting large areas of map
4182 at once - for example, if only setting a 3x3x3 node area, a
4183 `minetest.set_node()` loop may be more optimal. Always profile code using both
4184 methods of map manipulation to determine which is most appropriate for your
4185 usage.
4186
4187 A recent simple test of setting cubic areas showed that `minetest.set_node()`
4188 is faster than a VoxelManip for a 3x3x3 node cube or smaller.
4189
4190 Using VoxelManip
4191 ----------------
4192
4193 A VoxelManip object can be created any time using either:
4194 `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
4195
4196 If the optional position parameters are present for either of these routines,
4197 the specified region will be pre-loaded into the VoxelManip object on creation.
4198 Otherwise, the area of map you wish to manipulate must first be loaded into the
4199 VoxelManip object using `VoxelManip:read_from_map()`.
4200
4201 Note that `VoxelManip:read_from_map()` returns two position vectors. The region
4202 formed by these positions indicate the minimum and maximum (respectively)
4203 positions of the area actually loaded in the VoxelManip, which may be larger
4204 than the area requested. For convenience, the loaded area coordinates can also
4205 be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
4206
4207 Now that the VoxelManip object is populated with map data, your mod can fetch a
4208 copy of this data using either of two methods. `VoxelManip:get_node_at()`,
4209 which retrieves an individual node in a MapNode formatted table at the position
4210 requested is the simplest method to use, but also the slowest.
4211
4212 Nodes in a VoxelManip object may also be read in bulk to a flat array table
4213 using:
4214
4215 * `VoxelManip:get_data()` for node content (in Content ID form, see section
4216   [Content IDs]),
4217 * `VoxelManip:get_light_data()` for node light levels, and
4218 * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
4219
4220 See section [Flat array format] for more details.
4221
4222 It is very important to understand that the tables returned by any of the above
4223 three functions represent a snapshot of the VoxelManip's internal state at the
4224 time of the call. This copy of the data will not magically update itself if
4225 another function modifies the internal VoxelManip state.
4226 Any functions that modify a VoxelManip's contents work on the VoxelManip's
4227 internal state unless otherwise explicitly stated.
4228
4229 Once the bulk data has been edited to your liking, the internal VoxelManip
4230 state can be set using:
4231
4232 * `VoxelManip:set_data()` for node content (in Content ID form, see section
4233   [Content IDs]),
4234 * `VoxelManip:set_light_data()` for node light levels, and
4235 * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
4236
4237 The parameter to each of the above three functions can use any table at all in
4238 the same flat array format as produced by `get_data()` etc. and is not required
4239 to be a table retrieved from `get_data()`.
4240
4241 Once the internal VoxelManip state has been modified to your liking, the
4242 changes can be committed back to the map by calling `VoxelManip:write_to_map()`
4243
4244 ### Flat array format
4245
4246 Let
4247     `Nx = p2.X - p1.X + 1`,
4248     `Ny = p2.Y - p1.Y + 1`, and
4249     `Nz = p2.Z - p1.Z + 1`.
4250
4251 Then, for a loaded region of p1..p2, this array ranges from `1` up to and
4252 including the value of the expression `Nx * Ny * Nz`.
4253
4254 Positions offset from p1 are present in the array with the format of:
4255
4256     [
4257         (0, 0, 0),   (1, 0, 0),   (2, 0, 0),   ... (Nx, 0, 0),
4258         (0, 1, 0),   (1, 1, 0),   (2, 1, 0),   ... (Nx, 1, 0),
4259         ...
4260         (0, Ny, 0),  (1, Ny, 0),  (2, Ny, 0),  ... (Nx, Ny, 0),
4261         (0, 0, 1),   (1, 0, 1),   (2, 0, 1),   ... (Nx, 0, 1),
4262         ...
4263         (0, Ny, 2),  (1, Ny, 2),  (2, Ny, 2),  ... (Nx, Ny, 2),
4264         ...
4265         (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
4266     ]
4267
4268 and the array index for a position p contained completely in p1..p2 is:
4269
4270 `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
4271
4272 Note that this is the same "flat 3D array" format as
4273 `PerlinNoiseMap:get3dMap_flat()`.
4274 VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
4275 of the index for a single point in a flat VoxelManip array.
4276
4277 ### Content IDs
4278
4279 A Content ID is a unique integer identifier for a specific node type.
4280 These IDs are used by VoxelManip in place of the node name string for
4281 `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
4282 `minetest.get_content_id()` to look up the Content ID for the specified node
4283 name, and `minetest.get_name_from_content_id()` to look up the node name string
4284 for a given Content ID.
4285 After registration of a node, its Content ID will remain the same throughout
4286 execution of the mod.
4287 Note that the node being queried needs to have already been been registered.
4288
4289 The following builtin node types have their Content IDs defined as constants:
4290
4291 * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
4292 * `minetest.CONTENT_AIR`:     ID for "air" nodes
4293 * `minetest.CONTENT_IGNORE`:  ID for "ignore" nodes
4294
4295 ### Mapgen VoxelManip objects
4296
4297 Inside of `on_generated()` callbacks, it is possible to retrieve the same
4298 VoxelManip object used by the core's Map Generator (commonly abbreviated
4299 Mapgen). Most of the rules previously described still apply but with a few
4300 differences:
4301
4302 * The Mapgen VoxelManip object is retrieved using:
4303   `minetest.get_mapgen_object("voxelmanip")`
4304 * This VoxelManip object already has the region of map just generated loaded
4305   into it; it's not necessary to call `VoxelManip:read_from_map()`.
4306   Note that the region of map it has loaded is NOT THE SAME as the `minp`, `maxp`
4307   parameters of `on_generated()`. Refer to `minetest.get_mapgen_object` docs.
4308 * The `on_generated()` callbacks of some mods may place individual nodes in the
4309   generated area using non-VoxelManip map modification methods. Because the
4310   same Mapgen VoxelManip object is passed through each `on_generated()`
4311   callback, it becomes necessary for the Mapgen VoxelManip object to maintain
4312   consistency with the current map state. For this reason, calling any of
4313   `minetest.add_node()`, `minetest.set_node()` or `minetest.swap_node()`
4314   will also update the Mapgen VoxelManip object's internal state active on the
4315   current thread.
4316 * After modifying the Mapgen VoxelManip object's internal buffer, it may be
4317   necessary to update lighting information using either:
4318   `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
4319
4320 ### Other API functions operating on a VoxelManip
4321
4322 If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
4323 `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
4324 flowing. It is recommended to call this function only after having written all
4325 buffered data back to the VoxelManip object, save for special situations where
4326 the modder desires to only have certain liquid nodes begin flowing.
4327
4328 The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
4329 will generate all registered decorations and ores throughout the full area
4330 inside of the specified VoxelManip object.
4331
4332 `minetest.place_schematic_on_vmanip()` is otherwise identical to
4333 `minetest.place_schematic()`, except instead of placing the specified schematic
4334 directly on the map at the specified position, it will place the schematic
4335 inside the VoxelManip.
4336
4337 ### Notes
4338
4339 * Attempting to read data from a VoxelManip object before map is read will
4340   result in a zero-length array table for `VoxelManip:get_data()`, and an
4341   "ignore" node at any position for `VoxelManip:get_node_at()`.
4342 * If either a region of map has not yet been generated or is out-of-bounds of
4343   the map, that region is filled with "ignore" nodes.
4344 * Other mods, or the core itself, could possibly modify the area of map
4345   currently loaded into a VoxelManip object. With the exception of Mapgen
4346   VoxelManips (see above section), the internal buffers are not updated. For
4347   this reason, it is strongly encouraged to complete the usage of a particular
4348   VoxelManip object in the same callback it had been created.
4349 * If a VoxelManip object will be used often, such as in an `on_generated()`
4350   callback, consider passing a file-scoped table as the optional parameter to
4351   `VoxelManip:get_data()`, which serves as a static buffer the function can use
4352   to write map data to instead of returning a new table each call. This greatly
4353   enhances performance by avoiding unnecessary memory allocations.
4354
4355 Methods
4356 -------
4357
4358 * `read_from_map(p1, p2)`:  Loads a chunk of map into the VoxelManip object
4359   containing the region formed by `p1` and `p2`.
4360     * returns actual emerged `pmin`, actual emerged `pmax`
4361 * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
4362   the map.
4363     * **important**: data must be set using `VoxelManip:set_data()` before
4364       calling this.
4365     * if `light` is true, then lighting is automatically recalculated.
4366       The default value is true.
4367       If `light` is false, no light calculations happen, and you should correct
4368       all modified blocks with `minetest.fix_light()` as soon as possible.
4369       Keep in mind that modifying the map where light is incorrect can cause
4370       more lighting bugs.
4371 * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
4372   the `VoxelManip` at that position
4373 * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
4374   that position.
4375 * `get_data([buffer])`: Retrieves the node content data loaded into the
4376   `VoxelManip` object.
4377     * returns raw node data in the form of an array of node content IDs
4378     * if the param `buffer` is present, this table will be used to store the
4379       result instead.
4380 * `set_data(data)`: Sets the data contents of the `VoxelManip` object
4381 * `update_map()`: Does nothing, kept for compatibility.
4382 * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
4383   a uniform value.
4384     * `light` is a table, `{day=<0...15>, night=<0...15>}`
4385     * To be used only by a `VoxelManip` object from
4386       `minetest.get_mapgen_object`.
4387     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4388       area if left out.
4389 * `get_light_data([buffer])`: Gets the light data read into the
4390   `VoxelManip` object
4391     * Returns an array (indices 1 to volume) of integers ranging from `0` to
4392       `255`.
4393     * Each value is the bitwise combination of day and night light values
4394       (`0` to `15` each).
4395     * `light = day + (night * 16)`
4396     * If the param `buffer` is present, this table will be used to store the
4397       result instead.
4398 * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
4399   in the `VoxelManip`.
4400     * expects lighting data in the same format that `get_light_data()` returns
4401 * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
4402   `VoxelManip` object.
4403     * Returns an array (indices 1 to volume) of integers ranging from `0` to
4404       `255`.
4405     * If the param `buffer` is present, this table will be used to store the
4406       result instead.
4407 * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
4408   the `VoxelManip`.
4409 * `calc_lighting([p1, p2], [propagate_shadow])`:  Calculate lighting within the
4410   `VoxelManip`.
4411     * To be used only by a `VoxelManip` object from
4412       `minetest.get_mapgen_object`.
4413     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4414       area if left out or nil. For almost all uses these should be left out
4415       or nil to use the default.
4416     * `propagate_shadow` is an optional boolean deciding whether shadows in a
4417       generated mapchunk above are propagated down into the mapchunk, defaults
4418       to `true` if left out.
4419 * `update_liquids()`: Update liquid flow
4420 * `was_modified()`: Returns `true` or `false` if the data in the voxel
4421   manipulator had been modified since the last read from map, due to a call to
4422   `minetest.set_data()` on the loaded area elsewhere.
4423 * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
4424
4425 `VoxelArea`
4426 -----------
4427
4428 A helper class for voxel areas.
4429 It can be created via `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
4430 The coordinates are *inclusive*, like most other things in Minetest.
4431
4432 ### Methods
4433
4434 * `getExtent()`: returns a 3D vector containing the size of the area formed by
4435   `MinEdge` and `MaxEdge`.
4436 * `getVolume()`: returns the volume of the area formed by `MinEdge` and
4437   `MaxEdge`.
4438 * `index(x, y, z)`: returns the index of an absolute position in a flat array
4439   starting at `1`.
4440     * `x`, `y` and `z` must be integers to avoid an incorrect index result.
4441     * The position (x, y, z) is not checked for being inside the area volume,
4442       being outside can cause an incorrect index result.
4443     * Useful for things like `VoxelManip`, raw Schematic specifiers,
4444       `PerlinNoiseMap:get2d`/`3dMap`, and so on.
4445 * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
4446     * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
4447       is not checked for being inside the area volume.
4448 * `position(i)`: returns the absolute position vector corresponding to index
4449   `i`.
4450 * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
4451   `MinEdge` and `MaxEdge`.
4452 * `containsp(p)`: same as above, except takes a vector
4453 * `containsi(i)`: same as above, except takes an index `i`
4454 * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
4455   indices.
4456     * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
4457       `[z [y [x]]]`.
4458 * `iterp(minp, maxp)`: same as above, except takes a vector
4459
4460 ### Y stride and z stride of a flat array
4461
4462 For a particular position in a voxel area, whose flat array index is known,
4463 it is often useful to know the index of a neighboring or nearby position.
4464 The table below shows the changes of index required for 1 node movements along
4465 the axes in a voxel area:
4466
4467     Movement    Change of index
4468     +x          +1
4469     -x          -1
4470     +y          +ystride
4471     -y          -ystride
4472     +z          +zstride
4473     -z          -zstride
4474
4475 If, for example:
4476
4477     local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
4478
4479 The values of `ystride` and `zstride` can be obtained using `area.ystride` and
4480 `area.zstride`.
4481
4482
4483
4484
4485 Mapgen objects
4486 ==============
4487
4488 A mapgen object is a construct used in map generation. Mapgen objects can be
4489 used by an `on_generate` callback to speed up operations by avoiding
4490 unnecessary recalculations, these can be retrieved using the
4491 `minetest.get_mapgen_object()` function. If the requested Mapgen object is
4492 unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
4493 callback, `nil` is returned.
4494
4495 The following Mapgen objects are currently available:
4496
4497 ### `voxelmanip`
4498
4499 This returns three values; the `VoxelManip` object to be used, minimum and
4500 maximum emerged position, in that order. All mapgens support this object.
4501
4502 ### `heightmap`
4503
4504 Returns an array containing the y coordinates of the ground levels of nodes in
4505 the most recently generated chunk by the current mapgen.
4506
4507 ### `biomemap`
4508
4509 Returns an array containing the biome IDs of nodes in the most recently
4510 generated chunk by the current mapgen.
4511
4512 ### `heatmap`
4513
4514 Returns an array containing the temperature values of nodes in the most
4515 recently generated chunk by the current mapgen.
4516
4517 ### `humiditymap`
4518
4519 Returns an array containing the humidity values of nodes in the most recently
4520 generated chunk by the current mapgen.
4521
4522 ### `gennotify`
4523
4524 Returns a table mapping requested generation notification types to arrays of
4525 positions at which the corresponding generated structures are located within
4526 the current chunk. To enable the capture of positions of interest to be recorded
4527 call `minetest.set_gen_notify()` first.
4528
4529 Possible fields of the returned table are:
4530
4531 * `dungeon`: bottom center position of dungeon rooms
4532 * `temple`: as above but for desert temples (mgv6 only)
4533 * `cave_begin`
4534 * `cave_end`
4535 * `large_cave_begin`
4536 * `large_cave_end`
4537 * `decoration#id` (see below)
4538
4539 Decorations have a key in the format of `"decoration#id"`, where `id` is the
4540 numeric unique decoration ID as returned by `minetest.get_decoration_id()`.
4541 For example, `decoration#123`.
4542
4543 The returned positions are the ground surface 'place_on' nodes,
4544 not the decorations themselves. A 'simple' type decoration is often 1
4545 node above the returned position and possibly displaced by 'place_offset_y'.
4546
4547
4548 Registered entities
4549 ===================
4550
4551 Functions receive a "luaentity" table as `self`:
4552
4553 * It has the member `name`, which is the registered name `("mod:thing")`
4554 * It has the member `object`, which is an `ObjectRef` pointing to the object
4555 * The original prototype is visible directly via a metatable
4556
4557 Callbacks:
4558
4559 * `on_activate(self, staticdata, dtime_s)`
4560     * Called when the object is instantiated.
4561     * `dtime_s` is the time passed since the object was unloaded, which can be
4562       used for updating the entity state.
4563 * `on_deactivate(self, removal)`
4564     * Called when the object is about to get removed or unloaded.
4565         * `removal`: boolean indicating whether the object is about to get removed.
4566           Calling `object:remove()` on an active object will call this with `removal=true`.
4567           The mapblock the entity resides in being unloaded will call this with `removal=false`.
4568         * Note that this won't be called if the object hasn't been activated in the first place.
4569           In particular, `minetest.clear_objects({mode = "full"})` won't call this,
4570           whereas `minetest.clear_objects({mode = "quick"})` might call this.
4571 * `on_step(self, dtime, moveresult)`
4572     * Called on every server tick, after movement and collision processing.
4573     * `dtime`: elapsed time since last call
4574     * `moveresult`: table with collision info (only available if physical=true)
4575 * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
4576     * Called when somebody punches the object.
4577     * Note that you probably want to handle most punches using the automatic
4578       armor group system.
4579     * `puncher`: an `ObjectRef` (can be `nil`)
4580     * `time_from_last_punch`: Meant for disallowing spamming of clicks
4581       (can be `nil`).
4582     * `tool_capabilities`: capability table of used item (can be `nil`)
4583     * `dir`: unit vector of direction of punch. Always defined. Points from the
4584       puncher to the punched.
4585     * `damage`: damage that will be done to entity.
4586     * Can return `true` to prevent the default damage mechanism.
4587 * `on_death(self, killer)`
4588     * Called when the object dies.
4589     * `killer`: an `ObjectRef` (can be `nil`)
4590 * `on_rightclick(self, clicker)`
4591     * Called when `clicker` pressed the 'place/use' key while pointing
4592       to the object (not neccessarily an actual rightclick)
4593     * `clicker`: an `ObjectRef` (may or may not be a player)
4594 * `on_attach_child(self, child)`
4595     * `child`: an `ObjectRef` of the child that attaches
4596 * `on_detach_child(self, child)`
4597     * `child`: an `ObjectRef` of the child that detaches
4598 * `on_detach(self, parent)`
4599     * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
4600     * This happens before the parent object is removed from the world
4601 * `get_staticdata(self)`
4602     * Should return a string that will be passed to `on_activate` when the
4603       object is instantiated the next time.
4604
4605 Collision info passed to `on_step` (`moveresult` argument):
4606
4607     {
4608         touching_ground = boolean,
4609         -- Note that touching_ground is only true if the entity was moving and
4610         -- collided with ground.
4611
4612         collides = boolean,
4613         standing_on_object = boolean,
4614
4615         collisions = {
4616             {
4617                 type = string, -- "node" or "object",
4618                 axis = string, -- "x", "y" or "z"
4619                 node_pos = vector, -- if type is "node"
4620                 object = ObjectRef, -- if type is "object"
4621                 old_velocity = vector,
4622                 new_velocity = vector,
4623             },
4624             ...
4625         }
4626         -- `collisions` does not contain data of unloaded mapblock collisions
4627         -- or when the velocity changes are negligibly small
4628     }
4629
4630
4631
4632 L-system trees
4633 ==============
4634
4635 Tree definition
4636 ---------------
4637
4638     treedef={
4639         axiom,         --string  initial tree axiom
4640         rules_a,       --string  rules set A
4641         rules_b,       --string  rules set B
4642         rules_c,       --string  rules set C
4643         rules_d,       --string  rules set D
4644         trunk,         --string  trunk node name
4645         leaves,        --string  leaves node name
4646         leaves2,       --string  secondary leaves node name
4647         leaves2_chance,--num     chance (0-100) to replace leaves with leaves2
4648         angle,         --num     angle in deg
4649         iterations,    --num     max # of iterations, usually 2 -5
4650         random_level,  --num     factor to lower nr of iterations, usually 0 - 3
4651         trunk_type,    --string  single/double/crossed) type of trunk: 1 node,
4652                        --        2x2 nodes or 3x3 in cross shape
4653         thin_branches, --boolean true -> use thin (1 node) branches
4654         fruit,         --string  fruit node name
4655         fruit_chance,  --num     chance (0-100) to replace leaves with fruit node
4656         seed,          --num     random seed, if no seed is provided, the engine
4657                                  will create one.
4658     }
4659
4660 Key for special L-System symbols used in axioms
4661 -----------------------------------------------
4662
4663 * `G`: move forward one unit with the pen up
4664 * `F`: move forward one unit with the pen down drawing trunks and branches
4665 * `f`: move forward one unit with the pen down drawing leaves (100% chance)
4666 * `T`: move forward one unit with the pen down drawing trunks only
4667 * `R`: move forward one unit with the pen down placing fruit
4668 * `A`: replace with rules set A
4669 * `B`: replace with rules set B
4670 * `C`: replace with rules set C
4671 * `D`: replace with rules set D
4672 * `a`: replace with rules set A, chance 90%
4673 * `b`: replace with rules set B, chance 80%
4674 * `c`: replace with rules set C, chance 70%
4675 * `d`: replace with rules set D, chance 60%
4676 * `+`: yaw the turtle right by `angle` parameter
4677 * `-`: yaw the turtle left by `angle` parameter
4678 * `&`: pitch the turtle down by `angle` parameter
4679 * `^`: pitch the turtle up by `angle` parameter
4680 * `/`: roll the turtle to the right by `angle` parameter
4681 * `*`: roll the turtle to the left by `angle` parameter
4682 * `[`: save in stack current state info
4683 * `]`: recover from stack state info
4684
4685 Example
4686 -------
4687
4688 Spawn a small apple tree:
4689
4690     pos = {x=230,y=20,z=4}
4691     apple_tree={
4692         axiom="FFFFFAFFBF",
4693         rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
4694         rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
4695         trunk="default:tree",
4696         leaves="default:leaves",
4697         angle=30,
4698         iterations=2,
4699         random_level=0,
4700         trunk_type="single",
4701         thin_branches=true,
4702         fruit_chance=10,
4703         fruit="default:apple"
4704     }
4705     minetest.spawn_tree(pos,apple_tree)
4706
4707
4708 Privileges
4709 ==========
4710
4711 Privileges provide a means for server administrators to give certain players
4712 access to special abilities in the engine, games or mods.
4713 For example, game moderators may need to travel instantly to any place in the world,
4714 this ability is implemented in `/teleport` command which requires `teleport` privilege.
4715
4716 Registering privileges
4717 ----------------------
4718
4719 A mod can register a custom privilege using `minetest.register_privilege` function
4720 to give server administrators fine-grained access control over mod functionality.
4721
4722 For consistency and practical reasons, privileges should strictly increase the abilities of the user.
4723 Do not register custom privileges that e.g. restrict the player from certain in-game actions.
4724
4725 Checking privileges
4726 -------------------
4727
4728 A mod can call `minetest.check_player_privs` to test whether a player has privileges
4729 to perform an operation.
4730 Also, when registering a chat command with `minetest.register_chatcommand` a mod can
4731 declare privileges that the command requires using the `privs` field of the command
4732 definition.
4733
4734 Managing player privileges
4735 --------------------------
4736
4737 A mod can update player privileges using `minetest.set_player_privs` function.
4738 Players holding the `privs` privilege can see and manage privileges for all
4739 players on the server.
4740
4741 A mod can subscribe to changes in player privileges using `minetest.register_on_priv_grant`
4742 and `minetest.register_on_priv_revoke` functions.
4743
4744 Built-in privileges
4745 -------------------
4746
4747 Minetest includes a set of built-in privileges that control capabilities
4748 provided by the Minetest engine and can be used by mods:
4749
4750   * Basic privileges are normally granted to all players:
4751       * `shout`: can communicate using the in-game chat.
4752       * `interact`: can modify the world by digging, building and interacting
4753         with the nodes, entities and other players. Players without the `interact`
4754         privilege can only travel and observe the world.
4755
4756   * Advanced privileges allow bypassing certain aspects of the gameplay:
4757       * `fast`: can use "fast mode" to move with maximum speed.
4758       * `fly`: can use "fly mode" to move freely above the ground without falling.
4759       * `noclip`: can use "noclip mode" to fly through solid nodes (e.g. walls).
4760       * `teleport`: can use `/teleport` command to move to any point in the world.
4761       * `creative`: can access creative inventory.
4762       * `bring`: can teleport other players to oneself.
4763       * `give`: can use `/give` and `/giveme` commands to give any item
4764         in the game to oneself or others.
4765       * `settime`: can use `/time` command to change current in-game time.
4766       * `debug`: can enable wireframe rendering mode.
4767
4768   * Security-related privileges:
4769       * `privs`: can modify privileges of the players using `/grant[me]` and
4770         `/revoke[me]` commands.
4771       * `basic_privs`: can grant and revoke basic privileges as defined by
4772         the `basic_privs` setting.
4773       * `kick`: can kick other players from the server using `/kick` command.
4774       * `ban`: can ban other players using `/ban` command.
4775       * `password`: can use `/setpassword` and `/clearpassword` commands
4776         to manage players' passwords.
4777       * `protection_bypass`: can bypass node protection. Note that the engine does not act upon this privilege,
4778         it is only an implementation suggestion for games.
4779
4780   * Administrative privileges:
4781       * `server`: can use `/fixlight`, `/deleteblocks` and `/deleteobjects`
4782         commands. Can clear inventory of other players using `/clearinv` command.
4783       * `rollback`: can use `/rollback_check` and `/rollback` commands.
4784
4785 Related settings
4786 ----------------
4787
4788 Minetest includes the following settings to control behavior of privileges:
4789
4790    * `default_privs`: defines privileges granted to new players.
4791    * `basic_privs`: defines privileges that can be granted/revoked by players having
4792     the `basic_privs` privilege. This can be used, for example, to give
4793     limited moderation powers to selected users.
4794
4795 'minetest' namespace reference
4796 ==============================
4797
4798 Utilities
4799 ---------
4800
4801 * `minetest.get_current_modname()`: returns the currently loading mod's name,
4802   when loading a mod.
4803 * `minetest.get_modpath(modname)`: returns the directory path for a mod,
4804   e.g. `"/home/user/.minetest/usermods/modname"`.
4805     * Returns nil if the mod is not enabled or does not exist (not installed).
4806     * Works regardless of whether the mod has been loaded yet.
4807     * Useful for loading additional `.lua` modules or static data from a mod,
4808   or checking if a mod is enabled.
4809 * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
4810     * Does not include disabled mods, even if they are installed.
4811 * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
4812     * Useful for storing custom data
4813 * `minetest.is_singleplayer()`
4814 * `minetest.features`: Table containing API feature flags
4815
4816       {
4817           glasslike_framed = true,  -- 0.4.7
4818           nodebox_as_selectionbox = true,  -- 0.4.7
4819           get_all_craft_recipes_works = true,  -- 0.4.7
4820           -- The transparency channel of textures can optionally be used on
4821           -- nodes (0.4.7)
4822           use_texture_alpha = true,
4823           -- Tree and grass ABMs are no longer done from C++ (0.4.8)
4824           no_legacy_abms = true,
4825           -- Texture grouping is possible using parentheses (0.4.11)
4826           texture_names_parens = true,
4827           -- Unique Area ID for AreaStore:insert_area (0.4.14)
4828           area_store_custom_ids = true,
4829           -- add_entity supports passing initial staticdata to on_activate
4830           -- (0.4.16)
4831           add_entity_with_staticdata = true,
4832           -- Chat messages are no longer predicted (0.4.16)
4833           no_chat_message_prediction = true,
4834           -- The transparency channel of textures can optionally be used on
4835           -- objects (ie: players and lua entities) (5.0.0)
4836           object_use_texture_alpha = true,
4837           -- Object selectionbox is settable independently from collisionbox
4838           -- (5.0.0)
4839           object_independent_selectionbox = true,
4840           -- Specifies whether binary data can be uploaded or downloaded using
4841           -- the HTTP API (5.1.0)
4842           httpfetch_binary_data = true,
4843           -- Whether formspec_version[<version>] may be used (5.1.0)
4844           formspec_version_element = true,
4845           -- Whether AreaStore's IDs are kept on save/load (5.1.0)
4846           area_store_persistent_ids = true,
4847           -- Whether minetest.find_path is functional (5.2.0)
4848           pathfinder_works = true,
4849           -- Whether Collision info is available to an objects' on_step (5.3.0)
4850           object_step_has_moveresult = true,
4851           -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
4852           direct_velocity_on_players = true,
4853           -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
4854           use_texture_alpha_string_modes = true,
4855           -- degrotate param2 rotates in units of 1.5° instead of 2°
4856           -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
4857           degrotate_240_steps = true,
4858           -- ABM supports min_y and max_y fields in definition (5.5.0)
4859           abm_min_max_y = true,
4860           -- dynamic_add_media supports passing a table with options (5.5.0)
4861           dynamic_add_media_table = true,
4862           -- particlespawners support texpools and animation of properties,
4863           -- particle textures support smooth fade and scale animations, and
4864           -- sprite-sheet particle animations can by synced to the lifetime
4865           -- of individual particles (5.6.0)
4866           particlespawner_tweenable = true,
4867           -- allows get_sky to return a table instead of separate values (5.6.0)
4868           get_sky_as_table = true,
4869           -- VoxelManip:get_light_data accepts an optional buffer argument (5.7.0)
4870           get_light_data_buffer = true,
4871       }
4872
4873 * `minetest.has_feature(arg)`: returns `boolean, missing_features`
4874     * `arg`: string or table in format `{foo=true, bar=true}`
4875     * `missing_features`: `{foo=true, bar=true}`
4876 * `minetest.get_player_information(player_name)`: Table containing information
4877   about a player. Example return value:
4878
4879       {
4880           address = "127.0.0.1",     -- IP address of client
4881           ip_version = 4,            -- IPv4 / IPv6
4882           connection_uptime = 200,   -- seconds since client connected
4883           protocol_version = 32,     -- protocol version used by client
4884           formspec_version = 2,      -- supported formspec version
4885           lang_code = "fr"           -- Language code used for translation
4886           -- the following keys can be missing if no stats have been collected yet
4887           min_rtt = 0.01,            -- minimum round trip time
4888           max_rtt = 0.2,             -- maximum round trip time
4889           avg_rtt = 0.02,            -- average round trip time
4890           min_jitter = 0.01,         -- minimum packet time jitter
4891           max_jitter = 0.5,          -- maximum packet time jitter
4892           avg_jitter = 0.03,         -- average packet time jitter
4893           -- the following information is available in a debug build only!!!
4894           -- DO NOT USE IN MODS
4895           --ser_vers = 26,             -- serialization version used by client
4896           --major = 0,                 -- major version number
4897           --minor = 4,                 -- minor version number
4898           --patch = 10,                -- patch version number
4899           --vers_string = "0.4.9-git", -- full version string
4900           --state = "Active"           -- current client state
4901       }
4902
4903 * `minetest.mkdir(path)`: returns success.
4904     * Creates a directory specified by `path`, creating parent directories
4905       if they don't exist.
4906 * `minetest.rmdir(path, recursive)`: returns success.
4907     * Removes a directory specified by `path`.
4908     * If `recursive` is set to `true`, the directory is recursively removed.
4909       Otherwise, the directory will only be removed if it is empty.
4910     * Returns true on success, false on failure.
4911 * `minetest.cpdir(source, destination)`: returns success.
4912     * Copies a directory specified by `path` to `destination`
4913     * Any files in `destination` will be overwritten if they already exist.
4914     * Returns true on success, false on failure.
4915 * `minetest.mvdir(source, destination)`: returns success.
4916     * Moves a directory specified by `path` to `destination`.
4917     * If the `destination` is a non-empty directory, then the move will fail.
4918     * Returns true on success, false on failure.
4919 * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
4920     * is_dir is one of:
4921         * nil: return all entries,
4922         * true: return only subdirectory names, or
4923         * false: return only file names.
4924 * `minetest.safe_file_write(path, content)`: returns boolean indicating success
4925     * Replaces contents of file at path with new contents in a safe (atomic)
4926       way. Use this instead of below code when writing e.g. database files:
4927       `local f = io.open(path, "wb"); f:write(content); f:close()`
4928 * `minetest.get_version()`: returns a table containing components of the
4929    engine version.  Components:
4930     * `project`: Name of the project, eg, "Minetest"
4931     * `string`: Simple version, eg, "1.2.3-dev"
4932     * `hash`: Full git version (only set if available),
4933       eg, "1.2.3-dev-01234567-dirty".
4934     * `is_dev`: Boolean value indicating whether it's a development build
4935   Use this for informational purposes only. The information in the returned
4936   table does not represent the capabilities of the engine, nor is it
4937   reliable or verifiable. Compatible forks will have a different name and
4938   version entirely. To check for the presence of engine features, test
4939   whether the functions exported by the wanted features exist. For example:
4940   `if minetest.check_for_falling then ... end`.
4941 * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
4942     * `data`: string of data to hash
4943     * `raw`: return raw bytes instead of hex digits, default: false
4944 * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
4945   ColorString. If the ColorSpec is invalid, returns `nil`.
4946     * `colorspec`: The ColorSpec to convert
4947 * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
4948   string of four bytes in an RGBA layout, returned as a string.
4949   * `colorspec`: The ColorSpec to convert
4950 * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
4951   image and return it in string form.
4952     * `width`: Width of the image
4953     * `height`: Height of the image
4954     * `data`: Image data, one of:
4955         * array table of ColorSpec, length must be width*height
4956         * string with raw RGBA pixels, length must be width*height*4
4957     * `compression`: Optional zlib compression level, number in range 0 to 9.
4958   The data is one-dimensional, starting in the upper left corner of the image
4959   and laid out in scanlines going from left to right, then top to bottom.
4960   Please note that it's not safe to use string.char to generate raw data,
4961   use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
4962   The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
4963   You may use this to procedurally generate textures during server init.
4964
4965 Logging
4966 -------
4967
4968 * `minetest.debug(...)`
4969     * Equivalent to `minetest.log(table.concat({...}, "\t"))`
4970 * `minetest.log([level,] text)`
4971     * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
4972       `"info"`, or `"verbose"`.  Default is `"none"`.
4973
4974 Registration functions
4975 ----------------------
4976
4977 Call these functions only at load time!
4978
4979 ### Environment
4980
4981 * `minetest.register_node(name, node definition)`
4982 * `minetest.register_craftitem(name, item definition)`
4983 * `minetest.register_tool(name, item definition)`
4984 * `minetest.override_item(name, redefinition)`
4985     * Overrides fields of an item registered with register_node/tool/craftitem.
4986     * Note: Item must already be defined, (opt)depend on the mod defining it.
4987     * Example: `minetest.override_item("default:mese",
4988       {light_source=minetest.LIGHT_MAX})`
4989 * `minetest.unregister_item(name)`
4990     * Unregisters the item from the engine, and deletes the entry with key
4991       `name` from `minetest.registered_items` and from the associated item table
4992       according to its nature: `minetest.registered_nodes`, etc.
4993 * `minetest.register_entity(name, entity definition)`
4994 * `minetest.register_abm(abm definition)`
4995 * `minetest.register_lbm(lbm definition)`
4996 * `minetest.register_alias(alias, original_name)`
4997     * Also use this to set the 'mapgen aliases' needed in a game for the core
4998       mapgens. See [Mapgen aliases] section above.
4999 * `minetest.register_alias_force(alias, original_name)`
5000 * `minetest.register_ore(ore definition)`
5001     * Returns an integer object handle uniquely identifying the registered
5002       ore on success.
5003     * The order of ore registrations determines the order of ore generation.
5004 * `minetest.register_biome(biome definition)`
5005     * Returns an integer object handle uniquely identifying the registered
5006       biome on success. To get the biome ID, use `minetest.get_biome_id`.
5007 * `minetest.unregister_biome(name)`
5008     * Unregisters the biome from the engine, and deletes the entry with key
5009       `name` from `minetest.registered_biomes`.
5010     * Warning: This alters the biome to biome ID correspondences, so any
5011       decorations or ores using the 'biomes' field must afterwards be cleared
5012       and re-registered.
5013 * `minetest.register_decoration(decoration definition)`
5014     * Returns an integer object handle uniquely identifying the registered
5015       decoration on success. To get the decoration ID, use
5016       `minetest.get_decoration_id`.
5017     * The order of decoration registrations determines the order of decoration
5018       generation.
5019 * `minetest.register_schematic(schematic definition)`
5020     * Returns an integer object handle uniquely identifying the registered
5021       schematic on success.
5022     * If the schematic is loaded from a file, the `name` field is set to the
5023       filename.
5024     * If the function is called when loading the mod, and `name` is a relative
5025       path, then the current mod path will be prepended to the schematic
5026       filename.
5027 * `minetest.clear_registered_biomes()`
5028     * Clears all biomes currently registered.
5029     * Warning: Clearing and re-registering biomes alters the biome to biome ID
5030       correspondences, so any decorations or ores using the 'biomes' field must
5031       afterwards be cleared and re-registered.
5032 * `minetest.clear_registered_decorations()`
5033     * Clears all decorations currently registered.
5034 * `minetest.clear_registered_ores()`
5035     * Clears all ores currently registered.
5036 * `minetest.clear_registered_schematics()`
5037     * Clears all schematics currently registered.
5038
5039 ### Gameplay
5040
5041 * `minetest.register_craft(recipe)`
5042     * Check recipe table syntax for different types below.
5043 * `minetest.clear_craft(recipe)`
5044     * Will erase existing craft based either on output item or on input recipe.
5045     * Specify either output or input only. If you specify both, input will be
5046       ignored. For input use the same recipe table syntax as for
5047       `minetest.register_craft(recipe)`. For output specify only the item,
5048       without a quantity.
5049     * Returns false if no erase candidate could be found, otherwise returns true.
5050     * **Warning**! The type field ("shaped", "cooking" or any other) will be
5051       ignored if the recipe contains output. Erasing is then done independently
5052       from the crafting method.
5053 * `minetest.register_chatcommand(cmd, chatcommand definition)`
5054 * `minetest.override_chatcommand(name, redefinition)`
5055     * Overrides fields of a chatcommand registered with `register_chatcommand`.
5056 * `minetest.unregister_chatcommand(name)`
5057     * Unregisters a chatcommands registered with `register_chatcommand`.
5058 * `minetest.register_privilege(name, definition)`
5059     * `definition` can be a description or a definition table (see [Privilege
5060       definition]).
5061     * If it is a description, the priv will be granted to singleplayer and admin
5062       by default.
5063     * To allow players with `basic_privs` to grant, see the `basic_privs`
5064       minetest.conf setting.
5065 * `minetest.register_authentication_handler(authentication handler definition)`
5066     * Registers an auth handler that overrides the builtin one.
5067     * This function can be called by a single mod once only.
5068
5069 Global callback registration functions
5070 --------------------------------------
5071
5072 Call these functions only at load time!
5073
5074 * `minetest.register_globalstep(function(dtime))`
5075     * Called every server step, usually interval of 0.1s
5076 * `minetest.register_on_mods_loaded(function())`
5077     * Called after mods have finished loading and before the media is cached or the
5078       aliases handled.
5079 * `minetest.register_on_shutdown(function())`
5080     * Called before server shutdown
5081     * **Warning**: If the server terminates abnormally (i.e. crashes), the
5082       registered callbacks **will likely not be run**. Data should be saved at
5083       semi-frequent intervals as well as on server shutdown.
5084 * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
5085     * Called when a node has been placed
5086     * If return `true` no item is taken from `itemstack`
5087     * `placer` may be any valid ObjectRef or nil.
5088     * **Not recommended**; use `on_construct` or `after_place_node` in node
5089       definition whenever possible.
5090 * `minetest.register_on_dignode(function(pos, oldnode, digger))`
5091     * Called when a node has been dug.
5092     * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
5093       definition whenever possible.
5094 * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
5095     * Called when a node is punched
5096 * `minetest.register_on_generated(function(minp, maxp, blockseed))`
5097     * Called after generating a piece of world. Modifying nodes inside the area
5098       is a bit faster than usual.
5099 * `minetest.register_on_newplayer(function(ObjectRef))`
5100     * Called when a new player enters the world for the first time
5101 * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
5102     * Called when a player is punched
5103     * Note: This callback is invoked even if the punched player is dead.
5104     * `player`: ObjectRef - Player that was punched
5105     * `hitter`: ObjectRef - Player that hit
5106     * `time_from_last_punch`: Meant for disallowing spamming of clicks
5107       (can be nil).
5108     * `tool_capabilities`: Capability table of used item (can be nil)
5109     * `dir`: Unit vector of direction of punch. Always defined. Points from
5110       the puncher to the punched.
5111     * `damage`: Number that represents the damage calculated by the engine
5112     * should return `true` to prevent the default damage mechanism
5113 * `minetest.register_on_rightclickplayer(function(player, clicker))`
5114     * Called when the 'place/use' key was used while pointing a player
5115       (not neccessarily an actual rightclick)
5116     * `player`: ObjectRef - Player that is acted upon
5117     * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
5118 * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
5119     * Called when the player gets damaged or healed
5120     * `player`: ObjectRef of the player
5121     * `hp_change`: the amount of change. Negative when it is damage.
5122     * `reason`: a PlayerHPChangeReason table.
5123         * The `type` field will have one of the following values:
5124             * `set_hp`: A mod or the engine called `set_hp` without
5125                         giving a type - use this for custom damage types.
5126             * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
5127             * `fall`
5128             * `node_damage`: `damage_per_second` from a neighbouring node.
5129                              `reason.node` will hold the node name or nil.
5130             * `drown`
5131             * `respawn`
5132         * Any of the above types may have additional fields from mods.
5133         * `reason.from` will be `mod` or `engine`.
5134     * `modifier`: when true, the function should return the actual `hp_change`.
5135        Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
5136        Modifiers can return true as a second argument to stop the execution of further functions.
5137        Non-modifiers receive the final HP change calculated by the modifiers.
5138 * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
5139     * Called when a player dies
5140     * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
5141 * `minetest.register_on_respawnplayer(function(ObjectRef))`
5142     * Called when player is to be respawned
5143     * Called _before_ repositioning of player occurs
5144     * return true in func to disable regular player placement
5145 * `minetest.register_on_prejoinplayer(function(name, ip))`
5146     * Called when a client connects to the server, prior to authentication
5147     * If it returns a string, the client is disconnected with that string as
5148       reason.
5149 * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
5150     * Called when a player joins the game
5151     * `last_login`: The timestamp of the previous login, or nil if player is new
5152 * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
5153     * Called when a player leaves the game
5154     * `timed_out`: True for timeout, false for other reasons.
5155 * `minetest.register_on_authplayer(function(name, ip, is_success))`
5156     * Called when a client attempts to log into an account.
5157     * `name`: The name of the account being authenticated.
5158     * `ip`: The IP address of the client
5159     * `is_success`: Whether the client was successfully authenticated
5160     * For newly registered accounts, `is_success` will always be true
5161 * `minetest.register_on_auth_fail(function(name, ip))`
5162     * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
5163 * `minetest.register_on_cheat(function(ObjectRef, cheat))`
5164     * Called when a player cheats
5165     * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
5166         * `moved_too_fast`
5167         * `interacted_too_far`
5168         * `interacted_with_self`
5169         * `interacted_while_dead`
5170         * `finished_unknown_dig`
5171         * `dug_unbreakable`
5172         * `dug_too_fast`
5173 * `minetest.register_on_chat_message(function(name, message))`
5174     * Called always when a player says something
5175     * Return `true` to mark the message as handled, which means that it will
5176       not be sent to other players.
5177 * `minetest.register_on_chatcommand(function(name, command, params))`
5178     * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
5179       is checked to see if the command exists, but after the input is parsed.
5180     * Return `true` to mark the command as handled, which means that the default
5181       handlers will be prevented.
5182 * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
5183     * Called when the server received input from `player` in a formspec with
5184       the given `formname`. Specifically, this is called on any of the
5185       following events:
5186           * a button was pressed,
5187           * Enter was pressed while the focus was on a text field
5188           * a checkbox was toggled,
5189           * something was selected in a dropdown list,
5190           * a different tab was selected,
5191           * selection was changed in a textlist or table,
5192           * an entry was double-clicked in a textlist or table,
5193           * a scrollbar was moved, or
5194           * the form was actively closed by the player.
5195     * Fields are sent for formspec elements which define a field. `fields`
5196       is a table containing each formspecs element value (as string), with
5197       the `name` parameter as index for each. The value depends on the
5198       formspec element type:
5199         * `animated_image`: Returns the index of the current frame.
5200         * `button` and variants: If pressed, contains the user-facing button
5201           text as value. If not pressed, is `nil`
5202         * `field`, `textarea` and variants: Text in the field
5203         * `dropdown`: Either the index or value, depending on the `index event`
5204           dropdown argument.
5205         * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
5206         * `checkbox`: `"true"` if checked, `"false"` if unchecked
5207         * `textlist`: See `minetest.explode_textlist_event`
5208         * `table`: See `minetest.explode_table_event`
5209         * `scrollbar`: See `minetest.explode_scrollbar_event`
5210         * Special case: `["quit"]="true"` is sent when the user actively
5211           closed the form by mouse click, keypress or through a button_exit[]
5212           element.
5213         * Special case: `["key_enter"]="true"` is sent when the user pressed
5214           the Enter key and the focus was either nowhere (causing the formspec
5215           to be closed) or on a button. If the focus was on a text field,
5216           additionally, the index `key_enter_field` contains the name of the
5217           text field. See also: `field_close_on_enter`.
5218     * Newest functions are called first
5219     * If function returns `true`, remaining functions are not called
5220 * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
5221     * Called when `player` crafts something
5222     * `itemstack` is the output
5223     * `old_craft_grid` contains the recipe (Note: the one in the inventory is
5224       cleared).
5225     * `craft_inv` is the inventory with the crafting grid
5226     * Return either an `ItemStack`, to replace the output, or `nil`, to not
5227       modify it.
5228 * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
5229     * The same as before, except that it is called before the player crafts, to
5230       make craft prediction, and it should not change anything.
5231 * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
5232     * Determines how much of a stack may be taken, put or moved to a
5233       player inventory.
5234     * `player` (type `ObjectRef`) is the player who modified the inventory
5235       `inventory` (type `InvRef`).
5236     * List of possible `action` (string) values and their
5237       `inventory_info` (table) contents:
5238         * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
5239         * `put`:  `{listname=string, index=number, stack=ItemStack}`
5240         * `take`: Same as `put`
5241     * Return a numeric value to limit the amount of items to be taken, put or
5242       moved. A value of `-1` for `take` will make the source stack infinite.
5243 * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
5244     * Called after a take, put or move event from/to/in a player inventory
5245     * Function arguments: see `minetest.register_allow_player_inventory_action`
5246     * Does not accept or handle any return value.
5247 * `minetest.register_on_protection_violation(function(pos, name))`
5248     * Called by `builtin` and mods when a player violates protection at a
5249       position (eg, digs a node or punches a protected entity).
5250     * The registered functions can be called using
5251       `minetest.record_protection_violation`.
5252     * The provided function should check that the position is protected by the
5253       mod calling this function before it prints a message, if it does, to
5254       allow for multiple protection mods.
5255 * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
5256     * Called when an item is eaten, by `minetest.item_eat`
5257     * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
5258 * `minetest.register_on_priv_grant(function(name, granter, priv))`
5259     * Called when `granter` grants the priv `priv` to `name`.
5260     * Note that the callback will be called twice if it's done by a player,
5261       once with granter being the player name, and again with granter being nil.
5262 * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
5263     * Called when `revoker` revokes the priv `priv` from `name`.
5264     * Note that the callback will be called twice if it's done by a player,
5265       once with revoker being the player name, and again with revoker being nil.
5266 * `minetest.register_can_bypass_userlimit(function(name, ip))`
5267     * Called when `name` user connects with `ip`.
5268     * Return `true` to by pass the player limit
5269 * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
5270     * Called when an incoming mod channel message is received
5271     * You should have joined some channels to receive events.
5272     * If message comes from a server mod, `sender` field is an empty string.
5273 * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
5274     * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
5275       engine's liquid transformation process.
5276     * `pos_list` is an array of all modified positions.
5277     * `node_list` is an array of the old node that was previously at the position
5278       with the corresponding index in pos_list.
5279
5280 Setting-related
5281 ---------------
5282
5283 * `minetest.settings`: Settings object containing all of the settings from the
5284   main config file (`minetest.conf`).
5285 * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
5286   parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
5287
5288 Authentication
5289 --------------
5290
5291 * `minetest.string_to_privs(str[, delim])`:
5292     * Converts string representation of privs into table form
5293     * `delim`: String separating the privs. Defaults to `","`.
5294     * Returns `{ priv1 = true, ... }`
5295 * `minetest.privs_to_string(privs[, delim])`:
5296     * Returns the string representation of `privs`
5297     * `delim`: String to delimit privs. Defaults to `","`.
5298 * `minetest.get_player_privs(name) -> {priv1=true,...}`
5299 * `minetest.check_player_privs(player_or_name, ...)`:
5300   returns `bool, missing_privs`
5301     * A quickhand for checking privileges.
5302     * `player_or_name`: Either a Player object or the name of a player.
5303     * `...` is either a list of strings, e.g. `"priva", "privb"` or
5304       a table, e.g. `{ priva = true, privb = true }`.
5305
5306 * `minetest.check_password_entry(name, entry, password)`
5307     * Returns true if the "password entry" for a player with name matches given
5308       password, false otherwise.
5309     * The "password entry" is the password representation generated by the
5310       engine as returned as part of a `get_auth()` call on the auth handler.
5311     * Only use this function for making it possible to log in via password from
5312       external protocols such as IRC, other uses are frowned upon.
5313 * `minetest.get_password_hash(name, raw_password)`
5314     * Convert a name-password pair to a password hash that Minetest can use.
5315     * The returned value alone is not a good basis for password checks based
5316       on comparing the password hash in the database with the password hash
5317       from the function, with an externally provided password, as the hash
5318       in the db might use the new SRP verifier format.
5319     * For this purpose, use `minetest.check_password_entry` instead.
5320 * `minetest.get_player_ip(name)`: returns an IP address string for the player
5321   `name`.
5322     * The player needs to be online for this to be successful.
5323
5324 * `minetest.get_auth_handler()`: Return the currently active auth handler
5325     * See the [Authentication handler definition]
5326     * Use this to e.g. get the authentication data for a player:
5327       `local auth_data = minetest.get_auth_handler().get_auth(playername)`
5328 * `minetest.notify_authentication_modified(name)`
5329     * Must be called by the authentication handler for privilege changes.
5330     * `name`: string; if omitted, all auth data should be considered modified
5331 * `minetest.set_player_password(name, password_hash)`: Set password hash of
5332   player `name`.
5333 * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
5334   `name`.
5335 * `minetest.auth_reload()`
5336     * See `reload()` in authentication handler definition
5337
5338 `minetest.set_player_password`, `minetest.set_player_privs`,
5339 `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
5340 handler.
5341
5342 Chat
5343 ----
5344
5345 * `minetest.chat_send_all(text)`
5346 * `minetest.chat_send_player(name, text)`
5347 * `minetest.format_chat_message(name, message)`
5348     * Used by the server to format a chat message, based on the setting `chat_message_format`.
5349       Refer to the documentation of the setting for a list of valid placeholders.
5350     * Takes player name and message, and returns the formatted string to be sent to players.
5351     * Can be redefined by mods if required, for things like colored names or messages.
5352     * **Only** the first occurrence of each placeholder will be replaced.
5353
5354 Environment access
5355 ------------------
5356
5357 * `minetest.set_node(pos, node)`
5358 * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
5359     * Set node at position `pos`
5360     * `node`: table `{name=string, param1=number, param2=number}`
5361     * If param1 or param2 is omitted, it's set to `0`.
5362     * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
5363 * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
5364     * Set node on all positions set in the first argument.
5365     * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
5366     * For node specification or position syntax see `minetest.set_node` call
5367     * Faster than set_node due to single call, but still considerably slower
5368       than Lua Voxel Manipulators (LVM) for large numbers of nodes.
5369       Unlike LVMs, this will call node callbacks. It also allows setting nodes
5370       in spread out positions which would cause LVMs to waste memory.
5371       For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
5372       times faster.
5373 * `minetest.swap_node(pos, node)`
5374     * Set node at position, but don't remove metadata
5375 * `minetest.remove_node(pos)`
5376     * By default it does the same as `minetest.set_node(pos, {name="air"})`
5377 * `minetest.get_node(pos)`
5378     * Returns the node at the given position as table in the format
5379       `{name="node_name", param1=0, param2=0}`,
5380       returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
5381 * `minetest.get_node_or_nil(pos)`
5382     * Same as `get_node` but returns `nil` for unloaded areas.
5383 * `minetest.get_node_light(pos, timeofday)`
5384     * Gets the light value at the given position. Note that the light value
5385       "inside" the node at the given position is returned, so you usually want
5386       to get the light value of a neighbor.
5387     * `pos`: The position where to measure the light.
5388     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5389     * Returns a number between `0` and `15` or `nil`
5390     * `nil` is returned e.g. when the map isn't loaded at `pos`
5391 * `minetest.get_natural_light(pos[, timeofday])`
5392     * Figures out the sunlight (or moonlight) value at pos at the given time of
5393       day.
5394     * `pos`: The position of the node
5395     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5396     * Returns a number between `0` and `15` or `nil`
5397     * This function tests 203 nodes in the worst case, which happens very
5398       unlikely
5399 * `minetest.get_artificial_light(param1)`
5400     * Calculates the artificial light (light from e.g. torches) value from the
5401       `param1` value.
5402     * `param1`: The param1 value of a `paramtype = "light"` node.
5403     * Returns a number between `0` and `15`
5404     * Currently it's the same as `math.floor(param1 / 16)`, except that it
5405       ensures compatibility.
5406 * `minetest.place_node(pos, node)`
5407     * Place node with the same effects that a player would cause
5408 * `minetest.dig_node(pos)`
5409     * Dig node with the same effects that a player would cause
5410     * Returns `true` if successful, `false` on failure (e.g. protected location)
5411 * `minetest.punch_node(pos)`
5412     * Punch node with the same effects that a player would cause
5413 * `minetest.spawn_falling_node(pos)`
5414     * Change node into falling node
5415     * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
5416
5417 * `minetest.find_nodes_with_meta(pos1, pos2)`
5418     * Get a table of positions of nodes that have metadata within a region
5419       {pos1, pos2}.
5420 * `minetest.get_meta(pos)`
5421     * Get a `NodeMetaRef` at that position
5422 * `minetest.get_node_timer(pos)`
5423     * Get `NodeTimerRef`
5424
5425 * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
5426   position.
5427     * Returns `ObjectRef`, or `nil` if failed
5428 * `minetest.add_item(pos, item)`: Spawn item
5429     * Returns `ObjectRef`, or `nil` if failed
5430 * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
5431 * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
5432   ObjectRefs.
5433     * `radius`: using an euclidean metric
5434 * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
5435   ObjectRefs.
5436      * `pos1` and `pos2` are the min and max positions of the area to search.
5437 * `minetest.set_timeofday(val)`
5438     * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
5439 * `minetest.get_timeofday()`
5440 * `minetest.get_gametime()`: returns the time, in seconds, since the world was
5441   created.
5442 * `minetest.get_day_count()`: returns number days elapsed since world was
5443   created.
5444     * accounts for time changes.
5445 * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
5446   pos or `nil`.
5447     * `radius`: using a maximum metric
5448     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5449     * `search_center` is an optional boolean (default: `false`)
5450       If true `pos` is also checked for the nodes
5451 * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
5452     * `pos1` and `pos2` are the min and max positions of the area to search.
5453     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5454     * If `grouped` is true the return value is a table indexed by node name
5455       which contains lists of positions.
5456     * If `grouped` is false or absent the return values are as follows:
5457       first value: Table with all node positions
5458       second value: Table with the count of each node with the node name
5459       as index
5460     * Area volume is limited to 4,096,000 nodes
5461 * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
5462   list of positions.
5463     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5464     * Return value: Table with all node positions with a node air above
5465     * Area volume is limited to 4,096,000 nodes
5466 * `minetest.get_perlin(noiseparams)`
5467     * Return world-specific perlin noise.
5468     * The actual seed used is the noiseparams seed plus the world seed.
5469 * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
5470     * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
5471     * Return world-specific perlin noise.
5472 * `minetest.get_voxel_manip([pos1, pos2])`
5473     * Return voxel manipulator object.
5474     * Loads the manipulator from the map if positions are passed.
5475 * `minetest.set_gen_notify(flags, {deco_ids})`
5476     * Set the types of on-generate notifications that should be collected.
5477     * `flags` is a flag field with the available flags:
5478         * dungeon
5479         * temple
5480         * cave_begin
5481         * cave_end
5482         * large_cave_begin
5483         * large_cave_end
5484         * decoration
5485     * The second parameter is a list of IDs of decorations which notification
5486       is requested for.
5487 * `minetest.get_gen_notify()`
5488     * Returns a flagstring and a table with the `deco_id`s.
5489 * `minetest.get_decoration_id(decoration_name)`
5490     * Returns the decoration ID number for the provided decoration name string,
5491       or `nil` on failure.
5492 * `minetest.get_mapgen_object(objectname)`
5493     * Return requested mapgen object if available (see [Mapgen objects])
5494 * `minetest.get_heat(pos)`
5495     * Returns the heat at the position, or `nil` on failure.
5496 * `minetest.get_humidity(pos)`
5497     * Returns the humidity at the position, or `nil` on failure.
5498 * `minetest.get_biome_data(pos)`
5499     * Returns a table containing:
5500         * `biome` the biome id of the biome at that position
5501         * `heat` the heat at the position
5502         * `humidity` the humidity at the position
5503     * Or returns `nil` on failure.
5504 * `minetest.get_biome_id(biome_name)`
5505     * Returns the biome id, as used in the biomemap Mapgen object and returned
5506       by `minetest.get_biome_data(pos)`, for a given biome_name string.
5507 * `minetest.get_biome_name(biome_id)`
5508     * Returns the biome name string for the provided biome id, or `nil` on
5509       failure.
5510     * If no biomes have been registered, such as in mgv6, returns `default`.
5511 * `minetest.get_mapgen_params()`
5512     * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
5513     * Returns a table containing:
5514         * `mgname`
5515         * `seed`
5516         * `chunksize`
5517         * `water_level`
5518         * `flags`
5519 * `minetest.set_mapgen_params(MapgenParams)`
5520     * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
5521       instead.
5522     * Set map generation parameters.
5523     * Function cannot be called after the registration period.
5524     * Takes a table as an argument with the fields:
5525         * `mgname`
5526         * `seed`
5527         * `chunksize`
5528         * `water_level`
5529         * `flags`
5530     * Leave field unset to leave that parameter unchanged.
5531     * `flags` contains a comma-delimited string of flags to set, or if the
5532       prefix `"no"` is attached, clears instead.
5533     * `flags` is in the same format and has the same options as `mg_flags` in
5534       `minetest.conf`.
5535 * `minetest.get_mapgen_setting(name)`
5536     * Gets the *active* mapgen setting (or nil if none exists) in string
5537       format with the following order of precedence:
5538         1) Settings loaded from map_meta.txt or overrides set during mod
5539            execution.
5540         2) Settings set by mods without a metafile override
5541         3) Settings explicitly set in the user config file, minetest.conf
5542         4) Settings set as the user config default
5543 * `minetest.get_mapgen_setting_noiseparams(name)`
5544     * Same as above, but returns the value as a NoiseParams table if the
5545       setting `name` exists and is a valid NoiseParams.
5546 * `minetest.set_mapgen_setting(name, value, [override_meta])`
5547     * Sets a mapgen param to `value`, and will take effect if the corresponding
5548       mapgen setting is not already present in map_meta.txt.
5549     * `override_meta` is an optional boolean (default: `false`). If this is set
5550       to true, the setting will become the active setting regardless of the map
5551       metafile contents.
5552     * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
5553 * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
5554     * Same as above, except value is a NoiseParams table.
5555 * `minetest.set_noiseparams(name, noiseparams, set_default)`
5556     * Sets the noiseparams setting of `name` to the noiseparams table specified
5557       in `noiseparams`.
5558     * `set_default` is an optional boolean (default: `true`) that specifies
5559       whether the setting should be applied to the default config or current
5560       active config.
5561 * `minetest.get_noiseparams(name)`
5562     * Returns a table of the noiseparams for name.
5563 * `minetest.generate_ores(vm, pos1, pos2)`
5564     * Generate all registered ores within the VoxelManip `vm` and in the area
5565       from `pos1` to `pos2`.
5566     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5567 * `minetest.generate_decorations(vm, pos1, pos2)`
5568     * Generate all registered decorations within the VoxelManip `vm` and in the
5569       area from `pos1` to `pos2`.
5570     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5571 * `minetest.clear_objects([options])`
5572     * Clear all objects in the environment
5573     * Takes an optional table as an argument with the field `mode`.
5574         * mode = `"full"` : Load and go through every mapblock, clearing
5575                             objects (default).
5576         * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
5577                             clear objects in unloaded mapblocks only when the
5578                             mapblocks are next activated.
5579 * `minetest.load_area(pos1[, pos2])`
5580     * Load the mapblocks containing the area from `pos1` to `pos2`.
5581       `pos2` defaults to `pos1` if not specified.
5582     * This function does not trigger map generation.
5583 * `minetest.emerge_area(pos1, pos2, [callback], [param])`
5584     * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
5585       asynchronously fetched from memory, loaded from disk, or if inexistent,
5586       generates them.
5587     * If `callback` is a valid Lua function, this will be called for each block
5588       emerged.
5589     * The function signature of callback is:
5590       `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
5591         * `blockpos` is the *block* coordinates of the block that had been
5592           emerged.
5593         * `action` could be one of the following constant values:
5594             * `minetest.EMERGE_CANCELLED`
5595             * `minetest.EMERGE_ERRORED`
5596             * `minetest.EMERGE_FROM_MEMORY`
5597             * `minetest.EMERGE_FROM_DISK`
5598             * `minetest.EMERGE_GENERATED`
5599         * `calls_remaining` is the number of callbacks to be expected after
5600           this one.
5601         * `param` is the user-defined parameter passed to emerge_area (or
5602           nil if the parameter was absent).
5603 * `minetest.delete_area(pos1, pos2)`
5604     * delete all mapblocks in the area from pos1 to pos2, inclusive
5605 * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
5606     * Checks if there is anything other than air between pos1 and pos2.
5607     * Returns false if something is blocking the sight.
5608     * Returns the position of the blocking node when `false`
5609     * `pos1`: First position
5610     * `pos2`: Second position
5611 * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
5612     * Creates a `Raycast` object.
5613     * `pos1`: start of the ray
5614     * `pos2`: end of the ray
5615     * `objects`: if false, only nodes will be returned. Default is `true`.
5616     * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
5617                  returned. Default is `false`.
5618 * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
5619     * returns table containing path that can be walked on
5620     * returns a table of 3D points representing a path from `pos1` to `pos2` or
5621       `nil` on failure.
5622     * Reasons for failure:
5623         * No path exists at all
5624         * No path exists within `searchdistance` (see below)
5625         * Start or end pos is buried in land
5626     * `pos1`: start position
5627     * `pos2`: end position
5628     * `searchdistance`: maximum distance from the search positions to search in.
5629       In detail: Path must be completely inside a cuboid. The minimum
5630       `searchdistance` of 1 will confine search between `pos1` and `pos2`.
5631       Larger values will increase the size of this cuboid in all directions
5632     * `max_jump`: maximum height difference to consider walkable
5633     * `max_drop`: maximum height difference to consider droppable
5634     * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
5635       Difference between `"A*"` and `"A*_noprefetch"` is that
5636       `"A*"` will pre-calculate the cost-data, the other will calculate it
5637       on-the-fly
5638 * `minetest.spawn_tree (pos, {treedef})`
5639     * spawns L-system tree at given `pos` with definition in `treedef` table
5640 * `minetest.transforming_liquid_add(pos)`
5641     * add node to liquid flow update queue
5642 * `minetest.get_node_max_level(pos)`
5643     * get max available level for leveled node
5644 * `minetest.get_node_level(pos)`
5645     * get level of leveled node (water, snow)
5646 * `minetest.set_node_level(pos, level)`
5647     * set level of leveled node, default `level` equals `1`
5648     * if `totallevel > maxlevel`, returns rest (`total-max`).
5649 * `minetest.add_node_level(pos, level)`
5650     * increase level of leveled node by level, default `level` equals `1`
5651     * if `totallevel > maxlevel`, returns rest (`total-max`)
5652     * `level` must be between -127 and 127
5653 * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
5654     * resets the light in a cuboid-shaped part of
5655       the map and removes lighting bugs.
5656     * Loads the area if it is not loaded.
5657     * `pos1` is the corner of the cuboid with the least coordinates
5658       (in node coordinates), inclusive.
5659     * `pos2` is the opposite corner of the cuboid, inclusive.
5660     * The actual updated cuboid might be larger than the specified one,
5661       because only whole map blocks can be updated.
5662       The actual updated area consists of those map blocks that intersect
5663       with the given cuboid.
5664     * However, the neighborhood of the updated area might change
5665       as well, as light can spread out of the cuboid, also light
5666       might be removed.
5667     * returns `false` if the area is not fully generated,
5668       `true` otherwise
5669 * `minetest.check_single_for_falling(pos)`
5670     * causes an unsupported `group:falling_node` node to fall and causes an
5671       unattached `group:attached_node` node to fall.
5672     * does not spread these updates to neighbours.
5673 * `minetest.check_for_falling(pos)`
5674     * causes an unsupported `group:falling_node` node to fall and causes an
5675       unattached `group:attached_node` node to fall.
5676     * spread these updates to neighbours and can cause a cascade
5677       of nodes to fall.
5678 * `minetest.get_spawn_level(x, z)`
5679     * Returns a player spawn y co-ordinate for the provided (x, z)
5680       co-ordinates, or `nil` for an unsuitable spawn point.
5681     * For most mapgens a 'suitable spawn point' is one with y between
5682       `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
5683       so `nil` will be returned for many (x, z) co-ordinates.
5684     * The spawn level returned is for a player spawn in unmodified terrain.
5685     * The spawn level is intentionally above terrain level to cope with
5686       full-node biome 'dust' nodes.
5687
5688 Mod channels
5689 ------------
5690
5691 You can find mod channels communication scheme in `doc/mod_channels.png`.
5692
5693 * `minetest.mod_channel_join(channel_name)`
5694     * Server joins channel `channel_name`, and creates it if necessary. You
5695       should listen for incoming messages with
5696       `minetest.register_on_modchannel_message`
5697
5698 Inventory
5699 ---------
5700
5701 `minetest.get_inventory(location)`: returns an `InvRef`
5702
5703 * `location` = e.g.
5704     * `{type="player", name="celeron55"}`
5705     * `{type="node", pos={x=, y=, z=}}`
5706     * `{type="detached", name="creative"}`
5707 * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
5708   an `InvRef`.
5709     * `callbacks`: See [Detached inventory callbacks]
5710     * `player_name`: Make detached inventory available to one player
5711       exclusively, by default they will be sent to every player (even if not
5712       used).
5713       Note that this parameter is mostly just a workaround and will be removed
5714       in future releases.
5715     * Creates a detached inventory. If it already exists, it is cleared.
5716 * `minetest.remove_detached_inventory(name)`
5717     * Returns a `boolean` indicating whether the removal succeeded.
5718 * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
5719   returns leftover ItemStack or nil to indicate no inventory change
5720     * See `minetest.item_eat` and `minetest.register_on_item_eat`
5721
5722 Formspec
5723 --------
5724
5725 * `minetest.show_formspec(playername, formname, formspec)`
5726     * `playername`: name of player to show formspec
5727     * `formname`: name passed to `on_player_receive_fields` callbacks.
5728       It should follow the `"modname:<whatever>"` naming convention
5729     * `formspec`: formspec to display
5730 * `minetest.close_formspec(playername, formname)`
5731     * `playername`: name of player to close formspec
5732     * `formname`: has to exactly match the one given in `show_formspec`, or the
5733       formspec will not close.
5734     * calling `show_formspec(playername, formname, "")` is equal to this
5735       expression.
5736     * to close a formspec regardless of the formname, call
5737       `minetest.close_formspec(playername, "")`.
5738       **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
5739 * `minetest.formspec_escape(string)`: returns a string
5740     * escapes the characters "[", "]", "\", "," and ";", which can not be used
5741       in formspecs.
5742 * `minetest.explode_table_event(string)`: returns a table
5743     * returns e.g. `{type="CHG", row=1, column=2}`
5744     * `type` is one of:
5745         * `"INV"`: no row selected
5746         * `"CHG"`: selected
5747         * `"DCL"`: double-click
5748 * `minetest.explode_textlist_event(string)`: returns a table
5749     * returns e.g. `{type="CHG", index=1}`
5750     * `type` is one of:
5751         * `"INV"`: no row selected
5752         * `"CHG"`: selected
5753         * `"DCL"`: double-click
5754 * `minetest.explode_scrollbar_event(string)`: returns a table
5755     * returns e.g. `{type="CHG", value=500}`
5756     * `type` is one of:
5757         * `"INV"`: something failed
5758         * `"CHG"`: has been changed
5759         * `"VAL"`: not changed
5760
5761 Item handling
5762 -------------
5763
5764 * `minetest.inventorycube(img1, img2, img3)`
5765     * Returns a string for making an image of a cube (useful as an item image)
5766 * `minetest.get_pointed_thing_position(pointed_thing, above)`
5767     * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
5768       does not refer to a node or entity.
5769     * If the optional `above` parameter is true and the `pointed_thing` refers
5770       to a node, then it will return the `above` position of the `pointed_thing`.
5771 * `minetest.dir_to_facedir(dir, is6d)`
5772     * Convert a vector to a facedir value, used in `param2` for
5773       `paramtype2="facedir"`.
5774     * passing something non-`nil`/`false` for the optional second parameter
5775       causes it to take the y component into account.
5776 * `minetest.facedir_to_dir(facedir)`
5777     * Convert a facedir back into a vector aimed directly out the "back" of a
5778       node.
5779 * `minetest.dir_to_wallmounted(dir)`
5780     * Convert a vector to a wallmounted value, used for
5781       `paramtype2="wallmounted"`.
5782 * `minetest.wallmounted_to_dir(wallmounted)`
5783     * Convert a wallmounted value back into a vector aimed directly out the
5784       "back" of a node.
5785 * `minetest.dir_to_yaw(dir)`
5786     * Convert a vector into a yaw (angle)
5787 * `minetest.yaw_to_dir(yaw)`
5788     * Convert yaw (angle) to a vector
5789 * `minetest.is_colored_paramtype(ptype)`
5790     * Returns a boolean. Returns `true` if the given `paramtype2` contains
5791       color information (`color`, `colorwallmounted` or `colorfacedir`).
5792 * `minetest.strip_param2_color(param2, paramtype2)`
5793     * Removes everything but the color information from the
5794       given `param2` value.
5795     * Returns `nil` if the given `paramtype2` does not contain color
5796       information.
5797 * `minetest.get_node_drops(node, toolname)`
5798     * Returns list of itemstrings that are dropped by `node` when dug
5799       with the item `toolname` (not limited to tools).
5800     * `node`: node as table or node name
5801     * `toolname`: name of the item used to dig (can be `nil`)
5802 * `minetest.get_craft_result(input)`: returns `output, decremented_input`
5803     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5804     * `input.width` = for example `3`
5805     * `input.items` = for example
5806       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5807     * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
5808     * `output.time` = a number, if unsuccessful: `0`
5809     * `output.replacements` = List of replacement `ItemStack`s that couldn't be
5810       placed in `decremented_input.items`. Replacements can be placed in
5811       `decremented_input` if the stack of the replaced item has a count of 1.
5812     * `decremented_input` = like `input`
5813 * `minetest.get_craft_recipe(output)`: returns input
5814     * returns last registered recipe for output item (node)
5815     * `output` is a node or item type such as `"default:torch"`
5816     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5817     * `input.width` = for example `3`
5818     * `input.items` = for example
5819       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5820         * `input.items` = `nil` if no recipe found
5821 * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
5822     * returns indexed table with all registered recipes for query item (node)
5823       or `nil` if no recipe was found.
5824     * recipe entry table:
5825         * `method`: 'normal' or 'cooking' or 'fuel'
5826         * `width`: 0-3, 0 means shapeless recipe
5827         * `items`: indexed [1-9] table with recipe items
5828         * `output`: string with item name and quantity
5829     * Example result for `"default:gold_ingot"` with two recipes:
5830
5831           {
5832               {
5833                   method = "cooking", width = 3,
5834                   output = "default:gold_ingot", items = {"default:gold_lump"}
5835               },
5836               {
5837                   method = "normal", width = 1,
5838                   output = "default:gold_ingot 9", items = {"default:goldblock"}
5839               }
5840           }
5841
5842 * `minetest.handle_node_drops(pos, drops, digger)`
5843     * `drops`: list of itemstrings
5844     * Handles drops from nodes after digging: Default action is to put them
5845       into digger's inventory.
5846     * Can be overridden to get different functionality (e.g. dropping items on
5847       ground)
5848 * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
5849   string.
5850     * Creates an item string which contains palette index information
5851       for hardware colorization. You can use the returned string
5852       as an output in a craft recipe.
5853     * `item`: the item stack which becomes colored. Can be in string,
5854       table and native form.
5855     * `palette_index`: this index is added to the item stack
5856 * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
5857     * Creates an item string which contains static color information
5858       for hardware colorization. Use this method if you wish to colorize
5859       an item that does not own a palette. You can use the returned string
5860       as an output in a craft recipe.
5861     * `item`: the item stack which becomes colored. Can be in string,
5862       table and native form.
5863     * `colorstring`: the new color of the item stack
5864
5865 Rollback
5866 --------
5867
5868 * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
5869   returns `{{actor, pos, time, oldnode, newnode}, ...}`
5870     * Find who has done something to a node, or near a node
5871     * `actor`: `"player:<name>"`, also `"liquid"`.
5872 * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
5873   `boolean, log_messages`.
5874     * Revert latest actions of someone
5875     * `actor`: `"player:<name>"`, also `"liquid"`.
5876
5877 Defaults for the `on_place` and `on_drop` item definition functions
5878 -------------------------------------------------------------------
5879
5880 * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
5881     * Place item as a node
5882     * `param2` overrides `facedir` and wallmounted `param2`
5883     * `prevent_after_place`: if set to `true`, `after_place_node` is not called
5884       for the newly placed node to prevent a callback and placement loop
5885     * returns `itemstack, position`
5886       * `position`: the location the node was placed to. `nil` if nothing was placed.
5887 * `minetest.item_place_object(itemstack, placer, pointed_thing)`
5888     * Place item as-is
5889     * returns the leftover itemstack
5890     * **Note**: This function is deprecated and will never be called.
5891 * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
5892     * Wrapper that calls `minetest.item_place_node` if appropriate
5893     * Calls `on_rightclick` of `pointed_thing.under` if defined instead
5894     * **Note**: is not called when wielded item overrides `on_place`
5895     * `param2` overrides facedir and wallmounted `param2`
5896     * returns `itemstack, position`
5897       * `position`: the location the node was placed to. `nil` if nothing was placed.
5898 * `minetest.item_drop(itemstack, dropper, pos)`
5899     * Drop the item
5900     * returns the leftover itemstack
5901 * `minetest.item_eat(hp_change[, replace_with_item])`
5902     * Returns `function(itemstack, user, pointed_thing)` as a
5903       function wrapper for `minetest.do_item_eat`.
5904     * `replace_with_item` is the itemstring which is added to the inventory.
5905       If the player is eating a stack, then replace_with_item goes to a
5906       different spot.
5907
5908 Defaults for the `on_punch` and `on_dig` node definition callbacks
5909 ------------------------------------------------------------------
5910
5911 * `minetest.node_punch(pos, node, puncher, pointed_thing)`
5912     * Calls functions registered by `minetest.register_on_punchnode()`
5913 * `minetest.node_dig(pos, node, digger)`
5914     * Checks if node can be dug, puts item into inventory, removes node
5915     * Calls functions registered by `minetest.registered_on_dignodes()`
5916
5917 Sounds
5918 ------
5919
5920 * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
5921     * `spec` is a `SimpleSoundSpec`
5922     * `parameters` is a sound parameter table
5923     * `ephemeral` is a boolean (default: false)
5924       Ephemeral sounds will not return a handle and can't be stopped or faded.
5925       It is recommend to use this for short sounds that happen in response to
5926       player actions (e.g. door closing).
5927 * `minetest.sound_stop(handle)`
5928     * `handle` is a handle returned by `minetest.sound_play`
5929 * `minetest.sound_fade(handle, step, gain)`
5930     * `handle` is a handle returned by `minetest.sound_play`
5931     * `step` determines how fast a sound will fade.
5932       The gain will change by this much per second,
5933       until it reaches the target gain.
5934       Note: Older versions used a signed step. This is deprecated, but old
5935       code will still work. (the client uses abs(step) to correct it)
5936     * `gain` the target gain for the fade.
5937       Fading to zero will delete the sound.
5938
5939 Timing
5940 ------
5941
5942 * `minetest.after(time, func, ...)` : returns job table to use as below.
5943     * Call the function `func` after `time` seconds, may be fractional
5944     * Optional: Variable number of arguments that are passed to `func`
5945
5946 * `job:cancel()`
5947     * Cancels the job function from being called
5948
5949 Async environment
5950 -----------------
5951
5952 The engine allows you to submit jobs to be ran in an isolated environment
5953 concurrently with normal server operation.
5954 A job consists of a function to be ran in the async environment, any amount of
5955 arguments (will be serialized) and a callback that will be called with the return
5956 value of the job function once it is finished.
5957
5958 The async environment does *not* have access to the map, entities, players or any
5959 globals defined in the 'usual' environment. Consequently, functions like
5960 `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
5961
5962 Arguments and return values passed through this can contain certain userdata
5963 objects that will be seamlessly copied (not shared) to the async environment.
5964 This allows you easy interoperability for delegating work to jobs.
5965
5966 * `minetest.handle_async(func, callback, ...)`:
5967     * Queue the function `func` to be ran in an async environment.
5968       Note that there are multiple persistent workers and any of them may
5969       end up running a given job. The engine will scale the amount of
5970       worker threads automatically.
5971     * When `func` returns the callback is called (in the normal environment)
5972       with all of the return values as arguments.
5973     * Optional: Variable number of arguments that are passed to `func`
5974 * `minetest.register_async_dofile(path)`:
5975     * Register a path to a Lua file to be imported when an async environment
5976       is initialized. You can use this to preload code which you can then call
5977       later using `minetest.handle_async()`.
5978
5979 ### List of APIs available in an async environment
5980
5981 Classes:
5982 * `ItemStack`
5983 * `PerlinNoise`
5984 * `PerlinNoiseMap`
5985 * `PseudoRandom`
5986 * `PcgRandom`
5987 * `SecureRandom`
5988 * `VoxelArea`
5989 * `VoxelManip`
5990     * only if transferred into environment; can't read/write to map
5991 * `Settings`
5992
5993 Class instances that can be transferred between environments:
5994 * `ItemStack`
5995 * `PerlinNoise`
5996 * `PerlinNoiseMap`
5997 * `VoxelManip`
5998
5999 Functions:
6000 * Standalone helpers such as logging, filesystem, encoding,
6001   hashing or compression APIs
6002 * `minetest.request_insecure_environment` (same restrictions apply)
6003
6004 Variables:
6005 * `minetest.settings`
6006 * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
6007   `registered_craftitems` and `registered_aliases`
6008     * with all functions and userdata values replaced by `true`, calling any
6009       callbacks here is obviously not possible
6010
6011 Server
6012 ------
6013
6014 * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
6015   server shutdown. Will display `message` to clients.
6016     * `reconnect` == true displays a reconnect button
6017     * `delay` adds an optional delay (in seconds) before shutdown.
6018       Negative delay cancels the current active shutdown.
6019       Zero delay triggers an immediate shutdown.
6020 * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
6021 * `minetest.get_server_status(name, joined)`
6022     * Returns the server status string when a player joins or when the command
6023       `/status` is called. Returns `nil` or an empty string when the message is
6024       disabled.
6025     * `joined`: Boolean value, indicates whether the function was called when
6026       a player joined.
6027     * This function may be overwritten by mods to customize the status message.
6028 * `minetest.get_server_uptime()`: returns the server uptime in seconds
6029 * `minetest.get_server_max_lag()`: returns the current maximum lag
6030   of the server in seconds or nil if server is not fully loaded yet
6031 * `minetest.remove_player(name)`: remove player from database (if they are not
6032   connected).
6033     * As auth data is not removed, minetest.player_exists will continue to
6034       return true. Call the below method as well if you want to remove auth
6035       data too.
6036     * Returns a code (0: successful, 1: no such player, 2: player is connected)
6037 * `minetest.remove_player_auth(name)`: remove player authentication data
6038     * Returns boolean indicating success (false if player nonexistant)
6039 * `minetest.dynamic_add_media(options, callback)`
6040     * `options`: table containing the following parameters
6041         * `filepath`: path to a media file on the filesystem
6042         * `to_player`: name of the player the media should be sent to instead of
6043                        all players (optional)
6044         * `ephemeral`: boolean that marks the media as ephemeral,
6045                        it will not be cached on the client (optional, default false)
6046     * `callback`: function with arguments `name`, which is a player name
6047     * Pushes the specified media file to client(s). (details below)
6048       The file must be a supported image, sound or model format.
6049       Dynamically added media is not persisted between server restarts.
6050     * Returns false on error, true if the request was accepted
6051     * The given callback will be called for every player as soon as the
6052       media is available on the client.
6053     * Details/Notes:
6054       * If `ephemeral`=false and `to_player` is unset the file is added to the media
6055         sent to clients on startup, this means the media will appear even on
6056         old clients if they rejoin the server.
6057       * If `ephemeral`=false the file must not be modified, deleted, moved or
6058         renamed after calling this function.
6059       * Regardless of any use of `ephemeral`, adding media files with the same
6060         name twice is not possible/guaranteed to work. An exception to this is the
6061         use of `to_player` to send the same, already existent file to multiple
6062         chosen players.
6063     * Clients will attempt to fetch files added this way via remote media,
6064       this can make transfer of bigger files painless (if set up). Nevertheless
6065       it is advised not to use dynamic media for big media files.
6066
6067 Bans
6068 ----
6069
6070 * `minetest.get_ban_list()`: returns a list of all bans formatted as string
6071 * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
6072   IP address or name formatted as string
6073 * `minetest.ban_player(name)`: ban the IP of a currently connected player
6074     * Returns boolean indicating success
6075 * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
6076   IP address or name
6077 * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
6078   reason.
6079     * Returns boolean indicating success (false if player nonexistant)
6080 * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
6081   optional reason, this will not prefix with 'Kicked: ' like kick_player.
6082   If no reason is given, it will default to 'Disconnected.'
6083     * Returns boolean indicating success (false if player nonexistant)
6084
6085 Particles
6086 ---------
6087
6088 * `minetest.add_particle(particle definition)`
6089     * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
6090       expirationtime, size, collisiondetection, texture, playername)`
6091
6092 * `minetest.add_particlespawner(particlespawner definition)`
6093     * Add a `ParticleSpawner`, an object that spawns an amount of particles
6094       over `time` seconds.
6095     * Returns an `id`, and -1 if adding didn't succeed
6096     * Deprecated: `minetest.add_particlespawner(amount, time,
6097       minpos, maxpos,
6098       minvel, maxvel,
6099       minacc, maxacc,
6100       minexptime, maxexptime,
6101       minsize, maxsize,
6102       collisiondetection, texture, playername)`
6103
6104 * `minetest.delete_particlespawner(id, player)`
6105     * Delete `ParticleSpawner` with `id` (return value from
6106       `minetest.add_particlespawner`).
6107     * If playername is specified, only deletes on the player's client,
6108       otherwise on all clients.
6109
6110 Schematics
6111 ----------
6112
6113 * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
6114     * Create a schematic from the volume of map specified by the box formed by
6115       p1 and p2.
6116     * Apply the specified probability and per-node force-place to the specified
6117       nodes according to the `probability_list`.
6118         * `probability_list` is an array of tables containing two fields, `pos`
6119           and `prob`.
6120             * `pos` is the 3D vector specifying the absolute coordinates of the
6121               node being modified,
6122             * `prob` is an integer value from `0` to `255` that encodes
6123               probability and per-node force-place. Probability has levels
6124               0-127, then 128 may be added to encode per-node force-place.
6125               For probability stated as 0-255, divide by 2 and round down to
6126               get values 0-127, then add 128 to apply per-node force-place.
6127             * If there are two or more entries with the same pos value, the
6128               last entry is used.
6129             * If `pos` is not inside the box formed by `p1` and `p2`, it is
6130               ignored.
6131             * If `probability_list` equals `nil`, no probabilities are applied.
6132     * Apply the specified probability to the specified horizontal slices
6133       according to the `slice_prob_list`.
6134         * `slice_prob_list` is an array of tables containing two fields, `ypos`
6135           and `prob`.
6136             * `ypos` indicates the y position of the slice with a probability
6137               applied, the lowest slice being `ypos = 0`.
6138             * If slice probability list equals `nil`, no slice probabilities
6139               are applied.
6140     * Saves schematic in the Minetest Schematic format to filename.
6141
6142 * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
6143     * Place the schematic specified by schematic (see [Schematic specifier]) at
6144       `pos`.
6145     * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
6146     * If the `rotation` parameter is omitted, the schematic is not rotated.
6147     * `replacements` = `{["old_name"] = "convert_to", ...}`
6148     * `force_placement` is a boolean indicating whether nodes other than `air`
6149       and `ignore` are replaced by the schematic.
6150     * Returns nil if the schematic could not be loaded.
6151     * **Warning**: Once you have loaded a schematic from a file, it will be
6152       cached. Future calls will always use the cached version and the
6153       replacement list defined for it, regardless of whether the file or the
6154       replacement list parameter have changed. The only way to load the file
6155       anew is to restart the server.
6156     * `flags` is a flag field with the available flags:
6157         * place_center_x
6158         * place_center_y
6159         * place_center_z
6160
6161 * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
6162     * This function is analogous to minetest.place_schematic, but places a
6163       schematic onto the specified VoxelManip object `vmanip` instead of the
6164       map.
6165     * Returns false if any part of the schematic was cut-off due to the
6166       VoxelManip not containing the full area required, and true if the whole
6167       schematic was able to fit.
6168     * Returns nil if the schematic could not be loaded.
6169     * After execution, any external copies of the VoxelManip contents are
6170       invalidated.
6171     * `flags` is a flag field with the available flags:
6172         * place_center_x
6173         * place_center_y
6174         * place_center_z
6175
6176 * `minetest.serialize_schematic(schematic, format, options)`
6177     * Return the serialized schematic specified by schematic
6178       (see [Schematic specifier])
6179     * in the `format` of either "mts" or "lua".
6180     * "mts" - a string containing the binary MTS data used in the MTS file
6181       format.
6182     * "lua" - a string containing Lua code representing the schematic in table
6183       format.
6184     * `options` is a table containing the following optional parameters:
6185         * If `lua_use_comments` is true and `format` is "lua", the Lua code
6186           generated will have (X, Z) position comments for every X row
6187           generated in the schematic data for easier reading.
6188         * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
6189           the Lua code generated will use that number of spaces as indentation
6190           instead of a tab character.
6191
6192 * `minetest.read_schematic(schematic, options)`
6193     * Returns a Lua table representing the schematic (see: [Schematic specifier])
6194     * `schematic` is the schematic to read (see: [Schematic specifier])
6195     * `options` is a table containing the following optional parameters:
6196         * `write_yslice_prob`: string value:
6197             * `none`: no `write_yslice_prob` table is inserted,
6198             * `low`: only probabilities that are not 254 or 255 are written in
6199               the `write_ylisce_prob` table,
6200             * `all`: write all probabilities to the `write_yslice_prob` table.
6201             * The default for this option is `all`.
6202             * Any invalid value will be interpreted as `all`.
6203
6204 HTTP Requests
6205 -------------
6206
6207 * `minetest.request_http_api()`:
6208     * returns `HTTPApiTable` containing http functions if the calling mod has
6209       been granted access by being listed in the `secure.http_mods` or
6210       `secure.trusted_mods` setting, otherwise returns `nil`.
6211     * The returned table contains the functions `fetch`, `fetch_async` and
6212       `fetch_async_get` described below.
6213     * Only works at init time and must be called from the mod's main scope
6214       (not from a function).
6215     * Function only exists if minetest server was built with cURL support.
6216     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
6217       A LOCAL VARIABLE!**
6218 * `HTTPApiTable.fetch(HTTPRequest req, callback)`
6219     * Performs given request asynchronously and calls callback upon completion
6220     * callback: `function(HTTPRequestResult res)`
6221     * Use this HTTP function if you are unsure, the others are for advanced use
6222 * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
6223     * Performs given request asynchronously and returns handle for
6224       `HTTPApiTable.fetch_async_get`
6225 * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
6226     * Return response data for given asynchronous HTTP request
6227
6228 Storage API
6229 -----------
6230
6231 * `minetest.get_mod_storage()`:
6232     * returns reference to mod private `StorageRef`
6233     * must be called during mod load time
6234
6235 Misc.
6236 -----
6237
6238 * `minetest.get_connected_players()`: returns list of `ObjectRefs`
6239 * `minetest.is_player(obj)`: boolean, whether `obj` is a player
6240 * `minetest.player_exists(name)`: boolean, whether player exists
6241   (regardless of online status)
6242 * `minetest.hud_replace_builtin(name, hud_definition)`
6243     * Replaces definition of a builtin hud element
6244     * `name`: `"breath"` or `"health"`
6245     * `hud_definition`: definition to replace builtin definition
6246 * `minetest.send_join_message(player_name)`
6247     * This function can be overridden by mods to change the join message.
6248 * `minetest.send_leave_message(player_name, timed_out)`
6249     * This function can be overridden by mods to change the leave message.
6250 * `minetest.hash_node_position(pos)`: returns an 48-bit integer
6251     * `pos`: table {x=number, y=number, z=number},
6252     * Gives a unique hash number for a node position (16+16+16=48bit)
6253 * `minetest.get_position_from_hash(hash)`: returns a position
6254     * Inverse transform of `minetest.hash_node_position`
6255 * `minetest.get_item_group(name, group)`: returns a rating
6256     * Get rating of a group of an item. (`0` means: not in group)
6257 * `minetest.get_node_group(name, group)`: returns a rating
6258     * Deprecated: An alias for the former.
6259 * `minetest.raillike_group(name)`: returns a rating
6260     * Returns rating of the connect_to_raillike group corresponding to name
6261     * If name is not yet the name of a connect_to_raillike group, a new group
6262       id is created, with that name.
6263 * `minetest.get_content_id(name)`: returns an integer
6264     * Gets the internal content ID of `name`
6265 * `minetest.get_name_from_content_id(content_id)`: returns a string
6266     * Gets the name of the content with that content ID
6267 * `minetest.parse_json(string[, nullvalue])`: returns something
6268     * Convert a string containing JSON data into the Lua equivalent
6269     * `nullvalue`: returned in place of the JSON null; defaults to `nil`
6270     * On success returns a table, a string, a number, a boolean or `nullvalue`
6271     * On failure outputs an error message and returns `nil`
6272     * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
6273 * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
6274   message.
6275     * Convert a Lua table into a JSON string
6276     * styled: Outputs in a human-readable format if this is set, defaults to
6277       false.
6278     * Unserializable things like functions and userdata will cause an error.
6279     * **Warning**: JSON is more strict than the Lua table format.
6280         1. You can only use strings and positive integers of at least one as
6281            keys.
6282         2. You can not mix string and integer keys.
6283            This is due to the fact that JSON has two distinct array and object
6284            values.
6285     * Example: `write_json({10, {a = false}})`,
6286       returns `'[10, {"a": false}]'`
6287 * `minetest.serialize(table)`: returns a string
6288     * Convert a table containing tables, strings, numbers, booleans and `nil`s
6289       into string form readable by `minetest.deserialize`
6290     * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
6291 * `minetest.deserialize(string[, safe])`: returns a table
6292     * Convert a string returned by `minetest.serialize` into a table
6293     * `string` is loaded in an empty sandbox environment.
6294     * Will load functions if safe is false or omitted. Although these functions
6295       cannot directly access the global environment, they could bypass this
6296       restriction with maliciously crafted Lua bytecode if mod security is
6297       disabled.
6298     * This function should not be used on untrusted data, regardless of the
6299      value of `safe`. It is fine to serialize then deserialize user-provided
6300      data, but directly providing user input to deserialize is always unsafe.
6301     * Example: `deserialize('return { ["foo"] = "bar" }')`,
6302       returns `{foo="bar"}`
6303     * Example: `deserialize('print("foo")')`, returns `nil`
6304       (function call fails), returns
6305       `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
6306 * `minetest.compress(data, method, ...)`: returns `compressed_data`
6307     * Compress a string of data.
6308     * `method` is a string identifying the compression method to be used.
6309     * Supported compression methods:
6310         * Deflate (zlib): `"deflate"`
6311     * `...` indicates method-specific arguments. Currently defined arguments
6312       are:
6313         * Deflate: `level` - Compression level, `0`-`9` or `nil`.
6314 * `minetest.decompress(compressed_data, method, ...)`: returns data
6315     * Decompress a string of data (using ZLib).
6316     * See documentation on `minetest.compress()` for supported compression
6317       methods.
6318     * `...` indicates method-specific arguments. Currently, no methods use this
6319 * `minetest.rgba(red, green, blue[, alpha])`: returns a string
6320     * Each argument is a 8 Bit unsigned integer
6321     * Returns the ColorString from rgb or rgba values
6322     * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
6323 * `minetest.encode_base64(string)`: returns string encoded in base64
6324     * Encodes a string in base64.
6325 * `minetest.decode_base64(string)`: returns string or nil on failure
6326     * Padding characters are only supported starting at version 5.4.0, where
6327       5.5.0 and newer perform proper checks.
6328     * Decodes a string encoded in base64.
6329 * `minetest.is_protected(pos, name)`: returns boolean
6330     * Returning `true` restricts the player `name` from modifying (i.e. digging,
6331        placing) the node at position `pos`.
6332     * `name` will be `""` for non-players or unknown players.
6333     * This function should be overridden by protection mods. It is highly
6334       recommended to grant access to players with the `protection_bypass` privilege.
6335     * Cache and call the old version of this function if the position is
6336       not protected by the mod. This will allow using multiple protection mods.
6337     * Example:
6338
6339           local old_is_protected = minetest.is_protected
6340           function minetest.is_protected(pos, name)
6341               if mymod:position_protected_from(pos, name) then
6342                   return true
6343               end
6344               return old_is_protected(pos, name)
6345           end
6346 * `minetest.record_protection_violation(pos, name)`
6347     * This function calls functions registered with
6348       `minetest.register_on_protection_violation`.
6349 * `minetest.is_creative_enabled(name)`: returns boolean
6350     * Returning `true` means that Creative Mode is enabled for player `name`.
6351     * `name` will be `""` for non-players or if the player is unknown.
6352     * This function should be overridden by Creative Mode-related mods to
6353       implement a per-player Creative Mode.
6354     * By default, this function returns `true` if the setting
6355       `creative_mode` is `true` and `false` otherwise.
6356 * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
6357     * Returns the position of the first node that `player_name` may not modify
6358       in the specified cuboid between `pos1` and `pos2`.
6359     * Returns `false` if no protections were found.
6360     * Applies `is_protected()` to a 3D lattice of points in the defined volume.
6361       The points are spaced evenly throughout the volume and have a spacing
6362       similar to, but no larger than, `interval`.
6363     * All corners and edges of the defined volume are checked.
6364     * `interval` defaults to 4.
6365     * `interval` should be carefully chosen and maximised to avoid an excessive
6366       number of points being checked.
6367     * Like `minetest.is_protected`, this function may be extended or
6368       overwritten by mods to provide a faster implementation to check the
6369       cuboid for intersections.
6370 * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
6371   orient_flags, prevent_after_place])`
6372     * Attempt to predict the desired orientation of the facedir-capable node
6373       defined by `itemstack`, and place it accordingly (on-wall, on the floor,
6374       or hanging from the ceiling).
6375     * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
6376       stacks are handled normally.
6377     * `orient_flags`: Optional table containing extra tweaks to the placement code:
6378         * `invert_wall`:   if `true`, place wall-orientation on the ground and
6379           ground-orientation on the wall.
6380         * `force_wall` :   if `true`, always place the node in wall orientation.
6381         * `force_ceiling`: if `true`, always place on the ceiling.
6382         * `force_floor`:   if `true`, always place the node on the floor.
6383         * `force_facedir`: if `true`, forcefully reset the facedir to north
6384           when placing on the floor or ceiling.
6385         * The first four options are mutually-exclusive; the last in the list
6386           takes precedence over the first.
6387     * `prevent_after_place` is directly passed to `minetest.item_place_node`
6388     * Returns the new itemstack after placement
6389 * `minetest.rotate_node(itemstack, placer, pointed_thing)`
6390     * calls `rotate_and_place()` with `infinitestacks` set according to the state
6391       of the creative mode setting, checks for "sneak" to set the `invert_wall`
6392       parameter and `prevent_after_place` set to `true`.
6393
6394 * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
6395   tool_capabilities, dir, distance, damage)`
6396     * Returns the amount of knockback applied on the punched player.
6397     * Arguments are equivalent to `register_on_punchplayer`, except the following:
6398         * `distance`: distance between puncher and punched player
6399     * This function can be overriden by mods that wish to modify this behaviour.
6400     * You may want to cache and call the old function to allow multiple mods to
6401       change knockback behaviour.
6402
6403 * `minetest.forceload_block(pos[, transient])`
6404     * forceloads the position `pos`.
6405     * returns `true` if area could be forceloaded
6406     * If `transient` is `false` or absent, the forceload will be persistent
6407       (saved between server runs). If `true`, the forceload will be transient
6408       (not saved between server runs).
6409
6410 * `minetest.forceload_free_block(pos[, transient])`
6411     * stops forceloading the position `pos`
6412     * If `transient` is `false` or absent, frees a persistent forceload.
6413       If `true`, frees a transient forceload.
6414
6415 * `minetest.compare_block_status(pos, condition)`
6416     * Checks whether the mapblock at positition `pos` is in the wanted condition.
6417     * `condition` may be one of the following values:
6418         * `"unknown"`: not in memory
6419         * `"emerging"`: in the queue for loading from disk or generating
6420         * `"loaded"`: in memory but inactive (no ABMs are executed)
6421         * `"active"`: in memory and active
6422         * Other values are reserved for future functionality extensions
6423     * Return value, the comparison status:
6424         * `false`: Mapblock does not fulfil the wanted condition
6425         * `true`: Mapblock meets the requirement
6426         * `nil`: Unsupported `condition` value
6427
6428 * `minetest.request_insecure_environment()`: returns an environment containing
6429   insecure functions if the calling mod has been listed as trusted in the
6430   `secure.trusted_mods` setting or security is disabled, otherwise returns
6431   `nil`.
6432     * Only works at init time and must be called from the mod's main scope
6433       (ie: the init.lua of the mod, not from another Lua file or within a function).
6434     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
6435       IT IN A LOCAL VARIABLE!**
6436
6437 * `minetest.global_exists(name)`
6438     * Checks if a global variable has been set, without triggering a warning.
6439
6440 Global objects
6441 --------------
6442
6443 * `minetest.env`: `EnvRef` of the server environment and world.
6444     * Any function in the minetest namespace can be called using the syntax
6445       `minetest.env:somefunction(somearguments)`
6446       instead of `minetest.somefunction(somearguments)`
6447     * Deprecated, but support is not to be dropped soon
6448
6449 Global tables
6450 -------------
6451
6452 ### Registered definition tables
6453
6454 * `minetest.registered_items`
6455     * Map of registered items, indexed by name
6456 * `minetest.registered_nodes`
6457     * Map of registered node definitions, indexed by name
6458 * `minetest.registered_craftitems`
6459     * Map of registered craft item definitions, indexed by name
6460 * `minetest.registered_tools`
6461     * Map of registered tool definitions, indexed by name
6462 * `minetest.registered_entities`
6463     * Map of registered entity prototypes, indexed by name
6464     * Values in this table may be modified directly.
6465       Note: changes to initial properties will only affect entities spawned afterwards,
6466       as they are only read when spawning.
6467 * `minetest.object_refs`
6468     * Map of object references, indexed by active object id
6469 * `minetest.luaentities`
6470     * Map of Lua entities, indexed by active object id
6471 * `minetest.registered_abms`
6472     * List of ABM definitions
6473 * `minetest.registered_lbms`
6474     * List of LBM definitions
6475 * `minetest.registered_aliases`
6476     * Map of registered aliases, indexed by name
6477 * `minetest.registered_ores`
6478     * Map of registered ore definitions, indexed by the `name` field.
6479     * If `name` is nil, the key is the object handle returned by
6480       `minetest.register_ore`.
6481 * `minetest.registered_biomes`
6482     * Map of registered biome definitions, indexed by the `name` field.
6483     * If `name` is nil, the key is the object handle returned by
6484       `minetest.register_biome`.
6485 * `minetest.registered_decorations`
6486     * Map of registered decoration definitions, indexed by the `name` field.
6487     * If `name` is nil, the key is the object handle returned by
6488       `minetest.register_decoration`.
6489 * `minetest.registered_schematics`
6490     * Map of registered schematic definitions, indexed by the `name` field.
6491     * If `name` is nil, the key is the object handle returned by
6492       `minetest.register_schematic`.
6493 * `minetest.registered_chatcommands`
6494     * Map of registered chat command definitions, indexed by name
6495 * `minetest.registered_privileges`
6496     * Map of registered privilege definitions, indexed by name
6497     * Registered privileges can be modified directly in this table.
6498
6499 ### Registered callback tables
6500
6501 All callbacks registered with [Global callback registration functions] are added
6502 to corresponding `minetest.registered_*` tables.
6503
6504
6505
6506
6507 Class reference
6508 ===============
6509
6510 Sorted alphabetically.
6511
6512 `AreaStore`
6513 -----------
6514
6515 AreaStore is a data structure to calculate intersections of 3D cuboid volumes
6516 and points. The `data` field (string) may be used to store and retrieve any
6517 mod-relevant information to the specified area.
6518
6519 Despite its name, mods must take care of persisting AreaStore data. They may
6520 use the provided load and write functions for this.
6521
6522
6523 ### Methods
6524
6525 * `AreaStore(type_name)`
6526     * Returns a new AreaStore instance
6527     * `type_name`: optional, forces the internally used API.
6528         * Possible values: `"LibSpatial"` (default).
6529         * When other values are specified, or SpatialIndex is not available,
6530           the custom Minetest functions are used.
6531 * `get_area(id, include_corners, include_data)`
6532     * Returns the area information about the specified ID.
6533     * Returned values are either of these:
6534
6535             nil  -- Area not found
6536             true -- Without `include_corners` and `include_data`
6537             {
6538                 min = pos, max = pos -- `include_corners == true`
6539                 data = string        -- `include_data == true`
6540             }
6541
6542 * `get_areas_for_pos(pos, include_corners, include_data)`
6543     * Returns all areas as table, indexed by the area ID.
6544     * Table values: see `get_area`.
6545 * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
6546     * Returns all areas that contain all nodes inside the area specified by`
6547       `corner1 and `corner2` (inclusive).
6548     * `accept_overlap`: if `true`, areas are returned that have nodes in
6549       common (intersect) with the specified area.
6550     * Returns the same values as `get_areas_for_pos`.
6551 * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
6552     * Returns the new area's ID, or nil if the insertion failed.
6553     * The (inclusive) positions `corner1` and `corner2` describe the area.
6554     * `data` is a string stored with the area.
6555     * `id` (optional): will be used as the internal area ID if it is an unique
6556       number between 0 and 2^32-2.
6557 * `reserve(count)`
6558     * Requires SpatialIndex, no-op function otherwise.
6559     * Reserves resources for `count` many contained areas to improve
6560       efficiency when working with many area entries. Additional areas can still
6561       be inserted afterwards at the usual complexity.
6562 * `remove_area(id)`: removes the area with the given id from the store, returns
6563   success.
6564 * `set_cache_params(params)`: sets params for the included prefiltering cache.
6565   Calling invalidates the cache, so that its elements have to be newly
6566   generated.
6567     * `params` is a table with the following fields:
6568
6569           enabled = boolean,   -- Whether to enable, default true
6570           block_radius = int,  -- The radius (in nodes) of the areas the cache
6571                                -- generates prefiltered lists for, minimum 16,
6572                                -- default 64
6573           limit = int,         -- The cache size, minimum 20, default 1000
6574 * `to_string()`: Experimental. Returns area store serialized as a (binary)
6575   string.
6576 * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
6577   a file.
6578 * `from_string(str)`: Experimental. Deserializes string and loads it into the
6579   AreaStore.
6580   Returns success and, optionally, an error message.
6581 * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
6582   from a file.
6583
6584 `InvRef`
6585 --------
6586
6587 An `InvRef` is a reference to an inventory.
6588
6589 ### Methods
6590
6591 * `is_empty(listname)`: return `true` if list is empty
6592 * `get_size(listname)`: get size of a list
6593 * `set_size(listname, size)`: set size of a list
6594     * returns `false` on error (e.g. invalid `listname` or `size`)
6595 * `get_width(listname)`: get width of a list
6596 * `set_width(listname, width)`: set width of list; currently used for crafting
6597 * `get_stack(listname, i)`: get a copy of stack index `i` in list
6598 * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
6599 * `get_list(listname)`: return full list (list of `ItemStack`s)
6600 * `set_list(listname, list)`: set full list (size will not change)
6601 * `get_lists()`: returns table that maps listnames to inventory lists
6602 * `set_lists(lists)`: sets inventory lists (size will not change)
6603 * `add_item(listname, stack)`: add item somewhere in list, returns leftover
6604   `ItemStack`.
6605 * `room_for_item(listname, stack):` returns `true` if the stack of items
6606   can be fully added to the list
6607 * `contains_item(listname, stack, [match_meta])`: returns `true` if
6608   the stack of items can be fully taken from the list.
6609   If `match_meta` is false, only the items' names are compared
6610   (default: `false`).
6611 * `remove_item(listname, stack)`: take as many items as specified from the
6612   list, returns the items that were actually removed (as an `ItemStack`)
6613   -- note that any item metadata is ignored, so attempting to remove a specific
6614   unique item this way will likely remove the wrong one -- to do that use
6615   `set_stack` with an empty `ItemStack`.
6616 * `get_location()`: returns a location compatible to
6617   `minetest.get_inventory(location)`.
6618     * returns `{type="undefined"}` in case location is not known
6619
6620 ### Callbacks
6621
6622 Detached & nodemeta inventories provide the following callbacks for move actions:
6623
6624 #### Before
6625
6626 The `allow_*` callbacks return how many items can be moved.
6627
6628 * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
6629 * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
6630 * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
6631
6632 #### After
6633
6634 The `on_*` callbacks are called after the items have been placed in the inventories.
6635
6636 * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
6637 * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
6638 * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
6639
6640 #### Swapping
6641
6642 When a player tries to put an item to a place where another item is, the items are *swapped*.
6643 This means that all callbacks will be called twice (once for each action).
6644
6645 `ItemStack`
6646 -----------
6647
6648 An `ItemStack` is a stack of items.
6649
6650 It can be created via `ItemStack(x)`, where x is an `ItemStack`,
6651 an itemstring, a table or `nil`.
6652
6653 ### Methods
6654
6655 * `is_empty()`: returns `true` if stack is empty.
6656 * `get_name()`: returns item name (e.g. `"default:stone"`).
6657 * `set_name(item_name)`: returns a boolean indicating whether the item was
6658   cleared.
6659 * `get_count()`: Returns number of items on the stack.
6660 * `set_count(count)`: returns a boolean indicating whether the item was cleared
6661     * `count`: number, unsigned 16 bit integer
6662 * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
6663 * `set_wear(wear)`: returns boolean indicating whether item was cleared
6664     * `wear`: number, unsigned 16 bit integer
6665 * `get_meta()`: returns ItemStackMetaRef. See section for more details
6666 * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
6667   stack).
6668 * `set_metadata(metadata)`: (DEPRECATED) Returns true.
6669 * `get_description()`: returns the description shown in inventory list tooltips.
6670     * The engine uses this when showing item descriptions in tooltips.
6671     * Fields for finding the description, in order:
6672         * `description` in item metadata (See [Item Metadata].)
6673         * `description` in item definition
6674         * item name
6675 * `get_short_description()`: returns the short description or nil.
6676     * Unlike the description, this does not include new lines.
6677     * Fields for finding the short description, in order:
6678         * `short_description` in item metadata (See [Item Metadata].)
6679         * `short_description` in item definition
6680         * first line of the description (From item meta or def, see `get_description()`.)
6681         * Returns nil if none of the above are set
6682 * `clear()`: removes all items from the stack, making it empty.
6683 * `replace(item)`: replace the contents of this stack.
6684     * `item` can also be an itemstring or table.
6685 * `to_string()`: returns the stack in itemstring form.
6686 * `to_table()`: returns the stack in Lua table form.
6687 * `get_stack_max()`: returns the maximum size of the stack (depends on the
6688   item).
6689 * `get_free_space()`: returns `get_stack_max() - get_count()`.
6690 * `is_known()`: returns `true` if the item name refers to a defined item type.
6691 * `get_definition()`: returns the item definition table.
6692 * `get_tool_capabilities()`: returns the digging properties of the item,
6693   or those of the hand if none are defined for this item type
6694 * `add_wear(amount)`
6695     * Increases wear by `amount` if the item is a tool, otherwise does nothing
6696     * Valid `amount` range is [0,65536]
6697     * `amount`: number, integer
6698 * `add_wear_by_uses(max_uses)`
6699     * Increases wear in such a way that, if only this function is called,
6700       the item breaks after `max_uses` times
6701     * Valid `max_uses` range is [0,65536]
6702     * Does nothing if item is not a tool or if `max_uses` is 0
6703 * `add_item(item)`: returns leftover `ItemStack`
6704     * Put some item or stack onto this stack
6705 * `item_fits(item)`: returns `true` if item or stack can be fully added to
6706   this one.
6707 * `take_item(n)`: returns taken `ItemStack`
6708     * Take (and remove) up to `n` items from this stack
6709     * `n`: number, default: `1`
6710 * `peek_item(n)`: returns taken `ItemStack`
6711     * Copy (don't remove) up to `n` items from this stack
6712     * `n`: number, default: `1`
6713
6714 `ItemStackMetaRef`
6715 ------------------
6716
6717 ItemStack metadata: reference extra data and functionality stored in a stack.
6718 Can be obtained via `item:get_meta()`.
6719
6720 ### Methods
6721
6722 * All methods in MetaDataRef
6723 * `set_tool_capabilities([tool_capabilities])`
6724     * Overrides the item's tool capabilities
6725     * A nil value will clear the override data and restore the original
6726       behavior.
6727
6728 `MetaDataRef`
6729 -------------
6730
6731 Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
6732 and [`PlayerMetaRef`].
6733
6734 ### Methods
6735
6736 * `contains(key)`: Returns true if key present, otherwise false.
6737     * Returns `nil` when the MetaData is inexistent.
6738 * `get(key)`: Returns `nil` if key not present, else the stored string.
6739 * `set_string(key, value)`: Value of `""` will delete the key.
6740 * `get_string(key)`: Returns `""` if key not present.
6741 * `set_int(key, value)`
6742 * `get_int(key)`: Returns `0` if key not present.
6743 * `set_float(key, value)`
6744 * `get_float(key)`: Returns `0` if key not present.
6745 * `to_table()`: returns `nil` or a table with keys:
6746     * `fields`: key-value storage
6747     * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
6748 * `from_table(nil or {})`
6749     * Any non-table value will clear the metadata
6750     * See [Node Metadata] for an example
6751     * returns `true` on success
6752 * `equals(other)`
6753     * returns `true` if this metadata has the same key-value pairs as `other`
6754
6755 `ModChannel`
6756 ------------
6757
6758 An interface to use mod channels on client and server
6759
6760 ### Methods
6761
6762 * `leave()`: leave the mod channel.
6763     * Server leaves channel `channel_name`.
6764     * No more incoming or outgoing messages can be sent to this channel from
6765       server mods.
6766     * This invalidate all future object usage.
6767     * Ensure you set mod_channel to nil after that to free Lua resources.
6768 * `is_writeable()`: returns true if channel is writeable and mod can send over
6769   it.
6770 * `send_all(message)`: Send `message` though the mod channel.
6771     * If mod channel is not writeable or invalid, message will be dropped.
6772     * Message size is limited to 65535 characters by protocol.
6773
6774 `NodeMetaRef`
6775 -------------
6776
6777 Node metadata: reference extra data and functionality stored in a node.
6778 Can be obtained via `minetest.get_meta(pos)`.
6779
6780 ### Methods
6781
6782 * All methods in MetaDataRef
6783 * `get_inventory()`: returns `InvRef`
6784 * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
6785   This will prevent them from being sent to the client. Note that the "private"
6786   status will only be remembered if an associated key-value pair exists,
6787   meaning it's best to call this when initializing all other meta (e.g.
6788   `on_construct`).
6789
6790 `NodeTimerRef`
6791 --------------
6792
6793 Node Timers: a high resolution persistent per-node timer.
6794 Can be gotten via `minetest.get_node_timer(pos)`.
6795
6796 ### Methods
6797
6798 * `set(timeout,elapsed)`
6799     * set a timer's state
6800     * `timeout` is in seconds, and supports fractional values (0.1 etc)
6801     * `elapsed` is in seconds, and supports fractional values (0.1 etc)
6802     * will trigger the node's `on_timer` function after `(timeout - elapsed)`
6803       seconds.
6804 * `start(timeout)`
6805     * start a timer
6806     * equivalent to `set(timeout,0)`
6807 * `stop()`
6808     * stops the timer
6809 * `get_timeout()`: returns current timeout in seconds
6810     * if `timeout` equals `0`, timer is inactive
6811 * `get_elapsed()`: returns current elapsed time in seconds
6812     * the node's `on_timer` function will be called after `(timeout - elapsed)`
6813       seconds.
6814 * `is_started()`: returns boolean state of timer
6815     * returns `true` if timer is started, otherwise `false`
6816
6817 `ObjectRef`
6818 -----------
6819
6820 Moving things in the game are generally these.
6821 This is basically a reference to a C++ `ServerActiveObject`.
6822
6823 ### Advice on handling `ObjectRefs`
6824
6825 When you receive an `ObjectRef` as a callback argument or from another API
6826 function, it is possible to store the reference somewhere and keep it around.
6827 It will keep functioning until the object is unloaded or removed.
6828
6829 However, doing this is **NOT** recommended as there is (intentionally) no method
6830 to test if a previously acquired `ObjectRef` is still valid.
6831 Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
6832 Lua back to the engine.
6833 Doing so is much less error-prone and you will never need to wonder if the
6834 object you are working with still exists.
6835
6836 ### Attachments
6837
6838 It is possible to attach objects to other objects (`set_attach` method).
6839
6840 When an object is attached, it is positioned relative to the parent's position
6841 and rotation. `get_pos` and `get_rotation` will always return the parent's
6842 values and changes via their setter counterparts are ignored.
6843
6844 To change position or rotation call `set_attach` again with the new values.
6845
6846 **Note**: Just like model dimensions, the relative position in `set_attach`
6847 must be multiplied by 10 compared to world positions.
6848
6849 It is also possible to attach to a bone of the parent object. In that case the
6850 child will follow movement and rotation of that bone.
6851
6852 ### Methods
6853
6854 * `get_pos()`: returns `{x=num, y=num, z=num}`
6855 * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
6856 * `get_velocity()`: returns the velocity, a vector.
6857 * `add_velocity(vel)`
6858     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
6859     * In comparison to using get_velocity, adding the velocity and then using
6860       set_velocity, add_velocity is supposed to avoid synchronization problems.
6861       Additionally, players also do not support set_velocity.
6862     * If a player:
6863         * Does not apply during free_move.
6864         * Note that since the player speed is normalized at each move step,
6865           increasing e.g. Y velocity beyond what would usually be achieved
6866           (see: physics overrides) will cause existing X/Z velocity to be reduced.
6867         * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
6868           pressing the jump key (assuming default settings)
6869 * `move_to(pos, continuous=false)`
6870     * Does an interpolated move for Lua entities for visually smooth transitions.
6871     * If `continuous` is true, the Lua entity will not be moved to the current
6872       position before starting the interpolated move.
6873     * For players this does the same as `set_pos`,`continuous` is ignored.
6874 * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
6875     * `puncher` = another `ObjectRef`,
6876     * `time_from_last_punch` = time since last punch action of the puncher
6877     * `direction`: can be `nil`
6878 * `right_click(clicker)`; `clicker` is another `ObjectRef`
6879 * `get_hp()`: returns number of health points
6880 * `set_hp(hp, reason)`: set number of health points
6881     * See reason in register_on_player_hpchange
6882     * Is limited to the range of 0 ... 65535 (2^16 - 1)
6883     * For players: HP are also limited by `hp_max` specified in object properties
6884 * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
6885 * `get_wield_list()`: returns the name of the inventory list the wielded item
6886    is in.
6887 * `get_wield_index()`: returns the index of the wielded item
6888 * `get_wielded_item()`: returns an `ItemStack`
6889 * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
6890   successful.
6891 * `set_armor_groups({group1=rating, group2=rating, ...})`
6892 * `get_armor_groups()`: returns a table with the armor group ratings
6893 * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
6894     * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
6895     * `frame_speed`: number, default: `15.0`
6896     * `frame_blend`: number, default: `0.0`
6897     * `frame_loop`: boolean, default: `true`
6898 * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
6899   `frame_loop`.
6900 * `set_animation_frame_speed(frame_speed)`
6901     * `frame_speed`: number, default: `15.0`
6902 * `set_attach(parent[, bone, position, rotation, forced_visible])`
6903     * `parent`: `ObjectRef` to attach to
6904     * `bone`: default `""` (the root bone)
6905     * `position`: relative position, default `{x=0, y=0, z=0}`
6906     * `rotation`: relative rotation in degrees, default `{x=0, y=0, z=0}`
6907     * `forced_visible`: Boolean to control whether the attached entity
6908        should appear in first person, default `false`.
6909     * Please also read the [Attachments] section above.
6910     * This command may fail silently (do nothing) when it would result
6911       in circular attachments.
6912 * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
6913     or nil if it isn't attached.
6914 * `get_children()`: returns a list of ObjectRefs that are attached to the
6915     object.
6916 * `set_detach()`
6917 * `set_bone_position([bone, position, rotation])`
6918     * `bone`: string. Default is `""`, the root bone
6919     * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
6920     * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
6921 * `get_bone_position(bone)`: returns position and rotation of the bone
6922 * `set_properties(object property table)`
6923 * `get_properties()`: returns object property table
6924 * `is_player()`: returns true for players, false otherwise
6925 * `get_nametag_attributes()`
6926     * returns a table with the attributes of the nametag of an object
6927     * {
6928         text = "",
6929         color = {a=0..255, r=0..255, g=0..255, b=0..255},
6930         bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
6931       }
6932 * `set_nametag_attributes(attributes)`
6933     * sets the attributes of the nametag of an object
6934     * `attributes`:
6935       {
6936         text = "My Nametag",
6937         color = ColorSpec,
6938         -- ^ Text color
6939         bgcolor = ColorSpec or false,
6940         -- ^ Sets background color of nametag
6941         -- `false` will cause the background to be set automatically based on user settings
6942         -- Default: false
6943       }
6944
6945 #### Lua entity only (no-op for other objects)
6946
6947 * `remove()`: remove object
6948     * The object is removed after returning from Lua. However the `ObjectRef`
6949       itself instantly becomes unusable with all further method calls having
6950       no effect and returning `nil`.
6951 * `set_velocity(vel)`
6952     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
6953 * `set_acceleration(acc)`
6954     * `acc` is a vector
6955 * `get_acceleration()`: returns the acceleration, a vector
6956 * `set_rotation(rot)`
6957     * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
6958       and Z is roll (bank).
6959 * `get_rotation()`: returns the rotation, a vector (radians)
6960 * `set_yaw(yaw)`: sets the yaw in radians (heading).
6961 * `get_yaw()`: returns number in radians
6962 * `set_texture_mod(mod)`
6963     * Set a texture modifier to the base texture, for sprites and meshes.
6964     * When calling `set_texture_mod` again, the previous one is discarded.
6965     * `mod` the texture modifier. See [Texture modifiers].
6966 * `get_texture_mod()` returns current texture modifier
6967 * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
6968     * Specifies and starts a sprite animation
6969     * Animations iterate along the frame `y` position.
6970     * `start_frame`: {x=column number, y=row number}, the coordinate of the
6971       first frame, default: `{x=0, y=0}`
6972     * `num_frames`: Total frames in the texture, default: `1`
6973     * `framelength`: Time per animated frame in seconds, default: `0.2`
6974     * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
6975       position according to the view direction. default: `false`.
6976         * First column:  subject facing the camera
6977         * Second column: subject looking to the left
6978         * Third column:  subject backing the camera
6979         * Fourth column: subject looking to the right
6980         * Fifth column:  subject viewed from above
6981         * Sixth column:  subject viewed from below
6982 * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
6983 * `get_luaentity()`
6984
6985 #### Player only (no-op for other objects)
6986
6987 * `get_player_name()`: returns `""` if is not a player
6988 * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
6989   table {x, y, z} representing the player's instantaneous velocity in nodes/s
6990 * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
6991 * `get_look_dir()`: get camera direction as a unit vector
6992 * `get_look_vertical()`: pitch in radians
6993     * Angle ranges between -pi/2 and pi/2, which are straight up and down
6994       respectively.
6995 * `get_look_horizontal()`: yaw in radians
6996     * Angle is counter-clockwise from the +z direction.
6997 * `set_look_vertical(radians)`: sets look pitch
6998     * radians: Angle from looking forward, where positive is downwards.
6999 * `set_look_horizontal(radians)`: sets look yaw
7000     * radians: Angle from the +z direction, where positive is counter-clockwise.
7001 * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
7002   `get_look_vertical`.
7003     * Angle ranges between -pi/2 and pi/2, which are straight down and up
7004       respectively.
7005 * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
7006   `get_look_horizontal`.
7007     * Angle is counter-clockwise from the +x direction.
7008 * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
7009   `set_look_vertical`.
7010 * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
7011   `set_look_horizontal`.
7012 * `get_breath()`: returns player's breath
7013 * `set_breath(value)`: sets player's breath
7014     * values:
7015         * `0`: player is drowning
7016         * max: bubbles bar is not shown
7017         * See [Object properties] for more information
7018     * Is limited to range 0 ... 65535 (2^16 - 1)
7019 * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
7020     * `fov`: FOV value.
7021     * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
7022       Defaults to `false`.
7023     * `transition_time`: If defined, enables smooth FOV transition.
7024       Interpreted as the time (in seconds) to reach target FOV.
7025       If set to 0, FOV change is instantaneous. Defaults to 0.
7026     * Set `fov` to 0 to clear FOV override.
7027 * `get_fov()`: Returns the following:
7028     * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
7029     * Boolean indicating whether the FOV value is a multiplier.
7030     * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
7031 * `set_attribute(attribute, value)`:  DEPRECATED, use get_meta() instead
7032     * Sets an extra attribute with value on player.
7033     * `value` must be a string, or a number which will be converted to a
7034       string.
7035     * If `value` is `nil`, remove attribute from player.
7036 * `get_attribute(attribute)`:  DEPRECATED, use get_meta() instead
7037     * Returns value (a string) for extra attribute.
7038     * Returns `nil` if no attribute found.
7039 * `get_meta()`: Returns a PlayerMetaRef.
7040 * `set_inventory_formspec(formspec)`
7041     * Redefine player's inventory form
7042     * Should usually be called in `on_joinplayer`
7043     * If `formspec` is `""`, the player's inventory is disabled.
7044 * `get_inventory_formspec()`: returns a formspec string
7045 * `set_formspec_prepend(formspec)`:
7046     * the formspec string will be added to every formspec shown to the user,
7047       except for those with a no_prepend[] tag.
7048     * This should be used to set style elements such as background[] and
7049       bgcolor[], any non-style elements (eg: label) may result in weird behaviour.
7050     * Only affects formspecs shown after this is called.
7051 * `get_formspec_prepend(formspec)`: returns a formspec string.
7052 * `get_player_control()`: returns table with player pressed keys
7053     * The table consists of fields with the following boolean values
7054       representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
7055       `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
7056     * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
7057       and exist only to preserve backwards compatibility.
7058     * Returns an empty table `{}` if the object is not a player.
7059 * `get_player_control_bits()`: returns integer with bit packed player pressed
7060   keys.
7061     * Bits:
7062         * 0 - up
7063         * 1 - down
7064         * 2 - left
7065         * 3 - right
7066         * 4 - jump
7067         * 5 - aux1
7068         * 6 - sneak
7069         * 7 - dig
7070         * 8 - place
7071         * 9 - zoom
7072     * Returns `0` (no bits set) if the object is not a player.
7073 * `set_physics_override(override_table)`
7074     * `override_table` is a table with the following fields:
7075         * `speed`: multiplier to default walking speed value (default: `1`)
7076         * `jump`: multiplier to default jump value (default: `1`)
7077         * `gravity`: multiplier to default gravity value (default: `1`)
7078         * `sneak`: whether player can sneak (default: `true`)
7079         * `sneak_glitch`: whether player can use the new move code replications
7080           of the old sneak side-effects: sneak ladders and 2 node sneak jump
7081           (default: `false`)
7082         * `new_move`: use new move/sneak code. When `false` the exact old code
7083           is used for the specific old sneak behaviour (default: `true`)
7084 * `get_physics_override()`: returns the table given to `set_physics_override`
7085 * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
7086    number on success
7087 * `hud_remove(id)`: remove the HUD element of the specified id
7088 * `hud_change(id, stat, value)`: change a value of a previously added HUD
7089   element.
7090     * `stat` supports the same keys as in the hud definition table except for
7091       `"hud_elem_type"`.
7092 * `hud_get(id)`: gets the HUD element definition structure of the specified ID
7093 * `hud_set_flags(flags)`: sets specified HUD flags of player.
7094     * `flags`: A table with the following fields set to boolean values
7095         * `hotbar`
7096         * `healthbar`
7097         * `crosshair`
7098         * `wielditem`
7099         * `breathbar`
7100         * `minimap`: Modifies the client's permission to view the minimap.
7101           The client may locally elect to not view the minimap.
7102         * `minimap_radar`: is only usable when `minimap` is true
7103         * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
7104           This includes map seed, player position, look direction, the pointed node and block bounds.
7105           Does not affect players with the `debug` privilege.
7106     * If a flag equals `nil`, the flag is not modified
7107 * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
7108     * See `hud_set_flags` for a list of flags that can be toggled.
7109 * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
7110     * `count`: number of items, must be between `1` and `32`
7111 * `hud_get_hotbar_itemcount`: returns number of visible items
7112 * `hud_set_hotbar_image(texturename)`
7113     * sets background image for hotbar
7114 * `hud_get_hotbar_image`: returns texturename
7115 * `hud_set_hotbar_selected_image(texturename)`
7116     * sets image for selected item of hotbar
7117 * `hud_get_hotbar_selected_image`: returns texturename
7118 * `set_minimap_modes({mode, mode, ...}, selected_mode)`
7119     * Overrides the available minimap modes (and toggle order), and changes the
7120     selected mode.
7121     * `mode` is a table consisting of up to four fields:
7122         * `type`: Available type:
7123             * `off`: Minimap off
7124             * `surface`: Minimap in surface mode
7125             * `radar`: Minimap in radar mode
7126             * `texture`: Texture to be displayed instead of terrain map
7127               (texture is centered around 0,0 and can be scaled).
7128               Texture size is limited to 512 x 512 pixel.
7129         * `label`: Optional label to display on minimap mode toggle
7130           The translation must be handled within the mod.
7131         * `size`: Sidelength or diameter, in number of nodes, of the terrain
7132           displayed in minimap
7133         * `texture`: Only for texture type, name of the texture to display
7134         * `scale`: Only for texture type, scale of the texture map in nodes per
7135           pixel (for example a `scale` of 2 means each pixel represents a 2x2
7136           nodes square)
7137     * `selected_mode` is the mode index to be selected after modes have been changed
7138     (0 is the first mode).
7139 * `set_sky(sky_parameters)`
7140     * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
7141       whether `set_sky` accepts this format. Check the legacy format otherwise.
7142     * Passing no arguments resets the sky to its default values.
7143     * `sky_parameters` is a table with the following optional fields:
7144         * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
7145           (default: `#ffffff`)
7146         * `type`: Available types:
7147             * `"regular"`: Uses 0 textures, `base_color` ignored
7148             * `"skybox"`: Uses 6 textures, `base_color` used as fog.
7149             * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
7150             (default: `"regular"`)
7151         * `textures`: A table containing up to six textures in the following
7152             order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
7153         * `clouds`: Boolean for whether clouds appear. (default: `true`)
7154         * `sky_color`: A table used in `"regular"` type only, containing the
7155           following values (alpha is ignored):
7156             * `day_sky`: ColorSpec, for the top half of the sky during the day.
7157               (default: `#61b5f5`)
7158             * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
7159               (default: `#90d3f6`)
7160             * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
7161               (default: `#b4bafa`)
7162               The resulting sky color will be a darkened version of the ColorSpec.
7163               Warning: The darkening of the ColorSpec is subject to change.
7164             * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
7165               (default: `#bac1f0`)
7166               The resulting sky color will be a darkened version of the ColorSpec.
7167               Warning: The darkening of the ColorSpec is subject to change.
7168             * `night_sky`: ColorSpec, for the top half of the sky during the night.
7169               (default: `#006bff`)
7170               The resulting sky color will be a dark version of the ColorSpec.
7171               Warning: The darkening of the ColorSpec is subject to change.
7172             * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
7173               (default: `#4090ff`)
7174               The resulting sky color will be a dark version of the ColorSpec.
7175               Warning: The darkening of the ColorSpec is subject to change.
7176             * `indoors`: ColorSpec, for when you're either indoors or underground.
7177               (default: `#646464`)
7178             * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
7179               at sunrise and sunset. (default: `#f47d1d`)
7180             * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
7181               at sunrise and sunset. (default: `#7f99cc`)
7182             * `fog_tint_type`: string, changes which mode the directional fog
7183                 abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
7184                 `"default"` uses the classic Minetest sun and moon tinting.
7185                 Will use tonemaps, if set to `"default"`. (default: `"default"`)
7186 * `set_sky(base_color, type, {texture names}, clouds)`
7187     * Deprecated. Use `set_sky(sky_parameters)`
7188     * `base_color`: ColorSpec, defaults to white
7189     * `type`: Available types:
7190         * `"regular"`: Uses 0 textures, `bgcolor` ignored
7191         * `"skybox"`: Uses 6 textures, `bgcolor` used
7192         * `"plain"`: Uses 0 textures, `bgcolor` used
7193     * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
7194       `"plain"` custom skyboxes (default: `true`)
7195 * `get_sky(as_table)`:
7196     * `as_table`: boolean that determines whether the deprecated version of this
7197     function is being used.
7198         * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
7199         * Deprecated: `false` or `nil` returns base_color, type, table of textures,
7200         clouds.
7201 * `get_sky_color()`:
7202     * Deprecated: Use `get_sky(as_table)` instead.
7203     * returns a table with the `sky_color` parameters as in `set_sky`.
7204 * `set_sun(sun_parameters)`:
7205     * Passing no arguments resets the sun to its default values.
7206     * `sun_parameters` is a table with the following optional fields:
7207         * `visible`: Boolean for whether the sun is visible.
7208             (default: `true`)
7209         * `texture`: A regular texture for the sun. Setting to `""`
7210             will re-enable the mesh sun. (default: "sun.png", if it exists)
7211             The texture appears non-rotated at sunrise and rotated 180 degrees
7212             (upside down) at sunset.
7213         * `tonemap`: A 512x1 texture containing the tonemap for the sun
7214             (default: `"sun_tonemap.png"`)
7215         * `sunrise`: A regular texture for the sunrise texture.
7216             (default: `"sunrisebg.png"`)
7217         * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
7218             (default: `true`)
7219         * `scale`: Float controlling the overall size of the sun. (default: `1`)
7220             Note: For legacy reasons, the sun is bigger than the moon by a factor
7221             of about `1.57` for equal `scale` values.
7222 * `get_sun()`: returns a table with the current sun parameters as in
7223     `set_sun`.
7224 * `set_moon(moon_parameters)`:
7225     * Passing no arguments resets the moon to its default values.
7226     * `moon_parameters` is a table with the following optional fields:
7227         * `visible`: Boolean for whether the moon is visible.
7228             (default: `true`)
7229         * `texture`: A regular texture for the moon. Setting to `""`
7230             will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
7231             The texture appears non-rotated at sunrise / moonset and rotated 180
7232             degrees (upside down) at sunset / moonrise.
7233             Note: Relative to the sun, the moon texture is hence rotated by 180°.
7234             You can use the `^[transformR180` texture modifier to achieve the same orientation.
7235         * `tonemap`: A 512x1 texture containing the tonemap for the moon
7236             (default: `"moon_tonemap.png"`)
7237         * `scale`: Float controlling the overall size of the moon (default: `1`)
7238             Note: For legacy reasons, the sun is bigger than the moon by a factor
7239             of about `1.57` for equal `scale` values.
7240 * `get_moon()`: returns a table with the current moon parameters as in
7241     `set_moon`.
7242 * `set_stars(star_parameters)`:
7243     * Passing no arguments resets stars to their default values.
7244     * `star_parameters` is a table with the following optional fields:
7245         * `visible`: Boolean for whether the stars are visible.
7246             (default: `true`)
7247         * `day_opacity`: Float for maximum opacity of stars at day.
7248             No effect if `visible` is false.
7249             (default: 0.0; maximum: 1.0; minimum: 0.0)
7250         * `count`: Integer number to set the number of stars in
7251             the skybox. Only applies to `"skybox"` and `"regular"` sky types.
7252             (default: `1000`)
7253         * `star_color`: ColorSpec, sets the colors of the stars,
7254             alpha channel is used to set overall star brightness.
7255             (default: `#ebebff69`)
7256         * `scale`: Float controlling the overall size of the stars (default: `1`)
7257 * `get_stars()`: returns a table with the current stars parameters as in
7258     `set_stars`.
7259 * `set_clouds(cloud_parameters)`: set cloud parameters
7260     * Passing no arguments resets clouds to their default values.
7261     * `cloud_parameters` is a table with the following optional fields:
7262         * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
7263         * `color`: basic cloud color with alpha channel, ColorSpec
7264           (default `#fff0f0e5`).
7265         * `ambient`: cloud color lower bound, use for a "glow at night" effect.
7266           ColorSpec (alpha ignored, default `#000000`)
7267         * `height`: cloud height, i.e. y of cloud base (default per conf,
7268           usually `120`)
7269         * `thickness`: cloud thickness in nodes (default `16`)
7270         * `speed`: 2D cloud speed + direction in nodes per second
7271           (default `{x=0, z=-2}`).
7272 * `get_clouds()`: returns a table with the current cloud parameters as in
7273   `set_clouds`.
7274 * `override_day_night_ratio(ratio or nil)`
7275     * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
7276       amount.
7277     * `nil`: Disables override, defaulting to sunlight based on day-night cycle
7278 * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
7279 * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
7280   set animation for player model in third person view.
7281     * Every animation equals to a `{x=starting frame, y=ending frame}` table.
7282     * `frame_speed` sets the animations frame speed. Default is 30.
7283 * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
7284   `frame_speed`.
7285 * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
7286   camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
7287     * in first person view
7288     * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
7289 * `get_eye_offset()`: returns first and third person offsets.
7290 * `send_mapblock(blockpos)`:
7291     * Sends an already loaded mapblock to the player.
7292     * Returns `false` if nothing was sent (note that this can also mean that
7293       the client already has the block)
7294     * Resource intensive - use sparsely
7295 * `set_lighting(light_definition)`: sets lighting for the player
7296     * `light_definition` is a table with the following optional fields:
7297       * `shadows` is a table that controls ambient shadows
7298         * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
7299 * `get_lighting()`: returns the current state of lighting for the player.
7300     * Result is a table with the same fields as `light_definition` in `set_lighting`.
7301 * `respawn()`: Respawns the player using the same mechanism as the death screen,
7302   including calling on_respawnplayer callbacks.
7303
7304 `PcgRandom`
7305 -----------
7306
7307 A 32-bit pseudorandom number generator.
7308 Uses PCG32, an algorithm of the permuted congruential generator family,
7309 offering very strong randomness.
7310
7311 It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
7312
7313 ### Methods
7314
7315 * `next()`: return next integer random number [`-2147483648`...`2147483647`]
7316 * `next(min, max)`: return next integer random number [`min`...`max`]
7317 * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
7318   random number [`min`...`max`].
7319     * This is only a rough approximation of a normal distribution with:
7320     * `mean = (max - min) / 2`, and
7321     * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
7322     * Increasing `num_trials` improves accuracy of the approximation
7323
7324 `PerlinNoise`
7325 -------------
7326
7327 A perlin noise generator.
7328 It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
7329 For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
7330 plus the world seed, to create world-specific noise.
7331
7332 `PerlinNoise(noiseparams)`
7333 `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
7334
7335 `minetest.get_perlin(noiseparams)`
7336 `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
7337
7338 ### Methods
7339
7340 * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
7341 * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
7342
7343 `PerlinNoiseMap`
7344 ----------------
7345
7346 A fast, bulk perlin noise generator.
7347
7348 It can be created via `PerlinNoiseMap(noiseparams, size)` or
7349 `minetest.get_perlin_map(noiseparams, size)`.
7350 For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
7351 plus the world seed, to create world-specific noise.
7352
7353 Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
7354 for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
7355 `nil` is returned).
7356
7357 For each of the functions with an optional `buffer` parameter: If `buffer` is
7358 not nil, this table will be used to store the result instead of creating a new
7359 table.
7360
7361 ### Methods
7362
7363 * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
7364   with values starting at `pos={x=,y=}`
7365 * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
7366   3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
7367 * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
7368   array of 2D noise with values starting at `pos={x=,y=}`
7369 * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
7370 * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
7371   is stored internally.
7372 * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
7373   is stored internally.
7374 * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
7375   returns a slice of the most recently computed noise results. The result slice
7376   begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
7377   E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
7378   offset y = 20:
7379   `noisevals = noise:get_map_slice({y=20}, {y=2})`
7380   It is important to note that `slice_offset` offset coordinates begin at 1,
7381   and are relative to the starting position of the most recently calculated
7382   noise.
7383   To grab a single vertical column of noise starting at map coordinates
7384   x = 1023, y=1000, z = 1000:
7385   `noise:calc_3d_map({x=1000, y=1000, z=1000})`
7386   `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
7387
7388 `PlayerMetaRef`
7389 ---------------
7390
7391 Player metadata.
7392 Uses the same method of storage as the deprecated player attribute API, so
7393 data there will also be in player meta.
7394 Can be obtained using `player:get_meta()`.
7395
7396 ### Methods
7397
7398 * All methods in MetaDataRef
7399
7400 `PseudoRandom`
7401 --------------
7402
7403 A 16-bit pseudorandom number generator.
7404 Uses a well-known LCG algorithm introduced by K&R.
7405
7406 It can be created via `PseudoRandom(seed)`.
7407
7408 ### Methods
7409
7410 * `next()`: return next integer random number [`0`...`32767`]
7411 * `next(min, max)`: return next integer random number [`min`...`max`]
7412     * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
7413       due to the simple implementation making bad distribution otherwise.
7414
7415 `Raycast`
7416 ---------
7417
7418 A raycast on the map. It works with selection boxes.
7419 Can be used as an iterator in a for loop as:
7420
7421     local ray = Raycast(...)
7422     for pointed_thing in ray do
7423         ...
7424     end
7425
7426 The map is loaded as the ray advances. If the map is modified after the
7427 `Raycast` is created, the changes may or may not have an effect on the object.
7428
7429 It can be created via `Raycast(pos1, pos2, objects, liquids)` or
7430 `minetest.raycast(pos1, pos2, objects, liquids)` where:
7431
7432 * `pos1`: start of the ray
7433 * `pos2`: end of the ray
7434 * `objects`: if false, only nodes will be returned. Default is true.
7435 * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
7436              returned. Default is false.
7437
7438 ### Methods
7439
7440 * `next()`: returns a `pointed_thing` with exact pointing location
7441     * Returns the next thing pointed by the ray or nil.
7442
7443 `SecureRandom`
7444 --------------
7445
7446 Interface for the operating system's crypto-secure PRNG.
7447
7448 It can be created via `SecureRandom()`.  The constructor returns nil if a
7449 secure random device cannot be found on the system.
7450
7451 ### Methods
7452
7453 * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
7454   random bytes, as a string.
7455
7456 `Settings`
7457 ----------
7458
7459 An interface to read config files in the format of `minetest.conf`.
7460
7461 It can be created via `Settings(filename)`.
7462
7463 ### Methods
7464
7465 * `get(key)`: returns a value
7466 * `get_bool(key, [default])`: returns a boolean
7467     * `default` is the value returned if `key` is not found.
7468     * Returns `nil` if `key` is not found and `default` not specified.
7469 * `get_np_group(key)`: returns a NoiseParams table
7470 * `get_flags(key)`:
7471     * Returns `{flag = true/false, ...}` according to the set flags.
7472     * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
7473       flags like `mgv5_spflags`.
7474 * `set(key, value)`
7475     * Setting names can't contain whitespace or any of `="{}#`.
7476     * Setting values can't contain the sequence `\n"""`.
7477     * Setting names starting with "secure." can't be set on the main settings
7478       object (`minetest.settings`).
7479 * `set_bool(key, value)`
7480     * See documentation for set() above.
7481 * `set_np_group(key, value)`
7482     * `value` is a NoiseParams table.
7483     * Also, see documentation for set() above.
7484 * `remove(key)`: returns a boolean (`true` for success)
7485 * `get_names()`: returns `{key1,...}`
7486 * `write()`: returns a boolean (`true` for success)
7487     * Writes changes to file.
7488 * `to_table()`: returns `{[key1]=value1,...}`
7489
7490 ### Format
7491
7492 The settings have the format `key = value`. Example:
7493
7494     foo = example text
7495     bar = """
7496     Multiline
7497     value
7498     """
7499
7500
7501 `StorageRef`
7502 ------------
7503
7504 Mod metadata: per mod metadata, saved automatically.
7505 Can be obtained via `minetest.get_mod_storage()` during load time.
7506
7507 WARNING: This storage backend is incapable of saving raw binary data due
7508 to restrictions of JSON.
7509
7510 ### Methods
7511
7512 * All methods in MetaDataRef
7513
7514
7515
7516
7517 Definition tables
7518 =================
7519
7520 Object properties
7521 -----------------
7522
7523 Used by `ObjectRef` methods. Part of an Entity definition.
7524 These properties are not persistent, but are applied automatically to the
7525 corresponding Lua entity using the given registration fields.
7526 Player properties need to be saved manually.
7527
7528     {
7529         hp_max = 10,
7530         -- Defines the maximum and default HP of the entity
7531         -- For Lua entities the maximum is not enforced.
7532         -- For players this defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
7533
7534         breath_max = 0,
7535         -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
7536
7537         zoom_fov = 0.0,
7538         -- For players only. Zoom FOV in degrees.
7539         -- Note that zoom loads and/or generates world beyond the server's
7540         -- maximum send and generate distances, so acts like a telescope.
7541         -- Smaller zoom_fov values increase the distance loaded/generated.
7542         -- Defaults to 15 in creative mode, 0 in survival mode.
7543         -- zoom_fov = 0 disables zooming for the player.
7544
7545         eye_height = 1.625,
7546         -- For players only. Camera height above feet position in nodes.
7547
7548         physical = false,
7549         -- Collide with `walkable` nodes.
7550
7551         collide_with_objects = true,
7552         -- Collide with other objects if physical = true
7553
7554         collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
7555         selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
7556         -- Selection box uses collision box dimensions when not set.
7557         -- For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
7558         -- object position.
7559
7560         pointable = true,
7561         -- Whether the object can be pointed at
7562
7563         visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
7564         -- "cube" is a node-sized cube.
7565         -- "sprite" is a flat texture always facing the player.
7566         -- "upright_sprite" is a vertical flat texture.
7567         -- "mesh" uses the defined mesh model.
7568         -- "wielditem" is used for dropped items.
7569         --   (see builtin/game/item_entity.lua).
7570         --   For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
7571         --   If the item has a 'wield_image' the object will be an extrusion of
7572         --   that, otherwise:
7573         --   If 'itemname' is a cubic node or nodebox the object will appear
7574         --   identical to 'itemname'.
7575         --   If 'itemname' is a plantlike node the object will be an extrusion
7576         --   of its texture.
7577         --   Otherwise for non-node items, the object will be an extrusion of
7578         --   'inventory_image'.
7579         --   If 'itemname' contains a ColorString or palette index (e.g. from
7580         --   `minetest.itemstring_with_palette()`), the entity will inherit the color.
7581         -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
7582
7583         visual_size = {x = 1, y = 1, z = 1},
7584         -- Multipliers for the visual size. If `z` is not specified, `x` will be used
7585         -- to scale the entity along both horizontal axes.
7586
7587         mesh = "model.obj",
7588         -- File name of mesh when using "mesh" visual
7589
7590         textures = {},
7591         -- Number of required textures depends on visual.
7592         -- "cube" uses 6 textures just like a node, but all 6 must be defined.
7593         -- "sprite" uses 1 texture.
7594         -- "upright_sprite" uses 2 textures: {front, back}.
7595         -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
7596         -- "mesh" requires one texture for each mesh buffer/material (in order)
7597
7598         colors = {},
7599         -- Number of required colors depends on visual
7600
7601         use_texture_alpha = false,
7602         -- Use texture's alpha channel.
7603         -- Excludes "upright_sprite" and "wielditem".
7604         -- Note: currently causes visual issues when viewed through other
7605         -- semi-transparent materials such as water.
7606
7607         spritediv = {x = 1, y = 1},
7608         -- Used with spritesheet textures for animation and/or frame selection
7609         -- according to position relative to player.
7610         -- Defines the number of columns and rows in the spritesheet:
7611         -- {columns, rows}.
7612
7613         initial_sprite_basepos = {x = 0, y = 0},
7614         -- Used with spritesheet textures.
7615         -- Defines the {column, row} position of the initially used frame in the
7616         -- spritesheet.
7617
7618         is_visible = true,
7619         -- If false, object is invisible and can't be pointed.
7620
7621         makes_footstep_sound = false,
7622         -- If true, is able to make footstep sounds of nodes
7623         -- (see node sound definition for details).
7624
7625         automatic_rotate = 0,
7626         -- Set constant rotation in radians per second, positive or negative.
7627         -- Object rotates along the local Y-axis, and works with set_rotation.
7628         -- Set to 0 to disable constant rotation.
7629
7630         stepheight = 0,
7631         -- If positive number, object will climb upwards when it moves
7632         -- horizontally against a `walkable` node, if the height difference
7633         -- is within `stepheight`.
7634
7635         automatic_face_movement_dir = 0.0,
7636         -- Automatically set yaw to movement direction, offset in degrees.
7637         -- 'false' to disable.
7638
7639         automatic_face_movement_max_rotation_per_sec = -1,
7640         -- Limit automatic rotation to this value in degrees per second.
7641         -- No limit if value <= 0.
7642
7643         backface_culling = true,
7644         -- Set to false to disable backface_culling for model
7645
7646         glow = 0,
7647         -- Add this much extra lighting when calculating texture color.
7648         -- Value < 0 disables light's effect on texture color.
7649         -- For faking self-lighting, UI style entities, or programmatic coloring
7650         -- in mods.
7651
7652         nametag = "",
7653         -- The name to display on the head of the object. By default empty.
7654         -- If the object is a player, a nil or empty nametag is replaced by the player's name.
7655         -- For all other objects, a nil or empty string removes the nametag.
7656         -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
7657
7658         nametag_color = <ColorSpec>,
7659         -- Sets text color of nametag
7660
7661         nametag_bgcolor = <ColorSpec>,
7662         -- Sets background color of nametag
7663         -- `false` will cause the background to be set automatically based on user settings.
7664         -- Default: false
7665
7666         infotext = "",
7667         -- Same as infotext for nodes. Empty by default
7668
7669         static_save = true,
7670         -- If false, never save this object statically. It will simply be
7671         -- deleted when the block gets unloaded.
7672         -- The get_staticdata() callback is never called then.
7673         -- Defaults to 'true'.
7674
7675         damage_texture_modifier = "^[brighten",
7676         -- Texture modifier to be applied for a short duration when object is hit
7677
7678         shaded = true,
7679         -- Setting this to 'false' disables diffuse lighting of entity
7680
7681         show_on_minimap = false,
7682         -- Defaults to true for players, false for other entities.
7683         -- If set to true the entity will show as a marker on the minimap.
7684     }
7685
7686 Entity definition
7687 -----------------
7688
7689 Used by `minetest.register_entity`.
7690
7691     {
7692         initial_properties = {
7693             visual = "mesh",
7694             mesh = "boats_boat.obj",
7695             ...,
7696         },
7697         -- A table of object properties, see the `Object properties` section.
7698         -- The properties in this table are applied to the object
7699         -- once when it is spawned.
7700
7701         -- Refer to the "Registered entities" section for explanations
7702         on_activate = function(self, staticdata, dtime_s),
7703         on_deactivate = function(self, removal),
7704         on_step = function(self, dtime, moveresult),
7705         on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage),
7706         on_death = function(self, killer),
7707         on_rightclick = function(self, clicker),
7708         on_attach_child = function(self, child),
7709         on_detach_child = function(self, child),
7710         on_detach = function(self, parent),
7711         get_staticdata = function(self),
7712
7713         _custom_field = whatever,
7714         -- You can define arbitrary member variables here (see Item definition
7715         -- for more info) by using a '_' prefix
7716     }
7717
7718
7719 ABM (ActiveBlockModifier) definition
7720 ------------------------------------
7721
7722 Used by `minetest.register_abm`.
7723
7724     {
7725         label = "Lava cooling",
7726         -- Descriptive label for profiling purposes (optional).
7727         -- Definitions with identical labels will be listed as one.
7728
7729         nodenames = {"default:lava_source"},
7730         -- Apply `action` function to these nodes.
7731         -- `group:groupname` can also be used here.
7732
7733         neighbors = {"default:water_source", "default:water_flowing"},
7734         -- Only apply `action` to nodes that have one of, or any
7735         -- combination of, these neighbors.
7736         -- If left out or empty, any neighbor will do.
7737         -- `group:groupname` can also be used here.
7738
7739         interval = 1.0,
7740         -- Operation interval in seconds
7741
7742         chance = 1,
7743         -- Chance of triggering `action` per-node per-interval is 1.0 / this
7744         -- value
7745
7746         min_y = -32768,
7747         max_y = 32767,
7748         -- min and max height levels where ABM will be processed (inclusive)
7749         -- can be used to reduce CPU usage
7750
7751         catch_up = true,
7752         -- If true, catch-up behaviour is enabled: The `chance` value is
7753         -- temporarily reduced when returning to an area to simulate time lost
7754         -- by the area being unattended. Note that the `chance` value can often
7755         -- be reduced to 1.
7756
7757         action = function(pos, node, active_object_count, active_object_count_wider),
7758         -- Function triggered for each qualifying node.
7759         -- `active_object_count` is number of active objects in the node's
7760         -- mapblock.
7761         -- `active_object_count_wider` is number of active objects in the node's
7762         -- mapblock plus all 26 neighboring mapblocks. If any neighboring
7763         -- mapblocks are unloaded an estmate is calculated for them based on
7764         -- loaded mapblocks.
7765     }
7766
7767 LBM (LoadingBlockModifier) definition
7768 -------------------------------------
7769
7770 Used by `minetest.register_lbm`.
7771
7772 A loading block modifier (LBM) is used to define a function that is called for
7773 specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
7774 gets activated (not loaded!)
7775
7776     {
7777         label = "Upgrade legacy doors",
7778         -- Descriptive label for profiling purposes (optional).
7779         -- Definitions with identical labels will be listed as one.
7780
7781         name = "modname:replace_legacy_door",
7782         -- Identifier of the LBM, should follow the modname:<whatever> convention
7783
7784         nodenames = {"default:lava_source"},
7785         -- List of node names to trigger the LBM on.
7786         -- Names of non-registered nodes and groups (as group:groupname)
7787         -- will work as well.
7788
7789         run_at_every_load = false,
7790         -- Whether to run the LBM's action every time a block gets activated,
7791         -- and not only the first time the block gets activated after the LBM
7792         -- was introduced.
7793
7794         action = function(pos, node),
7795         -- Function triggered for each qualifying node.
7796     }
7797
7798 Tile definition
7799 ---------------
7800
7801 * `"image.png"`
7802 * `{name="image.png", animation={Tile Animation definition}}`
7803 * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
7804     * backface culling enabled by default for most nodes
7805     * align style determines whether the texture will be rotated with the node
7806       or kept aligned with its surroundings. "user" means that client
7807       setting will be used, similar to `glasslike_framed_optional`.
7808       Note: supported by solid nodes and nodeboxes only.
7809     * scale is used to make texture span several (exactly `scale`) nodes,
7810       instead of just one, in each direction. Works for world-aligned
7811       textures only.
7812       Note that as the effect is applied on per-mapblock basis, `16` should
7813       be equally divisible by `scale` or you may get wrong results.
7814 * `{name="image.png", color=ColorSpec}`
7815     * the texture's color will be multiplied with this color.
7816     * the tile's color overrides the owning node's color in all cases.
7817 * deprecated, yet still supported field names:
7818     * `image` (name)
7819
7820 Tile animation definition
7821 -------------------------
7822
7823     {
7824         type = "vertical_frames",
7825
7826         aspect_w = 16,
7827         -- Width of a frame in pixels
7828
7829         aspect_h = 16,
7830         -- Height of a frame in pixels
7831
7832         length = 3.0,
7833         -- Full loop length
7834     }
7835
7836     {
7837         type = "sheet_2d",
7838
7839         frames_w = 5,
7840         -- Width in number of frames
7841
7842         frames_h = 3,
7843         -- Height in number of frames
7844
7845         frame_length = 0.5,
7846         -- Length of a single frame
7847     }
7848
7849 Item definition
7850 ---------------
7851
7852 Used by `minetest.register_node`, `minetest.register_craftitem`, and
7853 `minetest.register_tool`.
7854
7855     {
7856         description = "",
7857         -- Can contain new lines. "\n" has to be used as new line character.
7858         -- See also: `get_description` in [`ItemStack`]
7859
7860         short_description = "",
7861         -- Must not contain new lines.
7862         -- Defaults to nil.
7863         -- Use an [`ItemStack`] to get the short description, e.g.:
7864         --   ItemStack(itemname):get_short_description()
7865
7866         groups = {},
7867         -- key = name, value = rating; rating = <number>.
7868         -- If rating not applicable, use 1.
7869         -- e.g. {wool = 1, fluffy = 3}
7870         --      {soil = 2, outerspace = 1, crumbly = 1}
7871         --      {bendy = 2, snappy = 1},
7872         --      {hard = 1, metal = 1, spikes = 1}
7873
7874         inventory_image = "",
7875         -- Texture shown in the inventory GUI
7876         -- Defaults to a 3D rendering of the node if left empty.
7877
7878         inventory_overlay = "",
7879         -- An overlay texture which is not affected by colorization
7880
7881         wield_image = "",
7882         -- Texture shown when item is held in hand
7883         -- Defaults to a 3D rendering of the node if left empty.
7884
7885         wield_overlay = "",
7886         -- Like inventory_overlay but only used in the same situation as wield_image
7887
7888         wield_scale = {x = 1, y = 1, z = 1},
7889         -- Scale for the item when held in hand
7890
7891         palette = "",
7892         -- An image file containing the palette of a node.
7893         -- You can set the currently used color as the "palette_index" field of
7894         -- the item stack metadata.
7895         -- The palette is always stretched to fit indices between 0 and 255, to
7896         -- ensure compatibility with "colorfacedir" and "colorwallmounted" nodes.
7897
7898         color = "#ffffffff",
7899         -- Color the item is colorized with. The palette overrides this.
7900
7901         stack_max = 99,
7902         -- Maximum amount of items that can be in a single stack.
7903         -- The default can be changed by the setting `default_stack_max`
7904
7905         range = 4.0,
7906         -- Range of node and object pointing that is possible with this item held
7907
7908         liquids_pointable = false,
7909         -- If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
7910         -- even those for which `pointable = false`
7911
7912         light_source = 0,
7913         -- When used for nodes: Defines amount of light emitted by node.
7914         -- Otherwise: Defines texture glow when viewed as a dropped item
7915         -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
7916         -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
7917         -- behavior.
7918
7919         -- See "Tool Capabilities" section for an example including explanation
7920         tool_capabilities = {
7921             full_punch_interval = 1.0,
7922             max_drop_level = 0,
7923             groupcaps = {
7924                 -- For example:
7925                 choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
7926             },
7927             damage_groups = {groupname = damage},
7928             -- Damage values must be between -32768 and 32767 (2^15)
7929
7930             punch_attack_uses = nil,
7931             -- Amount of uses this tool has for attacking players and entities
7932             -- by punching them (0 = infinite uses).
7933             -- For compatibility, this is automatically set from the first
7934             -- suitable groupcap using the forumla "uses * 3^(maxlevel - 1)".
7935             -- It is recommend to set this explicitly instead of relying on the
7936             -- fallback behavior.
7937         },
7938
7939         node_placement_prediction = nil,
7940         -- If nil and item is node, prediction is made automatically.
7941         -- If nil and item is not a node, no prediction is made.
7942         -- If "" and item is anything, no prediction is made.
7943         -- Otherwise should be name of node which the client immediately places
7944         -- on ground when the player places the item. Server will always update
7945         -- with actual result shortly.
7946
7947         node_dig_prediction = "air",
7948         -- if "", no prediction is made.
7949         -- if "air", node is removed.
7950         -- Otherwise should be name of node which the client immediately places
7951         -- upon digging. Server will always update with actual result shortly.
7952
7953         sound = {
7954             -- Definition of item sounds to be played at various events.
7955             -- All fields in this table are optional.
7956
7957             breaks = <SimpleSoundSpec>,
7958             -- When tool breaks due to wear. Ignored for non-tools
7959
7960             eat = <SimpleSoundSpec>,
7961             -- When item is eaten with `minetest.do_item_eat`
7962         },
7963
7964         on_place = function(itemstack, placer, pointed_thing),
7965         -- When the 'place' key was pressed with the item in hand
7966         -- and a node was pointed at.
7967         -- Shall place item and return the leftover itemstack
7968         -- or nil to not modify the inventory.
7969         -- The placer may be any ObjectRef or nil.
7970         -- default: minetest.item_place
7971
7972         on_secondary_use = function(itemstack, user, pointed_thing),
7973         -- Same as on_place but called when not pointing at a node.
7974         -- Function must return either nil if inventory shall not be modified,
7975         -- or an itemstack to replace the original itemstack.
7976         -- The user may be any ObjectRef or nil.
7977         -- default: nil
7978
7979         on_drop = function(itemstack, dropper, pos),
7980         -- Shall drop item and return the leftover itemstack.
7981         -- The dropper may be any ObjectRef or nil.
7982         -- default: minetest.item_drop
7983
7984         on_use = function(itemstack, user, pointed_thing),
7985         -- default: nil
7986         -- When user pressed the 'punch/mine' key with the item in hand.
7987         -- Function must return either nil if inventory shall not be modified,
7988         -- or an itemstack to replace the original itemstack.
7989         -- e.g. itemstack:take_item(); return itemstack
7990         -- Otherwise, the function is free to do what it wants.
7991         -- The user may be any ObjectRef or nil.
7992         -- The default functions handle regular use cases.
7993
7994         after_use = function(itemstack, user, node, digparams),
7995         -- default: nil
7996         -- If defined, should return an itemstack and will be called instead of
7997         -- wearing out the item (if tool). If returns nil, does nothing.
7998         -- If after_use doesn't exist, it is the same as:
7999         --   function(itemstack, user, node, digparams)
8000         --     itemstack:add_wear(digparams.wear)
8001         --     return itemstack
8002         --   end
8003         -- The user may be any ObjectRef or nil.
8004
8005         _custom_field = whatever,
8006         -- Add your own custom fields. By convention, all custom field names
8007         -- should start with `_` to avoid naming collisions with future engine
8008         -- usage.
8009     }
8010
8011 Node definition
8012 ---------------
8013
8014 Used by `minetest.register_node`.
8015
8016     {
8017         -- <all fields allowed in item definitions>
8018
8019         drawtype = "normal",  -- See "Node drawtypes"
8020
8021         visual_scale = 1.0,
8022         -- Supported for drawtypes "plantlike", "signlike", "torchlike",
8023         -- "firelike", "mesh", "nodebox", "allfaces".
8024         -- For plantlike and firelike, the image will start at the bottom of the
8025         -- node. For torchlike, the image will start at the surface to which the
8026         -- node "attaches". For the other drawtypes the image will be centered
8027         -- on the node.
8028
8029         tiles = {tile definition 1, def2, def3, def4, def5, def6},
8030         -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
8031         -- List can be shortened to needed length.
8032
8033         overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
8034         -- Same as `tiles`, but these textures are drawn on top of the base
8035         -- tiles. You can use this to colorize only specific parts of your
8036         -- texture. If the texture name is an empty string, that overlay is not
8037         -- drawn. Since such tiles are drawn twice, it is not recommended to use
8038         -- overlays on very common nodes.
8039
8040         special_tiles = {tile definition 1, Tile definition 2},
8041         -- Special textures of node; used rarely.
8042         -- List can be shortened to needed length.
8043
8044         color = ColorSpec,
8045         -- The node's original color will be multiplied with this color.
8046         -- If the node has a palette, then this setting only has an effect in
8047         -- the inventory and on the wield item.
8048
8049         use_texture_alpha = ...,
8050         -- Specifies how the texture's alpha channel will be used for rendering.
8051         -- possible values:
8052         -- * "opaque": Node is rendered opaque regardless of alpha channel
8053         -- * "clip": A given pixel is either fully see-through or opaque
8054         --           depending on the alpha channel being below/above 50% in value
8055         -- * "blend": The alpha channel specifies how transparent a given pixel
8056         --            of the rendered node is
8057         -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
8058         -- "clip" otherwise.
8059         -- If set to a boolean value (deprecated): true either sets it to blend
8060         -- or clip, false sets it to clip or opaque mode depending on the drawtype.
8061
8062         palette = "",
8063         -- The node's `param2` is used to select a pixel from the image.
8064         -- Pixels are arranged from left to right and from top to bottom.
8065         -- The node's color will be multiplied with the selected pixel's color.
8066         -- Tiles can override this behavior.
8067         -- Only when `paramtype2` supports palettes.
8068
8069         post_effect_color = "#00000000",
8070         -- Screen tint if player is inside node, see "ColorSpec"
8071
8072         paramtype = "none",  -- See "Nodes"
8073
8074         paramtype2 = "none",  -- See "Nodes"
8075
8076         place_param2 = 0,
8077         -- Value for param2 that is set when player places node
8078
8079         is_ground_content = true,
8080         -- If false, the cave generator and dungeon generator will not carve
8081         -- through this node.
8082         -- Specifically, this stops mod-added nodes being removed by caves and
8083         -- dungeons when those generate in a neighbor mapchunk and extend out
8084         -- beyond the edge of that mapchunk.
8085
8086         sunlight_propagates = false,
8087         -- If true, sunlight will go infinitely through this node
8088
8089         walkable = true,  -- If true, objects collide with node
8090
8091         pointable = true,  -- If true, can be pointed at
8092
8093         diggable = true,  -- If false, can never be dug
8094
8095         climbable = false,  -- If true, can be climbed on like a ladder
8096
8097         move_resistance = 0,
8098         -- Slows down movement of players through this node (max. 7).
8099         -- If this is nil, it will be equal to liquid_viscosity.
8100         -- Note: If liquid movement physics apply to the node
8101         -- (see `liquid_move_physics`), the movement speed will also be
8102         -- affected by the `movement_liquid_*` settings.
8103
8104         buildable_to = false,  -- If true, placed nodes can replace this node
8105
8106         floodable = false,
8107         -- If true, liquids flow into and replace this node.
8108         -- Warning: making a liquid node 'floodable' will cause problems.
8109
8110         liquidtype = "none",  -- specifies liquid flowing physics
8111         -- * "none":    no liquid flowing physics
8112         -- * "source":  spawns flowing liquid nodes at all 4 sides and below;
8113         --              recommended drawtype: "liquid".
8114         -- * "flowing": spawned from source, spawns more flowing liquid nodes
8115         --              around it until `liquid_range` is reached;
8116         --              will drain out without a source;
8117         --              recommended drawtype: "flowingliquid".
8118         -- If it's "source" or "flowing" and `liquid_range > 0`, then
8119         -- both `liquid_alternative_*` fields must be specified
8120
8121         liquid_alternative_flowing = "",
8122         -- Node that represents the flowing version of the liquid
8123
8124         liquid_alternative_source = "",
8125         -- Node that represents the source version of the liquid
8126
8127         liquid_viscosity = 0,
8128         -- Controls speed at which the liquid spreads/flows (max. 7).
8129         -- 0 is fastest, 7 is slowest.
8130         -- By default, this also slows down movement of players inside the node
8131         -- (can be overridden using `move_resistance`)
8132
8133         liquid_renewable = true,
8134         -- If true, a new liquid source can be created by placing two or more
8135         -- sources nearby
8136
8137         liquid_move_physics = nil, -- specifies movement physics if inside node
8138         -- * false: No liquid movement physics apply.
8139         -- * true: Enables liquid movement physics. Enables things like
8140         --   ability to "swim" up/down, sinking slowly if not moving,
8141         --   smoother speed change when falling into, etc. The `movement_liquid_*`
8142         --   settings apply.
8143         -- * nil: Will be treated as true if `liquidype ~= "none"`
8144         --   and as false otherwise.
8145
8146         leveled = 0,
8147         -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
8148         -- Allows defining the nodebox height without using param2.
8149         -- The nodebox height is 'leveled' / 64 nodes.
8150         -- The maximum value of 'leveled' is `leveled_max`.
8151
8152         leveled_max = 127,
8153         -- Maximum value for `leveled` (0-127), enforced in
8154         -- `minetest.set_node_level` and `minetest.add_node_level`.
8155         -- Values above 124 might causes collision detection issues.
8156
8157         liquid_range = 8,
8158         -- Maximum distance that flowing liquid nodes can spread around
8159         -- source on flat land;
8160         -- maximum = 8; set to 0 to disable liquid flow
8161
8162         drowning = 0,
8163         -- Player will take this amount of damage if no bubbles are left
8164
8165         damage_per_second = 0,
8166         -- If player is inside node, this damage is caused
8167
8168         node_box = {type = "regular"},  -- See "Node boxes"
8169
8170         connects_to = {},
8171         -- Used for nodebox nodes with the type == "connected".
8172         -- Specifies to what neighboring nodes connections will be drawn.
8173         -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
8174
8175         connect_sides = {},
8176         -- Tells connected nodebox nodes to connect only to these sides of this
8177         -- node. possible: "top", "bottom", "front", "left", "back", "right"
8178
8179         mesh = "",
8180         -- File name of mesh when using "mesh" drawtype
8181
8182         selection_box = {
8183             -- see [Node boxes] for possibilities
8184         },
8185         -- Custom selection box definition. Multiple boxes can be defined.
8186         -- If "nodebox" drawtype is used and selection_box is nil, then node_box
8187         -- definition is used for the selection box.
8188
8189         collision_box = {
8190             -- see [Node boxes] for possibilities
8191         },
8192         -- Custom collision box definition. Multiple boxes can be defined.
8193         -- If "nodebox" drawtype is used and collision_box is nil, then node_box
8194         -- definition is used for the collision box.
8195
8196         -- Support maps made in and before January 2012
8197         legacy_facedir_simple = false,
8198         legacy_wallmounted = false,
8199
8200         waving = 0,
8201         -- Valid for drawtypes:
8202         -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
8203         -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
8204         -- 2 - wave node like leaves (whole node moves side-to-side)
8205         -- 3 - wave node like liquids (whole node moves up and down)
8206         -- Not all models will properly wave.
8207         -- plantlike drawtype can only wave like plants.
8208         -- allfaces_optional drawtype can only wave like leaves.
8209         -- liquid, flowingliquid drawtypes can only wave like liquids.
8210
8211         sounds = {
8212             -- Definition of node sounds to be played at various events.
8213             -- All fields in this table are optional.
8214
8215             footstep = <SimpleSoundSpec>,
8216             -- If walkable, played when object walks on it. If node is
8217             -- climbable or a liquid, played when object moves through it
8218
8219             dig = <SimpleSoundSpec> or "__group",
8220             -- While digging node.
8221             -- If `"__group"`, then the sound will be
8222             -- `default_dig_<groupname>`, where `<groupname>` is the
8223             -- name of the item's digging group with the fastest digging time.
8224             -- In case of a tie, one of the sounds will be played (but we
8225             -- cannot predict which one)
8226             -- Default value: `"__group"`
8227
8228             dug = <SimpleSoundSpec>,
8229             -- Node was dug
8230
8231             place = <SimpleSoundSpec>,
8232             -- Node was placed. Also played after falling
8233
8234             place_failed = <SimpleSoundSpec>,
8235             -- When node placement failed.
8236             -- Note: This happens if the _built-in_ node placement failed.
8237             -- This sound will still be played if the node is placed in the
8238             -- `on_place` callback manually.
8239
8240             fall = <SimpleSoundSpec>,
8241             -- When node starts to fall or is detached
8242         },
8243
8244         drop = "",
8245         -- Name of dropped item when dug.
8246         -- Default dropped item is the node itself.
8247
8248         -- Using a table allows multiple items, drop chances and item filtering:
8249         drop = {
8250             max_items = 1,
8251             -- Maximum number of item lists to drop.
8252             -- The entries in 'items' are processed in order. For each:
8253             -- Item filtering is applied, chance of drop is applied, if both are
8254             -- successful the entire item list is dropped.
8255             -- Entry processing continues until the number of dropped item lists
8256             -- equals 'max_items'.
8257             -- Therefore, entries should progress from low to high drop chance.
8258             items = {
8259                 -- Examples:
8260                 {
8261                     -- 1 in 1000 chance of dropping a diamond.
8262                     -- Default rarity is '1'.
8263                     rarity = 1000,
8264                     items = {"default:diamond"},
8265                 },
8266                 {
8267                     -- Only drop if using an item whose name is identical to one
8268                     -- of these.
8269                     tools = {"default:shovel_mese", "default:shovel_diamond"},
8270                     rarity = 5,
8271                     items = {"default:dirt"},
8272                     -- Whether all items in the dropped item list inherit the
8273                     -- hardware coloring palette color from the dug node.
8274                     -- Default is 'false'.
8275                     inherit_color = true,
8276                 },
8277                 {
8278                     -- Only drop if using an item whose name contains
8279                     -- "default:shovel_" (this item filtering by string matching
8280                     -- is deprecated, use tool_groups instead).
8281                     tools = {"~default:shovel_"},
8282                     rarity = 2,
8283                     -- The item list dropped.
8284                     items = {"default:sand", "default:desert_sand"},
8285                 },
8286                 {
8287                     -- Only drop if using an item in the "magicwand" group, or
8288                     -- an item that is in both the "pickaxe" and the "lucky"
8289                     -- groups.
8290                     tool_groups = {
8291                         "magicwand",
8292                         {"pickaxe", "lucky"}
8293                     },
8294                     items = {"default:coal_lump"},
8295                 },
8296             },
8297         },
8298
8299         on_construct = function(pos),
8300         -- Node constructor; called after adding node.
8301         -- Can set up metadata and stuff like that.
8302         -- Not called for bulk node placement (i.e. schematics and VoxelManip).
8303         -- default: nil
8304
8305         on_destruct = function(pos),
8306         -- Node destructor; called before removing node.
8307         -- Not called for bulk node placement.
8308         -- default: nil
8309
8310         after_destruct = function(pos, oldnode),
8311         -- Node destructor; called after removing node.
8312         -- Not called for bulk node placement.
8313         -- default: nil
8314
8315         on_flood = function(pos, oldnode, newnode),
8316         -- Called when a liquid (newnode) is about to flood oldnode, if it has
8317         -- `floodable = true` in the nodedef. Not called for bulk node placement
8318         -- (i.e. schematics and VoxelManip) or air nodes. If return true the
8319         -- node is not flooded, but on_flood callback will most likely be called
8320         -- over and over again every liquid update interval.
8321         -- Default: nil
8322         -- Warning: making a liquid node 'floodable' will cause problems.
8323
8324         preserve_metadata = function(pos, oldnode, oldmeta, drops),
8325         -- Called when oldnode is about be converted to an item, but before the
8326         -- node is deleted from the world or the drops are added. This is
8327         -- generally the result of either the node being dug or an attached node
8328         -- becoming detached.
8329         -- oldmeta are the metadata fields (table) of the node before deletion.
8330         -- drops is a table of ItemStacks, so any metadata to be preserved can
8331         -- be added directly to one or more of the dropped items. See
8332         -- "ItemStackMetaRef".
8333         -- default: nil
8334
8335         after_place_node = function(pos, placer, itemstack, pointed_thing),
8336         -- Called after constructing node when node was placed using
8337         -- minetest.item_place_node / minetest.place_node.
8338         -- If return true no item is taken from itemstack.
8339         -- `placer` may be any valid ObjectRef or nil.
8340         -- default: nil
8341
8342         after_dig_node = function(pos, oldnode, oldmetadata, digger),
8343         -- oldmetadata is in table format.
8344         -- Called after destructing node when node was dug using
8345         -- minetest.node_dig / minetest.dig_node.
8346         -- default: nil
8347
8348         can_dig = function(pos, [player]),
8349         -- Returns true if node can be dug, or false if not.
8350         -- default: nil
8351
8352         on_punch = function(pos, node, puncher, pointed_thing),
8353         -- default: minetest.node_punch
8354         -- Called when puncher (an ObjectRef) punches the node at pos.
8355         -- By default calls minetest.register_on_punchnode callbacks.
8356
8357         on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
8358         -- default: nil
8359         -- Called when clicker (an ObjectRef) used the 'place/build' key
8360         -- (not neccessarily an actual rightclick)
8361         -- while pointing at the node at pos with 'node' being the node table.
8362         -- itemstack will hold clicker's wielded item.
8363         -- Shall return the leftover itemstack.
8364         -- Note: pointed_thing can be nil, if a mod calls this function.
8365         -- This function does not get triggered by clients <=0.4.16 if the
8366         -- "formspec" node metadata field is set.
8367
8368         on_dig = function(pos, node, digger),
8369         -- default: minetest.node_dig
8370         -- By default checks privileges, wears out item (if tool) and removes node.
8371         -- return true if the node was dug successfully, false otherwise.
8372         -- Deprecated: returning nil is the same as returning true.
8373
8374         on_timer = function(pos, elapsed),
8375         -- default: nil
8376         -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
8377         -- elapsed is the total time passed since the timer was started.
8378         -- return true to run the timer for another cycle with the same timeout
8379         -- value.
8380
8381         on_receive_fields = function(pos, formname, fields, sender),
8382         -- fields = {name1 = value1, name2 = value2, ...}
8383         -- Called when an UI form (e.g. sign text input) returns data.
8384         -- See minetest.register_on_player_receive_fields for more info.
8385         -- default: nil
8386
8387         allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8388         -- Called when a player wants to move items inside the inventory.
8389         -- Return value: number of items allowed to move.
8390
8391         allow_metadata_inventory_put = function(pos, listname, index, stack, player),
8392         -- Called when a player wants to put something into the inventory.
8393         -- Return value: number of items allowed to put.
8394         -- Return value -1: Allow and don't modify item count in inventory.
8395
8396         allow_metadata_inventory_take = function(pos, listname, index, stack, player),
8397         -- Called when a player wants to take something out of the inventory.
8398         -- Return value: number of items allowed to take.
8399         -- Return value -1: Allow and don't modify item count in inventory.
8400
8401         on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8402         on_metadata_inventory_put = function(pos, listname, index, stack, player),
8403         on_metadata_inventory_take = function(pos, listname, index, stack, player),
8404         -- Called after the actual action has happened, according to what was
8405         -- allowed.
8406         -- No return value.
8407
8408         on_blast = function(pos, intensity),
8409         -- intensity: 1.0 = mid range of regular TNT.
8410         -- If defined, called when an explosion touches the node, instead of
8411         -- removing the node.
8412
8413         mod_origin = "modname",
8414         -- stores which mod actually registered a node
8415         -- If the source could not be determined it contains "??"
8416         -- Useful for getting which mod truly registered something
8417         -- example: if a node is registered as ":othermodname:nodename",
8418         -- nodename will show "othermodname", but mod_orgin will say "modname"
8419     }
8420
8421 Crafting recipes
8422 ----------------
8423
8424 Used by `minetest.register_craft`.
8425
8426 ### Shaped
8427
8428     {
8429         output = "default:pick_stone",
8430         recipe = {
8431             {"default:cobble", "default:cobble", "default:cobble"},
8432             {"", "default:stick", ""},
8433             {"", "default:stick", ""},  -- Also groups; e.g. "group:crumbly"
8434         },
8435         replacements = <list of item pairs>,
8436         -- replacements: replace one input item with another item on crafting
8437         -- (optional).
8438     }
8439
8440 ### Shapeless
8441
8442     {
8443         type = "shapeless",
8444         output = "mushrooms:mushroom_stew",
8445         recipe = {
8446             "mushrooms:bowl",
8447             "mushrooms:mushroom_brown",
8448             "mushrooms:mushroom_red",
8449         },
8450         replacements = <list of item pairs>,
8451     }
8452
8453 ### Tool repair
8454
8455     {
8456         type = "toolrepair",
8457         additional_wear = -0.02, -- multiplier of 65536
8458     }
8459
8460 Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
8461 group. Player can put 2 equal tools in the craft grid to get one "repaired" tool
8462 back.
8463 The wear of the output is determined by the wear of both tools, plus a
8464 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
8465 you want `additional_wear` to be negative.
8466
8467 The formula used to calculate the resulting wear is:
8468
8469     65536 * (1 - ( (1 - tool_1_wear) + (1 - tool_2_wear) + additional_wear ))
8470
8471 The result is rounded and can't be lower than 0. If the result is 65536 or higher,
8472 no crafting is possible.
8473
8474 ### Cooking
8475
8476     {
8477         type = "cooking",
8478         output = "default:glass",
8479         recipe = "default:sand",
8480         cooktime = 3,
8481     }
8482
8483 ### Furnace fuel
8484
8485     {
8486         type = "fuel",
8487         recipe = "bucket:bucket_lava",
8488         burntime = 60,
8489         replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
8490     }
8491
8492 The engine does not implement anything specific to cooking or fuels, but the
8493 recpies can be retrieved later using `minetest.get_craft_result` to have a
8494 consistent interface across different games/mods.
8495
8496 Ore definition
8497 --------------
8498
8499 Used by `minetest.register_ore`.
8500
8501 See [Ores] section above for essential information.
8502
8503     {
8504         ore_type = "",
8505         -- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
8506
8507         ore = "",
8508         -- Ore node to place
8509
8510         ore_param2 = 0,
8511         -- Param2 to set for ore (e.g. facedir rotation)
8512
8513         wherein = "",
8514         -- Node to place ore in. Multiple are possible by passing a list.
8515
8516         clust_scarcity = 8 * 8 * 8,
8517         -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
8518         -- If the desired average distance between ores is 'd', set this to
8519         -- d * d * d.
8520
8521         clust_num_ores = 8,
8522         -- Number of ores in a cluster
8523
8524         clust_size = 3,
8525         -- Size of the bounding box of the cluster.
8526         -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
8527         -- nodes are coal ore.
8528
8529         y_min = -31000,
8530         y_max = 31000,
8531         -- Lower and upper limits for ore (inclusive)
8532
8533         flags = "",
8534         -- Attributes for the ore generation, see 'Ore attributes' section above
8535
8536         noise_threshold = 0,
8537         -- If noise is above this threshold, ore is placed. Not needed for a
8538         -- uniform distribution.
8539
8540         noise_params = {
8541             offset = 0,
8542             scale = 1,
8543             spread = {x = 100, y = 100, z = 100},
8544             seed = 23,
8545             octaves = 3,
8546             persistence = 0.7
8547         },
8548         -- NoiseParams structure describing one of the perlin noises used for
8549         -- ore distribution.
8550         -- Needed by "sheet", "puff", "blob" and "vein" ores.
8551         -- Omit from "scatter" ore for a uniform ore distribution.
8552         -- Omit from "stratum" ore for a simple horizontal strata from y_min to
8553         -- y_max.
8554
8555         biomes = {"desert", "rainforest"},
8556         -- List of biomes in which this ore occurs.
8557         -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
8558         -- being used does not support biomes.
8559         -- Can be a list of (or a single) biome names, IDs, or definitions.
8560
8561         -- Type-specific parameters
8562
8563         -- "sheet"
8564         column_height_min = 1,
8565         column_height_max = 16,
8566         column_midpoint_factor = 0.5,
8567
8568         -- "puff"
8569         np_puff_top = {
8570             offset = 4,
8571             scale = 2,
8572             spread = {x = 100, y = 100, z = 100},
8573             seed = 47,
8574             octaves = 3,
8575             persistence = 0.7
8576         },
8577         np_puff_bottom = {
8578             offset = 4,
8579             scale = 2,
8580             spread = {x = 100, y = 100, z = 100},
8581             seed = 11,
8582             octaves = 3,
8583             persistence = 0.7
8584         },
8585
8586         -- "vein"
8587         random_factor = 1.0,
8588
8589         -- "stratum"
8590         np_stratum_thickness = {
8591             offset = 8,
8592             scale = 4,
8593             spread = {x = 100, y = 100, z = 100},
8594             seed = 17,
8595             octaves = 3,
8596             persistence = 0.7
8597         },
8598         stratum_thickness = 8, -- only used if no noise defined
8599     }
8600
8601 Biome definition
8602 ----------------
8603
8604 Used by `minetest.register_biome`.
8605
8606 The maximum number of biomes that can be used is 65535. However, using an
8607 excessive number of biomes will slow down map generation. Depending on desired
8608 performance and computing power the practical limit is much lower.
8609
8610     {
8611         name = "tundra",
8612
8613         node_dust = "default:snow",
8614         -- Node dropped onto upper surface after all else is generated
8615
8616         node_top = "default:dirt_with_snow",
8617         depth_top = 1,
8618         -- Node forming surface layer of biome and thickness of this layer
8619
8620         node_filler = "default:permafrost",
8621         depth_filler = 3,
8622         -- Node forming lower layer of biome and thickness of this layer
8623
8624         node_stone = "default:bluestone",
8625         -- Node that replaces all stone nodes between roughly y_min and y_max.
8626
8627         node_water_top = "default:ice",
8628         depth_water_top = 10,
8629         -- Node forming a surface layer in seawater with the defined thickness
8630
8631         node_water = "",
8632         -- Node that replaces all seawater nodes not in the surface layer
8633
8634         node_river_water = "default:ice",
8635         -- Node that replaces river water in mapgens that use
8636         -- default:river_water
8637
8638         node_riverbed = "default:gravel",
8639         depth_riverbed = 2,
8640         -- Node placed under river water and thickness of this layer
8641
8642         node_cave_liquid = "default:lava_source",
8643         node_cave_liquid = {"default:water_source", "default:lava_source"},
8644         -- Nodes placed inside 50% of the medium size caves.
8645         -- Multiple nodes can be specified, each cave will use a randomly
8646         -- chosen node from the list.
8647         -- If this field is left out or 'nil', cave liquids fall back to
8648         -- classic behaviour of lava and water distributed using 3D noise.
8649         -- For no cave liquid, specify "air".
8650
8651         node_dungeon = "default:cobble",
8652         -- Node used for primary dungeon structure.
8653         -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
8654         -- alias, if that is also absent, dungeon nodes fall back to the biome
8655         -- 'node_stone'.
8656         -- If present, the following two nodes are also used.
8657
8658         node_dungeon_alt = "default:mossycobble",
8659         -- Node used for randomly-distributed alternative structure nodes.
8660         -- If alternative structure nodes are not wanted leave this absent.
8661
8662         node_dungeon_stair = "stairs:stair_cobble",
8663         -- Node used for dungeon stairs.
8664         -- If absent, stairs fall back to 'node_dungeon'.
8665
8666         y_max = 31000,
8667         y_min = 1,
8668         -- Upper and lower limits for biome.
8669         -- Alternatively you can use xyz limits as shown below.
8670
8671         max_pos = {x = 31000, y = 128, z = 31000},
8672         min_pos = {x = -31000, y = 9, z = -31000},
8673         -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
8674         -- Biome is limited to a cuboid defined by these positions.
8675         -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
8676         -- 31000 in 'max_pos'.
8677
8678         vertical_blend = 8,
8679         -- Vertical distance in nodes above 'y_max' over which the biome will
8680         -- blend with the biome above.
8681         -- Set to 0 for no vertical blend. Defaults to 0.
8682
8683         heat_point = 0,
8684         humidity_point = 50,
8685         -- Characteristic temperature and humidity for the biome.
8686         -- These values create 'biome points' on a voronoi diagram with heat and
8687         -- humidity as axes. The resulting voronoi cells determine the
8688         -- distribution of the biomes.
8689         -- Heat and humidity have average values of 50, vary mostly between
8690         -- 0 and 100 but can exceed these values.
8691     }
8692
8693 Decoration definition
8694 ---------------------
8695
8696 See [Decoration types]. Used by `minetest.register_decoration`.
8697
8698     {
8699         deco_type = "simple",
8700         -- Type. "simple" or "schematic" supported
8701
8702         place_on = "default:dirt_with_grass",
8703         -- Node (or list of nodes) that the decoration can be placed on
8704
8705         sidelen = 8,
8706         -- Size of the square (X / Z) divisions of the mapchunk being generated.
8707         -- Determines the resolution of noise variation if used.
8708         -- If the chunk size is not evenly divisible by sidelen, sidelen is made
8709         -- equal to the chunk size.
8710
8711         fill_ratio = 0.02,
8712         -- The value determines 'decorations per surface node'.
8713         -- Used only if noise_params is not specified.
8714         -- If >= 10.0 complete coverage is enabled and decoration placement uses
8715         -- a different and much faster method.
8716
8717         noise_params = {
8718             offset = 0,
8719             scale = 0.45,
8720             spread = {x = 100, y = 100, z = 100},
8721             seed = 354,
8722             octaves = 3,
8723             persistence = 0.7,
8724             lacunarity = 2.0,
8725             flags = "absvalue"
8726         },
8727         -- NoiseParams structure describing the perlin noise used for decoration
8728         -- distribution.
8729         -- A noise value is calculated for each square division and determines
8730         -- 'decorations per surface node' within each division.
8731         -- If the noise value >= 10.0 complete coverage is enabled and
8732         -- decoration placement uses a different and much faster method.
8733
8734         biomes = {"Oceanside", "Hills", "Plains"},
8735         -- List of biomes in which this decoration occurs. Occurs in all biomes
8736         -- if this is omitted, and ignored if the Mapgen being used does not
8737         -- support biomes.
8738         -- Can be a list of (or a single) biome names, IDs, or definitions.
8739
8740         y_min = -31000,
8741         y_max = 31000,
8742         -- Lower and upper limits for decoration (inclusive).
8743         -- These parameters refer to the Y co-ordinate of the 'place_on' node.
8744
8745         spawn_by = "default:water",
8746         -- Node (or list of nodes) that the decoration only spawns next to.
8747         -- Checks the 8 neighbouring nodes on the same Y, and also the ones
8748         -- at Y+1, excluding both center nodes.
8749
8750         num_spawn_by = 1,
8751         -- Number of spawn_by nodes that must be surrounding the decoration
8752         -- position to occur.
8753         -- If absent or -1, decorations occur next to any nodes.
8754
8755         flags = "liquid_surface, force_placement, all_floors, all_ceilings",
8756         -- Flags for all decoration types.
8757         -- "liquid_surface": Instead of placement on the highest solid surface
8758         --   in a mapchunk column, placement is on the highest liquid surface.
8759         --   Placement is disabled if solid nodes are found above the liquid
8760         --   surface.
8761         -- "force_placement": Nodes other than "air" and "ignore" are replaced
8762         --   by the decoration.
8763         -- "all_floors", "all_ceilings": Instead of placement on the highest
8764         --   surface in a mapchunk the decoration is placed on all floor and/or
8765         --   ceiling surfaces, for example in caves and dungeons.
8766         --   Ceiling decorations act as an inversion of floor decorations so the
8767         --   effect of 'place_offset_y' is inverted.
8768         --   Y-slice probabilities do not function correctly for ceiling
8769         --   schematic decorations as the behaviour is unchanged.
8770         --   If a single decoration registration has both flags the floor and
8771         --   ceiling decorations will be aligned vertically.
8772
8773         ----- Simple-type parameters
8774
8775         decoration = "default:grass",
8776         -- The node name used as the decoration.
8777         -- If instead a list of strings, a randomly selected node from the list
8778         -- is placed as the decoration.
8779
8780         height = 1,
8781         -- Decoration height in nodes.
8782         -- If height_max is not 0, this is the lower limit of a randomly
8783         -- selected height.
8784
8785         height_max = 0,
8786         -- Upper limit of the randomly selected height.
8787         -- If absent, the parameter 'height' is used as a constant.
8788
8789         param2 = 0,
8790         -- Param2 value of decoration nodes.
8791         -- If param2_max is not 0, this is the lower limit of a randomly
8792         -- selected param2.
8793
8794         param2_max = 0,
8795         -- Upper limit of the randomly selected param2.
8796         -- If absent, the parameter 'param2' is used as a constant.
8797
8798         place_offset_y = 0,
8799         -- Y offset of the decoration base node relative to the standard base
8800         -- node position.
8801         -- Can be positive or negative. Default is 0.
8802         -- Effect is inverted for "all_ceilings" decorations.
8803         -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
8804         -- to the 'place_on' node.
8805
8806         ----- Schematic-type parameters
8807
8808         schematic = "foobar.mts",
8809         -- If schematic is a string, it is the filepath relative to the current
8810         -- working directory of the specified Minetest schematic file.
8811         -- Could also be the ID of a previously registered schematic.
8812
8813         schematic = {
8814             size = {x = 4, y = 6, z = 4},
8815             data = {
8816                 {name = "default:cobble", param1 = 255, param2 = 0},
8817                 {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
8818                 {name = "air", param1 = 255, param2 = 0},
8819                  ...
8820             },
8821             yslice_prob = {
8822                 {ypos = 2, prob = 128},
8823                 {ypos = 5, prob = 64},
8824                  ...
8825             },
8826         },
8827         -- Alternative schematic specification by supplying a table. The fields
8828         -- size and data are mandatory whereas yslice_prob is optional.
8829         -- See 'Schematic specifier' for details.
8830
8831         replacements = {["oldname"] = "convert_to", ...},
8832         -- Map of node names to replace in the schematic after reading it.
8833
8834         flags = "place_center_x, place_center_y, place_center_z",
8835         -- Flags for schematic decorations. See 'Schematic attributes'.
8836
8837         rotation = "90",
8838         -- Rotation can be "0", "90", "180", "270", or "random"
8839
8840         place_offset_y = 0,
8841         -- If the flag 'place_center_y' is set this parameter is ignored.
8842         -- Y offset of the schematic base node layer relative to the 'place_on'
8843         -- node.
8844         -- Can be positive or negative. Default is 0.
8845         -- Effect is inverted for "all_ceilings" decorations.
8846         -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
8847         -- to the 'place_on' node.
8848     }
8849
8850 Chat command definition
8851 -----------------------
8852
8853 Used by `minetest.register_chatcommand`.
8854
8855     {
8856         params = "<name> <privilege>",  -- Short parameter description
8857
8858         description = "Remove privilege from player",  -- Full description
8859
8860         privs = {privs=true},  -- Require the "privs" privilege to run
8861
8862         func = function(name, param),
8863         -- Called when command is run. Returns boolean success and text output.
8864         -- Special case: The help message is shown to the player if `func`
8865         -- returns false without a text output.
8866     }
8867
8868 Note that in params, use of symbols is as follows:
8869
8870 * `<>` signifies a placeholder to be replaced when the command is used. For
8871   example, when a player name is needed: `<name>`
8872 * `[]` signifies param is optional and not required when the command is used.
8873   For example, if you require param1 but param2 is optional:
8874   `<param1> [<param2>]`
8875 * `|` signifies exclusive or. The command requires one param from the options
8876   provided. For example: `<param1> | <param2>`
8877 * `()` signifies grouping. For example, when param1 and param2 are both
8878   required, or only param3 is required: `(<param1> <param2>) | <param3>`
8879
8880 Privilege definition
8881 --------------------
8882
8883 Used by `minetest.register_privilege`.
8884
8885     {
8886         description = "",
8887         -- Privilege description
8888
8889         give_to_singleplayer = true,
8890         -- Whether to grant the privilege to singleplayer.
8891
8892         give_to_admin = true,
8893         -- Whether to grant the privilege to the server admin.
8894         -- Uses value of 'give_to_singleplayer' by default.
8895
8896         on_grant = function(name, granter_name),
8897         -- Called when given to player 'name' by 'granter_name'.
8898         -- 'granter_name' will be nil if the priv was granted by a mod.
8899
8900         on_revoke = function(name, revoker_name),
8901         -- Called when taken from player 'name' by 'revoker_name'.
8902         -- 'revoker_name' will be nil if the priv was revoked by a mod.
8903
8904         -- Note that the above two callbacks will be called twice if a player is
8905         -- responsible, once with the player name, and then with a nil player
8906         -- name.
8907         -- Return true in the above callbacks to stop register_on_priv_grant or
8908         -- revoke being called.
8909     }
8910
8911 Detached inventory callbacks
8912 ----------------------------
8913
8914 Used by `minetest.create_detached_inventory`.
8915
8916     {
8917         allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
8918         -- Called when a player wants to move items inside the inventory.
8919         -- Return value: number of items allowed to move.
8920
8921         allow_put = function(inv, listname, index, stack, player),
8922         -- Called when a player wants to put something into the inventory.
8923         -- Return value: number of items allowed to put.
8924         -- Return value -1: Allow and don't modify item count in inventory.
8925
8926         allow_take = function(inv, listname, index, stack, player),
8927         -- Called when a player wants to take something out of the inventory.
8928         -- Return value: number of items allowed to take.
8929         -- Return value -1: Allow and don't modify item count in inventory.
8930
8931         on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
8932         on_put = function(inv, listname, index, stack, player),
8933         on_take = function(inv, listname, index, stack, player),
8934         -- Called after the actual action has happened, according to what was
8935         -- allowed.
8936         -- No return value.
8937     }
8938
8939 HUD Definition
8940 --------------
8941
8942 Since most values have multiple different functions, please see the
8943 documentation in [HUD] section.
8944
8945 Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
8946
8947     {
8948         hud_elem_type = "image",
8949         -- Type of element, can be "image", "text", "statbar", "inventory",
8950         -- "waypoint", "image_waypoint", "compass" or "minimap"
8951
8952         position = {x=0.5, y=0.5},
8953         -- Top left corner position of element
8954
8955         name = "<name>",
8956
8957         scale = {x = 1, y = 1},
8958
8959         text = "<text>",
8960
8961         text2 = "<text>",
8962
8963         number = 0,
8964
8965         item = 0,
8966
8967         direction = 0,
8968         -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
8969
8970         alignment = {x=0, y=0},
8971
8972         offset = {x=0, y=0},
8973
8974         world_pos = {x=0, y=0, z=0},
8975
8976         size = {x=0, y=0},
8977
8978         z_index = 0,
8979         -- Z index: lower z-index HUDs are displayed behind higher z-index HUDs
8980
8981         style = 0,
8982     }
8983
8984 Particle definition
8985 -------------------
8986
8987 Used by `minetest.add_particle`.
8988
8989     {
8990         pos = {x=0, y=0, z=0},
8991         velocity = {x=0, y=0, z=0},
8992         acceleration = {x=0, y=0, z=0},
8993         -- Spawn particle at pos with velocity and acceleration
8994
8995         expirationtime = 1,
8996         -- Disappears after expirationtime seconds
8997
8998         size = 1,
8999         -- Scales the visual size of the particle texture.
9000         -- If `node` is set, size can be set to 0 to spawn a randomly-sized
9001         -- particle (just like actual node dig particles).
9002
9003         collisiondetection = false,
9004         -- If true collides with `walkable` nodes and, depending on the
9005         -- `object_collision` field, objects too.
9006
9007         collision_removal = false,
9008         -- If true particle is removed when it collides.
9009         -- Requires collisiondetection = true to have any effect.
9010
9011         object_collision = false,
9012         -- If true particle collides with objects that are defined as
9013         -- `physical = true,` and `collide_with_objects = true,`.
9014         -- Requires collisiondetection = true to have any effect.
9015
9016         vertical = false,
9017         -- If true faces player using y axis only
9018
9019         texture = "image.png",
9020         -- The texture of the particle
9021         -- v5.6.0 and later: also supports the table format described in the
9022         -- following section
9023
9024         playername = "singleplayer",
9025         -- Optional, if specified spawns particle only on the player's client
9026
9027         animation = {Tile Animation definition},
9028         -- Optional, specifies how to animate the particle texture
9029
9030         glow = 0
9031         -- Optional, specify particle self-luminescence in darkness.
9032         -- Values 0-14.
9033
9034         node = {name = "ignore", param2 = 0},
9035         -- Optional, if specified the particle will have the same appearance as
9036         -- node dig particles for the given node.
9037         -- `texture` and `animation` will be ignored if this is set.
9038
9039         node_tile = 0,
9040         -- Optional, only valid in combination with `node`
9041         -- If set to a valid number 1-6, specifies the tile from which the
9042         -- particle texture is picked.
9043         -- Otherwise, the default behavior is used. (currently: any random tile)
9044
9045         drag = {x=0, y=0, z=0},
9046         -- v5.6.0 and later: Optional drag value, consult the following section
9047
9048         bounce = {min = ..., max = ..., bias = 0},
9049         -- v5.6.0 and later: Optional bounce range, consult the following section
9050     }
9051
9052
9053 `ParticleSpawner` definition
9054 ----------------------------
9055
9056 Used by `minetest.add_particlespawner`.
9057
9058 Before v5.6.0, particlespawners used a different syntax and had a more limited set
9059 of features. Definition fields that are the same in both legacy and modern versions
9060 are shown in the next listing, and the fields that are used by legacy versions are
9061 shown separated by a comment; the modern fields are too complex to compactly
9062 describe in this manner and are documented after the listing.
9063
9064 The older syntax can be used in combination with the newer syntax (e.g. having
9065 `minpos`, `maxpos`, and `pos` all set) to support older servers. On newer servers,
9066 the new syntax will override the older syntax; on older servers, the newer syntax
9067 will be ignored.
9068
9069     {
9070         -- Common fields (same name and meaning in both new and legacy syntax)
9071
9072         amount = 1,
9073         -- Number of particles spawned over the time period `time`.
9074
9075         time = 1,
9076         -- Lifespan of spawner in seconds.
9077         -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
9078         -- a per-second basis.
9079
9080         collisiondetection = false,
9081         -- If true collide with `walkable` nodes and, depending on the
9082         -- `object_collision` field, objects too.
9083
9084         collision_removal = false,
9085         -- If true particles are removed when they collide.
9086         -- Requires collisiondetection = true to have any effect.
9087
9088         object_collision = false,
9089         -- If true particles collide with objects that are defined as
9090         -- `physical = true,` and `collide_with_objects = true,`.
9091         -- Requires collisiondetection = true to have any effect.
9092
9093         attached = ObjectRef,
9094         -- If defined, particle positions, velocities and accelerations are
9095         -- relative to this object's position and yaw
9096
9097         vertical = false,
9098         -- If true face player using y axis only
9099
9100         texture = "image.png",
9101         -- The texture of the particle
9102
9103         playername = "singleplayer",
9104         -- Optional, if specified spawns particles only on the player's client
9105
9106         animation = {Tile Animation definition},
9107         -- Optional, specifies how to animate the particles' texture
9108         -- v5.6.0 and later: set length to -1 to sychronize the length
9109         -- of the animation with the expiration time of individual particles.
9110         -- (-2 causes the animation to be played twice, and so on)
9111
9112         glow = 0,
9113         -- Optional, specify particle self-luminescence in darkness.
9114         -- Values 0-14.
9115
9116         node = {name = "ignore", param2 = 0},
9117         -- Optional, if specified the particles will have the same appearance as
9118         -- node dig particles for the given node.
9119         -- `texture` and `animation` will be ignored if this is set.
9120
9121         node_tile = 0,
9122         -- Optional, only valid in combination with `node`
9123         -- If set to a valid number 1-6, specifies the tile from which the
9124         -- particle texture is picked.
9125         -- Otherwise, the default behavior is used. (currently: any random tile)
9126
9127         -- Legacy definition fields
9128
9129         minpos = {x=0, y=0, z=0},
9130         maxpos = {x=0, y=0, z=0},
9131         minvel = {x=0, y=0, z=0},
9132         maxvel = {x=0, y=0, z=0},
9133         minacc = {x=0, y=0, z=0},
9134         maxacc = {x=0, y=0, z=0},
9135         minexptime = 1,
9136         maxexptime = 1,
9137         minsize = 1,
9138         maxsize = 1,
9139         -- The particles' properties are random values between the min and max
9140         -- values.
9141         -- applies to: pos, velocity, acceleration, expirationtime, size
9142         -- If `node` is set, min and maxsize can be set to 0 to spawn
9143         -- randomly-sized particles (just like actual node dig particles).
9144     }
9145
9146 ### Modern definition fields
9147
9148 After v5.6.0, spawner properties can be defined in several different ways depending
9149 on the level of control you need. `pos` for instance can be set as a single vector,
9150 in which case all particles will appear at that exact point throughout the lifetime
9151 of the spawner. Alternately, it can be specified as a min-max pair, specifying a
9152 cubic range the particles can appear randomly within. Finally, some properties can
9153 be animated by suffixing their key with `_tween` (e.g. `pos_tween`) and supplying
9154 a tween table.
9155
9156 The following definitions are all equivalent, listed in order of precedence from
9157 lowest (the legacy syntax) to highest (tween tables). If multiple forms of a
9158 property definition are present, the highest-precidence form will be selected
9159 and all lower-precedence fields will be ignored, allowing for graceful
9160 degradation in older clients).
9161
9162     {
9163       -- old syntax
9164       maxpos = {x = 0, y = 0, z = 0},
9165       minpos = {x = 0, y = 0, z = 0},
9166
9167       -- absolute value
9168       pos = 0,
9169       -- all components of every particle's position vector will be set to this
9170       -- value
9171
9172       -- vec3
9173       pos = vector.new(0,0,0),
9174       -- all particles will appear at this exact position throughout the lifetime
9175       -- of the particlespawner
9176
9177       -- vec3 range
9178       pos = {
9179             -- the particle will appear at a position that is picked at random from
9180             -- within a cubic range
9181
9182             min = vector.new(0,0,0),
9183             -- `min` is the minimum value this property will be set to in particles
9184             -- spawned by the generator
9185
9186             max = vector.new(0,0,0),
9187             -- `max` is the minimum value this property will be set to in particles
9188             -- spawned by the generator
9189
9190             bias = 0,
9191             -- when `bias` is 0, all random values are exactly as likely as any
9192             -- other. when it is positive, the higher it is, the more likely values
9193             -- will appear towards the minimum end of the allowed spectrum. when
9194             -- it is negative, the lower it is, the more likely values will appear
9195             -- towards the maximum end of the allowed spectrum. the curve is
9196             -- exponential and there is no particular maximum or minimum value
9197         },
9198
9199         -- tween table
9200         pos_tween = {...},
9201         -- a tween table should consist of a list of frames in the same form as the
9202         -- untweened pos property above, which the engine will interpolate between,
9203         -- and optionally a number of properties that control how the interpolation
9204         -- takes place. currently **only two frames**, the first and the last, are
9205         -- used, but extra frames are accepted for the sake of forward compatibility.
9206         -- any of the above definition styles can be used here as well in any combination
9207         -- supported by the property type
9208
9209         pos_tween = {
9210             style = "fwd",
9211             -- linear animation from first to last frame (default)
9212             style = "rev",
9213             -- linear animation from last to first frame
9214             style = "pulse",
9215             -- linear animation from first to last then back to first again
9216             style = "flicker",
9217             -- like "pulse", but slightly randomized to add a bit of stutter
9218
9219             reps = 1,
9220             -- number of times the animation is played over the particle's lifespan
9221
9222             start = 0.0,
9223             -- point in the spawner's lifespan at which the animation begins. 0 is
9224             -- the very beginning, 1 is the very end
9225
9226             -- frames can be defined in a number of different ways, depending on the
9227             -- underlying type of the property. for now, all but the first and last
9228             -- frame are ignored
9229
9230             -- frames
9231
9232                 -- floats
9233                 0, 0,
9234
9235                 -- vec3s
9236                 vector.new(0,0,0),
9237                 vector.new(0,0,0),
9238
9239                 -- vec3 ranges
9240                 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9241                 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9242
9243                 -- mixed
9244                 0, { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9245         },
9246     }
9247
9248 All of the properties that can be defined in this way are listed in the next
9249 section, along with the datatypes they accept.
9250
9251 #### List of particlespawner properties
9252 All of the properties in this list can be animated with `*_tween` tables
9253 unless otherwise specified. For example, `jitter` can be tweened by setting
9254 a `jitter_tween` table instead of (or in addition to) a `jitter` table/value.
9255 Types used are defined in the previous section.
9256
9257 * vec3 range `pos`: the position at which particles can appear
9258 * vec3 range `vel`: the initial velocity of the particle
9259 * vec3 range `acc`: the direction and speed with which the particle
9260   accelerates
9261 * vec3 range `jitter`: offsets the velocity of each particle by a random
9262   amount within the specified range each frame. used to create Brownian motion.
9263 * vec3 range `drag`: the amount by which absolute particle velocity along
9264   each axis is decreased per second.  a value of 1.0 means that the particle
9265   will be slowed to a stop over the space of a second; a value of -1.0 means
9266   that the particle speed will be doubled every second. to avoid interfering
9267   with gravity provided by `acc`, a drag vector like `vector.new(1,0,1)` can
9268   be used instead of a uniform value.
9269 * float range `bounce`: how bouncy the particles are when `collisiondetection`
9270   is turned on. values less than or equal to `0` turn off particle bounce;
9271   `1` makes the particles bounce without losing any velocity, and `2` makes
9272   them double their velocity with every bounce.  `bounce` is not bounded but
9273   values much larger than `1.0` probably aren't very useful.
9274 * float range `exptime`: the number of seconds after which the particle
9275   disappears.
9276 * table `attract`: sets the birth orientation of particles relative to various
9277   shapes defined in world coordinate space. this is an alternative means of
9278   setting the velocity which allows particles to emerge from or enter into
9279   some entity or node on the map, rather than simply being assigned random
9280   velocity values within a range. the velocity calculated by this method will
9281   be **added** to that specified by `vel` if `vel` is also set, so in most
9282   cases **`vel` should be set to 0**. `attract` has the fields:
9283   * string `kind`: selects the kind of shape towards which the particles will
9284     be oriented. it must have one of the following values:
9285     * `"none"`: no attractor is set and the `attractor` table is ignored
9286     * `"point"`: the particles are attracted to a specific point in space.
9287       use this also if you want a sphere-like effect, in combination with
9288       the `radius` property.
9289     * `"line"`: the particles are attracted to an (infinite) line passing
9290       through the points `origin` and `angle`. use this for e.g. beacon
9291       effects, energy beam effects, etc.
9292     * `"plane"`: the particles are attracted to an (infinite) plane on whose
9293       surface `origin` designates a point in world coordinate space. use this
9294       for e.g. particles entering or emerging from a portal.
9295   * float range `strength`: the speed with which particles will move towards
9296     `attractor`. If negative, the particles will instead move away from that
9297     point.
9298   * vec3 `origin`: the origin point of the shape towards which particles will
9299     initially be oriented. functions as an offset if `origin_attached` is also
9300     set.
9301   * vec3 `direction`: sets the direction in which the attractor shape faces. for
9302     lines, this sets the angle of the line; e.g. a vector of (0,1,0) will
9303     create a vertical line that passes through `origin`. for planes, `direction`
9304     is the surface normal of an infinite plane on whose surface `origin` is
9305     a point. functions as an offset if `direction_attached` is also set.
9306   * entity `origin_attached`: allows the origin to be specified as an offset
9307     from the position of an entity rather than a coordinate in world space.
9308   * entity `direction_attached`: allows the direction to be specified as an offset
9309     from the position of an entity rather than a coordinate in world space.
9310   * bool `die_on_contact`: if true, the particles' lifetimes are adjusted so
9311     that they will die as they cross the attractor threshold. this behavior
9312     is the default but is undesirable for some kinds of animations; set it to
9313     false to allow particles to live out their natural lives.
9314 * vec3 range `radius`: if set, particles will be arranged in a sphere around
9315   `pos`. A constant can be used to create a spherical shell of particles, a
9316   vector to create an ovoid shell, and a range to create a volume; e.g.
9317   `{min = 0.5, max = 1, bias = 1}` will allow particles to appear between 0.5
9318   and 1 nodes away from `pos` but will cluster them towards the center of the
9319   sphere. Usually if `radius` is used, `pos` should be a single point, but it
9320   can still be a range if you really know what you're doing (e.g. to create a
9321   "roundcube" emitter volume).
9322
9323 ### Textures
9324
9325 In versions before v5.6.0, particlespawner textures could only be specified as a single
9326 texture string. After v5.6.0, textures can now be specified as a table as well. This
9327 table contains options that allow simple animations to be applied to the texture.
9328
9329     texture = {
9330         name = "mymod_particle_texture.png",
9331         -- the texture specification string
9332
9333         alpha = 1.0,
9334         -- controls how visible the particle is; at 1.0 the particle is fully
9335         -- visible, at 0, it is completely invisible.
9336
9337         alpha_tween = {1, 0},
9338         -- can be used instead of `alpha` to animate the alpha value over the
9339         -- particle's lifetime. these tween tables work identically to the tween
9340         -- tables used in particlespawner properties, except that time references
9341         -- are understood with respect to the particle's lifetime, not the
9342         -- spawner's. {1,0} fades the particle out over its lifetime.
9343
9344         scale = 1,
9345         scale = {x = 1, y = 1},
9346         -- scales the texture onscreen
9347
9348         scale_tween = {
9349             {x = 1, y = 1},
9350             {x = 0, y = 1},
9351         },
9352         -- animates the scale over the particle's lifetime. works like the
9353         -- alpha_tween table, but can accept two-dimensional vectors as well as
9354         -- integer values. the example value would cause the particle to shrink
9355         -- in one dimension over the course of its life until it disappears
9356
9357         blend = "alpha",
9358         -- (default) blends transparent pixels with those they are drawn atop
9359         -- according to the alpha channel of the source texture. useful for
9360         -- e.g. material objects like rocks, dirt, smoke, or node chunks
9361         blend = "add",
9362         -- adds the value of pixels to those underneath them, modulo the sources
9363         -- alpha channel. useful for e.g. bright light effects like sparks or fire
9364         blend = "screen",
9365         -- like "add" but less bright. useful for subtler light effecs. note that
9366         -- this is NOT formally equivalent to the "screen" effect used in image
9367         -- editors and compositors, as it does not respect the alpha channel of
9368         -- of the image being blended
9369         blend = "sub",
9370         -- the inverse of "add"; the value of the source pixel is subtracted from
9371         -- the pixel underneath it. a white pixel will turn whatever is underneath
9372         -- it black; a black pixel will be "transparent". useful for creating
9373         -- darkening effects
9374
9375         animation = {Tile Animation definition},
9376         -- overrides the particlespawner's global animation property for a single
9377         -- specific texture
9378     }
9379
9380 Instead of setting a single texture definition, it is also possible to set a
9381 `texpool` property. A `texpool` consists of a list of possible particle textures.
9382 Every time a particle is spawned, the engine will pick a texture at random from
9383 the `texpool` and assign it as that particle's texture. You can also specify a
9384 `texture` in addition to a `texpool`; the `texture` value will be ignored on newer
9385 clients but will be sent to older (pre-v5.6.0) clients that do not implement
9386 texpools.
9387
9388     texpool = {
9389         "mymod_particle_texture.png";
9390         { name = "mymod_spark.png", fade = "out" },
9391         {
9392           name = "mymod_dust.png",
9393           alpha = 0.3,
9394           scale = 1.5,
9395           animation = {
9396                 type = "vertical_frames",
9397                 aspect_w = 16, aspect_h = 16,
9398
9399                 length = 3,
9400                 -- the animation lasts for 3s and then repeats
9401                 length = -3,
9402                 -- repeat the animation three times over the particle's lifetime
9403                 -- (post-v5.6.0 clients only)
9404           },
9405         },
9406   }
9407
9408 #### List of animatable texture properties
9409
9410 While animated particlespawner values vary over the course of the particlespawner's
9411 lifetime, animated texture properties vary over the lifespans of the individual
9412 particles spawned with that texture. So a particle with the texture property
9413
9414     alpha_tween = {
9415         0.0, 1.0,
9416         style = "pulse",
9417         reps = 4,
9418     }
9419
9420 would be invisible at its spawning, pulse visible four times throughout its
9421 lifespan, and then vanish again before expiring.
9422
9423 * float `alpha` (0.0 - 1.0): controls the visibility of the texture
9424 * vec2 `scale`: controls the size of the displayed billboard onscreen. Its units
9425   are multiples of the parent particle's assigned size (see the `size` property above)
9426
9427 `HTTPRequest` definition
9428 ------------------------
9429
9430 Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
9431
9432     {
9433         url = "http://example.org",
9434
9435         timeout = 10,
9436         -- Timeout for request to be completed in seconds. Default depends on engine settings.
9437
9438         method = "GET", "POST", "PUT" or "DELETE"
9439         -- The http method to use. Defaults to "GET".
9440
9441         data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
9442         -- Data for the POST, PUT or DELETE request.
9443         -- Accepts both a string and a table. If a table is specified, encodes
9444         -- table as x-www-form-urlencoded key-value pairs.
9445
9446         user_agent = "ExampleUserAgent",
9447         -- Optional, if specified replaces the default minetest user agent with
9448         -- given string
9449
9450         extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
9451         -- Optional, if specified adds additional headers to the HTTP request.
9452         -- You must make sure that the header strings follow HTTP specification
9453         -- ("Key: Value").
9454
9455         multipart = boolean
9456         -- Optional, if true performs a multipart HTTP request.
9457         -- Default is false.
9458         -- Post only, data must be array
9459
9460         post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
9461         -- Deprecated, use `data` instead. Forces `method = "POST"`.
9462     }
9463
9464 `HTTPRequestResult` definition
9465 ------------------------------
9466
9467 Passed to `HTTPApiTable.fetch` callback. Returned by
9468 `HTTPApiTable.fetch_async_get`.
9469
9470     {
9471         completed = true,
9472         -- If true, the request has finished (either succeeded, failed or timed
9473         -- out)
9474
9475         succeeded = true,
9476         -- If true, the request was successful
9477
9478         timeout = false,
9479         -- If true, the request timed out
9480
9481         code = 200,
9482         -- HTTP status code
9483
9484         data = "response"
9485     }
9486
9487 Authentication handler definition
9488 ---------------------------------
9489
9490 Used by `minetest.register_authentication_handler`.
9491
9492     {
9493         get_auth = function(name),
9494         -- Get authentication data for existing player `name` (`nil` if player
9495         -- doesn't exist).
9496         -- Returns following structure:
9497         -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
9498
9499         create_auth = function(name, password),
9500         -- Create new auth data for player `name`.
9501         -- Note that `password` is not plain-text but an arbitrary
9502         -- representation decided by the engine.
9503
9504         delete_auth = function(name),
9505         -- Delete auth data of player `name`.
9506         -- Returns boolean indicating success (false if player is nonexistent).
9507
9508         set_password = function(name, password),
9509         -- Set password of player `name` to `password`.
9510         -- Auth data should be created if not present.
9511
9512         set_privileges = function(name, privileges),
9513         -- Set privileges of player `name`.
9514         -- `privileges` is in table form, auth data should be created if not
9515         -- present.
9516
9517         reload = function(),
9518         -- Reload authentication data from the storage location.
9519         -- Returns boolean indicating success.
9520
9521         record_login = function(name),
9522         -- Called when player joins, used for keeping track of last_login
9523
9524         iterate = function(),
9525         -- Returns an iterator (use with `for` loops) for all player names
9526         -- currently in the auth database
9527     }
9528
9529 Bit Library
9530 -----------
9531
9532 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
9533
9534 See http://bitop.luajit.org/ for advanced information.