]> git.lizzy.rs Git - minetest.git/blob - doc/lua_api.txt
Dual wielding
[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     * `map_persistent`: Specifies whether newly created worlds should use
89       a persistent map backend. Defaults to `true` (= "sqlite3")
90     * `author`: The author of the game. It only appears when downloaded from
91                 ContentDB.
92     * `release`: Ignore this: Should only ever be set by ContentDB, as it is
93                  an internal ID used to track versions.
94 * `minetest.conf`:
95   Used to set default settings when running this game.
96 * `settingtypes.txt`:
97   In the same format as the one in builtin.
98   This settingtypes.txt will be parsed by the menu and the settings will be
99   displayed in the "Games" category in the advanced settings tab.
100 * If the game contains a folder called `textures` the server will load it as a
101   texturepack, overriding mod textures.
102   Any server texturepack will override mod textures and the game texturepack.
103
104 Menu images
105 -----------
106
107 Games can provide custom main menu images. They are put inside a `menu`
108 directory inside the game directory.
109
110 The images are named `$identifier.png`, where `$identifier` is one of
111 `overlay`, `background`, `footer`, `header`.
112 If you want to specify multiple images for one identifier, add additional
113 images named like `$identifier.$n.png`, with an ascending number $n starting
114 with 1, and a random image will be chosen from the provided ones.
115
116 Menu music
117 -----------
118
119 Games can provide custom main menu music. They are put inside a `menu`
120 directory inside the game directory.
121
122 The music files are named `theme.ogg`.
123 If you want to specify multiple music files for one game, add additional
124 images named like `theme.$n.ogg`, with an ascending number $n starting
125 with 1 (max 10), and a random music file will be chosen from the provided ones.
126
127 Mods
128 ====
129
130 Mod load path
131 -------------
132
133 Paths are relative to the directories listed in the [Paths] section above.
134
135 * `games/<gameid>/mods/`
136 * `mods/`
137 * `worlds/<worldname>/worldmods/`
138
139 World-specific games
140 --------------------
141
142 It is possible to include a game in a world; in this case, no mods or
143 games are loaded or checked from anywhere else.
144
145 This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
146 directory exists.
147
148 Mods should then be placed in `<worldname>/game/mods/`.
149
150 Modpacks
151 --------
152
153 Mods can be put in a subdirectory, if the parent directory, which otherwise
154 should be a mod, contains a file named `modpack.conf`.
155 The file is a key-value store of modpack details.
156
157 * `name`: The modpack name. Allows Minetest to determine the modpack name even
158           if the folder is wrongly named.
159 * `description`: Description of mod to be shown in the Mods tab of the main
160                  menu.
161 * `author`: The author of the modpack. It only appears when downloaded from
162             ContentDB.
163 * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
164              internal ID used to track versions.
165 * `title`: A human-readable title to address the modpack.
166
167 Note: to support 0.4.x, please also create an empty modpack.txt file.
168
169 Mod directory structure
170 -----------------------
171
172     mods
173     ├── modname
174     │   ├── mod.conf
175     │   ├── screenshot.png
176     │   ├── settingtypes.txt
177     │   ├── init.lua
178     │   ├── models
179     │   ├── textures
180     │   │   ├── modname_stuff.png
181     │   │   ├── modname_stuff_normal.png
182     │   │   ├── modname_something_else.png
183     │   │   ├── subfolder_foo
184     │   │   │   ├── modname_more_stuff.png
185     │   │   │   └── another_subfolder
186     │   │   └── bar_subfolder
187     │   ├── sounds
188     │   ├── media
189     │   ├── locale
190     │   └── <custom data>
191     └── another
192
193 ### modname
194
195 The location of this directory can be fetched by using
196 `minetest.get_modpath(modname)`.
197
198 ### mod.conf
199
200 A `Settings` file that provides meta information about the mod.
201
202 * `name`: The mod name. Allows Minetest to determine the mod name even if the
203           folder is wrongly named.
204 * `description`: Description of mod to be shown in the Mods tab of the main
205                  menu.
206 * `depends`: A comma separated list of dependencies. These are mods that must be
207              loaded before this mod.
208 * `optional_depends`: A comma separated list of optional dependencies.
209                       Like a dependency, but no error if the mod doesn't exist.
210 * `author`: The author of the mod. It only appears when downloaded from
211             ContentDB.
212 * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
213              internal ID used to track versions.
214 * `title`: A human-readable title to address the mod.
215
216 ### `screenshot.png`
217
218 A screenshot shown in the mod manager within the main menu. It should
219 have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
220
221 ### `depends.txt`
222
223 **Deprecated:** you should use mod.conf instead.
224
225 This file is used if there are no dependencies in mod.conf.
226
227 List of mods that have to be loaded before loading this mod.
228
229 A single line contains a single modname.
230
231 Optional dependencies can be defined by appending a question mark
232 to a single modname. This means that if the specified mod
233 is missing, it does not prevent this mod from being loaded.
234
235 ### `description.txt`
236
237 **Deprecated:** you should use mod.conf instead.
238
239 This file is used if there is no description in mod.conf.
240
241 A file containing a description to be shown in the Mods tab of the main menu.
242
243 ### `settingtypes.txt`
244
245 The format is documented in `builtin/settingtypes.txt`.
246 It is parsed by the main menu settings dialogue to list mod-specific
247 settings in the "Mods" category.
248
249 ### `init.lua`
250
251 The main Lua script. Running this script should register everything it
252 wants to register. Subsequent execution depends on minetest calling the
253 registered callbacks.
254
255 `minetest.settings` can be used to read custom or existing settings at load
256 time, if necessary. (See [`Settings`])
257
258 ### `textures`, `sounds`, `media`, `models`, `locale`
259
260 Media files (textures, sounds, whatever) that will be transferred to the
261 client and will be available for use by the mod and translation files for
262 the clients (see [Translations]).
263
264 It is suggested to use the folders for the purpose they are thought for,
265 eg. put textures into `textures`, translation files into `locale`,
266 models for entities or meshnodes into `models` et cetera.
267
268 These folders and subfolders can contain subfolders.
269 Subfolders with names starting with `_` or `.` are ignored.
270 If a subfolder contains a media file with the same name as a media file
271 in one of its parents, the parent's file is used.
272
273 Although it is discouraged, a mod can overwrite a media file of any mod that it
274 depends on by supplying a file with an equal name.
275
276 Naming conventions
277 ------------------
278
279 Registered names should generally be in this format:
280
281     modname:<whatever>
282
283 `<whatever>` can have these characters:
284
285     a-zA-Z0-9_
286
287 This is to prevent conflicting names from corrupting maps and is
288 enforced by the mod loader.
289
290 Registered names can be overridden by prefixing the name with `:`. This can
291 be used for overriding the registrations of some other mod.
292
293 The `:` prefix can also be used for maintaining backwards compatibility.
294
295 ### Example
296
297 In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
298 So the name should be `experimental:tnt`.
299
300 Any mod can redefine `experimental:tnt` by using the name
301
302     :experimental:tnt
303
304 when registering it. For this to work correctly, that mod must have
305 `experimental` as a dependency.
306
307
308
309
310 Aliases
311 =======
312
313 Aliases of itemnames can be added by using
314 `minetest.register_alias(alias, original_name)` or
315 `minetest.register_alias_force(alias, original_name)`.
316
317 This adds an alias `alias` for the item called `original_name`.
318 From now on, you can use `alias` to refer to the item `original_name`.
319
320 The only difference between `minetest.register_alias` and
321 `minetest.register_alias_force` is that if an item named `alias` already exists,
322 `minetest.register_alias` will do nothing while
323 `minetest.register_alias_force` will unregister it.
324
325 This can be used for maintaining backwards compatibility.
326
327 This can also set quick access names for things, e.g. if
328 you have an item called `epiclylongmodname:stuff`, you could do
329
330     minetest.register_alias("stuff", "epiclylongmodname:stuff")
331
332 and be able to use `/giveme stuff`.
333
334 Mapgen aliases
335 --------------
336
337 In a game, a certain number of these must be set to tell core mapgens which
338 of the game's nodes are to be used for core mapgen generation. For example:
339
340     minetest.register_alias("mapgen_stone", "default:stone")
341
342 ### Aliases for non-V6 mapgens
343
344 #### Essential aliases
345
346 * `mapgen_stone`
347 * `mapgen_water_source`
348 * `mapgen_river_water_source`
349
350 `mapgen_river_water_source` is required for mapgens with sloping rivers where
351 it is necessary to have a river liquid node with a short `liquid_range` and
352 `liquid_renewable = false` to avoid flooding.
353
354 #### Optional aliases
355
356 * `mapgen_lava_source`
357
358 Fallback lava node used if cave liquids are not defined in biome definitions.
359 Deprecated, define cave liquids in biome definitions instead.
360
361 * `mapgen_cobble`
362
363 Fallback node used if dungeon nodes are not defined in biome definitions.
364 Deprecated, define dungeon nodes in biome definitions instead.
365
366 ### Aliases for Mapgen V6
367
368 #### Essential
369
370 * `mapgen_stone`
371 * `mapgen_water_source`
372 * `mapgen_lava_source`
373 * `mapgen_dirt`
374 * `mapgen_dirt_with_grass`
375 * `mapgen_sand`
376
377 * `mapgen_tree`
378 * `mapgen_leaves`
379 * `mapgen_apple`
380
381 * `mapgen_cobble`
382
383 #### Optional
384
385 * `mapgen_gravel` (falls back to stone)
386 * `mapgen_desert_stone` (falls back to stone)
387 * `mapgen_desert_sand` (falls back to sand)
388 * `mapgen_dirt_with_snow` (falls back to dirt_with_grass)
389 * `mapgen_snowblock` (falls back to dirt_with_grass)
390 * `mapgen_snow` (not placed if missing)
391 * `mapgen_ice` (falls back to water_source)
392
393 * `mapgen_jungletree` (falls back to tree)
394 * `mapgen_jungleleaves` (falls back to leaves)
395 * `mapgen_junglegrass` (not placed if missing)
396 * `mapgen_pine_tree` (falls back to tree)
397 * `mapgen_pine_needles` (falls back to leaves)
398
399 * `mapgen_stair_cobble` (falls back to cobble)
400 * `mapgen_mossycobble` (falls back to cobble)
401 * `mapgen_stair_desert_stone` (falls back to desert_stone)
402
403 ### Setting the node used in Mapgen Singlenode
404
405 By default the world is filled with air nodes. To set a different node use e.g.:
406
407     minetest.register_alias("mapgen_singlenode", "default:stone")
408
409
410
411
412 Textures
413 ========
414
415 Mods should generally prefix their textures with `modname_`, e.g. given
416 the mod name `foomod`, a texture could be called:
417
418     foomod_foothing.png
419
420 Textures are referred to by their complete name, or alternatively by
421 stripping out the file extension:
422
423 * e.g. `foomod_foothing.png`
424 * e.g. `foomod_foothing`
425
426 Supported texture formats are PNG (`.png`), JPEG (`.jpg`), Bitmap (`.bmp`)
427 and Targa (`.tga`).
428 Since better alternatives exist, the latter two may be removed in the future.
429
430 Texture modifiers
431 -----------------
432
433 There are various texture modifiers that can be used
434 to let the client generate textures on-the-fly.
435 The modifiers are applied directly in sRGB colorspace,
436 i.e. without gamma-correction.
437
438 ### Texture overlaying
439
440 Textures can be overlaid by putting a `^` between them.
441
442 Example:
443
444     default_dirt.png^default_grass_side.png
445
446 `default_grass_side.png` is overlaid over `default_dirt.png`.
447 The texture with the lower resolution will be automatically upscaled to
448 the higher resolution texture.
449
450 ### Texture grouping
451
452 Textures can be grouped together by enclosing them in `(` and `)`.
453
454 Example: `cobble.png^(thing1.png^thing2.png)`
455
456 A texture for `thing1.png^thing2.png` is created and the resulting
457 texture is overlaid on top of `cobble.png`.
458
459 ### Escaping
460
461 Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
462 passing complex texture names as arguments. Escaping is done with backslash and
463 is required for `^` and `:`.
464
465 Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
466
467 The lower 50 percent of `color.png^[mask:trans.png` are overlaid
468 on top of `cobble.png`.
469
470 ### Advanced texture modifiers
471
472 #### Crack
473
474 * `[crack:<n>:<p>`
475 * `[cracko:<n>:<p>`
476 * `[crack:<t>:<n>:<p>`
477 * `[cracko:<t>:<n>:<p>`
478
479 Parameters:
480
481 * `<t>`: tile count (in each direction)
482 * `<n>`: animation frame count
483 * `<p>`: current animation frame
484
485 Draw a step of the crack animation on the texture.
486 `crack` draws it normally, while `cracko` lays it over, keeping transparent
487 pixels intact.
488
489 Example:
490
491     default_cobble.png^[crack:10:1
492
493 #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
494
495 * `<w>`: width
496 * `<h>`: height
497 * `<x>`: x position
498 * `<y>`: y position
499 * `<file>`: texture to combine
500
501 Creates a texture of size `<w>` times `<h>` and blits the listed files to their
502 specified coordinates.
503
504 Example:
505
506     [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
507
508 #### `[resize:<w>x<h>`
509
510 Resizes the texture to the given dimensions.
511
512 Example:
513
514     default_sandstone.png^[resize:16x16
515
516 #### `[opacity:<r>`
517
518 Makes the base image transparent according to the given ratio.
519
520 `r` must be between 0 (transparent) and 255 (opaque).
521
522 Example:
523
524     default_sandstone.png^[opacity:127
525
526 #### `[invert:<mode>`
527
528 Inverts the given channels of the base image.
529 Mode may contain the characters "r", "g", "b", "a".
530 Only the channels that are mentioned in the mode string will be inverted.
531
532 Example:
533
534     default_apple.png^[invert:rgb
535
536 #### `[brighten`
537
538 Brightens the texture.
539
540 Example:
541
542     tnt_tnt_side.png^[brighten
543
544 #### `[noalpha`
545
546 Makes the texture completely opaque.
547
548 Example:
549
550     default_leaves.png^[noalpha
551
552 #### `[makealpha:<r>,<g>,<b>`
553
554 Convert one color to transparency.
555
556 Example:
557
558     default_cobble.png^[makealpha:128,128,128
559
560 #### `[transform<t>`
561
562 * `<t>`: transformation(s) to apply
563
564 Rotates and/or flips the image.
565
566 `<t>` can be a number (between 0 and 7) or a transform name.
567 Rotations are counter-clockwise.
568
569     0  I      identity
570     1  R90    rotate by 90 degrees
571     2  R180   rotate by 180 degrees
572     3  R270   rotate by 270 degrees
573     4  FX     flip X
574     5  FXR90  flip X then rotate by 90 degrees
575     6  FY     flip Y
576     7  FYR90  flip Y then rotate by 90 degrees
577
578 Example:
579
580     default_stone.png^[transformFXR90
581
582 #### `[inventorycube{<top>{<left>{<right>`
583
584 Escaping does not apply here and `^` is replaced by `&` in texture names
585 instead.
586
587 Create an inventory cube texture using the side textures.
588
589 Example:
590
591     [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
592
593 Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
594 `dirt.png^grass_side.png` textures
595
596 #### `[lowpart:<percent>:<file>`
597
598 Blit the lower `<percent>`% part of `<file>` on the texture.
599
600 Example:
601
602     base.png^[lowpart:25:overlay.png
603
604 #### `[verticalframe:<t>:<n>`
605
606 * `<t>`: animation frame count
607 * `<n>`: current animation frame
608
609 Crops the texture to a frame of a vertical animation.
610
611 Example:
612
613     default_torch_animated.png^[verticalframe:16:8
614
615 #### `[mask:<file>`
616
617 Apply a mask to the base image.
618
619 The mask is applied using binary AND.
620
621 #### `[sheet:<w>x<h>:<x>,<y>`
622
623 Retrieves a tile at position x,y from the base image
624 which it assumes to be a tilesheet with dimensions w,h.
625
626 #### `[colorize:<color>:<ratio>`
627
628 Colorize the textures with the given color.
629 `<color>` is specified as a `ColorString`.
630 `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`".  If
631 it is an int, then it specifies how far to interpolate between the
632 colors where 0 is only the texture color and 255 is only `<color>`. If
633 omitted, the alpha of `<color>` will be used as the ratio.  If it is
634 the word "`alpha`", then each texture pixel will contain the RGB of
635 `<color>` and the alpha of `<color>` multiplied by the alpha of the
636 texture pixel.
637
638 #### `[multiply:<color>`
639
640 Multiplies texture colors with the given color.
641 `<color>` is specified as a `ColorString`.
642 Result is more like what you'd expect if you put a color on top of another
643 color, meaning white surfaces get a lot of your new color while black parts
644 don't change very much.
645
646 #### `[png:<base64>`
647
648 Embed a base64 encoded PNG image in the texture string.
649 You can produce a valid string for this by calling
650 `minetest.encode_base64(minetest.encode_png(tex))`,
651 refer to the documentation of these functions for details.
652 You can use this to send disposable images such as captchas
653 to individual clients, or render things that would be too
654 expensive to compose with `[combine:`.
655
656 IMPORTANT: Avoid sending large images this way.
657 This is not a replacement for asset files, do not use it to do anything
658 that you could instead achieve by just using a file.
659 In particular consider `minetest.dynamic_add_media` and test whether
660 using other texture modifiers could result in a shorter string than
661 embedding a whole image, this may vary by use case.
662
663 Hardware coloring
664 -----------------
665
666 The goal of hardware coloring is to simplify the creation of
667 colorful nodes. If your textures use the same pattern, and they only
668 differ in their color (like colored wool blocks), you can use hardware
669 coloring instead of creating and managing many texture files.
670 All of these methods use color multiplication (so a white-black texture
671 with red coloring will result in red-black color).
672
673 ### Static coloring
674
675 This method is useful if you wish to create nodes/items with
676 the same texture, in different colors, each in a new node/item definition.
677
678 #### Global color
679
680 When you register an item or node, set its `color` field (which accepts a
681 `ColorSpec`) to the desired color.
682
683 An `ItemStack`'s static color can be overwritten by the `color` metadata
684 field. If you set that field to a `ColorString`, that color will be used.
685
686 #### Tile color
687
688 Each tile may have an individual static color, which overwrites every
689 other coloring method. To disable the coloring of a face,
690 set its color to white (because multiplying with white does nothing).
691 You can set the `color` property of the tiles in the node's definition
692 if the tile is in table format.
693
694 ### Palettes
695
696 For nodes and items which can have many colors, a palette is more
697 suitable. A palette is a texture, which can contain up to 256 pixels.
698 Each pixel is one possible color for the node/item.
699 You can register one node/item, which can have up to 256 colors.
700
701 #### Palette indexing
702
703 When using palettes, you always provide a pixel index for the given
704 node or `ItemStack`. The palette is read from left to right and from
705 top to bottom. If the palette has less than 256 pixels, then it is
706 stretched to contain exactly 256 pixels (after arranging the pixels
707 to one line). The indexing starts from 0.
708
709 Examples:
710
711 * 16x16 palette, index = 0: the top left corner
712 * 16x16 palette, index = 4: the fifth pixel in the first row
713 * 16x16 palette, index = 16: the pixel below the top left corner
714 * 16x16 palette, index = 255: the bottom right corner
715 * 2 (width) x 4 (height) palette, index = 31: the top left corner.
716   The palette has 8 pixels, so each pixel is stretched to 32 pixels,
717   to ensure the total 256 pixels.
718 * 2x4 palette, index = 32: the top right corner
719 * 2x4 palette, index = 63: the top right corner
720 * 2x4 palette, index = 64: the pixel below the top left corner
721
722 #### Using palettes with items
723
724 When registering an item, set the item definition's `palette` field to
725 a texture. You can also use texture modifiers.
726
727 The `ItemStack`'s color depends on the `palette_index` field of the
728 stack's metadata. `palette_index` is an integer, which specifies the
729 index of the pixel to use.
730
731 #### Linking palettes with nodes
732
733 When registering a node, set the item definition's `palette` field to
734 a texture. You can also use texture modifiers.
735 The node's color depends on its `param2`, so you also must set an
736 appropriate `paramtype2`:
737
738 * `paramtype2 = "color"` for nodes which use their full `param2` for
739   palette indexing. These nodes can have 256 different colors.
740   The palette should contain 256 pixels.
741 * `paramtype2 = "colorwallmounted"` for nodes which use the first
742   five bits (most significant) of `param2` for palette indexing.
743   The remaining three bits are describing rotation, as in `wallmounted`
744   paramtype2. Division by 8 yields the palette index (without stretching the
745   palette). These nodes can have 32 different colors, and the palette
746   should contain 32 pixels.
747   Examples:
748     * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
749       pixel will be picked from the palette.
750     * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
751       pixel will be picked from the palette.
752 * `paramtype2 = "colorfacedir"` for nodes which use the first
753   three bits of `param2` for palette indexing. The remaining
754   five bits are describing rotation, as in `facedir` paramtype2.
755   Division by 32 yields the palette index (without stretching the
756   palette). These nodes can have 8 different colors, and the
757   palette should contain 8 pixels.
758   Examples:
759     * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
760       first (= 0 + 1) pixel will be picked from the palette.
761     * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
762       second (= 1 + 1) pixel will be picked from the palette.
763 * `paramtype2 = "color4dir"` for nodes which use the first
764   six bits of `param2` for palette indexing. The remaining
765   two bits are describing rotation, as in `4dir` paramtype2.
766   Division by 4 yields the palette index (without stretching the
767   palette). These nodes can have 64 different colors, and the
768   palette should contain 64 pixels.
769   Examples:
770     * `param2 = 17` is 4 * 4 + 1, so the rotation is 1 and the
771       fifth (= 4 + 1) pixel will be picked from the palette.
772     * `param2 = 35` is 8 * 4 + 3, so the rotation is 3 and the
773       ninth (= 8 + 1) pixel will be picked from the palette.
774
775 To colorize a node on the map, set its `param2` value (according
776 to the node's paramtype2).
777
778 ### Conversion between nodes in the inventory and on the map
779
780 Static coloring is the same for both cases, there is no need
781 for conversion.
782
783 If the `ItemStack`'s metadata contains the `color` field, it will be
784 lost on placement, because nodes on the map can only use palettes.
785
786 If the `ItemStack`'s metadata contains the `palette_index` field, it is
787 automatically transferred between node and item forms by the engine,
788 when a player digs or places a colored node.
789 You can disable this feature by setting the `drop` field of the node
790 to itself (without metadata).
791 To transfer the color to a special drop, you need a drop table.
792
793 Example:
794
795     minetest.register_node("mod:stone", {
796         description = "Stone",
797         tiles = {"default_stone.png"},
798         paramtype2 = "color",
799         palette = "palette.png",
800         drop = {
801             items = {
802                 -- assume that mod:cobblestone also has the same palette
803                 {items = {"mod:cobblestone"}, inherit_color = true },
804             }
805         }
806     })
807
808 ### Colored items in craft recipes
809
810 Craft recipes only support item strings, but fortunately item strings
811 can also contain metadata. Example craft recipe registration:
812
813     minetest.register_craft({
814         output = minetest.itemstring_with_palette("wool:block", 3),
815         type = "shapeless",
816         recipe = {
817             "wool:block",
818             "dye:red",
819         },
820     })
821
822 To set the `color` field, you can use `minetest.itemstring_with_color`.
823
824 Metadata field filtering in the `recipe` field are not supported yet,
825 so the craft output is independent of the color of the ingredients.
826
827 Soft texture overlay
828 --------------------
829
830 Sometimes hardware coloring is not enough, because it affects the
831 whole tile. Soft texture overlays were added to Minetest to allow
832 the dynamic coloring of only specific parts of the node's texture.
833 For example a grass block may have colored grass, while keeping the
834 dirt brown.
835
836 These overlays are 'soft', because unlike texture modifiers, the layers
837 are not merged in the memory, but they are simply drawn on top of each
838 other. This allows different hardware coloring, but also means that
839 tiles with overlays are drawn slower. Using too much overlays might
840 cause FPS loss.
841
842 For inventory and wield images you can specify overlays which
843 hardware coloring does not modify. You have to set `inventory_overlay`
844 and `wield_overlay` fields to an image name.
845
846 To define a node overlay, simply set the `overlay_tiles` field of the node
847 definition. These tiles are defined in the same way as plain tiles:
848 they can have a texture name, color etc.
849 To skip one face, set that overlay tile to an empty string.
850
851 Example (colored grass block):
852
853     minetest.register_node("default:dirt_with_grass", {
854         description = "Dirt with Grass",
855         -- Regular tiles, as usual
856         -- The dirt tile disables palette coloring
857         tiles = {{name = "default_grass.png"},
858             {name = "default_dirt.png", color = "white"}},
859         -- Overlay tiles: define them in the same style
860         -- The top and bottom tile does not have overlay
861         overlay_tiles = {"", "",
862             {name = "default_grass_side.png"}},
863         -- Global color, used in inventory
864         color = "green",
865         -- Palette in the world
866         paramtype2 = "color",
867         palette = "default_foilage.png",
868     })
869
870
871
872
873 Sounds
874 ======
875
876 Only Ogg Vorbis files are supported.
877
878 For positional playing of sounds, only single-channel (mono) files are
879 supported. Otherwise OpenAL will play them non-positionally.
880
881 Mods should generally prefix their sounds with `modname_`, e.g. given
882 the mod name "`foomod`", a sound could be called:
883
884     foomod_foosound.ogg
885
886 Sounds are referred to by their name with a dot, a single digit and the
887 file extension stripped out. When a sound is played, the actual sound file
888 is chosen randomly from the matching sounds.
889
890 When playing the sound `foomod_foosound`, the sound is chosen randomly
891 from the available ones of the following files:
892
893 * `foomod_foosound.ogg`
894 * `foomod_foosound.0.ogg`
895 * `foomod_foosound.1.ogg`
896 * (...)
897 * `foomod_foosound.9.ogg`
898
899 Examples of sound parameter tables:
900
901     -- Play locationless on all clients
902     {
903         gain = 1.0,   -- default
904         fade = 0.0,   -- default, change to a value > 0 to fade the sound in
905         pitch = 1.0,  -- default
906     }
907     -- Play locationless to one player
908     {
909         to_player = name,
910         gain = 1.0,   -- default
911         fade = 0.0,   -- default, change to a value > 0 to fade the sound in
912         pitch = 1.0,  -- default
913     }
914     -- Play locationless to one player, looped
915     {
916         to_player = name,
917         gain = 1.0,  -- default
918         loop = true,
919     }
920     -- Play at a location
921     {
922         pos = {x = 1, y = 2, z = 3},
923         gain = 1.0,  -- default
924         max_hear_distance = 32,  -- default, uses a Euclidean metric
925     }
926     -- Play connected to an object, looped
927     {
928         object = <an ObjectRef>,
929         gain = 1.0,  -- default
930         max_hear_distance = 32,  -- default, uses a Euclidean metric
931         loop = true,
932     }
933     -- Play at a location, heard by anyone *but* the given player
934     {
935         pos = {x = 32, y = 0, z = 100},
936         max_hear_distance = 40,
937         exclude_player = name,
938     }
939
940 Looped sounds must either be connected to an object or played locationless to
941 one player using `to_player = name`.
942
943 A positional sound will only be heard by players that are within
944 `max_hear_distance` of the sound position, at the start of the sound.
945
946 `exclude_player = name` can be applied to locationless, positional and object-
947 bound sounds to exclude a single player from hearing them.
948
949 `SimpleSoundSpec`
950 -----------------
951
952 Specifies a sound name, gain (=volume) and pitch.
953 This is either a string or a table.
954
955 In string form, you just specify the sound name or
956 the empty string for no sound.
957
958 Table form has the following fields:
959
960 * `name`: Sound name
961 * `gain`: Volume (`1.0` = 100%)
962 * `pitch`: Pitch (`1.0` = 100%)
963
964 `gain` and `pitch` are optional and default to `1.0`.
965
966 Examples:
967
968 * `""`: No sound
969 * `{}`: No sound
970 * `"default_place_node"`: Play e.g. `default_place_node.ogg`
971 * `{name = "default_place_node"}`: Same as above
972 * `{name = "default_place_node", gain = 0.5}`: 50% volume
973 * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
974
975 Special sound files
976 -------------------
977
978 These sound files are played back by the engine if provided.
979
980  * `player_damage`: Played when the local player takes damage (gain = 0.5)
981  * `player_falling_damage`: Played when the local player takes
982    damage by falling (gain = 0.5)
983  * `player_jump`: Played when the local player jumps
984  * `default_dig_<groupname>`: Default node digging sound (gain = 0.5)
985    (see node sound definition for details)
986
987 Registered definitions
988 ======================
989
990 Anything added using certain [Registration functions] gets added to one or more
991 of the global [Registered definition tables].
992
993 Note that in some cases you will stumble upon things that are not contained
994 in these tables (e.g. when a mod has been removed). Always check for
995 existence before trying to access the fields.
996
997 Example:
998
999 All nodes registered with `minetest.register_node` get added to the table
1000 `minetest.registered_nodes`.
1001
1002 If you want to check the drawtype of a node, you could do it like this:
1003
1004     local def = minetest.registered_nodes[nodename]
1005     local drawtype = def and def.drawtype
1006
1007
1008
1009
1010 Nodes
1011 =====
1012
1013 Nodes are the bulk data of the world: cubes and other things that take the
1014 space of a cube. Huge amounts of them are handled efficiently, but they
1015 are quite static.
1016
1017 The definition of a node is stored and can be accessed by using
1018
1019     minetest.registered_nodes[node.name]
1020
1021 See [Registered definitions].
1022
1023 Nodes are passed by value between Lua and the engine.
1024 They are represented by a table:
1025
1026     {name="name", param1=num, param2=num}
1027
1028 `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
1029 them for certain automated functions. If you don't use these functions, you can
1030 use them to store arbitrary values.
1031
1032 Node paramtypes
1033 ---------------
1034
1035 The functions of `param1` and `param2` are determined by certain fields in the
1036 node definition.
1037
1038 The function of `param1` is determined by `paramtype` in node definition.
1039 `param1` is reserved for the engine when `paramtype != "none"`.
1040
1041 * `paramtype = "light"`
1042     * The value stores light with and without sun in its lower and upper 4 bits
1043       respectively.
1044     * Required by a light source node to enable spreading its light.
1045     * Required by the following drawtypes as they determine their visual
1046       brightness from their internal light value:
1047         * torchlike
1048         * signlike
1049         * firelike
1050         * fencelike
1051         * raillike
1052         * nodebox
1053         * mesh
1054         * plantlike
1055         * plantlike_rooted
1056 * `paramtype = "none"`
1057     * `param1` will not be used by the engine and can be used to store
1058       an arbitrary value
1059
1060 The function of `param2` is determined by `paramtype2` in node definition.
1061 `param2` is reserved for the engine when `paramtype2 != "none"`.
1062
1063 * `paramtype2 = "flowingliquid"`
1064     * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
1065     * The liquid level and a flag of the liquid are stored in `param2`
1066     * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
1067       see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
1068       to access/manipulate the content of this field
1069     * Bit 3: If set, liquid is flowing downwards (no graphical effect)
1070 * `paramtype2 = "wallmounted"`
1071     * Supported drawtypes: "torchlike", "signlike", "plantlike",
1072       "plantlike_rooted", "normal", "nodebox", "mesh"
1073     * The rotation of the node is stored in `param2`
1074     * Node is 'mounted'/facing towards one of 6 directions
1075     * You can make this value by using `minetest.dir_to_wallmounted()`
1076     * Values range 0 - 5
1077     * The value denotes at which direction the node is "mounted":
1078       0 = y+,   1 = y-,   2 = x+,   3 = x-,   4 = z+,   5 = z-
1079     * By default, on placement the param2 is automatically set to the
1080       appropriate rotation, depending on which side was pointed at
1081 * `paramtype2 = "facedir"`
1082     * Supported drawtypes: "normal", "nodebox", "mesh"
1083     * The rotation of the node is stored in `param2`.
1084     * Node is rotated around face and axis; 24 rotations in total.
1085     * Can be made by using `minetest.dir_to_facedir()`.
1086     * Chests and furnaces can be rotated that way, and also 'flipped'
1087     * Values range 0 - 23
1088     * facedir / 4 = axis direction:
1089       0 = y+,   1 = z+,   2 = z-,   3 = x+,   4 = x-,   5 = y-
1090     * The node is rotated 90 degrees around the X or Z axis so that its top face
1091       points in the desired direction. For the y- direction, it's rotated 180
1092       degrees around the Z axis.
1093     * facedir modulo 4 = left-handed rotation around the specified axis, in 90° steps.
1094     * By default, on placement the param2 is automatically set to the
1095       horizontal direction the player was looking at (values 0-3)
1096     * Special case: If the node is a connected nodebox, the nodebox
1097       will NOT rotate, only the textures will.
1098 * `paramtype2 = "4dir"`
1099     * Supported drawtypes: "normal", "nodebox", "mesh"
1100     * The rotation of the node is stored in `param2`.
1101     * Allows node to be rotated horizontally, 4 rotations in total
1102     * Can be made by using `minetest.dir_to_fourdir()`.
1103     * Chests and furnaces can be rotated that way, but not flipped
1104     * Values range 0 - 3
1105     * 4dir modulo 4 = rotation
1106     * Otherwise, behavior is identical to facedir
1107 * `paramtype2 = "leveled"`
1108     * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
1109         * Leveled nodebox:
1110             * The level of the top face of the nodebox is stored in `param2`.
1111             * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
1112               nodeboxes.
1113             * The nodebox height is (`param2` / 64) nodes.
1114             * The maximum accepted value of `param2` is 127.
1115         * Rooted plantlike:
1116             * The height of the 'plantlike' section is stored in `param2`.
1117             * The height is (`param2` / 16) nodes.
1118 * `paramtype2 = "degrotate"`
1119     * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
1120       stored in `param2`.
1121     * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
1122       get the actual rotation in degrees of the node.
1123 * `paramtype2 = "meshoptions"`
1124     * Only valid for "plantlike" drawtype. `param2` encodes the shape and
1125       optional modifiers of the "plant". `param2` is a bitfield.
1126     * Bits 0 to 2 select the shape.
1127       Use only one of the values below:
1128         * 0 = an "x" shaped plant (ordinary plant)
1129         * 1 = a "+" shaped plant (just rotated 45 degrees)
1130         * 2 = a "*" shaped plant with 3 faces instead of 2
1131         * 3 = a "#" shaped plant with 4 faces instead of 2
1132         * 4 = a "#" shaped plant with 4 faces that lean outwards
1133         * 5-7 are unused and reserved for future meshes.
1134     * Bits 3 to 7 are used to enable any number of optional modifiers.
1135       Just add the corresponding value(s) below to `param2`:
1136         * 8  - Makes the plant slightly vary placement horizontally
1137         * 16 - Makes the plant mesh 1.4x larger
1138         * 32 - Moves each face randomly a small bit down (1/8 max)
1139         * values 64 and 128 (bits 6-7) are reserved for future use.
1140     * Example: `param2 = 0` selects a normal "x" shaped plant
1141     * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
1142 * `paramtype2 = "color"`
1143     * `param2` tells which color is picked from the palette.
1144       The palette should have 256 pixels.
1145 * `paramtype2 = "colorfacedir"`
1146     * Same as `facedir`, but with colors.
1147     * The first three bits of `param2` tells which color is picked from the
1148       palette. The palette should have 8 pixels.
1149 * `paramtype2 = "color4dir"`
1150     * Same as `facedir`, but with colors.
1151     * The first six bits of `param2` tells which color is picked from the
1152       palette. The palette should have 64 pixels.
1153 * `paramtype2 = "colorwallmounted"`
1154     * Same as `wallmounted`, but with colors.
1155     * The first five bits of `param2` tells which color is picked from the
1156       palette. The palette should have 32 pixels.
1157 * `paramtype2 = "glasslikeliquidlevel"`
1158     * Only valid for "glasslike_framed" or "glasslike_framed_optional"
1159       drawtypes. "glasslike_framed_optional" nodes are only affected if the
1160       "Connected Glass" setting is enabled.
1161     * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
1162       full.
1163     * Bits 6 and 7 modify the appearance of the frame and node faces. One or
1164       both of these values may be added to `param2`:
1165         * 64  - Makes the node not connect with neighbors above or below it.
1166         * 128 - Makes the node not connect with neighbors to its sides.
1167     * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
1168 * `paramtype2 = "colordegrotate"`
1169     * Same as `degrotate`, but with colors.
1170     * The first (most-significant) three bits of `param2` tells which color
1171       is picked from the palette. The palette should have 8 pixels.
1172     * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
1173 * `paramtype2 = "none"`
1174     * `param2` will not be used by the engine and can be used to store
1175       an arbitrary value
1176
1177 Nodes can also contain extra data. See [Node Metadata].
1178
1179 Node drawtypes
1180 --------------
1181
1182 There are a bunch of different looking node types.
1183
1184 Look for examples in `games/devtest` or `games/minetest_game`.
1185
1186 * `normal`
1187     * A node-sized cube.
1188 * `airlike`
1189     * Invisible, uses no texture.
1190 * `liquid`
1191     * The cubic source node for a liquid.
1192     * Faces bordering to the same node are never rendered.
1193     * Connects to node specified in `liquid_alternative_flowing`.
1194     * You *must* set `liquid_alternative_source` to the node's own name.
1195     * Use `backface_culling = false` for the tiles you want to make
1196       visible when inside the node.
1197 * `flowingliquid`
1198     * The flowing version of a liquid, appears with various heights and slopes.
1199     * Faces bordering to the same node are never rendered.
1200     * Connects to node specified in `liquid_alternative_source`.
1201     * You *must* set `liquid_alternative_flowing` to the node's own name.
1202     * Node textures are defined with `special_tiles` where the first tile
1203       is for the top and bottom faces and the second tile is for the side
1204       faces.
1205     * `tiles` is used for the item/inventory/wield image rendering.
1206     * Use `backface_culling = false` for the special tiles you want to make
1207       visible when inside the node
1208 * `glasslike`
1209     * Often used for partially-transparent nodes.
1210     * Only external sides of textures are visible.
1211 * `glasslike_framed`
1212     * All face-connected nodes are drawn as one volume within a surrounding
1213       frame.
1214     * The frame appearance is generated from the edges of the first texture
1215       specified in `tiles`. The width of the edges used are 1/16th of texture
1216       size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
1217     * The glass 'shine' (or other desired detail) on each node face is supplied
1218       by the second texture specified in `tiles`.
1219 * `glasslike_framed_optional`
1220     * This switches between the above 2 drawtypes according to the menu setting
1221       'Connected Glass'.
1222 * `allfaces`
1223     * Often used for partially-transparent nodes.
1224     * External and internal sides of textures are visible.
1225 * `allfaces_optional`
1226     * Often used for leaves nodes.
1227     * This switches between `normal`, `glasslike` and `allfaces` according to
1228       the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
1229     * With 'Simple Leaves' selected, the texture specified in `special_tiles`
1230       is used instead, if present. This allows a visually thicker texture to be
1231       used to compensate for how `glasslike` reduces visual thickness.
1232 * `torchlike`
1233     * A single vertical texture.
1234     * If `paramtype2="[color]wallmounted"`:
1235         * If placed on top of a node, uses the first texture specified in `tiles`.
1236         * If placed against the underside of a node, uses the second texture
1237           specified in `tiles`.
1238         * If placed on the side of a node, uses the third texture specified in
1239           `tiles` and is perpendicular to that node.
1240     * If `paramtype2="none"`:
1241         * Will be rendered as if placed on top of a node (see
1242           above) and only the first texture is used.
1243 * `signlike`
1244     * A single texture parallel to, and mounted against, the top, underside or
1245       side of a node.
1246     * If `paramtype2="[color]wallmounted"`, it rotates according to `param2`
1247     * If `paramtype2="none"`, it will always be on the floor.
1248 * `plantlike`
1249     * Two vertical and diagonal textures at right-angles to each other.
1250     * See `paramtype2 = "meshoptions"` above for other options.
1251 * `firelike`
1252     * When above a flat surface, appears as 6 textures, the central 2 as
1253       `plantlike` plus 4 more surrounding those.
1254     * If not above a surface the central 2 do not appear, but the texture
1255       appears against the faces of surrounding nodes if they are present.
1256 * `fencelike`
1257     * A 3D model suitable for a wooden fence.
1258     * One placed node appears as a single vertical post.
1259     * Adjacently-placed nodes cause horizontal bars to appear between them.
1260 * `raillike`
1261     * Often used for tracks for mining carts.
1262     * Requires 4 textures to be specified in `tiles`, in order: Straight,
1263       curved, t-junction, crossing.
1264     * Each placed node automatically switches to a suitable rotated texture
1265       determined by the adjacent `raillike` nodes, in order to create a
1266       continuous track network.
1267     * Becomes a sloping node if placed against stepped nodes.
1268 * `nodebox`
1269     * Often used for stairs and slabs.
1270     * Allows defining nodes consisting of an arbitrary number of boxes.
1271     * See [Node boxes] below for more information.
1272 * `mesh`
1273     * Uses models for nodes.
1274     * Tiles should hold model materials textures.
1275     * Only static meshes are implemented.
1276     * For supported model formats see Irrlicht engine documentation.
1277 * `plantlike_rooted`
1278     * Enables underwater `plantlike` without air bubbles around the nodes.
1279     * Consists of a base cube at the co-ordinates of the node plus a
1280       `plantlike` extension above
1281     * If `paramtype2="leveled", the `plantlike` extension has a height
1282       of `param2 / 16` nodes, otherwise it's the height of 1 node
1283     * If `paramtype2="wallmounted"`, the `plantlike` extension
1284       will be at one of the corresponding 6 sides of the base cube.
1285       Also, the base cube rotates like a `normal` cube would
1286     * The `plantlike` extension visually passes through any nodes above the
1287       base cube without affecting them.
1288     * The base cube texture tiles are defined as normal, the `plantlike`
1289       extension uses the defined special tile, for example:
1290       `special_tiles = {{name = "default_papyrus.png"}},`
1291
1292 `*_optional` drawtypes need less rendering time if deactivated
1293 (always client-side).
1294
1295 Node boxes
1296 ----------
1297
1298 Node selection boxes are defined using "node boxes".
1299
1300 A nodebox is defined as any of:
1301
1302     {
1303         -- A normal cube; the default in most things
1304         type = "regular"
1305     }
1306     {
1307         -- A fixed box (or boxes) (facedir param2 is used, if applicable)
1308         type = "fixed",
1309         fixed = box OR {box1, box2, ...}
1310     }
1311     {
1312         -- A variable height box (or boxes) with the top face position defined
1313         -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
1314         -- by param2.
1315         -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
1316         type = "leveled",
1317         fixed = box OR {box1, box2, ...}
1318     }
1319     {
1320         -- A box like the selection box for torches
1321         -- (wallmounted param2 is used, if applicable)
1322         type = "wallmounted",
1323         wall_top = box,
1324         wall_bottom = box,
1325         wall_side = box
1326     }
1327     {
1328         -- A node that has optional boxes depending on neighboring nodes'
1329         -- presence and type. See also `connects_to`.
1330         type = "connected",
1331         fixed = box OR {box1, box2, ...}
1332         connect_top = box OR {box1, box2, ...}
1333         connect_bottom = box OR {box1, box2, ...}
1334         connect_front = box OR {box1, box2, ...}
1335         connect_left = box OR {box1, box2, ...}
1336         connect_back = box OR {box1, box2, ...}
1337         connect_right = box OR {box1, box2, ...}
1338         -- The following `disconnected_*` boxes are the opposites of the
1339         -- `connect_*` ones above, i.e. when a node has no suitable neighbor
1340         -- on the respective side, the corresponding disconnected box is drawn.
1341         disconnected_top = box OR {box1, box2, ...}
1342         disconnected_bottom = box OR {box1, box2, ...}
1343         disconnected_front = box OR {box1, box2, ...}
1344         disconnected_left = box OR {box1, box2, ...}
1345         disconnected_back = box OR {box1, box2, ...}
1346         disconnected_right = box OR {box1, box2, ...}
1347         disconnected = box OR {box1, box2, ...} -- when there is *no* neighbor
1348         disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
1349                                                       -- neighbors to the sides
1350     }
1351
1352 A `box` is defined as:
1353
1354     {x1, y1, z1, x2, y2, z2}
1355
1356 A box of a regular node would look like:
1357
1358     {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
1359
1360 To avoid collision issues, keep each value within the range of +/- 1.45.
1361 This also applies to leveled nodeboxes, where the final height shall not
1362 exceed this soft limit.
1363
1364
1365
1366 Map terminology and coordinates
1367 ===============================
1368
1369 Nodes, mapblocks, mapchunks
1370 ---------------------------
1371
1372 A 'node' is the fundamental cubic unit of a world and appears to a player as
1373 roughly 1x1x1 meters in size.
1374
1375 A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
1376 fundamental region of a world that is stored in the world database, sent to
1377 clients and handled by many parts of the engine.
1378 'mapblock' is preferred terminology to 'block' to help avoid confusion with
1379 'node', however 'block' often appears in the API.
1380
1381 A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
1382 (80x80x80 nodes) and is the volume of world generated in one operation by
1383 the map generator.
1384 The size in mapblocks has been chosen to optimize map generation.
1385
1386 Coordinates
1387 -----------
1388
1389 ### Orientation of axes
1390
1391 For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
1392
1393 ### Node coordinates
1394
1395 Almost all positions used in the API use node coordinates.
1396
1397 ### Mapblock coordinates
1398
1399 Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
1400 specify a particular mapblock.
1401 For example blockpos (0,0,0) specifies the mapblock that extends from
1402 node position (0,0,0) to node position (15,15,15).
1403
1404 #### Converting node position to the containing blockpos
1405
1406 To calculate the blockpos of the mapblock that contains the node at 'nodepos',
1407 for each axis:
1408
1409 * blockpos = math.floor(nodepos / 16)
1410
1411 #### Converting blockpos to min/max node positions
1412
1413 To calculate the min/max node positions contained in the mapblock at 'blockpos',
1414 for each axis:
1415
1416 * Minimum:
1417   nodepos = blockpos * 16
1418 * Maximum:
1419   nodepos = blockpos * 16 + 15
1420
1421
1422
1423
1424 HUD
1425 ===
1426
1427 HUD element types
1428 -----------------
1429
1430 The position field is used for all element types.
1431 To account for differing resolutions, the position coordinates are the
1432 percentage of the screen, ranging in value from `0` to `1`.
1433
1434 The `name` field is not yet used, but should contain a description of what the
1435 HUD element represents.
1436
1437 The `direction` field is the direction in which something is drawn.
1438 `0` draws from left to right, `1` draws from right to left, `2` draws from
1439 top to bottom, and `3` draws from bottom to top.
1440
1441 The `alignment` field specifies how the item will be aligned. It is a table
1442 where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
1443 moved to the left/up, and `1` is to the right/down. Fractional values can be
1444 used.
1445
1446 The `offset` field specifies a pixel offset from the position. Contrary to
1447 position, the offset is not scaled to screen size. This allows for some
1448 precisely positioned items in the HUD.
1449
1450 **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
1451 factor!
1452
1453 The `z_index` field specifies the order of HUD elements from back to front.
1454 Lower z-index elements are displayed behind higher z-index elements. Elements
1455 with same z-index are displayed in an arbitrary order. Default 0.
1456 Supports negative values. By convention, the following values are recommended:
1457
1458 *  -400: Graphical effects, such as vignette
1459 *  -300: Name tags, waypoints
1460 *  -200: Wieldhand
1461 *  -100: Things that block the player's view, e.g. masks
1462 *     0: Default. For standard in-game HUD elements like crosshair, hotbar,
1463          minimap, builtin statbars, etc.
1464 *   100: Temporary text messages or notification icons
1465 *  1000: Full-screen effects such as full-black screen or credits.
1466          This includes effects that cover the entire screen
1467
1468 If your HUD element doesn't fit into any category, pick a number
1469 between the suggested values
1470
1471 Below are the specific uses for fields in each type; fields not listed for that
1472 type are ignored.
1473
1474 ### `image`
1475
1476 Displays an image on the HUD.
1477
1478 * `scale`: The scale of the image, with 1 being the original texture size.
1479   Only the X coordinate scale is used (positive values).
1480   Negative values represent that percentage of the screen it
1481   should take; e.g. `x=-100` means 100% (width).
1482 * `text`: The name of the texture that is displayed.
1483 * `alignment`: The alignment of the image.
1484 * `offset`: offset in pixels from position.
1485
1486 ### `text`
1487
1488 Displays text on the HUD.
1489
1490 * `scale`: Defines the bounding rectangle of the text.
1491   A value such as `{x=100, y=100}` should work.
1492 * `text`: The text to be displayed in the HUD element.
1493 * `number`: An integer containing the RGB value of the color used to draw the
1494   text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
1495 * `alignment`: The alignment of the text.
1496 * `offset`: offset in pixels from position.
1497 * `size`: size of the text.
1498   The player-set font size is multiplied by size.x (y value isn't used).
1499 * `style`: determines font style
1500   Bitfield with 1 = bold, 2 = italic, 4 = monospace
1501
1502 ### `statbar`
1503
1504 Displays a horizontal bar made up of half-images with an optional background.
1505
1506 * `text`: The name of the texture to use.
1507 * `text2`: Optional texture name to enable a background / "off state"
1508   texture (useful to visualize the maximal value). Both textures
1509   must have the same size.
1510 * `number`: The number of half-textures that are displayed.
1511   If odd, will end with a vertically center-split texture.
1512 * `item`: Same as `number` but for the "off state" texture
1513 * `direction`: To which direction the images will extend to
1514 * `offset`: offset in pixels from position.
1515 * `size`: If used, will force full-image size to this value (override texture
1516   pack image size)
1517
1518 ### `inventory`
1519
1520 * `text`: The name of the inventory list to be displayed.
1521 * `number`: Number of items in the inventory to be displayed.
1522 * `item`: Position of item that is selected.
1523 * `direction`: Direction the list will be displayed in
1524 * `offset`: offset in pixels from position.
1525
1526 ### `waypoint`
1527
1528 Displays distance to selected world position.
1529
1530 * `name`: The name of the waypoint.
1531 * `text`: Distance suffix. Can be blank.
1532 * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
1533   If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
1534   When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
1535   `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
1536   `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
1537   `precision = n` will show multiples of `1/n`
1538 * `number:` An integer containing the RGB value of the color used to draw the
1539   text.
1540 * `world_pos`: World position of the waypoint.
1541 * `offset`: offset in pixels from position.
1542 * `alignment`: The alignment of the waypoint.
1543
1544 ### `image_waypoint`
1545
1546 Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
1547
1548 * `scale`: The scale of the image, with 1 being the original texture size.
1549   Only the X coordinate scale is used (positive values).
1550   Negative values represent that percentage of the screen it
1551   should take; e.g. `x=-100` means 100% (width).
1552 * `text`: The name of the texture that is displayed.
1553 * `alignment`: The alignment of the image.
1554 * `world_pos`: World position of the waypoint.
1555 * `offset`: offset in pixels from position.
1556
1557 ### `compass`
1558
1559 Displays an image oriented or translated according to current heading direction.
1560
1561 * `size`: The size of this element. Negative values represent percentage
1562   of the screen; e.g. `x=-100` means 100% (width).
1563 * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
1564 * `text`: The name of the texture to use.
1565 * `alignment`: The alignment of the image.
1566 * `offset`: Offset in pixels from position.
1567 * `direction`: How the image is rotated/translated:
1568   * 0 - Rotate as heading direction
1569   * 1 - Rotate in reverse direction
1570   * 2 - Translate as landscape direction
1571   * 3 - Translate in reverse direction
1572
1573 If translation is chosen, texture is repeated horizontally to fill the whole element.
1574
1575 ### `minimap`
1576
1577 Displays a minimap on the HUD.
1578
1579 * `size`: Size of the minimap to display. Minimap should be a square to avoid
1580   distortion.
1581 * `alignment`: The alignment of the minimap.
1582 * `offset`: offset in pixels from position.
1583
1584 Representations of simple things
1585 ================================
1586
1587 Vector (ie. a position)
1588 -----------------------
1589
1590     vector.new(x, y, z)
1591
1592 See [Spatial Vectors] for details.
1593
1594 `pointed_thing`
1595 ---------------
1596
1597 * `{type="nothing"}`
1598 * `{type="node", under=pos, above=pos}`
1599     * Indicates a pointed node selection box.
1600     * `under` refers to the node position behind the pointed face.
1601     * `above` refers to the node position in front of the pointed face.
1602 * `{type="object", ref=ObjectRef}`
1603
1604 Exact pointing location (currently only `Raycast` supports these fields):
1605
1606 * `pointed_thing.intersection_point`: The absolute world coordinates of the
1607   point on the selection box which is pointed at. May be in the selection box
1608   if the pointer is in the box too.
1609 * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
1610   from 1).
1611 * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
1612   selected selection box. This specifies which face is pointed at.
1613   Is a null vector `vector.zero()` when the pointer is inside the selection box.
1614   For entities with rotated selection boxes, this will be rotated properly
1615   by the entity's rotation - it will always be in absolute world space.
1616
1617
1618
1619
1620 Flag Specifier Format
1621 =====================
1622
1623 Flags using the standardized flag specifier format can be specified in either
1624 of two ways, by string or table.
1625
1626 The string format is a comma-delimited set of flag names; whitespace and
1627 unrecognized flag fields are ignored. Specifying a flag in the string sets the
1628 flag, and specifying a flag prefixed by the string `"no"` explicitly
1629 clears the flag from whatever the default may be.
1630
1631 In addition to the standard string flag format, the schematic flags field can
1632 also be a table of flag names to boolean values representing whether or not the
1633 flag is set. Additionally, if a field with the flag name prefixed with `"no"`
1634 is present, mapped to a boolean of any value, the specified flag is unset.
1635
1636 E.g. A flag field of value
1637
1638     {place_center_x = true, place_center_y=false, place_center_z=true}
1639
1640 is equivalent to
1641
1642     {place_center_x = true, noplace_center_y=true, place_center_z=true}
1643
1644 which is equivalent to
1645
1646     "place_center_x, noplace_center_y, place_center_z"
1647
1648 or even
1649
1650     "place_center_x, place_center_z"
1651
1652 since, by default, no schematic attributes are set.
1653
1654
1655
1656
1657 Items
1658 =====
1659
1660 Items are things that can be held by players, dropped in the map and
1661 stored in inventories.
1662 Items come in the form of item stacks, which are collections of equal
1663 items that occupy a single inventory slot.
1664
1665 Item types
1666 ----------
1667
1668 There are three kinds of items: nodes, tools and craftitems.
1669
1670 * Node: Placeable item form of a node in the world's voxel grid
1671 * Tool: Has a changeable wear property but cannot be stacked
1672 * Craftitem: Has no special properties
1673
1674 Every registered node (the voxel in the world) has a corresponding
1675 item form (the thing in your inventory) that comes along with it.
1676 This item form can be placed which will create a node in the
1677 world (by default).
1678 Both the 'actual' node and its item form share the same identifier.
1679 For all practical purposes, you can treat the node and its item form
1680 interchangeably. We usually just say 'node' to the item form of
1681 the node as well.
1682
1683 Note the definition of tools is purely technical. The only really
1684 unique thing about tools is their wear, and that's basically it.
1685 Beyond that, you can't make any gameplay-relevant assumptions
1686 about tools or non-tools. It is perfectly valid to register something
1687 that acts as tool in a gameplay sense as a craftitem, and vice-versa.
1688
1689 Craftitems can be used for items that neither need to be a node
1690 nor a tool.
1691
1692 Amount and wear
1693 ---------------
1694
1695 All item stacks have an amount between 0 and 65535. It is 1 by
1696 default. Tool item stacks cannot have an amount greater than 1.
1697
1698 Tools use a wear (damage) value ranging from 0 to 65535. The
1699 value 0 is the default and is used for unworn tools. The values
1700 1 to 65535 are used for worn tools, where a higher value stands for
1701 a higher wear. Non-tools technically also have a wear property,
1702 but it is always 0. There is also a special 'toolrepair' crafting
1703 recipe that is only available to tools.
1704
1705 Item formats
1706 ------------
1707
1708 Items and item stacks can exist in three formats: Serializes, table format
1709 and `ItemStack`.
1710
1711 When an item must be passed to a function, it can usually be in any of
1712 these formats.
1713
1714 ### Serialized
1715
1716 This is called "stackstring" or "itemstring". It is a simple string with
1717 1-4 components:
1718
1719 1. Full item identifier ("item name")
1720 2. Optional amount
1721 3. Optional wear value
1722 4. Optional item metadata
1723
1724 Syntax:
1725
1726     <identifier> [<amount>[ <wear>[ <metadata>]]]
1727
1728 Examples:
1729
1730 * `"default:apple"`: 1 apple
1731 * `"default:dirt 5"`: 5 dirt
1732 * `"default:pick_stone"`: a new stone pickaxe
1733 * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
1734 * `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`:
1735   * a wooden pickaxe from the `default` mod,
1736   * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool),
1737   * with the `description` field set to `"My worn out pick"` in its metadata
1738 * `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`:
1739   * analogous to the above example
1740   * note how the wear is set to `0` as dirt is not a tool
1741
1742 You should ideally use the `ItemStack` format to build complex item strings
1743 (especially if they use item metadata)
1744 without relying on the serialization format. Example:
1745
1746     local stack = ItemStack("default:pick_wood")
1747     stack:set_wear(21323)
1748     stack:get_meta():set_string("description", "My worn out pick")
1749     local itemstring = stack:to_string()
1750
1751 Additionally the methods `minetest.itemstring_with_palette(item, palette_index)`
1752 and `minetest.itemstring_with_color(item, colorstring)` may be used to create
1753 item strings encoding color information in their metadata.
1754
1755 ### Table format
1756
1757 Examples:
1758
1759 5 dirt nodes:
1760
1761     {name="default:dirt", count=5, wear=0, metadata=""}
1762
1763 A wooden pick about 1/3 worn out:
1764
1765     {name="default:pick_wood", count=1, wear=21323, metadata=""}
1766
1767 An apple:
1768
1769     {name="default:apple", count=1, wear=0, metadata=""}
1770
1771 ### `ItemStack`
1772
1773 A native C++ format with many helper methods. Useful for converting
1774 between formats. See the [Class reference] section for details.
1775
1776
1777
1778
1779 Groups
1780 ======
1781
1782 In a number of places, there is a group table. Groups define the
1783 properties of a thing (item, node, armor of entity, tool capabilities)
1784 in such a way that the engine and other mods can can interact with
1785 the thing without actually knowing what the thing is.
1786
1787 Usage
1788 -----
1789
1790 Groups are stored in a table, having the group names with keys and the
1791 group ratings as values. Group ratings are integer values within the
1792 range [-32767, 32767]. For example:
1793
1794     -- Default dirt
1795     groups = {crumbly=3, soil=1}
1796
1797     -- A more special dirt-kind of thing
1798     groups = {crumbly=2, soil=1, level=2, outerspace=1}
1799
1800 Groups always have a rating associated with them. If there is no
1801 useful meaning for a rating for an enabled group, it shall be `1`.
1802
1803 When not defined, the rating of a group defaults to `0`. Thus when you
1804 read groups, you must interpret `nil` and `0` as the same value, `0`.
1805
1806 You can read the rating of a group for an item or a node by using
1807
1808     minetest.get_item_group(itemname, groupname)
1809
1810 Groups of items
1811 ---------------
1812
1813 Groups of items can define what kind of an item it is (e.g. wool).
1814
1815 Groups of nodes
1816 ---------------
1817
1818 In addition to the general item things, groups are used to define whether
1819 a node is destroyable and how long it takes to destroy by a tool.
1820
1821 Groups of entities
1822 ------------------
1823
1824 For entities, groups are, as of now, used only for calculating damage.
1825 The rating is the percentage of damage caused by items with this damage group.
1826 See [Entity damage mechanism].
1827
1828     object:get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
1829     object:set_armor_groups({fleshy=30, cracky=80})
1830
1831 Groups of tool capabilities
1832 ---------------------------
1833
1834 Groups in tool capabilities define which groups of nodes and entities they
1835 are effective towards.
1836
1837 Groups in crafting recipes
1838 --------------------------
1839
1840 In crafting recipes, you can specify a group as an input item.
1841 This means that any item in that group will be accepted as input.
1842
1843 The basic syntax is:
1844
1845     "group:<group_name>"
1846
1847 For example, `"group:meat"` will accept any item in the `meat` group.
1848
1849 It is also possible to require an input item to be in
1850 multiple groups at once. The syntax for that is:
1851
1852     "group:<group_name_1>,<group_name_2>,(...),<group_name_n>"
1853
1854 For example, `"group:leaves,birch,trimmed"` accepts any item which is member
1855 of *all* the groups `leaves` *and* `birch` *and* `trimmed`.
1856
1857 An example recipe: Craft a raw meat soup from any meat, any water and any bowl:
1858
1859     {
1860         output = "food:meat_soup_raw",
1861         recipe = {
1862             {"group:meat"},
1863             {"group:water"},
1864             {"group:bowl"},
1865         },
1866     }
1867
1868 Another example: Craft red wool from white wool and red dye
1869 (here, "red dye" is defined as any item which is member of
1870 *both* the groups `dye` and `basecolor_red`).
1871
1872     {
1873         type = "shapeless",
1874         output = "wool:red",
1875         recipe = {"wool:white", "group:dye,basecolor_red"},
1876     }
1877
1878 Special groups
1879 --------------
1880
1881 The asterisk `(*)` after a group name describes that there is no engine
1882 functionality bound to it, and implementation is left up as a suggestion
1883 to games.
1884
1885 ### Node and item groups
1886
1887 * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
1888   that the item should be hidden in item lists.
1889
1890
1891 ### Node-only groups
1892
1893 * `attached_node`: the node is 'attached' to a neighboring node. It checks
1894                    whether the node it is attached to is walkable. If it
1895                    isn't, the node will drop as an item.
1896     * `1`: if the node is wallmounted, the node is attached in the wallmounted
1897            direction. Otherwise, the node is attached to the node below.
1898     * `2`: if the node is facedir or 4dir, the facedir or 4dir direction is checked.
1899            No effect for other nodes.
1900            Note: The "attaching face" of this node is tile no. 5 (back face).
1901     * `3`: the node is always attached to the node below.
1902     * `4`: the node is always attached to the node above.
1903 * `bouncy`: value is bounce speed in percent.
1904   If positive, jump/sneak on floor impact will increase/decrease bounce height.
1905   Negative value is the same bounciness, but non-controllable.
1906 * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1907   connect to each other
1908 * `dig_immediate`: Player can always pick up node without reducing tool wear
1909     * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
1910     * `3`: the node always gets the digging time 0 seconds (torch)
1911 * `disable_jump`: Player (and possibly other things) cannot jump from node
1912   or if their feet are in the node. Note: not supported for `new_move = false`
1913 * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
1914   the top of this node. There's also an armor group with the same name.
1915   The final player damage is determined by the following formula:
1916     damage =
1917       collision speed
1918       * ((node_fall_damage_add_percent   + 100) / 100) -- node group
1919       * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
1920       - (14)                                           -- constant tolerance
1921   Negative damage values are discarded as no damage.
1922 * `falling_node`: if there is no walkable block under the node it will fall
1923 * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
1924 * `level`: Can be used to give an additional sense of progression in the game.
1925      * A larger level will cause e.g. a weapon of a lower level make much less
1926        damage, and get worn out much faster, or not be able to get drops
1927        from destroyed nodes.
1928      * `0` is something that is directly accessible at the start of gameplay
1929      * There is no upper limit
1930      * See also: `leveldiff` in [Tool Capabilities]
1931 * `slippery`: Players and items will slide on the node.
1932   Slipperiness rises steadily with `slippery` value, starting at 1.
1933
1934
1935 ### Tool-only groups
1936
1937 * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
1938   `"toolrepair"` crafting recipe
1939
1940
1941 ### `ObjectRef` armor groups
1942
1943 * `immortal`: Skips all damage and breath handling for an object. This group
1944   will also hide the integrated HUD status bars for players. It is
1945   automatically set to all players when damage is disabled on the server and
1946   cannot be reset (subject to change).
1947 * `fall_damage_add_percent`: Modifies the fall damage suffered by players
1948   when they hit the ground. It is analog to the node group with the same
1949   name. See the node group above for the exact calculation.
1950 * `punch_operable`: For entities; disables the regular damage mechanism for
1951   players punching it by hand or a non-tool item, so that it can do something
1952   else than take damage.
1953
1954
1955
1956 Known damage and digging time defining groups
1957 ---------------------------------------------
1958
1959 * `crumbly`: dirt, sand
1960 * `cracky`: tough but crackable stuff like stone.
1961 * `snappy`: something that can be cut using things like scissors, shears,
1962   bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
1963 * `choppy`: something that can be cut using force; e.g. trees, wooden planks
1964 * `fleshy`: Living things like animals and the player. This could imply
1965   some blood effects when hitting.
1966 * `explody`: Especially prone to explosions
1967 * `oddly_breakable_by_hand`:
1968    Can be added to nodes that shouldn't logically be breakable by the
1969    hand but are. Somewhat similar to `dig_immediate`, but times are more
1970    like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
1971    digging speed of an item if it can dig at a faster speed than this
1972    suggests for the hand.
1973
1974 Examples of custom groups
1975 -------------------------
1976
1977 Item groups are often used for defining, well, _groups of items_.
1978
1979 * `meat`: any meat-kind of a thing (rating might define the size or healing
1980   ability or be irrelevant -- it is not defined as of yet)
1981 * `eatable`: anything that can be eaten. Rating might define HP gain in half
1982   hearts.
1983 * `flammable`: can be set on fire. Rating might define the intensity of the
1984   fire, affecting e.g. the speed of the spreading of an open fire.
1985 * `wool`: any wool (any origin, any color)
1986 * `metal`: any metal
1987 * `weapon`: any weapon
1988 * `heavy`: anything considerably heavy
1989
1990 Digging time calculation specifics
1991 ----------------------------------
1992
1993 Groups such as `crumbly`, `cracky` and `snappy` are used for this
1994 purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
1995 faster digging time.
1996
1997 The `level` group is used to limit the toughness of nodes an item capable
1998 of digging can dig and to scale the digging times / damage to a greater extent.
1999
2000 **Please do understand this**, otherwise you cannot use the system to it's
2001 full potential.
2002
2003 Items define their properties by a list of parameters for groups. They
2004 cannot dig other groups; thus it is important to use a standard bunch of
2005 groups to enable interaction with items.
2006
2007
2008
2009
2010 Tool Capabilities
2011 =================
2012
2013 'Tool capabilities' is a property of items that defines two things:
2014
2015 1) Which nodes it can dig and how fast
2016 2) Which objects it can hurt by punching and by how much
2017
2018 Tool capabilities are available for all items, not just tools.
2019 But only tools can receive wear from digging and punching.
2020
2021 Missing or incomplete tool capabilities will default to the
2022 player's hand.
2023
2024 Tool capabilities definition
2025 ----------------------------
2026
2027 Tool capabilities define:
2028
2029 * Full punch interval
2030 * Maximum drop level
2031 * For an arbitrary list of node groups:
2032     * Uses (until the tool breaks)
2033     * Maximum level (usually `0`, `1`, `2` or `3`)
2034     * Digging times
2035 * Damage groups
2036 * Punch attack uses (until the tool breaks)
2037
2038 ### Full punch interval `full_punch_interval`
2039
2040 When used as a weapon, the item will do full damage if this time is spent
2041 between punches. If e.g. half the time is spent, the item will do half
2042 damage.
2043
2044 ### Maximum drop level `max_drop_level`
2045
2046 Suggests the maximum level of node, when dug with the item, that will drop
2047 its useful item. (e.g. iron ore to drop a lump of iron).
2048
2049 This value is not used in the engine; it is the responsibility of the game/mod
2050 code to implement this.
2051
2052 ### Uses `uses` (tools only)
2053
2054 Determines how many uses the tool has when it is used for digging a node,
2055 of this group, of the maximum level. The maximum supported number of
2056 uses is 65535. The special number 0 is used for infinite uses.
2057 For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
2058 `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
2059 node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
2060
2061 * `uses=10, leveldiff=0`: actual uses: 10
2062 * `uses=10, leveldiff=1`: actual uses: 30
2063 * `uses=10, leveldiff=2`: actual uses: 90
2064
2065 For non-tools, this has no effect.
2066
2067 ### Maximum level `maxlevel`
2068
2069 Tells what is the maximum level of a node of this group that the item will
2070 be able to dig.
2071
2072 ### Digging times `times`
2073
2074 List of digging times for different ratings of the group, for nodes of the
2075 maximum level.
2076
2077 For example, as a Lua table, `times={[2]=2.00, [3]=0.70}`. This would
2078 result in the item to be able to dig nodes that have a rating of `2` or `3`
2079 for this group, and unable to dig the rating `1`, which is the toughest.
2080 Unless there is a matching group that enables digging otherwise.
2081
2082 If the result digging time is 0, a delay of 0.15 seconds is added between
2083 digging nodes; If the player releases LMB after digging, this delay is set to 0,
2084 i.e. players can more quickly click the nodes away instead of holding LMB.
2085
2086 ### Damage groups
2087
2088 List of damage for groups of entities. See [Entity damage mechanism].
2089
2090 ### Punch attack uses (tools only)
2091
2092 Determines how many uses (before breaking) the tool has when dealing damage
2093 to an object, when the full punch interval (see above) was always
2094 waited out fully.
2095
2096 Wear received by the tool is proportional to the time spent, scaled by
2097 the full punch interval.
2098
2099 For non-tools, this has no effect.
2100
2101 Example definition of the capabilities of an item
2102 -------------------------------------------------
2103
2104     tool_capabilities = {
2105         groupcaps={
2106             crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
2107         },
2108     }
2109
2110 This makes the item capable of digging nodes that fulfill both of these:
2111
2112 * Have the `crumbly` group
2113 * Have a `level` group less or equal to `2`
2114
2115 Table of resulting digging times:
2116
2117     crumbly        0     1     2     3     4  <- level
2118          ->  0     -     -     -     -     -
2119              1  0.80  1.60  1.60     -     -
2120              2  0.60  1.20  1.20     -     -
2121              3  0.40  0.80  0.80     -     -
2122
2123     level diff:    2     1     0    -1    -2
2124
2125 Table of resulting tool uses:
2126
2127     ->  0     -     -     -     -     -
2128         1   180    60    20     -     -
2129         2   180    60    20     -     -
2130         3   180    60    20     -     -
2131
2132 **Notes**:
2133
2134 * At `crumbly==0`, the node is not diggable.
2135 * At `crumbly==3`, the level difference digging time divider kicks in and makes
2136   easy nodes to be quickly breakable.
2137 * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
2138
2139
2140
2141
2142 Entity damage mechanism
2143 =======================
2144
2145 Damage calculation:
2146
2147     damage = 0
2148     foreach group in cap.damage_groups:
2149         damage += cap.damage_groups[group]
2150             * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
2151             * (object.armor_groups[group] / 100.0)
2152             -- Where object.armor_groups[group] is 0 for inexistent values
2153     return damage
2154
2155 Client predicts damage based on damage groups. Because of this, it is able to
2156 give an immediate response when an entity is damaged or dies; the response is
2157 pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
2158 TODO).
2159 Currently a smoke puff will appear when an entity dies.
2160
2161 The group `immortal` completely disables normal damage.
2162
2163 Entities can define a special armor group, which is `punch_operable`. This
2164 group disables the regular damage mechanism for players punching it by hand or
2165 a non-tool item, so that it can do something else than take damage.
2166
2167 On the Lua side, every punch calls:
2168
2169     entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
2170                     damage)
2171
2172 This should never be called directly, because damage is usually not handled by
2173 the entity itself.
2174
2175 * `puncher` is the object performing the punch. Can be `nil`. Should never be
2176   accessed unless absolutely required, to encourage interoperability.
2177 * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
2178 * `tool_capabilities` can be `nil`.
2179 * `direction` is a unit vector, pointing from the source of the punch to
2180    the punched object.
2181 * `damage` damage that will be done to entity
2182 Return value of this function will determine if damage is done by this function
2183 (retval true) or shall be done by engine (retval false)
2184
2185 To punch an entity/object in Lua, call:
2186
2187   object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
2188
2189 * Return value is tool wear.
2190 * Parameters are equal to the above callback.
2191 * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
2192   will be automatically filled in based on the location of `puncher`.
2193
2194
2195
2196
2197 Metadata
2198 ========
2199
2200 Node Metadata
2201 -------------
2202
2203 The instance of a node in the world normally only contains the three values
2204 mentioned in [Nodes]. However, it is possible to insert extra data into a node.
2205 It is called "node metadata"; See `NodeMetaRef`.
2206
2207 Node metadata contains two things:
2208
2209 * A key-value store
2210 * An inventory
2211
2212 Some of the values in the key-value store are handled specially:
2213
2214 * `formspec`: Defines an inventory menu that is opened with the
2215               'place/use' key. Only works if no `on_rightclick` was
2216               defined for the node. See also [Formspec].
2217 * `infotext`: Text shown on the screen when the node is pointed at.
2218               Line-breaks will be applied automatically.
2219               If the infotext is very long, it will be truncated.
2220
2221 Example:
2222
2223     local meta = minetest.get_meta(pos)
2224     meta:set_string("formspec",
2225             "size[8,9]"..
2226             "list[context;main;0,0;8,4;]"..
2227             "list[current_player;main;0,5;8,4;]")
2228     meta:set_string("infotext", "Chest");
2229     local inv = meta:get_inventory()
2230     inv:set_size("main", 8*4)
2231     print(dump(meta:to_table()))
2232     meta:from_table({
2233         inventory = {
2234             main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
2235                     [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
2236                     [10] = "", [11] = "", [12] = "", [13] = "",
2237                     [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
2238                     [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
2239                     [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
2240                     [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
2241                     [32] = ""}
2242         },
2243         fields = {
2244             formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
2245             infotext = "Chest"
2246         }
2247     })
2248
2249 Item Metadata
2250 -------------
2251
2252 Item stacks can store metadata too. See [`ItemStackMetaRef`].
2253
2254 Item metadata only contains a key-value store.
2255
2256 Some of the values in the key-value store are handled specially:
2257
2258 * `description`: Set the item stack's description.
2259   See also: `get_description` in [`ItemStack`]
2260 * `short_description`: Set the item stack's short description.
2261   See also: `get_short_description` in [`ItemStack`]
2262 * `color`: A `ColorString`, which sets the stack's color.
2263 * `palette_index`: If the item has a palette, this is used to get the
2264   current color from the palette.
2265 * `count_meta`: Replace the displayed count with any string.
2266 * `count_alignment`: Set the alignment of the displayed count value. This is an
2267   int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
2268   4th bit specify the alignment in y-direction:
2269   0 = default, 1 = left / up, 2 = middle, 3 = right / down
2270   The default currently is the same as right/down.
2271   Example: 6 = 2 + 1*4 = middle,up
2272
2273 Example:
2274
2275     local meta = stack:get_meta()
2276     meta:set_string("key", "value")
2277     print(dump(meta:to_table()))
2278
2279 Example manipulations of "description" and expected output behaviors:
2280
2281     print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
2282     print(ItemStack("foobar"):get_description()) --> Unknown Item
2283
2284     local stack = ItemStack("default:stone")
2285     stack:get_meta():set_string("description", "Custom description\nAnother line")
2286     print(stack:get_description()) --> Custom description\nAnother line
2287     print(stack:get_short_description()) --> Custom description
2288
2289     stack:get_meta():set_string("short_description", "Short")
2290     print(stack:get_description()) --> Custom description\nAnother line
2291     print(stack:get_short_description()) --> Short
2292
2293     print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
2294
2295
2296
2297 Formspec
2298 ========
2299
2300 Formspec defines a menu. This supports inventories and some of the
2301 typical widgets like buttons, checkboxes, text input fields, etc.
2302 It is a string, with a somewhat strange format.
2303
2304 A formspec is made out of formspec elements, which includes widgets
2305 like buttons but also can be used to set stuff like background color.
2306
2307 Many formspec elements have a `name`, which is a unique identifier which
2308 is used when the server receives user input. You must not use the name
2309 "quit" for formspec elements.
2310
2311 Spaces and newlines can be inserted between the blocks, as is used in the
2312 examples.
2313
2314 Position and size units are inventory slots unless the new coordinate system
2315 is enabled. `X` and `Y` position the formspec element relative to the top left
2316 of the menu or container. `W` and `H` are its width and height values.
2317
2318 If the new system is enabled, all elements have unified coordinates for all
2319 elements with no padding or spacing in between. This is highly recommended
2320 for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
2321 Coordinates`.
2322
2323 Inventories with a `player:<name>` inventory location are only sent to the
2324 player named `<name>`.
2325
2326 When displaying text which can contain formspec code, e.g. text set by a player,
2327 use `minetest.formspec_escape`.
2328 For colored text you can use `minetest.colorize`.
2329
2330 Since formspec version 3, elements drawn in the order they are defined. All
2331 background elements are drawn before all other elements.
2332
2333 **WARNING**: do _not_ use an element name starting with `key_`; those names are
2334 reserved to pass key press events to formspec!
2335
2336 **WARNING**: Minetest allows you to add elements to every single formspec instance
2337 using `player:set_formspec_prepend()`, which may be the reason backgrounds are
2338 appearing when you don't expect them to, or why things are styled differently
2339 to normal. See [`no_prepend[]`] and [Styling Formspecs].
2340
2341 Examples
2342 --------
2343
2344 ### Chest
2345
2346     size[8,9]
2347     list[context;main;0,0;8,4;]
2348     list[current_player;main;0,5;8,4;]
2349
2350 ### Furnace
2351
2352     size[8,9]
2353     list[context;fuel;2,3;1,1;]
2354     list[context;src;2,1;1,1;]
2355     list[context;dst;5,1;2,2;]
2356     list[current_player;main;0,5;8,4;]
2357
2358 ### Minecraft-like player inventory
2359
2360     size[8,7.5]
2361     image[1,0.6;1,2;player.png]
2362     list[current_player;main;0,3.5;8,4;]
2363     list[current_player;craft;3,0;3,3;]
2364     list[current_player;craftpreview;7,1;1,1;]
2365
2366 Version History
2367 ---------------
2368
2369 * Formspec version 1 (pre-5.1.0):
2370   * (too much)
2371 * Formspec version 2 (5.1.0):
2372   * Forced real coordinates
2373   * background9[]: 9-slice scaling parameters
2374 * Formspec version 3 (5.2.0):
2375   * Formspec elements are drawn in the order of definition
2376   * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
2377   * box[] and image[] elements enable clipping by default
2378   * new element: scroll_container[]
2379 * Formspec version 4 (5.4.0):
2380   * Allow dropdown indexing events
2381 * Formspec version 5 (5.5.0):
2382   * Added padding[] element
2383 * Formspec version 6 (5.6.0):
2384   * Add nine-slice images, animated_image, and fgimg_middle
2385
2386 Elements
2387 --------
2388
2389 ### `formspec_version[<version>]`
2390
2391 * Set the formspec version to a certain number. If not specified,
2392   version 1 is assumed.
2393 * Must be specified before `size` element.
2394 * Clients older than this version can neither show newer elements nor display
2395   elements with new arguments correctly.
2396 * Available since feature `formspec_version_element`.
2397 * See also: [Version History]
2398
2399 ### `size[<W>,<H>,<fixed_size>]`
2400
2401 * Define the size of the menu in inventory slots
2402 * `fixed_size`: `true`/`false` (optional)
2403 * deprecated: `invsize[<W>,<H>;]`
2404
2405 ### `position[<X>,<Y>]`
2406
2407 * Must be used after `size` element.
2408 * Defines the position on the game window of the formspec's `anchor` point.
2409 * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
2410   for example:
2411     * [0.0, 0.0] sets the position to the top left corner of the game window.
2412     * [1.0, 1.0] sets the position to the bottom right of the game window.
2413 * Defaults to the center of the game window [0.5, 0.5].
2414
2415 ### `anchor[<X>,<Y>]`
2416
2417 * Must be used after both `size` and `position` (if present) elements.
2418 * Defines the location of the anchor point within the formspec.
2419 * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
2420   for example:
2421     * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
2422     * [1.0, 0.0] sets the anchor to the top right of the formspec.
2423 * Defaults to the center of the formspec [0.5, 0.5].
2424
2425 * `position` and `anchor` elements need suitable values to avoid a formspec
2426   extending off the game window due to particular game window sizes.
2427
2428 ### `padding[<X>,<Y>]`
2429
2430 * Must be used after the `size`, `position`, and `anchor` elements (if present).
2431 * Defines how much space is padded around the formspec if the formspec tries to
2432   increase past the size of the screen and coordinates have to be shrunk.
2433 * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
2434   screen), and 0.5 represents half the screen (which forces the coordinate size
2435   to 0). If negative, the formspec can extend off the edge of the screen.
2436 * Defaults to [0.05, 0.05].
2437
2438 ### `no_prepend[]`
2439
2440 * Must be used after the `size`, `position`, `anchor`, and `padding` elements
2441   (if present).
2442 * Disables player:set_formspec_prepend() from applying to this formspec.
2443
2444 ### `real_coordinates[<bool>]`
2445
2446 * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
2447 * When set to true, all following formspec elements will use the new coordinate system.
2448 * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
2449   (if present), the form size will use the new coordinate system.
2450 * **Note**: Formspec prepends are not affected by the coordinates in the main form.
2451   They must enable it explicitly.
2452 * For information on converting forms to the new coordinate system, see `Migrating
2453   to Real Coordinates`.
2454
2455 ### `container[<X>,<Y>]`
2456
2457 * Start of a container block, moves all physical elements in the container by
2458   (X, Y).
2459 * Must have matching `container_end`
2460 * Containers can be nested, in which case the offsets are added
2461   (child containers are relative to parent containers)
2462
2463 ### `container_end[]`
2464
2465 * End of a container, following elements are no longer relative to this
2466   container.
2467
2468 ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
2469
2470 * Start of a scroll_container block. All contained elements will ...
2471   * take the scroll_container coordinate as position origin,
2472   * be additionally moved by the current value of the scrollbar with the name
2473     `scrollbar name` times `scroll factor` along the orientation `orientation` and
2474   * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
2475 * `orientation`: possible values are `vertical` and `horizontal`.
2476 * `scroll factor`: optional, defaults to `0.1`.
2477 * Nesting is possible.
2478 * Some elements might work a little different if they are in a scroll_container.
2479 * Note: If you want the scroll_container to actually work, you also need to add a
2480   scrollbar element with the specified name. Furthermore, it is highly recommended
2481   to use a scrollbaroptions element on this scrollbar.
2482
2483 ### `scroll_container_end[]`
2484
2485 * End of a scroll_container, following elements are no longer bound to this
2486   container.
2487
2488 ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
2489
2490 * Show an inventory list if it has been sent to the client.
2491 * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
2492   are moved) while the formspec is open, the formspec element may (but is not guaranteed
2493   to) adapt to the new inventory list.
2494 * Item slots are drawn in a grid from left to right, then up to down, ordered
2495   according to the slot index.
2496 * `W` and `H` are in inventory slots, not in coordinates.
2497 * `starting item index` (Optional): The index of the first (upper-left) item to draw.
2498   Indices start at `0`. Default is `0`.
2499 * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
2500   `starting item index`.
2501 * **Note**: With the new coordinate system, the spacing between inventory
2502   slots is one-fourth the size of an inventory slot by default. Also see
2503   [Styling Formspecs] for changing the size of slots and spacing.
2504
2505 ### `listring[<inventory location>;<list name>]`
2506
2507 * Appends to an internal ring of inventory lists.
2508 * Shift-clicking on items in one element of the ring
2509   will send them to the next inventory list inside the ring
2510 * The first occurrence of an element inside the ring will
2511   determine the inventory where items will be sent to
2512
2513 ### `listring[]`
2514
2515 * Shorthand for doing `listring[<inventory location>;<list name>]`
2516   for the last two inventory lists added by list[...]
2517
2518 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
2519
2520 * Sets background color of slots as `ColorString`
2521 * Sets background color of slots on mouse hovering
2522
2523 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
2524
2525 * Sets background color of slots as `ColorString`
2526 * Sets background color of slots on mouse hovering
2527 * Sets color of slots border
2528
2529 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
2530
2531 * Sets background color of slots as `ColorString`
2532 * Sets background color of slots on mouse hovering
2533 * Sets color of slots border
2534 * Sets default background color of tooltips
2535 * Sets default font color of tooltips
2536
2537 ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2538
2539 * Adds tooltip for an element
2540 * `bgcolor` tooltip background color as `ColorString` (optional)
2541 * `fontcolor` tooltip font color as `ColorString` (optional)
2542
2543 ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2544
2545 * Adds tooltip for an area. Other tooltips will take priority when present.
2546 * `bgcolor` tooltip background color as `ColorString` (optional)
2547 * `fontcolor` tooltip font color as `ColorString` (optional)
2548
2549 ### `image[<X>,<Y>;<W>,<H>;<texture name>;<middle>]`
2550
2551 * Show an image.
2552 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2553     * Requires formspec version >= 6.
2554     * See `background9[]` documentation for more information.
2555
2556 ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
2557
2558 * Show an animated image. The image is drawn like a "vertical_frames" tile
2559   animation (See [Tile animation definition]), but uses a frame count/duration for simplicity
2560 * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
2561 * `texture name`: The image to use.
2562 * `frame count`: The number of frames animating the image.
2563 * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
2564 * `frame start` (optional): The index of the frame to start on. Default `1`.
2565 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2566     * Requires formspec version >= 6.
2567     * See `background9[]` documentation for more information.
2568
2569 ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
2570
2571 * Show a mesh model.
2572 * `name`: Element name that can be used for styling
2573 * `mesh`: The mesh model to use.
2574 * `textures`: The mesh textures to use according to the mesh materials.
2575    Texture names must be separated by commas.
2576 * `rotation {X,Y}` (Optional): Initial rotation of the camera.
2577   The axes are euler angles in degrees.
2578 * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
2579 * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
2580 * `frame loop range` (Optional): Range of the animation frames.
2581     * Defaults to the full range of all available frames.
2582     * Syntax: `<begin>,<end>`
2583 * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
2584
2585 ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
2586
2587 * Show an inventory image of registered item/node
2588
2589 ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
2590
2591 * Sets background color of formspec.
2592 * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
2593   of the non-fullscreen and the fullscreen background.
2594 * `fullscreen` (optional) can be one of the following:
2595   * `false`: Only the non-fullscreen background color is drawn. (default)
2596   * `true`: Only the fullscreen background color is drawn.
2597   * `both`: The non-fullscreen and the fullscreen background color are drawn.
2598   * `neither`: No background color is drawn.
2599 * Note: Leave a parameter empty to not modify the value.
2600 * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
2601   are not bools are only available since formspec version 3.
2602
2603 ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
2604
2605 * Example for formspec 8x4 in 16x resolution: image shall be sized
2606   8 times 16px  times  4 times 16px.
2607
2608 ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
2609
2610 * Example for formspec 8x4 in 16x resolution:
2611   image shall be sized 8 times 16px  times  4 times 16px
2612 * If `auto_clip` is `true`, the background is clipped to the formspec size
2613   (`x` and `y` are used as offset values, `w` and `h` are ignored)
2614
2615 ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
2616
2617 * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
2618 * Middle is a rect which defines the middle of the 9-slice.
2619     * `x` - The middle will be x pixels from all sides.
2620     * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
2621     * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
2622         will be added to the width and height of the texture, allowing it to be used as the
2623         distance from the far end.
2624     * All numbers in middle are integers.
2625 * If `auto_clip` is `true`, the background is clipped to the formspec size
2626   (`x` and `y` are used as offset values, `w` and `h` are ignored)
2627 * Available since formspec version 2
2628
2629 ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
2630
2631 * Textual password style field; will be sent to server when a button is clicked
2632 * When enter is pressed in field, fields.key_enter_field will be sent with the
2633   name of this field.
2634 * With the old coordinate system, fields are a set height, but will be vertically
2635   centered on `H`. With the new coordinate system, `H` will modify the height.
2636 * `name` is the name of the field as returned in fields to `on_receive_fields`
2637 * `label`, if not blank, will be text printed on the top left above the field
2638 * See `field_close_on_enter` to stop enter closing the formspec
2639
2640 ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2641
2642 * Textual field; will be sent to server when a button is clicked
2643 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2644   the name of this field.
2645 * With the old coordinate system, fields are a set height, but will be vertically
2646   centered on `H`. With the new coordinate system, `H` will modify the height.
2647 * `name` is the name of the field as returned in fields to `on_receive_fields`
2648 * `label`, if not blank, will be text printed on the top left above the field
2649 * `default` is the default value of the field
2650     * `default` may contain variable references such as `${text}` which
2651       will fill the value from the metadata value `text`
2652     * **Note**: no extra text or more than a single variable is supported ATM.
2653 * See `field_close_on_enter` to stop enter closing the formspec
2654
2655 ### `field[<name>;<label>;<default>]`
2656
2657 * As above, but without position/size units
2658 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2659   the name of this field.
2660 * Special field for creating simple forms, such as sign text input
2661 * Must be used without a `size[]` element
2662 * A "Proceed" button will be added automatically
2663 * See `field_close_on_enter` to stop enter closing the formspec
2664
2665 ### `field_close_on_enter[<name>;<close_on_enter>]`
2666
2667 * <name> is the name of the field
2668 * if <close_on_enter> is false, pressing enter in the field will submit the
2669   form but not close it.
2670 * defaults to true when not specified (ie: no tag for a field)
2671
2672 ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2673
2674 * Same as fields above, but with multi-line input
2675 * If the text overflows, a vertical scrollbar is added.
2676 * If the name is empty, the textarea is read-only and
2677   the background is not shown, which corresponds to a multi-line label.
2678
2679 ### `label[<X>,<Y>;<label>]`
2680
2681 * The label formspec element displays the text set in `label`
2682   at the specified position.
2683 * **Note**: If the new coordinate system is enabled, labels are
2684   positioned from the center of the text, not the top.
2685 * The text is displayed directly without automatic line breaking,
2686   so label should not be used for big text chunks.  Newlines can be
2687   used to make labels multiline.
2688 * **Note**: With the new coordinate system, newlines are spaced with
2689   half a coordinate.  With the old system, newlines are spaced 2/5 of
2690   an inventory slot.
2691
2692 ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
2693 * Displays a static formatted text with hyperlinks.
2694 * **Note**: This element is currently unstable and subject to change.
2695 * `x`, `y`, `w` and `h` work as per field
2696 * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
2697 * `text` is the formatted text using `Markup Language` described below.
2698
2699 ### `vertlabel[<X>,<Y>;<label>]`
2700 * Textual label drawn vertically
2701 * `label` is the text on the label
2702 * **Note**: If the new coordinate system is enabled, vertlabels are
2703   positioned from the center of the text, not the left.
2704
2705 ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
2706
2707 * Clickable button. When clicked, fields will be sent.
2708 * With the old coordinate system, buttons are a set height, but will be vertically
2709   centered on `H`. With the new coordinate system, `H` will modify the height.
2710 * `label` is the text on the button
2711
2712 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2713
2714 * `texture name` is the filename of an image
2715 * **Note**: Height is supported on both the old and new coordinate systems
2716   for image_buttons.
2717
2718 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
2719
2720 * `texture name` is the filename of an image
2721 * `noclip=true` means the image button doesn't need to be within specified
2722   formsize.
2723 * `drawborder`: draw button border or not
2724 * `pressed texture name` is the filename of an image on pressed state
2725
2726 ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
2727
2728 * `item name` is the registered name of an item/node
2729 * `name` is non-optional and must be unique, or else tooltips are broken.
2730 * The item description will be used as the tooltip. This can be overridden with
2731   a tooltip element.
2732
2733 ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
2734
2735 * When clicked, fields will be sent and the form will quit.
2736 * Same as `button` in all other respects.
2737
2738 ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2739
2740 * When clicked, fields will be sent and the form will quit.
2741 * Same as `image_button` in all other respects.
2742
2743 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
2744
2745 * Scrollable item list showing arbitrary text elements
2746 * `name` fieldname sent to server on doubleclick value is current selected
2747   element.
2748 * `listelements` can be prepended by #color in hexadecimal format RRGGBB
2749   (only).
2750     * if you want a listelement to start with "#" write "##".
2751
2752 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
2753
2754 * Scrollable itemlist showing arbitrary text elements
2755 * `name` fieldname sent to server on doubleclick value is current selected
2756   element.
2757 * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
2758     * if you want a listelement to start with "#" write "##"
2759 * Index to be selected within textlist
2760 * `true`/`false`: draw transparent background
2761 * See also `minetest.explode_textlist_event`
2762   (main menu: `core.explode_textlist_event`).
2763
2764 ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2765
2766 * Show a tab**header** at specific position (ignores formsize)
2767 * `X` and `Y`: position of the tabheader
2768 * *Note*: Width and height are automatically chosen with this syntax
2769 * `name` fieldname data is transferred to Lua
2770 * `caption 1`...: name shown on top of tab
2771 * `current_tab`: index of selected tab 1...
2772 * `transparent` (optional): if true, tabs are semi-transparent
2773 * `draw_border` (optional): if true, draw a thin line at tab base
2774
2775 ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2776
2777 * Show a tab**header** at specific position (ignores formsize)
2778 * **Important note**: This syntax for tabheaders can only be used with the
2779   new coordinate system.
2780 * `X` and `Y`: position of the tabheader
2781 * `H`: height of the tabheader. Width is automatically determined with this syntax.
2782 * `name` fieldname data is transferred to Lua
2783 * `caption 1`...: name shown on top of tab
2784 * `current_tab`: index of selected tab 1...
2785 * `transparent` (optional): show transparent
2786 * `draw_border` (optional): draw border
2787
2788 ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2789
2790 * Show a tab**header** at specific position (ignores formsize)
2791 * **Important note**: This syntax for tabheaders can only be used with the
2792   new coordinate system.
2793 * `X` and `Y`: position of the tabheader
2794 * `W` and `H`: width and height of the tabheader
2795 * `name` fieldname data is transferred to Lua
2796 * `caption 1`...: name shown on top of tab
2797 * `current_tab`: index of selected tab 1...
2798 * `transparent` (optional): show transparent
2799 * `draw_border` (optional): draw border
2800
2801 ### `box[<X>,<Y>;<W>,<H>;<color>]`
2802
2803 * Simple colored box
2804 * `color` is color specified as a `ColorString`.
2805   If the alpha component is left blank, the box will be semitransparent.
2806   If the color is not specified, the box will use the options specified by
2807   its style. If the color is specified, all styling options will be ignored.
2808
2809 ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2810
2811 * Show a dropdown field
2812 * **Important note**: There are two different operation modes:
2813     1. handle directly on change (only changed dropdown is submitted)
2814     2. read the value on pressing a button (all dropdown values are available)
2815 * `X` and `Y`: position of the dropdown
2816 * `W`: width of the dropdown. Height is automatically chosen with this syntax.
2817 * Fieldname data is transferred to Lua
2818 * Items to be shown in dropdown
2819 * Index of currently selected dropdown item
2820 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2821   event field value for selected items.
2822     * `true`: Selected item index
2823     * `false` (default): Selected item value
2824
2825 ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2826
2827 * Show a dropdown field
2828 * **Important note**: This syntax for dropdowns can only be used with the
2829   new coordinate system.
2830 * **Important note**: There are two different operation modes:
2831     1. handle directly on change (only changed dropdown is submitted)
2832     2. read the value on pressing a button (all dropdown values are available)
2833 * `X` and `Y`: position of the dropdown
2834 * `W` and `H`: width and height of the dropdown
2835 * Fieldname data is transferred to Lua
2836 * Items to be shown in dropdown
2837 * Index of currently selected dropdown item
2838 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2839   event field value for selected items.
2840     * `true`: Selected item index
2841     * `false` (default): Selected item value
2842
2843 ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
2844
2845 * Show a checkbox
2846 * `name` fieldname data is transferred to Lua
2847 * `label` to be shown left of checkbox
2848 * `selected` (optional): `true`/`false`
2849 * **Note**: If the new coordinate system is enabled, checkboxes are
2850   positioned from the center of the checkbox, not the top.
2851
2852 ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
2853
2854 * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
2855 * There are two ways to use it:
2856     1. handle the changed event (only changed scrollbar is available)
2857     2. read the value on pressing a button (all scrollbars are available)
2858 * `orientation`: `vertical`/`horizontal`. Default horizontal.
2859 * Fieldname data is transferred to Lua
2860 * Value of this trackbar is set to (`0`-`1000`) by default
2861 * See also `minetest.explode_scrollbar_event`
2862   (main menu: `core.explode_scrollbar_event`).
2863
2864 ### `scrollbaroptions[opt1;opt2;...]`
2865 * Sets options for all following `scrollbar[]` elements
2866 * `min=<int>`
2867     * Sets scrollbar minimum value, defaults to `0`.
2868 * `max=<int>`
2869     * Sets scrollbar maximum value, defaults to `1000`.
2870       If the max is equal to the min, the scrollbar will be disabled.
2871 * `smallstep=<int>`
2872     * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
2873       scrolled.
2874     * If this is set to a negative number, the value will be reset to `10`.
2875 * `largestep=<int>`
2876     * Sets scrollbar step value used by page up and page down.
2877     * If this is set to a negative number, the value will be reset to `100`.
2878 * `thumbsize=<int>`
2879     * Sets size of the thumb on the scrollbar. Size is calculated in the number of
2880       units the thumb spans out of the range of the scrollbar values.
2881     * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
2882       would span a tenth of the scrollbar space.
2883     * If this is set to zero or less, the value will be reset to `1`.
2884 * `arrows=<show/hide/default>`
2885     * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
2886       when the scrollbar gets too small, but shows them otherwise.
2887
2888 ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
2889
2890 * Show scrollable table using options defined by the previous `tableoptions[]`
2891 * Displays cells as defined by the previous `tablecolumns[]`
2892 * `name`: fieldname sent to server on row select or doubleclick
2893 * `cell 1`...`cell n`: cell contents given in row-major order
2894 * `selected idx`: index of row to be selected within table (first row = `1`)
2895 * See also `minetest.explode_table_event`
2896   (main menu: `core.explode_table_event`).
2897
2898 ### `tableoptions[<opt 1>;<opt 2>;...]`
2899
2900 * Sets options for `table[]`
2901 * `color=#RRGGBB`
2902     * default text color (`ColorString`), defaults to `#FFFFFF`
2903 * `background=#RRGGBB`
2904     * table background color (`ColorString`), defaults to `#000000`
2905 * `border=<true/false>`
2906     * should the table be drawn with a border? (default: `true`)
2907 * `highlight=#RRGGBB`
2908     * highlight background color (`ColorString`), defaults to `#466432`
2909 * `highlight_text=#RRGGBB`
2910     * highlight text color (`ColorString`), defaults to `#FFFFFF`
2911 * `opendepth=<value>`
2912     * all subtrees up to `depth < value` are open (default value = `0`)
2913     * only useful when there is a column of type "tree"
2914
2915 ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
2916
2917 * Sets columns for `table[]`
2918 * Types: `text`, `image`, `color`, `indent`, `tree`
2919     * `text`:   show cell contents as text
2920     * `image`:  cell contents are an image index, use column options to define
2921                 images.
2922     * `color`:  cell contents are a ColorString and define color of following
2923                 cell.
2924     * `indent`: cell contents are a number and define indentation of following
2925                 cell.
2926     * `tree`:   same as indent, but user can open and close subtrees
2927                 (treeview-like).
2928 * Column options:
2929     * `align=<value>`
2930         * for `text` and `image`: content alignment within cells.
2931           Available values: `left` (default), `center`, `right`, `inline`
2932     * `width=<value>`
2933         * for `text` and `image`: minimum width in em (default: `0`)
2934         * for `indent` and `tree`: indent width in em (default: `1.5`)
2935     * `padding=<value>`: padding left of the column, in em (default `0.5`).
2936       Exception: defaults to 0 for indent columns
2937     * `tooltip=<value>`: tooltip text (default: empty)
2938     * `image` column options:
2939         * `0=<value>` sets image for image index 0
2940         * `1=<value>` sets image for image index 1
2941         * `2=<value>` sets image for image index 2
2942         * and so on; defined indices need not be contiguous empty or
2943           non-numeric cells are treated as `0`.
2944     * `color` column options:
2945         * `span=<value>`: number of following columns to affect
2946           (default: infinite).
2947
2948 ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2949
2950 * Set the style for the element(s) matching `selector` by name.
2951 * `selector` can be one of:
2952     * `<name>` - An element name. Includes `*`, which represents every element.
2953     * `<name>:<state>` - An element name, a colon, and one or more states.
2954 * `state` is a list of states separated by the `+` character.
2955     * If a state is provided, the style will only take effect when the element is in that state.
2956     * All provided states must be active for the style to apply.
2957 * Note: this **must** be before the element is defined.
2958 * See [Styling Formspecs].
2959
2960
2961 ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2962
2963 * Set the style for the element(s) matching `selector` by type.
2964 * `selector` can be one of:
2965     * `<type>` - An element type. Includes `*`, which represents every element.
2966     * `<type>:<state>` - An element type, a colon, and one or more states.
2967 * `state` is a list of states separated by the `+` character.
2968     * If a state is provided, the style will only take effect when the element is in that state.
2969     * All provided states must be active for the style to apply.
2970 * See [Styling Formspecs].
2971
2972 ### `set_focus[<name>;<force>]`
2973
2974 * Sets the focus to the element with the same `name` parameter.
2975 * **Note**: This element must be placed before the element it focuses.
2976 * `force` (optional, default `false`): By default, focus is not applied for
2977   re-sent formspecs with the same name so that player-set focus is kept.
2978   `true` sets the focus to the specified element for every sent formspec.
2979 * The following elements have the ability to be focused:
2980     * checkbox
2981     * button
2982     * button_exit
2983     * image_button
2984     * image_button_exit
2985     * item_image_button
2986     * table
2987     * textlist
2988     * dropdown
2989     * field
2990     * pwdfield
2991     * textarea
2992     * scrollbar
2993
2994 Migrating to Real Coordinates
2995 -----------------------------
2996
2997 In the old system, positions included padding and spacing. Padding is a gap between
2998 the formspec window edges and content, and spacing is the gaps between items. For
2999 example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
3000 and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
3001 in the new coordinate system from scratch.
3002
3003 To recreate an old layout with padding, you'll need to pass the positions and sizes
3004 through the following formula to re-introduce padding:
3005
3006 ```
3007 pos = (oldpos + 1)*spacing + padding
3008 where
3009     padding = 3/8
3010     spacing = 5/4
3011 ```
3012
3013 You'll need to change the `size[]` tag like this:
3014
3015 ```
3016 size = (oldsize-1)*spacing + padding*2 + 1
3017 ```
3018
3019 A few elements had random offsets in the old system. Here is a table which shows these
3020 offsets when migrating:
3021
3022 | Element |  Position  |  Size   | Notes
3023 |---------|------------|---------|-------
3024 | box     | +0.3, +0.1 | 0, -0.4 |
3025 | button  |            |         | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
3026 | list    |            |         | Spacing is now 0.25 for both directions, meaning lists will be taller in height
3027 | label   | 0, +0.3    |         | The first line of text is now positioned centered exactly at the position specified
3028
3029 Styling Formspecs
3030 -----------------
3031
3032 Formspec elements can be themed using the style elements:
3033
3034     style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
3035     style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
3036     style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
3037     style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
3038
3039 Where a prop is:
3040
3041     property_name=property_value
3042
3043 For example:
3044
3045     style_type[button;bgcolor=#006699]
3046     style[world_delete;bgcolor=red;textcolor=yellow]
3047     button[4,3.95;2.6,1;world_delete;Delete]
3048
3049 A name/type can optionally be a comma separated list of names/types, like so:
3050
3051     world_delete,world_create,world_configure
3052     button,image_button
3053
3054 A `*` type can be used to select every element in the formspec.
3055
3056 Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
3057
3058     world_delete:hovered+pressed
3059     button:pressed
3060
3061 States allow you to apply styles in response to changes in the element, instead of applying at all times.
3062
3063 Setting a property to nothing will reset it to the default value. For example:
3064
3065     style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
3066     style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
3067
3068
3069 ### Supported Element Types
3070
3071 Some types may inherit styles from parent types.
3072
3073 * animated_image, inherits from image
3074 * box
3075 * button
3076 * button_exit, inherits from button
3077 * checkbox
3078 * dropdown
3079 * field
3080 * image
3081 * image_button
3082 * item_image_button
3083 * label
3084 * list
3085 * model
3086 * pwdfield, inherits from field
3087 * scrollbar
3088 * tabheader
3089 * table
3090 * textarea
3091 * textlist
3092 * vertlabel, inherits from label
3093
3094
3095 ### Valid Properties
3096
3097 * animated_image
3098     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3099 * box
3100     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3101         * Defaults to false in formspec_version version 3 or higher
3102     * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
3103         * Single value (e.g. `#FF0`): All corners/borders.
3104         * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
3105           top and bottom,left and right.
3106         * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
3107         * These work similarly to CSS borders.
3108     * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
3109     * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
3110     * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
3111       negative, the border will extend inside the box, whereas positive extends outside
3112       the box. A width of zero results in no border; this is default.
3113 * button, button_exit, image_button, item_image_button
3114     * alpha - boolean, whether to draw alpha in bgimg. Default true.
3115     * bgcolor - color, sets button tint.
3116     * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
3117         * This is deprecated, use states instead.
3118     * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
3119         * This is deprecated, use states instead.
3120     * bgimg - standard background image. Defaults to none.
3121     * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
3122         * This is deprecated, use states instead.
3123     * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
3124                      See background9[] documentation for more details. This property also pads the
3125                      button's content when set.
3126     * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
3127         * This is deprecated, use states instead.
3128     * font - Sets font type. This is a comma separated list of options. Valid options:
3129       * Main font type options. These cannot be combined with each other:
3130         * `normal`: Default font
3131         * `mono`: Monospaced font
3132       * Font modification options. If used without a main font type, `normal` is used:
3133         * `bold`: Makes font bold.
3134         * `italic`: Makes font italic.
3135       Default `normal`.
3136     * font_size - Sets font size. Default is user-set. Can have multiple values:
3137       * `<number>`: Sets absolute font size to `number`.
3138       * `+<number>`/`-<number>`: Offsets default font size by `number` points.
3139       * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
3140     * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
3141     * content_offset - 2d vector, shifts the position of the button's content without resizing it.
3142     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3143     * padding - rect, adds space between the edges of the button and the content. This value is
3144                 relative to bgimg_middle.
3145     * sound - a sound to be played when triggered.
3146     * textcolor - color, default white.
3147 * checkbox
3148     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3149     * sound - a sound to be played when triggered.
3150 * dropdown
3151     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3152     * sound - a sound to be played when the entry is changed.
3153 * field, pwdfield, textarea
3154     * border - set to false to hide the textbox background and border. Default true.
3155     * font - Sets font type. See button `font` property for more information.
3156     * font_size - Sets font size. See button `font_size` property for more information.
3157     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3158     * textcolor - color. Default white.
3159 * model
3160     * bgcolor - color, sets background color.
3161     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3162         * Default to false in formspec_version version 3 or higher
3163 * image
3164     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3165         * Default to false in formspec_version version 3 or higher
3166 * item_image
3167     * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
3168 * label, vertlabel
3169     * font - Sets font type. See button `font` property for more information.
3170     * font_size - Sets font size. See button `font_size` property for more information.
3171     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3172 * list
3173     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3174     * size - 2d vector, sets the size of inventory slots in coordinates.
3175     * spacing - 2d vector, sets the space between inventory slots in coordinates.
3176 * image_button (additional properties)
3177     * fgimg - standard image. Defaults to none.
3178     * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
3179         * This is deprecated, use states instead.
3180     * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
3181         * This is deprecated, use states instead.
3182     * fgimg_middle - Makes the fgimg textures render in 9-sliced mode and defines the middle rect.
3183                      See background9[] documentation for more details.
3184     * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
3185     * sound - a sound to be played when triggered.
3186 * scrollbar
3187     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3188 * tabheader
3189     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3190     * sound - a sound to be played when a different tab is selected.
3191     * textcolor - color. Default white.
3192 * table, textlist
3193     * font - Sets font type. See button `font` property for more information.
3194     * font_size - Sets font size. See button `font_size` property for more information.
3195     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3196
3197 ### Valid States
3198
3199 * *all elements*
3200     * default - Equivalent to providing no states
3201 * button, button_exit, image_button, item_image_button
3202     * hovered - Active when the mouse is hovering over the element
3203     * pressed - Active when the button is pressed
3204
3205 Markup Language
3206 ---------------
3207
3208 Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
3209 The markup language is currently unstable and subject to change. Use with caution.
3210 Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
3211 Tags can have attributes, in that case, attributes are in the opening tag in
3212 form of a key/value separated with equal signs. Attribute values should not be quoted.
3213
3214 If you want to insert a literal greater-than sign or a backslash into the text,
3215 you must escape it by preceding it with a backslash.
3216
3217 These are the technically basic tags but see below for usual tags. Base tags are:
3218
3219 `<style color=... font=... size=...>...</style>`
3220
3221 Changes the style of the text.
3222
3223 * `color`: Text color. Given color is a `colorspec`.
3224 * `size`: Text size.
3225 * `font`: Text font (`mono` or `normal`).
3226
3227 `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
3228
3229 Sets global style.
3230
3231 Global only styles:
3232 * `background`: Text background, a `colorspec` or `none`.
3233 * `margin`: Page margins in pixel.
3234 * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
3235
3236 Inheriting styles (affects child elements):
3237 * `color`: Default text color. Given color is a `colorspec`.
3238 * `hovercolor`: Color of <action> tags when mouse is over.
3239 * `size`: Default text size.
3240 * `font`: Default text font (`mono` or `normal`).
3241 * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
3242
3243 This tag needs to be placed only once as it changes the global settings of the
3244 text. Anyway, if several tags are placed, each changed will be made in the order
3245 tags appear.
3246
3247 `<tag name=... color=... hovercolor=... font=... size=...>`
3248
3249 Defines or redefines tag style. This can be used to define new tags.
3250 * `name`: Name of the tag to define or change.
3251 * `color`: Text color. Given color is a `colorspec`.
3252 * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
3253 * `size`: Text size.
3254 * `font`: Text font (`mono` or `normal`).
3255
3256 Following tags are the usual tags for text layout. They are defined by default.
3257 Other tags can be added using `<tag ...>` tag.
3258
3259 `<normal>...</normal>`: Normal size text
3260
3261 `<big>...</big>`: Big text
3262
3263 `<bigger>...</bigger>`: Bigger text
3264
3265 `<center>...</center>`: Centered text
3266
3267 `<left>...</left>`: Left-aligned text
3268
3269 `<right>...</right>`: Right-aligned text
3270
3271 `<justify>...</justify>`: Justified text
3272
3273 `<mono>...</mono>`: Monospaced font
3274
3275 `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
3276
3277 `<action name=...>...</action>`
3278
3279 Make that text a clickable text triggering an action.
3280
3281 * `name`: Name of the action (mandatory).
3282
3283 When clicked, the formspec is send to the server. The value of the text field
3284 sent to `on_player_receive_fields` will be "action:" concatenated to the action
3285 name.
3286
3287 `<img name=... float=... width=... height=...>`
3288
3289 Draws an image which is present in the client media cache.
3290
3291 * `name`: Name of the texture (mandatory).
3292 * `float`: If present, makes the image floating (`left` or `right`).
3293 * `width`: Force image width instead of taking texture width.
3294 * `height`: Force image height instead of taking texture height.
3295
3296 If only width or height given, texture aspect is kept.
3297
3298 `<item name=... float=... width=... height=... rotate=...>`
3299
3300 Draws an item image.
3301
3302 * `name`: Item string of the item to draw (mandatory).
3303 * `float`: If present, makes the image floating (`left` or `right`).
3304 * `width`: Item image width.
3305 * `height`: Item image height.
3306 * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
3307 rotation speeds in percent of standard speed (-1000 to 1000). Works only if
3308 `inventory_items_animations` is set to true.
3309 * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
3310 X, Y and Z being angles around each three axes. Works only if
3311 `inventory_items_animations` is set to true.
3312
3313 Inventory
3314 =========
3315
3316 Inventory locations
3317 -------------------
3318
3319 * `"context"`: Selected node metadata (deprecated: `"current_name"`)
3320 * `"current_player"`: Player to whom the menu is shown
3321 * `"player:<name>"`: Any player
3322 * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
3323 * `"detached:<name>"`: A detached inventory
3324
3325 Player Inventory lists
3326 ----------------------
3327
3328 * `main`: list containing the default inventory
3329 * `craft`: list containing the craft input
3330 * `craftpreview`: list containing the craft prediction
3331 * `craftresult`: list containing the crafted output
3332 * `hand`: list containing an override for the empty hand
3333     * Is not created automatically, use `InvRef:set_size`
3334     * Is only used to enhance the empty hand's tool capabilities
3335 * `offhand`: list containing the offhand wielded item.
3336     * Is not created automatically, use `InvRef:set_size`
3337     * Will be used for placements and secondary uses if the
3338         main hand does not have any node_place_prediction, on_place
3339         or on_secondary_use callbacks.
3340     * Is passed to on_place and on_secondary_use callbacks; make sure
3341         mods are aware of the itemstack not neccessarily being
3342         located in the main hand.
3343     *  The offhand item cannot have its own range or liquids_pointable and
3344         will always reuse the characteristics from the hand item.
3345
3346 Colors
3347 ======
3348
3349 `ColorString`
3350 -------------
3351
3352 `#RGB` defines a color in hexadecimal format.
3353
3354 `#RGBA` defines a color in hexadecimal format and alpha channel.
3355
3356 `#RRGGBB` defines a color in hexadecimal format.
3357
3358 `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
3359
3360 Named colors are also supported and are equivalent to
3361 [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
3362 To specify the value of the alpha channel, append `#A` or `#AA` to the end of
3363 the color name (e.g. `colorname#08`).
3364
3365 `ColorSpec`
3366 -----------
3367
3368 A ColorSpec specifies a 32-bit color. It can be written in any of the following
3369 forms:
3370
3371 * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
3372     * `colorspec = {a=255, r=0, g=255, b=0}`
3373 * numerical form: The raw integer value of an ARGB8 quad:
3374     * `colorspec = 0xFF00FF00`
3375 * string form: A ColorString (defined above):
3376     * `colorspec = "green"`
3377
3378
3379
3380
3381 Escape sequences
3382 ================
3383
3384 Most text can contain escape sequences, that can for example color the text.
3385 There are a few exceptions: tab headers, dropdowns and vertical labels can't.
3386 The following functions provide escape sequences:
3387
3388 * `minetest.get_color_escape_sequence(color)`:
3389     * `color` is a ColorString
3390     * The escape sequence sets the text color to `color`
3391 * `minetest.colorize(color, message)`:
3392     * Equivalent to:
3393       `minetest.get_color_escape_sequence(color) ..
3394       message ..
3395       minetest.get_color_escape_sequence("#ffffff")`
3396 * `minetest.get_background_escape_sequence(color)`
3397     * `color` is a ColorString
3398     * The escape sequence sets the background of the whole text element to
3399       `color`. Only defined for item descriptions and tooltips.
3400 * `minetest.strip_foreground_colors(str)`
3401     * Removes foreground colors added by `get_color_escape_sequence`.
3402 * `minetest.strip_background_colors(str)`
3403     * Removes background colors added by `get_background_escape_sequence`.
3404 * `minetest.strip_colors(str)`
3405     * Removes all color escape sequences.
3406
3407
3408
3409
3410 Spatial Vectors
3411 ===============
3412
3413 Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
3414 and has a class to represent them (`vector.*`), which this chapter is about.
3415 For details on what a spatial vectors is, please refer to Wikipedia:
3416 https://en.wikipedia.org/wiki/Euclidean_vector.
3417
3418 Spatial vectors are used for various things, including, but not limited to:
3419
3420 * any 3D spatial vector (x/y/z-directions)
3421 * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
3422   meaning here. Therefore, most vector operations make no sense in this use case.)
3423
3424 Note that they are *not* used for:
3425
3426 * n-dimensional vectors where n is not 3 (ie. n=2)
3427 * arrays of the form `{num, num, num}`
3428
3429 The API documentation may refer to spatial vectors, as produced by `vector.new`,
3430 by any of the following notations:
3431
3432 * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
3433 * `vector.new(x, y, z)`
3434 * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
3435
3436 Compatibility notes
3437 -------------------
3438
3439 Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
3440 Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
3441 Note: Those old-style vectors can still be found in old mod code. Hence, mod and
3442 engine APIs still need to be able to cope with them in many places.
3443
3444 Manually constructed tables are deprecated and highly discouraged. This interface
3445 should be used to ensure seamless compatibility between mods and the Minetest API.
3446 This is especially important to callback function parameters and functions overwritten
3447 by mods.
3448 Also, though not likely, the internal implementation of a vector might change in
3449 the future.
3450 In your own code, or if you define your own API, you can, of course, still use
3451 other representations of vectors.
3452
3453 Vectors provided by API functions will provide an instance of this class if not
3454 stated otherwise. Mods should adapt this for convenience reasons.
3455
3456 Special properties of the class
3457 -------------------------------
3458
3459 Vectors can be indexed with numbers and allow method and operator syntax.
3460
3461 All these forms of addressing a vector `v` are valid:
3462 `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
3463 Note: Prefer letter over number indexing for performance and compatibility reasons.
3464
3465 Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
3466 the same as `vector.foo(v, ...)`, apart from deprecated functionality.
3467
3468 `tostring` is defined for vectors, see `vector.to_string`.
3469
3470 The metatable that is used for vectors can be accessed via `vector.metatable`.
3471 Do not modify it!
3472
3473 All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
3474 Returned vectors always have a metatable set.
3475
3476 Common functions and methods
3477 ----------------------------
3478
3479 For the following functions (and subchapters),
3480 `v`, `v1`, `v2` are vectors,
3481 `p1`, `p2` are position vectors,
3482 `s` is a scalar (a number),
3483 vectors are written like this: `(x, y, z)`:
3484
3485 * `vector.new([a[, b, c]])`:
3486     * Returns a new vector `(a, b, c)`.
3487     * Deprecated: `vector.new()` does the same as `vector.zero()` and
3488       `vector.new(v)` does the same as `vector.copy(v)`
3489 * `vector.zero()`:
3490     * Returns a new vector `(0, 0, 0)`.
3491 * `vector.copy(v)`:
3492     * Returns a copy of the vector `v`.
3493 * `vector.from_string(s[, init])`:
3494     * Returns `v, np`, where `v` is a vector read from the given string `s` and
3495       `np` is the next position in the string after the vector.
3496     * Returns `nil` on failure.
3497     * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
3498            spaces, leaving away commas and adding an additional comma to the end
3499            is allowed.
3500     * `init`: If given starts looking for the vector at this string index.
3501 * `vector.to_string(v)`:
3502     * Returns a string of the form `"(x, y, z)"`.
3503     *  `tostring(v)` does the same.
3504 * `vector.direction(p1, p2)`:
3505     * Returns a vector of length 1 with direction `p1` to `p2`.
3506     * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
3507 * `vector.distance(p1, p2)`:
3508     * Returns zero or a positive number, the distance between `p1` and `p2`.
3509 * `vector.length(v)`:
3510     * Returns zero or a positive number, the length of vector `v`.
3511 * `vector.normalize(v)`:
3512     * Returns a vector of length 1 with direction of vector `v`.
3513     * If `v` has zero length, returns `(0, 0, 0)`.
3514 * `vector.floor(v)`:
3515     * Returns a vector, each dimension rounded down.
3516 * `vector.round(v)`:
3517     * Returns a vector, each dimension rounded to nearest integer.
3518     * At a multiple of 0.5, rounds away from zero.
3519 * `vector.apply(v, func)`:
3520     * Returns a vector where the function `func` has been applied to each
3521       component.
3522 * `vector.combine(v, w, func)`:
3523     * Returns a vector where the function `func` has combined both components of `v` and `w`
3524       for each component
3525 * `vector.equals(v1, v2)`:
3526     * Returns a boolean, `true` if the vectors are identical.
3527 * `vector.sort(v1, v2)`:
3528     * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
3529 * `vector.angle(v1, v2)`:
3530     * Returns the angle between `v1` and `v2` in radians.
3531 * `vector.dot(v1, v2)`:
3532     * Returns the dot product of `v1` and `v2`.
3533 * `vector.cross(v1, v2)`:
3534     * Returns the cross product of `v1` and `v2`.
3535 * `vector.offset(v, x, y, z)`:
3536     * Returns the sum of the vectors `v` and `(x, y, z)`.
3537 * `vector.check(v)`:
3538     * Returns a boolean value indicating whether `v` is a real vector, eg. created
3539       by a `vector.*` function.
3540     * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
3541
3542 For the following functions `x` can be either a vector or a number:
3543
3544 * `vector.add(v, x)`:
3545     * Returns a vector.
3546     * If `x` is a vector: Returns the sum of `v` and `x`.
3547     * If `x` is a number: Adds `x` to each component of `v`.
3548 * `vector.subtract(v, x)`:
3549     * Returns a vector.
3550     * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
3551     * If `x` is a number: Subtracts `x` from each component of `v`.
3552 * `vector.multiply(v, s)`:
3553     * Returns a scaled vector.
3554     * Deprecated: If `s` is a vector: Returns the Schur product.
3555 * `vector.divide(v, s)`:
3556     * Returns a scaled vector.
3557     * Deprecated: If `s` is a vector: Returns the Schur quotient.
3558
3559 Operators
3560 ---------
3561
3562 Operators can be used if all of the involved vectors have metatables:
3563 * `v1 == v2`:
3564     * Returns whether `v1` and `v2` are identical.
3565 * `-v`:
3566     * Returns the additive inverse of v.
3567 * `v1 + v2`:
3568     * Returns the sum of both vectors.
3569     * Note: `+` cannot be used together with scalars.
3570 * `v1 - v2`:
3571     * Returns the difference of `v1` subtracted by `v2`.
3572     * Note: `-` cannot be used together with scalars.
3573 * `v * s` or `s * v`:
3574     * Returns `v` scaled by `s`.
3575 * `v / s`:
3576     * Returns `v` scaled by `1 / s`.
3577
3578 Rotation-related functions
3579 --------------------------
3580
3581 For the following functions `a` is an angle in radians and `r` is a rotation
3582 vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
3583 angles in radians.
3584
3585 * `vector.rotate(v, r)`:
3586     * Applies the rotation `r` to `v` and returns the result.
3587     * `vector.rotate(vector.new(0, 0, 1), r)` and
3588       `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
3589       forward and up relative to an entity's rotation `r`.
3590 * `vector.rotate_around_axis(v1, v2, a)`:
3591     * Returns `v1` rotated around axis `v2` by `a` radians according to
3592       the right hand rule.
3593 * `vector.dir_to_rotation(direction[, up])`:
3594     * Returns a rotation vector for `direction` pointing forward using `up`
3595       as the up vector.
3596     * If `up` is omitted, the roll of the returned vector defaults to zero.
3597     * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
3598
3599 Further helpers
3600 ---------------
3601
3602 There are more helper functions involving vectors, but they are listed elsewhere
3603 because they only work on specific sorts of vectors or involve things that are not
3604 vectors.
3605
3606 For example:
3607
3608 * `minetest.hash_node_position` (Only works on node positions.)
3609 * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
3610
3611
3612
3613
3614 Helper functions
3615 ================
3616
3617 * `dump2(obj, name, dumped)`: returns a string which makes `obj`
3618   human-readable, handles reference loops.
3619     * `obj`: arbitrary variable
3620     * `name`: string, default: `"_"`
3621     * `dumped`: table, default: `{}`
3622 * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
3623     * `obj`: arbitrary variable
3624     * `dumped`: table, default: `{}`
3625 * `math.hypot(x, y)`
3626     * Get the hypotenuse of a triangle with legs x and y.
3627       Useful for distance calculation.
3628 * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
3629     * Get the sign of a number.
3630     * tolerance: number, default: `0.0`
3631     * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
3632       `0` is returned.
3633 * `math.factorial(x)`: returns the factorial of `x`
3634 * `math.round(x)`: Returns `x` rounded to the nearest integer.
3635     * At a multiple of 0.5, rounds away from zero.
3636 * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
3637     * `separator`: string, cannot be empty, default: `","`
3638     * `include_empty`: boolean, default: `false`
3639     * `max_splits`: number, if it's negative, splits aren't limited,
3640       default: `-1`
3641     * `sep_is_pattern`: boolean, it specifies whether separator is a plain
3642       string or a pattern (regex), default: `false`
3643     * e.g. `"a,b":split","` returns `{"a","b"}`
3644 * `string:trim()`: returns the string without whitespace pre- and suffixes
3645     * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
3646 * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
3647     * Adds newlines to the string to keep it within the specified character
3648       limit
3649     * Note that the returned lines may be longer than the limit since it only
3650       splits at word borders.
3651     * `limit`: number, maximal amount of characters in one line
3652     * `as_table`: boolean, if set to true, a table of lines instead of a string
3653       is returned, default: `false`
3654 * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
3655     * `pos`: table {x=X, y=Y, z=Z}
3656     * Converts the position `pos` to a human-readable, printable string
3657     * `decimal_places`: number, if specified, the x, y and z values of
3658       the position are rounded to the given decimal place.
3659 * `minetest.string_to_pos(string)`: returns a position or `nil`
3660     * Same but in reverse.
3661     * If the string can't be parsed to a position, nothing is returned.
3662 * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`:
3663     * returns two positions
3664     * Converts a string representing an area box into two positions
3665     * X1, Y1, ... Z2 are coordinates
3666     * `relative_to`: Optional. If set to a position, each coordinate
3667       can use the tilde notation for relative positions
3668     * Tilde notation: "~": Relative coordinate
3669                       "~<number>": Relative coordinate plus <number>
3670     * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
3671       returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
3672 * `minetest.formspec_escape(string)`: returns a string
3673     * escapes the characters "[", "]", "\", "," and ";", which cannot be used
3674       in formspecs.
3675 * `minetest.is_yes(arg)`
3676     * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
3677 * `minetest.is_nan(arg)`
3678     * returns true when the passed number represents NaN.
3679 * `minetest.get_us_time()`
3680     * returns time with microsecond precision. May not return wall time.
3681 * `table.copy(table)`: returns a table
3682     * returns a deep copy of `table`
3683 * `table.indexof(list, val)`: returns the smallest numerical index containing
3684       the value `val` in the table `list`. Non-numerical indices are ignored.
3685       If `val` could not be found, `-1` is returned. `list` must not have
3686       negative indices.
3687 * `table.insert_all(table, other_table)`:
3688     * Appends all values in `other_table` to `table` - uses `#table + 1` to
3689       find new indices.
3690 * `table.key_value_swap(t)`: returns a table with keys and values swapped
3691     * If multiple keys in `t` map to the same value, it is unspecified which
3692       value maps to that key.
3693 * `table.shuffle(table, [from], [to], [random_func])`:
3694     * Shuffles elements `from` to `to` in `table` in place
3695     * `from` defaults to `1`
3696     * `to` defaults to `#table`
3697     * `random_func` defaults to `math.random`. This function receives two
3698       integers as arguments and should return a random integer inclusively
3699       between them.
3700 * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
3701   position.
3702     * returns the exact position on the surface of a pointed node
3703 * `minetest.get_tool_wear_after_use(uses [, initial_wear])`
3704     * Simulates a tool being used once and returns the added wear,
3705       such that, if only this function is used to calculate wear,
3706       the tool will break exactly after `uses` times of uses
3707     * `uses`: Number of times the tool can be used
3708     * `initial_wear`: The initial wear the tool starts with (default: 0)
3709 * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
3710     Simulates an item that digs a node.
3711     Returns a table with the following fields:
3712     * `diggable`: `true` if node can be dug, `false` otherwise.
3713     * `time`: Time it would take to dig the node.
3714     * `wear`: How much wear would be added to the tool (ignored for non-tools).
3715     `time` and `wear` are meaningless if node's not diggable
3716     Parameters:
3717     * `groups`: Table of the node groups of the node that would be dug
3718     * `tool_capabilities`: Tool capabilities table of the item
3719     * `wear`: Amount of wear the tool starts with (default: 0)
3720 * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
3721     Simulates an item that punches an object.
3722     Returns a table with the following fields:
3723     * `hp`: How much damage the punch would cause (between -65535 and 65535).
3724     * `wear`: How much wear would be added to the tool (ignored for non-tools).
3725     Parameters:
3726     * `groups`: Damage groups of the object
3727     * `tool_capabilities`: Tool capabilities table of the item
3728     * `time_from_last_punch`: time in seconds since last punch action
3729     * `wear`: Amount of wear the item starts with (default: 0)
3730
3731
3732
3733
3734 Translations
3735 ============
3736
3737 Texts can be translated client-side with the help of `minetest.translate` and
3738 translation files.
3739
3740 Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
3741 to generate and update translation files automatically from the Lua source.
3742
3743 Translating a string
3744 --------------------
3745
3746 Two functions are provided to translate strings: `minetest.translate` and
3747 `minetest.get_translator`.
3748
3749 * `minetest.get_translator(textdomain)` is a simple wrapper around
3750   `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
3751   equivalent to `minetest.translate(textdomain, str, ...)`.
3752   It is intended to be used in the following way, so that it avoids verbose
3753   repetitions of `minetest.translate`:
3754
3755       local S = minetest.get_translator(textdomain)
3756       S(str, ...)
3757
3758   As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
3759
3760 * `minetest.translate(textdomain, str, ...)` translates the string `str` with
3761   the given `textdomain` for disambiguation. The textdomain must match the
3762   textdomain specified in the translation file in order to get the string
3763   translated. This can be used so that a string is translated differently in
3764   different contexts.
3765   It is advised to use the name of the mod as textdomain whenever possible, to
3766   avoid clashes with other mods.
3767   This function must be given a number of arguments equal to the number of
3768   arguments the translated string expects.
3769   Arguments are literal strings -- they will not be translated, so if you want
3770   them to be, they need to come as outputs of `minetest.translate` as well.
3771
3772   For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
3773   by the translation of "Red". We can do the following:
3774
3775       local S = minetest.get_translator()
3776       S("@1 Wool", S("Red"))
3777
3778   This will be displayed as "Red Wool" on old clients and on clients that do
3779   not have localization enabled. However, if we have for instance a translation
3780   file named `wool.fr.tr` containing the following:
3781
3782       @1 Wool=Laine @1
3783       Red=Rouge
3784
3785   this will be displayed as "Laine Rouge" on clients with a French locale.
3786
3787 Operations on translated strings
3788 --------------------------------
3789
3790 The output of `minetest.translate` is a string, with escape sequences adding
3791 additional information to that string so that it can be translated on the
3792 different clients. In particular, you can't expect operations like string.length
3793 to work on them like you would expect them to, or string.gsub to work in the
3794 expected manner. However, string concatenation will still work as expected
3795 (note that you should only use this for things like formspecs; do not translate
3796 sentences by breaking them into parts; arguments should be used instead), and
3797 operations such as `minetest.colorize` which are also concatenation.
3798
3799 Translation file format
3800 -----------------------
3801
3802 A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
3803 it corresponds to. It must be put into the `locale` subdirectory of the mod.
3804 The file should be a text file, with the following format:
3805
3806 * Lines beginning with `# textdomain:` (the space is significant) can be used
3807   to specify the text domain of all following translations in the file.
3808 * All other empty lines or lines beginning with `#` are ignored.
3809 * Other lines should be in the format `original=translated`. Both `original`
3810   and `translated` can contain escape sequences beginning with `@` to insert
3811   arguments, literal `@`, `=` or newline (See [Escapes] below).
3812   There must be no extraneous whitespace around the `=` or at the beginning or
3813   the end of the line.
3814
3815 Escapes
3816 -------
3817
3818 Strings that need to be translated can contain several escapes, preceded by `@`.
3819
3820 * `@@` acts as a literal `@`.
3821 * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
3822   string that will be inlined when translated. Due to how translations are
3823   implemented, the original translation string **must** have its arguments in
3824   increasing order, without gaps or repetitions, starting from 1.
3825 * `@=` acts as a literal `=`. It is not required in strings given to
3826   `minetest.translate`, but is in translation files to avoid being confused
3827   with the `=` separating the original from the translation.
3828 * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
3829   As with `@=`, this escape is not required in strings given to
3830   `minetest.translate`, but is in translation files.
3831 * `@n` acts as a literal newline as well.
3832
3833 Server side translations
3834 ------------------------
3835
3836 On some specific cases, server translation could be useful. For example, filter
3837 a list on labels and send results to client. A method is supplied to achieve
3838 that:
3839
3840 `minetest.get_translated_string(lang_code, string)`: Translates `string` using
3841 translations for `lang_code` language. It gives the same result as if the string
3842 was translated by the client.
3843
3844 The `lang_code` to use for a given player can be retrieved from
3845 the table returned by `minetest.get_player_information(name)`.
3846
3847 IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
3848 You do not need to use this to get translated strings to show up on the client.
3849
3850 Perlin noise
3851 ============
3852
3853 Perlin noise creates a continuously-varying value depending on the input values.
3854 Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
3855 The result is used during map generation to create the terrain shape, vary heat
3856 and humidity to distribute biomes, vary the density of decorations or vary the
3857 structure of ores.
3858
3859 Structure of perlin noise
3860 -------------------------
3861
3862 An 'octave' is a simple noise generator that outputs a value between -1 and 1.
3863 The smooth wavy noise it generates has a single characteristic scale, almost
3864 like a 'wavelength', so on its own does not create fine detail.
3865 Due to this perlin noise combines several octaves to create variation on
3866 multiple scales. Each additional octave has a smaller 'wavelength' than the
3867 previous.
3868
3869 This combination results in noise varying very roughly between -2.0 and 2.0 and
3870 with an average value of 0.0, so `scale` and `offset` are then used to multiply
3871 and offset the noise variation.
3872
3873 The final perlin noise variation is created as follows:
3874
3875 noise = offset + scale * (octave1 +
3876                           octave2 * persistence +
3877                           octave3 * persistence ^ 2 +
3878                           octave4 * persistence ^ 3 +
3879                           ...)
3880
3881 Noise Parameters
3882 ----------------
3883
3884 Noise Parameters are commonly called `NoiseParams`.
3885
3886 ### `offset`
3887
3888 After the multiplication by `scale` this is added to the result and is the final
3889 step in creating the noise value.
3890 Can be positive or negative.
3891
3892 ### `scale`
3893
3894 Once all octaves have been combined, the result is multiplied by this.
3895 Can be positive or negative.
3896
3897 ### `spread`
3898
3899 For octave1, this is roughly the change of input value needed for a very large
3900 variation in the noise value generated by octave1. It is almost like a
3901 'wavelength' for the wavy noise variation.
3902 Each additional octave has a 'wavelength' that is smaller than the previous
3903 octave, to create finer detail. `spread` will therefore roughly be the typical
3904 size of the largest structures in the final noise variation.
3905
3906 `spread` is a vector with values for x, y, z to allow the noise variation to be
3907 stretched or compressed in the desired axes.
3908 Values are positive numbers.
3909
3910 ### `seed`
3911
3912 This is a whole number that determines the entire pattern of the noise
3913 variation. Altering it enables different noise patterns to be created.
3914 With other parameters equal, different seeds produce different noise patterns
3915 and identical seeds produce identical noise patterns.
3916
3917 For this parameter you can randomly choose any whole number. Usually it is
3918 preferable for this to be different from other seeds, but sometimes it is useful
3919 to be able to create identical noise patterns.
3920
3921 In some noise APIs the world seed is added to the seed specified in noise
3922 parameters. This is done to make the resulting noise pattern vary in different
3923 worlds, and be 'world-specific'.
3924
3925 ### `octaves`
3926
3927 The number of simple noise generators that are combined.
3928 A whole number, 1 or more.
3929 Each additional octave adds finer detail to the noise but also increases the
3930 noise calculation load.
3931 3 is a typical minimum for a high quality, complex and natural-looking noise
3932 variation. 1 octave has a slight 'gridlike' appearance.
3933
3934 Choose the number of octaves according to the `spread` and `lacunarity`, and the
3935 size of the finest detail you require. For example:
3936 if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
3937 nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
3938 512, 256, 128, 64, 32, 16 nodes.
3939 Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
3940
3941 ### `persistence`
3942
3943 Each additional octave has an amplitude that is the amplitude of the previous
3944 octave multiplied by `persistence`, to reduce the amplitude of finer details,
3945 as is often helpful and natural to do so.
3946 Since this controls the balance of fine detail to large-scale detail
3947 `persistence` can be thought of as the 'roughness' of the noise.
3948
3949 A positive or negative non-zero number, often between 0.3 and 1.0.
3950 A common medium value is 0.5, such that each octave has half the amplitude of
3951 the previous octave.
3952 This may need to be tuned when altering `lacunarity`; when doing so consider
3953 that a common medium value is 1 / lacunarity.
3954
3955 ### `lacunarity`
3956
3957 Each additional octave has a 'wavelength' that is the 'wavelength' of the
3958 previous octave multiplied by 1 / lacunarity, to create finer detail.
3959 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
3960
3961 A positive number no smaller than 1.0.
3962 Values below 2.0 create higher quality noise at the expense of requiring more
3963 octaves to cover a particular range of 'wavelengths'.
3964
3965 ### `flags`
3966
3967 Leave this field unset for no special handling.
3968 Currently supported are `defaults`, `eased` and `absvalue`:
3969
3970 #### `defaults`
3971
3972 Specify this if you would like to keep auto-selection of eased/not-eased while
3973 specifying some other flags.
3974
3975 #### `eased`
3976
3977 Maps noise gradient values onto a quintic S-curve before performing
3978 interpolation. This results in smooth, rolling noise.
3979 Disable this (`noeased`) for sharp-looking noise with a slightly gridded
3980 appearance.
3981 If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
3982 not eased.
3983 Easing a 3D noise significantly increases the noise calculation load, so use
3984 with restraint.
3985
3986 #### `absvalue`
3987
3988 The absolute value of each octave's noise variation is used when combining the
3989 octaves. The final perlin noise variation is created as follows:
3990
3991 noise = offset + scale * (abs(octave1) +
3992                           abs(octave2) * persistence +
3993                           abs(octave3) * persistence ^ 2 +
3994                           abs(octave4) * persistence ^ 3 +
3995                           ...)
3996
3997 ### Format example
3998
3999 For 2D or 3D perlin noise or perlin noise maps:
4000
4001     np_terrain = {
4002         offset = 0,
4003         scale = 1,
4004         spread = {x = 500, y = 500, z = 500},
4005         seed = 571347,
4006         octaves = 5,
4007         persistence = 0.63,
4008         lacunarity = 2.0,
4009         flags = "defaults, absvalue",
4010     }
4011
4012 For 2D noise the Z component of `spread` is still defined but is ignored.
4013 A single noise parameter table can be used for 2D or 3D noise.
4014
4015
4016
4017
4018 Ores
4019 ====
4020
4021 Ore types
4022 ---------
4023
4024 These tell in what manner the ore is generated.
4025
4026 All default ores are of the uniformly-distributed scatter type.
4027
4028 ### `scatter`
4029
4030 Randomly chooses a location and generates a cluster of ore.
4031
4032 If `noise_params` is specified, the ore will be placed if the 3D perlin noise
4033 at that point is greater than the `noise_threshold`, giving the ability to
4034 create a non-equal distribution of ore.
4035
4036 ### `sheet`
4037
4038 Creates a sheet of ore in a blob shape according to the 2D perlin noise
4039 described by `noise_params` and `noise_threshold`. This is essentially an
4040 improved version of the so-called "stratus" ore seen in some unofficial mods.
4041
4042 This sheet consists of vertical columns of uniform randomly distributed height,
4043 varying between the inclusive range `column_height_min` and `column_height_max`.
4044 If `column_height_min` is not specified, this parameter defaults to 1.
4045 If `column_height_max` is not specified, this parameter defaults to `clust_size`
4046 for reverse compatibility. New code should prefer `column_height_max`.
4047
4048 The `column_midpoint_factor` parameter controls the position of the column at
4049 which ore emanates from.
4050 If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
4051 equally starting from each direction.
4052 `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
4053 this parameter is not specified, the default is 0.5.
4054
4055 The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
4056 ore type.
4057
4058 ### `puff`
4059
4060 Creates a sheet of ore in a cloud-like puff shape.
4061
4062 As with the `sheet` ore type, the size and shape of puffs are described by
4063 `noise_params` and `noise_threshold` and are placed at random vertical
4064 positions within the currently generated chunk.
4065
4066 The vertical top and bottom displacement of each puff are determined by the
4067 noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
4068
4069 ### `blob`
4070
4071 Creates a deformed sphere of ore according to 3d perlin noise described by
4072 `noise_params`. The maximum size of the blob is `clust_size`, and
4073 `clust_scarcity` has the same meaning as with the `scatter` type.
4074
4075 ### `vein`
4076
4077 Creates veins of ore varying in density by according to the intersection of two
4078 instances of 3d perlin noise with different seeds, both described by
4079 `noise_params`.
4080
4081 `random_factor` varies the influence random chance has on placement of an ore
4082 inside the vein, which is `1` by default. Note that modifying this parameter
4083 may require adjusting `noise_threshold`.
4084
4085 The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
4086 by this ore type.
4087
4088 This ore type is difficult to control since it is sensitive to small changes.
4089 The following is a decent set of parameters to work from:
4090
4091     noise_params = {
4092         offset  = 0,
4093         scale   = 3,
4094         spread  = {x=200, y=200, z=200},
4095         seed    = 5390,
4096         octaves = 4,
4097         persistence = 0.5,
4098         lacunarity = 2.0,
4099         flags = "eased",
4100     },
4101     noise_threshold = 1.6
4102
4103 **WARNING**: Use this ore type *very* sparingly since it is ~200x more
4104 computationally expensive than any other ore.
4105
4106 ### `stratum`
4107
4108 Creates a single undulating ore stratum that is continuous across mapchunk
4109 borders and horizontally spans the world.
4110
4111 The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
4112 the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
4113 defines the stratum's vertical thickness (in units of nodes). Due to being
4114 continuous across mapchunk borders the stratum's vertical thickness is
4115 unlimited.
4116
4117 If the noise parameter `noise_params` is omitted the ore will occur from y_min
4118 to y_max in a simple horizontal stratum.
4119
4120 A parameter `stratum_thickness` can be provided instead of the noise parameter
4121 `np_stratum_thickness`, to create a constant thickness.
4122
4123 Leaving out one or both noise parameters makes the ore generation less
4124 intensive, useful when adding multiple strata.
4125
4126 `y_min` and `y_max` define the limits of the ore generation and for performance
4127 reasons should be set as close together as possible but without clipping the
4128 stratum's Y variation.
4129
4130 Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
4131 solid-ore stratum would require a `clust_scarcity` of 1.
4132
4133 The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
4134 `random_factor` are ignored by this ore type.
4135
4136 Ore attributes
4137 --------------
4138
4139 See section [Flag Specifier Format].
4140
4141 Currently supported flags:
4142 `puff_cliffs`, `puff_additive_composition`.
4143
4144 ### `puff_cliffs`
4145
4146 If set, puff ore generation will not taper down large differences in
4147 displacement when approaching the edge of a puff. This flag has no effect for
4148 ore types other than `puff`.
4149
4150 ### `puff_additive_composition`
4151
4152 By default, when noise described by `np_puff_top` or `np_puff_bottom` results
4153 in a negative displacement, the sub-column at that point is not generated. With
4154 this attribute set, puff ore generation will instead generate the absolute
4155 difference in noise displacement values. This flag has no effect for ore types
4156 other than `puff`.
4157
4158
4159
4160
4161 Decoration types
4162 ================
4163
4164 The varying types of decorations that can be placed.
4165
4166 `simple`
4167 --------
4168
4169 Creates a 1 times `H` times 1 column of a specified node (or a random node from
4170 a list, if a decoration list is specified). Can specify a certain node it must
4171 spawn next to, such as water or lava, for example. Can also generate a
4172 decoration of random height between a specified lower and upper bound.
4173 This type of decoration is intended for placement of grass, flowers, cacti,
4174 papyri, waterlilies and so on.
4175
4176 `schematic`
4177 -----------
4178
4179 Copies a box of `MapNodes` from a specified schematic file (or raw description).
4180 Can specify a probability of a node randomly appearing when placed.
4181 This decoration type is intended to be used for multi-node sized discrete
4182 structures, such as trees, cave spikes, rocks, and so on.
4183
4184
4185
4186
4187 Schematics
4188 ==========
4189
4190 Schematic specifier
4191 --------------------
4192
4193 A schematic specifier identifies a schematic by either a filename to a
4194 Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
4195 in the form of a table.  This table specifies the following fields:
4196
4197 * The `size` field is a 3D vector containing the dimensions of the provided
4198   schematic. (required field)
4199 * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
4200   sets the probability of a particular horizontal slice of the schematic being
4201   placed. (optional field)
4202   `ypos` = 0 for the lowest horizontal slice of a schematic.
4203   The default of `prob` is 255.
4204 * The `data` field is a flat table of MapNode tables making up the schematic,
4205   in the order of `[z [y [x]]]`. (required field)
4206   Each MapNode table contains:
4207     * `name`: the name of the map node to place (required)
4208     * `prob` (alias `param1`): the probability of this node being placed
4209       (default: 255)
4210     * `param2`: the raw param2 value of the node being placed onto the map
4211       (default: 0)
4212     * `force_place`: boolean representing if the node should forcibly overwrite
4213       any previous contents (default: false)
4214
4215 About probability values:
4216
4217 * A probability value of `0` or `1` means that node will never appear
4218   (0% chance).
4219 * A probability value of `254` or `255` means the node will always appear
4220   (100% chance).
4221 * If the probability value `p` is greater than `1`, then there is a
4222   `(p / 256 * 100)` percent chance that node will appear when the schematic is
4223   placed on the map.
4224
4225 Schematic attributes
4226 --------------------
4227
4228 See section [Flag Specifier Format].
4229
4230 Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
4231                            `force_placement`.
4232
4233 * `place_center_x`: Placement of this decoration is centered along the X axis.
4234 * `place_center_y`: Placement of this decoration is centered along the Y axis.
4235 * `place_center_z`: Placement of this decoration is centered along the Z axis.
4236 * `force_placement`: Schematic nodes other than "ignore" will replace existing
4237   nodes.
4238
4239
4240
4241
4242 Lua Voxel Manipulator
4243 =====================
4244
4245 About VoxelManip
4246 ----------------
4247
4248 VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
4249 facility. The purpose of this object is for fast, low-level, bulk access to
4250 reading and writing Map content. As such, setting map nodes through VoxelManip
4251 will lack many of the higher level features and concepts you may be used to
4252 with other methods of setting nodes. For example, nodes will not have their
4253 construction and destruction callbacks run, and no rollback information is
4254 logged.
4255
4256 It is important to note that VoxelManip is designed for speed, and *not* ease
4257 of use or flexibility. If your mod requires a map manipulation facility that
4258 will handle 100% of all edge cases, or the use of high level node placement
4259 features, perhaps `minetest.set_node()` is better suited for the job.
4260
4261 In addition, VoxelManip might not be faster, or could even be slower, for your
4262 specific use case. VoxelManip is most effective when setting large areas of map
4263 at once - for example, if only setting a 3x3x3 node area, a
4264 `minetest.set_node()` loop may be more optimal. Always profile code using both
4265 methods of map manipulation to determine which is most appropriate for your
4266 usage.
4267
4268 A recent simple test of setting cubic areas showed that `minetest.set_node()`
4269 is faster than a VoxelManip for a 3x3x3 node cube or smaller.
4270
4271 Using VoxelManip
4272 ----------------
4273
4274 A VoxelManip object can be created any time using either:
4275 `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
4276
4277 If the optional position parameters are present for either of these routines,
4278 the specified region will be pre-loaded into the VoxelManip object on creation.
4279 Otherwise, the area of map you wish to manipulate must first be loaded into the
4280 VoxelManip object using `VoxelManip:read_from_map()`.
4281
4282 Note that `VoxelManip:read_from_map()` returns two position vectors. The region
4283 formed by these positions indicate the minimum and maximum (respectively)
4284 positions of the area actually loaded in the VoxelManip, which may be larger
4285 than the area requested. For convenience, the loaded area coordinates can also
4286 be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
4287
4288 Now that the VoxelManip object is populated with map data, your mod can fetch a
4289 copy of this data using either of two methods. `VoxelManip:get_node_at()`,
4290 which retrieves an individual node in a MapNode formatted table at the position
4291 requested is the simplest method to use, but also the slowest.
4292
4293 Nodes in a VoxelManip object may also be read in bulk to a flat array table
4294 using:
4295
4296 * `VoxelManip:get_data()` for node content (in Content ID form, see section
4297   [Content IDs]),
4298 * `VoxelManip:get_light_data()` for node light levels, and
4299 * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
4300
4301 See section [Flat array format] for more details.
4302
4303 It is very important to understand that the tables returned by any of the above
4304 three functions represent a snapshot of the VoxelManip's internal state at the
4305 time of the call. This copy of the data will not magically update itself if
4306 another function modifies the internal VoxelManip state.
4307 Any functions that modify a VoxelManip's contents work on the VoxelManip's
4308 internal state unless otherwise explicitly stated.
4309
4310 Once the bulk data has been edited to your liking, the internal VoxelManip
4311 state can be set using:
4312
4313 * `VoxelManip:set_data()` for node content (in Content ID form, see section
4314   [Content IDs]),
4315 * `VoxelManip:set_light_data()` for node light levels, and
4316 * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
4317
4318 The parameter to each of the above three functions can use any table at all in
4319 the same flat array format as produced by `get_data()` etc. and is not required
4320 to be a table retrieved from `get_data()`.
4321
4322 Once the internal VoxelManip state has been modified to your liking, the
4323 changes can be committed back to the map by calling `VoxelManip:write_to_map()`
4324
4325 ### Flat array format
4326
4327 Let
4328     `Nx = p2.X - p1.X + 1`,
4329     `Ny = p2.Y - p1.Y + 1`, and
4330     `Nz = p2.Z - p1.Z + 1`.
4331
4332 Then, for a loaded region of p1..p2, this array ranges from `1` up to and
4333 including the value of the expression `Nx * Ny * Nz`.
4334
4335 Positions offset from p1 are present in the array with the format of:
4336
4337     [
4338         (0, 0, 0),   (1, 0, 0),   (2, 0, 0),   ... (Nx, 0, 0),
4339         (0, 1, 0),   (1, 1, 0),   (2, 1, 0),   ... (Nx, 1, 0),
4340         ...
4341         (0, Ny, 0),  (1, Ny, 0),  (2, Ny, 0),  ... (Nx, Ny, 0),
4342         (0, 0, 1),   (1, 0, 1),   (2, 0, 1),   ... (Nx, 0, 1),
4343         ...
4344         (0, Ny, 2),  (1, Ny, 2),  (2, Ny, 2),  ... (Nx, Ny, 2),
4345         ...
4346         (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
4347     ]
4348
4349 and the array index for a position p contained completely in p1..p2 is:
4350
4351 `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
4352
4353 Note that this is the same "flat 3D array" format as
4354 `PerlinNoiseMap:get3dMap_flat()`.
4355 VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
4356 of the index for a single point in a flat VoxelManip array.
4357
4358 ### Content IDs
4359
4360 A Content ID is a unique integer identifier for a specific node type.
4361 These IDs are used by VoxelManip in place of the node name string for
4362 `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
4363 `minetest.get_content_id()` to look up the Content ID for the specified node
4364 name, and `minetest.get_name_from_content_id()` to look up the node name string
4365 for a given Content ID.
4366 After registration of a node, its Content ID will remain the same throughout
4367 execution of the mod.
4368 Note that the node being queried needs to have already been been registered.
4369
4370 The following builtin node types have their Content IDs defined as constants:
4371
4372 * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
4373 * `minetest.CONTENT_AIR`:     ID for "air" nodes
4374 * `minetest.CONTENT_IGNORE`:  ID for "ignore" nodes
4375
4376 ### Mapgen VoxelManip objects
4377
4378 Inside of `on_generated()` callbacks, it is possible to retrieve the same
4379 VoxelManip object used by the core's Map Generator (commonly abbreviated
4380 Mapgen). Most of the rules previously described still apply but with a few
4381 differences:
4382
4383 * The Mapgen VoxelManip object is retrieved using:
4384   `minetest.get_mapgen_object("voxelmanip")`
4385 * This VoxelManip object already has the region of map just generated loaded
4386   into it; it's not necessary to call `VoxelManip:read_from_map()`.
4387   Note that the region of map it has loaded is NOT THE SAME as the `minp`, `maxp`
4388   parameters of `on_generated()`. Refer to `minetest.get_mapgen_object` docs.
4389 * The `on_generated()` callbacks of some mods may place individual nodes in the
4390   generated area using non-VoxelManip map modification methods. Because the
4391   same Mapgen VoxelManip object is passed through each `on_generated()`
4392   callback, it becomes necessary for the Mapgen VoxelManip object to maintain
4393   consistency with the current map state. For this reason, calling any of
4394   `minetest.add_node()`, `minetest.set_node()` or `minetest.swap_node()`
4395   will also update the Mapgen VoxelManip object's internal state active on the
4396   current thread.
4397 * After modifying the Mapgen VoxelManip object's internal buffer, it may be
4398   necessary to update lighting information using either:
4399   `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
4400
4401 ### Other API functions operating on a VoxelManip
4402
4403 If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
4404 `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
4405 flowing. It is recommended to call this function only after having written all
4406 buffered data back to the VoxelManip object, save for special situations where
4407 the modder desires to only have certain liquid nodes begin flowing.
4408
4409 The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
4410 will generate all registered decorations and ores throughout the full area
4411 inside of the specified VoxelManip object.
4412
4413 `minetest.place_schematic_on_vmanip()` is otherwise identical to
4414 `minetest.place_schematic()`, except instead of placing the specified schematic
4415 directly on the map at the specified position, it will place the schematic
4416 inside the VoxelManip.
4417
4418 ### Notes
4419
4420 * Attempting to read data from a VoxelManip object before map is read will
4421   result in a zero-length array table for `VoxelManip:get_data()`, and an
4422   "ignore" node at any position for `VoxelManip:get_node_at()`.
4423 * If either a region of map has not yet been generated or is out-of-bounds of
4424   the map, that region is filled with "ignore" nodes.
4425 * Other mods, or the core itself, could possibly modify the area of map
4426   currently loaded into a VoxelManip object. With the exception of Mapgen
4427   VoxelManips (see above section), the internal buffers are not updated. For
4428   this reason, it is strongly encouraged to complete the usage of a particular
4429   VoxelManip object in the same callback it had been created.
4430 * If a VoxelManip object will be used often, such as in an `on_generated()`
4431   callback, consider passing a file-scoped table as the optional parameter to
4432   `VoxelManip:get_data()`, which serves as a static buffer the function can use
4433   to write map data to instead of returning a new table each call. This greatly
4434   enhances performance by avoiding unnecessary memory allocations.
4435
4436 Methods
4437 -------
4438
4439 * `read_from_map(p1, p2)`:  Loads a chunk of map into the VoxelManip object
4440   containing the region formed by `p1` and `p2`.
4441     * returns actual emerged `pmin`, actual emerged `pmax`
4442 * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
4443   the map.
4444     * **important**: data must be set using `VoxelManip:set_data()` before
4445       calling this.
4446     * if `light` is true, then lighting is automatically recalculated.
4447       The default value is true.
4448       If `light` is false, no light calculations happen, and you should correct
4449       all modified blocks with `minetest.fix_light()` as soon as possible.
4450       Keep in mind that modifying the map where light is incorrect can cause
4451       more lighting bugs.
4452 * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
4453   the `VoxelManip` at that position
4454 * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
4455   that position.
4456 * `get_data([buffer])`: Retrieves the node content data loaded into the
4457   `VoxelManip` object.
4458     * returns raw node data in the form of an array of node content IDs
4459     * if the param `buffer` is present, this table will be used to store the
4460       result instead.
4461 * `set_data(data)`: Sets the data contents of the `VoxelManip` object
4462 * `update_map()`: Does nothing, kept for compatibility.
4463 * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
4464   a uniform value.
4465     * `light` is a table, `{day=<0...15>, night=<0...15>}`
4466     * To be used only by a `VoxelManip` object from
4467       `minetest.get_mapgen_object`.
4468     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4469       area if left out.
4470 * `get_light_data([buffer])`: Gets the light data read into the
4471   `VoxelManip` object
4472     * Returns an array (indices 1 to volume) of integers ranging from `0` to
4473       `255`.
4474     * Each value is the bitwise combination of day and night light values
4475       (`0` to `15` each).
4476     * `light = day + (night * 16)`
4477     * If the param `buffer` is present, this table will be used to store the
4478       result instead.
4479 * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
4480   in the `VoxelManip`.
4481     * expects lighting data in the same format that `get_light_data()` returns
4482 * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
4483   `VoxelManip` object.
4484     * Returns an array (indices 1 to volume) of integers ranging from `0` to
4485       `255`.
4486     * If the param `buffer` is present, this table will be used to store the
4487       result instead.
4488 * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
4489   the `VoxelManip`.
4490 * `calc_lighting([p1, p2], [propagate_shadow])`:  Calculate lighting within the
4491   `VoxelManip`.
4492     * To be used only by a `VoxelManip` object from
4493       `minetest.get_mapgen_object`.
4494     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4495       area if left out or nil. For almost all uses these should be left out
4496       or nil to use the default.
4497     * `propagate_shadow` is an optional boolean deciding whether shadows in a
4498       generated mapchunk above are propagated down into the mapchunk, defaults
4499       to `true` if left out.
4500 * `update_liquids()`: Update liquid flow
4501 * `was_modified()`: Returns `true` or `false` if the data in the voxel
4502   manipulator had been modified since the last read from map, due to a call to
4503   `minetest.set_data()` on the loaded area elsewhere.
4504 * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
4505
4506 `VoxelArea`
4507 -----------
4508
4509 A helper class for voxel areas.
4510 It can be created via `VoxelArea(pmin, pmax)` or
4511 `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
4512 The coordinates are *inclusive*, like most other things in Minetest.
4513
4514 ### Methods
4515
4516 * `getExtent()`: returns a 3D vector containing the size of the area formed by
4517   `MinEdge` and `MaxEdge`.
4518 * `getVolume()`: returns the volume of the area formed by `MinEdge` and
4519   `MaxEdge`.
4520 * `index(x, y, z)`: returns the index of an absolute position in a flat array
4521   starting at `1`.
4522     * `x`, `y` and `z` must be integers to avoid an incorrect index result.
4523     * The position (x, y, z) is not checked for being inside the area volume,
4524       being outside can cause an incorrect index result.
4525     * Useful for things like `VoxelManip`, raw Schematic specifiers,
4526       `PerlinNoiseMap:get2d`/`3dMap`, and so on.
4527 * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
4528     * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
4529       is not checked for being inside the area volume.
4530 * `position(i)`: returns the absolute position vector corresponding to index
4531   `i`.
4532 * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
4533   `MinEdge` and `MaxEdge`.
4534 * `containsp(p)`: same as above, except takes a vector
4535 * `containsi(i)`: same as above, except takes an index `i`
4536 * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
4537   indices.
4538     * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
4539       `[z [y [x]]]`.
4540 * `iterp(minp, maxp)`: same as above, except takes a vector
4541
4542 ### Y stride and z stride of a flat array
4543
4544 For a particular position in a voxel area, whose flat array index is known,
4545 it is often useful to know the index of a neighboring or nearby position.
4546 The table below shows the changes of index required for 1 node movements along
4547 the axes in a voxel area:
4548
4549     Movement    Change of index
4550     +x          +1
4551     -x          -1
4552     +y          +ystride
4553     -y          -ystride
4554     +z          +zstride
4555     -z          -zstride
4556
4557 If, for example:
4558
4559     local area = VoxelArea(emin, emax)
4560
4561 The values of `ystride` and `zstride` can be obtained using `area.ystride` and
4562 `area.zstride`.
4563
4564
4565
4566
4567 Mapgen objects
4568 ==============
4569
4570 A mapgen object is a construct used in map generation. Mapgen objects can be
4571 used by an `on_generate` callback to speed up operations by avoiding
4572 unnecessary recalculations, these can be retrieved using the
4573 `minetest.get_mapgen_object()` function. If the requested Mapgen object is
4574 unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
4575 callback, `nil` is returned.
4576
4577 The following Mapgen objects are currently available:
4578
4579 ### `voxelmanip`
4580
4581 This returns three values; the `VoxelManip` object to be used, minimum and
4582 maximum emerged position, in that order. All mapgens support this object.
4583
4584 ### `heightmap`
4585
4586 Returns an array containing the y coordinates of the ground levels of nodes in
4587 the most recently generated chunk by the current mapgen.
4588
4589 ### `biomemap`
4590
4591 Returns an array containing the biome IDs of nodes in the most recently
4592 generated chunk by the current mapgen.
4593
4594 ### `heatmap`
4595
4596 Returns an array containing the temperature values of nodes in the most
4597 recently generated chunk by the current mapgen.
4598
4599 ### `humiditymap`
4600
4601 Returns an array containing the humidity values of nodes in the most recently
4602 generated chunk by the current mapgen.
4603
4604 ### `gennotify`
4605
4606 Returns a table mapping requested generation notification types to arrays of
4607 positions at which the corresponding generated structures are located within
4608 the current chunk. To enable the capture of positions of interest to be recorded
4609 call `minetest.set_gen_notify()` first.
4610
4611 Possible fields of the returned table are:
4612
4613 * `dungeon`: bottom center position of dungeon rooms
4614 * `temple`: as above but for desert temples (mgv6 only)
4615 * `cave_begin`
4616 * `cave_end`
4617 * `large_cave_begin`
4618 * `large_cave_end`
4619 * `decoration#id` (see below)
4620
4621 Decorations have a key in the format of `"decoration#id"`, where `id` is the
4622 numeric unique decoration ID as returned by `minetest.get_decoration_id()`.
4623 For example, `decoration#123`.
4624
4625 The returned positions are the ground surface 'place_on' nodes,
4626 not the decorations themselves. A 'simple' type decoration is often 1
4627 node above the returned position and possibly displaced by 'place_offset_y'.
4628
4629
4630 Registered entities
4631 ===================
4632
4633 Functions receive a "luaentity" table as `self`:
4634
4635 * It has the member `name`, which is the registered name `("mod:thing")`
4636 * It has the member `object`, which is an `ObjectRef` pointing to the object
4637 * The original prototype is visible directly via a metatable
4638
4639 Callbacks:
4640
4641 * `on_activate(self, staticdata, dtime_s)`
4642     * Called when the object is instantiated.
4643     * `dtime_s` is the time passed since the object was unloaded, which can be
4644       used for updating the entity state.
4645 * `on_deactivate(self, removal)`
4646     * Called when the object is about to get removed or unloaded.
4647     * `removal`: boolean indicating whether the object is about to get removed.
4648       Calling `object:remove()` on an active object will call this with `removal=true`.
4649       The mapblock the entity resides in being unloaded will call this with `removal=false`.
4650     * Note that this won't be called if the object hasn't been activated in the first place.
4651       In particular, `minetest.clear_objects({mode = "full"})` won't call this,
4652       whereas `minetest.clear_objects({mode = "quick"})` might call this.
4653 * `on_step(self, dtime, moveresult)`
4654     * Called on every server tick, after movement and collision processing.
4655     * `dtime`: elapsed time since last call
4656     * `moveresult`: table with collision info (only available if physical=true)
4657 * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
4658     * Called when somebody punches the object.
4659     * Note that you probably want to handle most punches using the automatic
4660       armor group system.
4661     * `puncher`: an `ObjectRef` (can be `nil`)
4662     * `time_from_last_punch`: Meant for disallowing spamming of clicks
4663       (can be `nil`).
4664     * `tool_capabilities`: capability table of used item (can be `nil`)
4665     * `dir`: unit vector of direction of punch. Always defined. Points from the
4666       puncher to the punched.
4667     * `damage`: damage that will be done to entity.
4668     * Can return `true` to prevent the default damage mechanism.
4669 * `on_death(self, killer)`
4670     * Called when the object dies.
4671     * `killer`: an `ObjectRef` (can be `nil`)
4672 * `on_rightclick(self, clicker)`
4673     * Called when `clicker` pressed the 'place/use' key while pointing
4674       to the object (not necessarily an actual rightclick)
4675     * `clicker`: an `ObjectRef` (may or may not be a player)
4676 * `on_attach_child(self, child)`
4677     * `child`: an `ObjectRef` of the child that attaches
4678 * `on_detach_child(self, child)`
4679     * `child`: an `ObjectRef` of the child that detaches
4680 * `on_detach(self, parent)`
4681     * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
4682     * This happens before the parent object is removed from the world
4683 * `get_staticdata(self)`
4684     * Should return a string that will be passed to `on_activate` when the
4685       object is instantiated the next time.
4686
4687 Collision info passed to `on_step` (`moveresult` argument):
4688
4689     {
4690         touching_ground = boolean,
4691         -- Note that touching_ground is only true if the entity was moving and
4692         -- collided with ground.
4693
4694         collides = boolean,
4695         standing_on_object = boolean,
4696
4697         collisions = {
4698             {
4699                 type = string, -- "node" or "object",
4700                 axis = string, -- "x", "y" or "z"
4701                 node_pos = vector, -- if type is "node"
4702                 object = ObjectRef, -- if type is "object"
4703                 old_velocity = vector,
4704                 new_velocity = vector,
4705             },
4706             ...
4707         }
4708         -- `collisions` does not contain data of unloaded mapblock collisions
4709         -- or when the velocity changes are negligibly small
4710     }
4711
4712
4713
4714 L-system trees
4715 ==============
4716
4717 Tree definition
4718 ---------------
4719
4720     treedef={
4721         axiom,         --string  initial tree axiom
4722         rules_a,       --string  rules set A
4723         rules_b,       --string  rules set B
4724         rules_c,       --string  rules set C
4725         rules_d,       --string  rules set D
4726         trunk,         --string  trunk node name
4727         leaves,        --string  leaves node name
4728         leaves2,       --string  secondary leaves node name
4729         leaves2_chance,--num     chance (0-100) to replace leaves with leaves2
4730         angle,         --num     angle in deg
4731         iterations,    --num     max # of iterations, usually 2 -5
4732         random_level,  --num     factor to lower number of iterations, usually 0 - 3
4733         trunk_type,    --string  single/double/crossed) type of trunk: 1 node,
4734                        --        2x2 nodes or 3x3 in cross shape
4735         thin_branches, --boolean true -> use thin (1 node) branches
4736         fruit,         --string  fruit node name
4737         fruit_chance,  --num     chance (0-100) to replace leaves with fruit node
4738         seed,          --num     random seed, if no seed is provided, the engine
4739                                  will create one.
4740     }
4741
4742 Key for special L-System symbols used in axioms
4743 -----------------------------------------------
4744
4745 * `G`: move forward one unit with the pen up
4746 * `F`: move forward one unit with the pen down drawing trunks and branches
4747 * `f`: move forward one unit with the pen down drawing leaves (100% chance)
4748 * `T`: move forward one unit with the pen down drawing trunks only
4749 * `R`: move forward one unit with the pen down placing fruit
4750 * `A`: replace with rules set A
4751 * `B`: replace with rules set B
4752 * `C`: replace with rules set C
4753 * `D`: replace with rules set D
4754 * `a`: replace with rules set A, chance 90%
4755 * `b`: replace with rules set B, chance 80%
4756 * `c`: replace with rules set C, chance 70%
4757 * `d`: replace with rules set D, chance 60%
4758 * `+`: yaw the turtle right by `angle` parameter
4759 * `-`: yaw the turtle left by `angle` parameter
4760 * `&`: pitch the turtle down by `angle` parameter
4761 * `^`: pitch the turtle up by `angle` parameter
4762 * `/`: roll the turtle to the right by `angle` parameter
4763 * `*`: roll the turtle to the left by `angle` parameter
4764 * `[`: save in stack current state info
4765 * `]`: recover from stack state info
4766
4767 Example
4768 -------
4769
4770 Spawn a small apple tree:
4771
4772     pos = {x=230,y=20,z=4}
4773     apple_tree={
4774         axiom="FFFFFAFFBF",
4775         rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
4776         rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
4777         trunk="default:tree",
4778         leaves="default:leaves",
4779         angle=30,
4780         iterations=2,
4781         random_level=0,
4782         trunk_type="single",
4783         thin_branches=true,
4784         fruit_chance=10,
4785         fruit="default:apple"
4786     }
4787     minetest.spawn_tree(pos,apple_tree)
4788
4789
4790 Privileges
4791 ==========
4792
4793 Privileges provide a means for server administrators to give certain players
4794 access to special abilities in the engine, games or mods.
4795 For example, game moderators may need to travel instantly to any place in the world,
4796 this ability is implemented in `/teleport` command which requires `teleport` privilege.
4797
4798 Registering privileges
4799 ----------------------
4800
4801 A mod can register a custom privilege using `minetest.register_privilege` function
4802 to give server administrators fine-grained access control over mod functionality.
4803
4804 For consistency and practical reasons, privileges should strictly increase the abilities of the user.
4805 Do not register custom privileges that e.g. restrict the player from certain in-game actions.
4806
4807 Checking privileges
4808 -------------------
4809
4810 A mod can call `minetest.check_player_privs` to test whether a player has privileges
4811 to perform an operation.
4812 Also, when registering a chat command with `minetest.register_chatcommand` a mod can
4813 declare privileges that the command requires using the `privs` field of the command
4814 definition.
4815
4816 Managing player privileges
4817 --------------------------
4818
4819 A mod can update player privileges using `minetest.set_player_privs` function.
4820 Players holding the `privs` privilege can see and manage privileges for all
4821 players on the server.
4822
4823 A mod can subscribe to changes in player privileges using `minetest.register_on_priv_grant`
4824 and `minetest.register_on_priv_revoke` functions.
4825
4826 Built-in privileges
4827 -------------------
4828
4829 Minetest includes a set of built-in privileges that control capabilities
4830 provided by the Minetest engine and can be used by mods:
4831
4832   * Basic privileges are normally granted to all players:
4833       * `shout`: can communicate using the in-game chat.
4834       * `interact`: can modify the world by digging, building and interacting
4835         with the nodes, entities and other players. Players without the `interact`
4836         privilege can only travel and observe the world.
4837
4838   * Advanced privileges allow bypassing certain aspects of the gameplay:
4839       * `fast`: can use "fast mode" to move with maximum speed.
4840       * `fly`: can use "fly mode" to move freely above the ground without falling.
4841       * `noclip`: can use "noclip mode" to fly through solid nodes (e.g. walls).
4842       * `teleport`: can use `/teleport` command to move to any point in the world.
4843       * `creative`: can access creative inventory.
4844       * `bring`: can teleport other players to oneself.
4845       * `give`: can use `/give` and `/giveme` commands to give any item
4846         in the game to oneself or others.
4847       * `settime`: can use `/time` command to change current in-game time.
4848       * `debug`: can enable wireframe rendering mode.
4849
4850   * Security-related privileges:
4851       * `privs`: can modify privileges of the players using `/grant[me]` and
4852         `/revoke[me]` commands.
4853       * `basic_privs`: can grant and revoke basic privileges as defined by
4854         the `basic_privs` setting.
4855       * `kick`: can kick other players from the server using `/kick` command.
4856       * `ban`: can ban other players using `/ban` command.
4857       * `password`: can use `/setpassword` and `/clearpassword` commands
4858         to manage players' passwords.
4859       * `protection_bypass`: can bypass node protection. Note that the engine does not act upon this privilege,
4860         it is only an implementation suggestion for games.
4861
4862   * Administrative privileges:
4863       * `server`: can use `/fixlight`, `/deleteblocks` and `/deleteobjects`
4864         commands. Can clear inventory of other players using `/clearinv` command.
4865       * `rollback`: can use `/rollback_check` and `/rollback` commands.
4866
4867 Related settings
4868 ----------------
4869
4870 Minetest includes the following settings to control behavior of privileges:
4871
4872    * `default_privs`: defines privileges granted to new players.
4873    * `basic_privs`: defines privileges that can be granted/revoked by players having
4874     the `basic_privs` privilege. This can be used, for example, to give
4875     limited moderation powers to selected users.
4876
4877 'minetest' namespace reference
4878 ==============================
4879
4880 Utilities
4881 ---------
4882
4883 * `minetest.get_current_modname()`: returns the currently loading mod's name,
4884   when loading a mod.
4885 * `minetest.get_modpath(modname)`: returns the directory path for a mod,
4886   e.g. `"/home/user/.minetest/usermods/modname"`.
4887     * Returns nil if the mod is not enabled or does not exist (not installed).
4888     * Works regardless of whether the mod has been loaded yet.
4889     * Useful for loading additional `.lua` modules or static data from a mod,
4890   or checking if a mod is enabled.
4891 * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
4892     * Does not include disabled mods, even if they are installed.
4893 * `minetest.get_game_info()`: returns a table containing information about the
4894   current game. Note that other meta information (e.g. version/release number)
4895   can be manually read from `game.conf` in the game's root directory.
4896
4897       {
4898           id = string,
4899           title = string,
4900           author = string,
4901           -- The root directory of the game
4902           path = string,
4903       }
4904
4905 * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
4906     * Useful for storing custom data
4907 * `minetest.is_singleplayer()`
4908 * `minetest.features`: Table containing API feature flags
4909
4910       {
4911           glasslike_framed = true,  -- 0.4.7
4912           nodebox_as_selectionbox = true,  -- 0.4.7
4913           get_all_craft_recipes_works = true,  -- 0.4.7
4914           -- The transparency channel of textures can optionally be used on
4915           -- nodes (0.4.7)
4916           use_texture_alpha = true,
4917           -- Tree and grass ABMs are no longer done from C++ (0.4.8)
4918           no_legacy_abms = true,
4919           -- Texture grouping is possible using parentheses (0.4.11)
4920           texture_names_parens = true,
4921           -- Unique Area ID for AreaStore:insert_area (0.4.14)
4922           area_store_custom_ids = true,
4923           -- add_entity supports passing initial staticdata to on_activate
4924           -- (0.4.16)
4925           add_entity_with_staticdata = true,
4926           -- Chat messages are no longer predicted (0.4.16)
4927           no_chat_message_prediction = true,
4928           -- The transparency channel of textures can optionally be used on
4929           -- objects (ie: players and lua entities) (5.0.0)
4930           object_use_texture_alpha = true,
4931           -- Object selectionbox is settable independently from collisionbox
4932           -- (5.0.0)
4933           object_independent_selectionbox = true,
4934           -- Specifies whether binary data can be uploaded or downloaded using
4935           -- the HTTP API (5.1.0)
4936           httpfetch_binary_data = true,
4937           -- Whether formspec_version[<version>] may be used (5.1.0)
4938           formspec_version_element = true,
4939           -- Whether AreaStore's IDs are kept on save/load (5.1.0)
4940           area_store_persistent_ids = true,
4941           -- Whether minetest.find_path is functional (5.2.0)
4942           pathfinder_works = true,
4943           -- Whether Collision info is available to an objects' on_step (5.3.0)
4944           object_step_has_moveresult = true,
4945           -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
4946           direct_velocity_on_players = true,
4947           -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
4948           use_texture_alpha_string_modes = true,
4949           -- degrotate param2 rotates in units of 1.5° instead of 2°
4950           -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
4951           degrotate_240_steps = true,
4952           -- ABM supports min_y and max_y fields in definition (5.5.0)
4953           abm_min_max_y = true,
4954           -- dynamic_add_media supports passing a table with options (5.5.0)
4955           dynamic_add_media_table = true,
4956           -- particlespawners support texpools and animation of properties,
4957           -- particle textures support smooth fade and scale animations, and
4958           -- sprite-sheet particle animations can by synced to the lifetime
4959           -- of individual particles (5.6.0)
4960           particlespawner_tweenable = true,
4961           -- allows get_sky to return a table instead of separate values (5.6.0)
4962           get_sky_as_table = true,
4963           -- VoxelManip:get_light_data accepts an optional buffer argument (5.7.0)
4964           get_light_data_buffer = true,
4965           -- When using a mod storage backend that is not "files" or "dummy",
4966           -- the amount of data in mod storage is not constrained by
4967           -- the amount of RAM available. (5.7.0)
4968           mod_storage_on_disk = true,
4969           -- "zstd" method for compress/decompress (5.7.0)
4970           compress_zstd = true,
4971       }
4972
4973 * `minetest.has_feature(arg)`: returns `boolean, missing_features`
4974     * `arg`: string or table in format `{foo=true, bar=true}`
4975     * `missing_features`: `{foo=true, bar=true}`
4976 * `minetest.get_player_information(player_name)`: Table containing information
4977   about a player. Example return value:
4978
4979       {
4980           address = "127.0.0.1",     -- IP address of client
4981           ip_version = 4,            -- IPv4 / IPv6
4982           connection_uptime = 200,   -- seconds since client connected
4983           protocol_version = 32,     -- protocol version used by client
4984           formspec_version = 2,      -- supported formspec version
4985           lang_code = "fr"           -- Language code used for translation
4986
4987           -- the following keys can be missing if no stats have been collected yet
4988           min_rtt = 0.01,            -- minimum round trip time
4989           max_rtt = 0.2,             -- maximum round trip time
4990           avg_rtt = 0.02,            -- average round trip time
4991           min_jitter = 0.01,         -- minimum packet time jitter
4992           max_jitter = 0.5,          -- maximum packet time jitter
4993           avg_jitter = 0.03,         -- average packet time jitter
4994           -- the following information is available in a debug build only!!!
4995           -- DO NOT USE IN MODS
4996           --ser_vers = 26,             -- serialization version used by client
4997           --major = 0,                 -- major version number
4998           --minor = 4,                 -- minor version number
4999           --patch = 10,                -- patch version number
5000           --vers_string = "0.4.9-git", -- full version string
5001           --state = "Active"           -- current client state
5002       }
5003 * `minetest.get_player_window_information(player_name)`:
5004
5005       -- Will only be present if the client sent this information (requires v5.7+)
5006       --
5007       -- Note that none of these things are constant, they are likely to change during a client
5008       -- connection as the player resizes the window and moves it between monitors
5009       --
5010       -- real_gui_scaling and real_hud_scaling can be used instead of DPI.
5011       -- OSes don't necessarily give the physical DPI, as they may allow user configuration.
5012       -- real_*_scaling is just OS DPI / 96 but with another level of user configuration.
5013       {
5014           -- Current size of the in-game render target (pixels).
5015           --
5016           -- This is usually the window size, but may be smaller in certain situations,
5017           -- such as side-by-side mode.
5018           size = {
5019               x = 1308,
5020               y = 577,
5021           },
5022
5023           -- Estimated maximum formspec size before Minetest will start shrinking the
5024           -- formspec to fit. For a fullscreen formspec, use a size 10-20% larger than
5025           -- this and `padding[-0.01,-0.01]`.
5026           max_formspec_size = {
5027               x = 20,
5028               y = 11.25
5029           },
5030
5031           -- GUI Scaling multiplier
5032           -- Equal to the setting `gui_scaling` multiplied by `dpi / 96`
5033           real_gui_scaling = 1,
5034
5035           -- HUD Scaling multiplier
5036           -- Equal to the setting `hud_scaling` multiplied by `dpi / 96`
5037           real_hud_scaling = 1,
5038       }
5039
5040 * `minetest.mkdir(path)`: returns success.
5041     * Creates a directory specified by `path`, creating parent directories
5042       if they don't exist.
5043 * `minetest.rmdir(path, recursive)`: returns success.
5044     * Removes a directory specified by `path`.
5045     * If `recursive` is set to `true`, the directory is recursively removed.
5046       Otherwise, the directory will only be removed if it is empty.
5047     * Returns true on success, false on failure.
5048 * `minetest.cpdir(source, destination)`: returns success.
5049     * Copies a directory specified by `path` to `destination`
5050     * Any files in `destination` will be overwritten if they already exist.
5051     * Returns true on success, false on failure.
5052 * `minetest.mvdir(source, destination)`: returns success.
5053     * Moves a directory specified by `path` to `destination`.
5054     * If the `destination` is a non-empty directory, then the move will fail.
5055     * Returns true on success, false on failure.
5056 * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
5057     * is_dir is one of:
5058         * nil: return all entries,
5059         * true: return only subdirectory names, or
5060         * false: return only file names.
5061 * `minetest.safe_file_write(path, content)`: returns boolean indicating success
5062     * Replaces contents of file at path with new contents in a safe (atomic)
5063       way. Use this instead of below code when writing e.g. database files:
5064       `local f = io.open(path, "wb"); f:write(content); f:close()`
5065 * `minetest.get_version()`: returns a table containing components of the
5066    engine version.  Components:
5067     * `project`: Name of the project, eg, "Minetest"
5068     * `string`: Simple version, eg, "1.2.3-dev"
5069     * `hash`: Full git version (only set if available),
5070       eg, "1.2.3-dev-01234567-dirty".
5071     * `is_dev`: Boolean value indicating whether it's a development build
5072   Use this for informational purposes only. The information in the returned
5073   table does not represent the capabilities of the engine, nor is it
5074   reliable or verifiable. Compatible forks will have a different name and
5075   version entirely. To check for the presence of engine features, test
5076   whether the functions exported by the wanted features exist. For example:
5077   `if minetest.check_for_falling then ... end`.
5078 * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
5079     * `data`: string of data to hash
5080     * `raw`: return raw bytes instead of hex digits, default: false
5081 * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
5082   ColorString. If the ColorSpec is invalid, returns `nil`.
5083     * `colorspec`: The ColorSpec to convert
5084 * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
5085   string of four bytes in an RGBA layout, returned as a string.
5086   * `colorspec`: The ColorSpec to convert
5087 * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
5088   image and return it in string form.
5089     * `width`: Width of the image
5090     * `height`: Height of the image
5091     * `data`: Image data, one of:
5092         * array table of ColorSpec, length must be width*height
5093         * string with raw RGBA pixels, length must be width*height*4
5094     * `compression`: Optional zlib compression level, number in range 0 to 9.
5095   The data is one-dimensional, starting in the upper left corner of the image
5096   and laid out in scanlines going from left to right, then top to bottom.
5097   Please note that it's not safe to use string.char to generate raw data,
5098   use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
5099   The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
5100   You may use this to procedurally generate textures during server init.
5101
5102 Logging
5103 -------
5104
5105 * `minetest.debug(...)`
5106     * Equivalent to `minetest.log(table.concat({...}, "\t"))`
5107 * `minetest.log([level,] text)`
5108     * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
5109       `"info"`, or `"verbose"`.  Default is `"none"`.
5110
5111 Registration functions
5112 ----------------------
5113
5114 Call these functions only at load time!
5115
5116 ### Environment
5117
5118 * `minetest.register_node(name, node definition)`
5119 * `minetest.register_craftitem(name, item definition)`
5120 * `minetest.register_tool(name, item definition)`
5121 * `minetest.override_item(name, redefinition)`
5122     * Overrides fields of an item registered with register_node/tool/craftitem.
5123     * Note: Item must already be defined, (opt)depend on the mod defining it.
5124     * Example: `minetest.override_item("default:mese",
5125       {light_source=minetest.LIGHT_MAX})`
5126 * `minetest.unregister_item(name)`
5127     * Unregisters the item from the engine, and deletes the entry with key
5128       `name` from `minetest.registered_items` and from the associated item table
5129       according to its nature: `minetest.registered_nodes`, etc.
5130 * `minetest.register_entity(name, entity definition)`
5131 * `minetest.register_abm(abm definition)`
5132 * `minetest.register_lbm(lbm definition)`
5133 * `minetest.register_alias(alias, original_name)`
5134     * Also use this to set the 'mapgen aliases' needed in a game for the core
5135       mapgens. See [Mapgen aliases] section above.
5136 * `minetest.register_alias_force(alias, original_name)`
5137 * `minetest.register_ore(ore definition)`
5138     * Returns an integer object handle uniquely identifying the registered
5139       ore on success.
5140     * The order of ore registrations determines the order of ore generation.
5141 * `minetest.register_biome(biome definition)`
5142     * Returns an integer object handle uniquely identifying the registered
5143       biome on success. To get the biome ID, use `minetest.get_biome_id`.
5144 * `minetest.unregister_biome(name)`
5145     * Unregisters the biome from the engine, and deletes the entry with key
5146       `name` from `minetest.registered_biomes`.
5147     * Warning: This alters the biome to biome ID correspondences, so any
5148       decorations or ores using the 'biomes' field must afterwards be cleared
5149       and re-registered.
5150 * `minetest.register_decoration(decoration definition)`
5151     * Returns an integer object handle uniquely identifying the registered
5152       decoration on success. To get the decoration ID, use
5153       `minetest.get_decoration_id`.
5154     * The order of decoration registrations determines the order of decoration
5155       generation.
5156 * `minetest.register_schematic(schematic definition)`
5157     * Returns an integer object handle uniquely identifying the registered
5158       schematic on success.
5159     * If the schematic is loaded from a file, the `name` field is set to the
5160       filename.
5161     * If the function is called when loading the mod, and `name` is a relative
5162       path, then the current mod path will be prepended to the schematic
5163       filename.
5164 * `minetest.clear_registered_biomes()`
5165     * Clears all biomes currently registered.
5166     * Warning: Clearing and re-registering biomes alters the biome to biome ID
5167       correspondences, so any decorations or ores using the 'biomes' field must
5168       afterwards be cleared and re-registered.
5169 * `minetest.clear_registered_decorations()`
5170     * Clears all decorations currently registered.
5171 * `minetest.clear_registered_ores()`
5172     * Clears all ores currently registered.
5173 * `minetest.clear_registered_schematics()`
5174     * Clears all schematics currently registered.
5175
5176 ### Gameplay
5177
5178 * `minetest.register_craft(recipe)`
5179     * Check recipe table syntax for different types below.
5180 * `minetest.clear_craft(recipe)`
5181     * Will erase existing craft based either on output item or on input recipe.
5182     * Specify either output or input only. If you specify both, input will be
5183       ignored. For input use the same recipe table syntax as for
5184       `minetest.register_craft(recipe)`. For output specify only the item,
5185       without a quantity.
5186     * Returns false if no erase candidate could be found, otherwise returns true.
5187     * **Warning**! The type field ("shaped", "cooking" or any other) will be
5188       ignored if the recipe contains output. Erasing is then done independently
5189       from the crafting method.
5190 * `minetest.register_chatcommand(cmd, chatcommand definition)`
5191 * `minetest.override_chatcommand(name, redefinition)`
5192     * Overrides fields of a chatcommand registered with `register_chatcommand`.
5193 * `minetest.unregister_chatcommand(name)`
5194     * Unregisters a chatcommands registered with `register_chatcommand`.
5195 * `minetest.register_privilege(name, definition)`
5196     * `definition` can be a description or a definition table (see [Privilege
5197       definition]).
5198     * If it is a description, the priv will be granted to singleplayer and admin
5199       by default.
5200     * To allow players with `basic_privs` to grant, see the `basic_privs`
5201       minetest.conf setting.
5202 * `minetest.register_authentication_handler(authentication handler definition)`
5203     * Registers an auth handler that overrides the builtin one.
5204     * This function can be called by a single mod once only.
5205
5206 Global callback registration functions
5207 --------------------------------------
5208
5209 Call these functions only at load time!
5210
5211 * `minetest.register_globalstep(function(dtime))`
5212     * Called every server step, usually interval of 0.1s
5213 * `minetest.register_on_mods_loaded(function())`
5214     * Called after mods have finished loading and before the media is cached or the
5215       aliases handled.
5216 * `minetest.register_on_shutdown(function())`
5217     * Called before server shutdown
5218     * **Warning**: If the server terminates abnormally (i.e. crashes), the
5219       registered callbacks **will likely not be run**. Data should be saved at
5220       semi-frequent intervals as well as on server shutdown.
5221 * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
5222     * Called when a node has been placed
5223     * If return `true` no item is taken from `itemstack`
5224     * `placer` may be any valid ObjectRef or nil.
5225     * **Not recommended**; use `on_construct` or `after_place_node` in node
5226       definition whenever possible.
5227 * `minetest.register_on_dignode(function(pos, oldnode, digger))`
5228     * Called when a node has been dug.
5229     * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
5230       definition whenever possible.
5231 * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
5232     * Called when a node is punched
5233 * `minetest.register_on_generated(function(minp, maxp, blockseed))`
5234     * Called after generating a piece of world. Modifying nodes inside the area
5235       is a bit faster than usual.
5236 * `minetest.register_on_newplayer(function(ObjectRef))`
5237     * Called when a new player enters the world for the first time
5238 * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
5239     * Called when a player is punched
5240     * Note: This callback is invoked even if the punched player is dead.
5241     * `player`: ObjectRef - Player that was punched
5242     * `hitter`: ObjectRef - Player that hit
5243     * `time_from_last_punch`: Meant for disallowing spamming of clicks
5244       (can be nil).
5245     * `tool_capabilities`: Capability table of used item (can be nil)
5246     * `dir`: Unit vector of direction of punch. Always defined. Points from
5247       the puncher to the punched.
5248     * `damage`: Number that represents the damage calculated by the engine
5249     * should return `true` to prevent the default damage mechanism
5250 * `minetest.register_on_rightclickplayer(function(player, clicker))`
5251     * Called when the 'place/use' key was used while pointing a player
5252       (not necessarily an actual rightclick)
5253     * `player`: ObjectRef - Player that is acted upon
5254     * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
5255 * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
5256     * Called when the player gets damaged or healed
5257     * `player`: ObjectRef of the player
5258     * `hp_change`: the amount of change. Negative when it is damage.
5259     * `reason`: a PlayerHPChangeReason table.
5260         * The `type` field will have one of the following values:
5261             * `set_hp`: A mod or the engine called `set_hp` without
5262                         giving a type - use this for custom damage types.
5263             * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
5264             * `fall`
5265             * `node_damage`: `damage_per_second` from a neighboring node.
5266                              `reason.node` will hold the node name or nil.
5267             * `drown`
5268             * `respawn`
5269         * Any of the above types may have additional fields from mods.
5270         * `reason.from` will be `mod` or `engine`.
5271     * `modifier`: when true, the function should return the actual `hp_change`.
5272        Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
5273        Modifiers can return true as a second argument to stop the execution of further functions.
5274        Non-modifiers receive the final HP change calculated by the modifiers.
5275 * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
5276     * Called when a player dies
5277     * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
5278 * `minetest.register_on_respawnplayer(function(ObjectRef))`
5279     * Called when player is to be respawned
5280     * Called _before_ repositioning of player occurs
5281     * return true in func to disable regular player placement
5282 * `minetest.register_on_prejoinplayer(function(name, ip))`
5283     * Called when a client connects to the server, prior to authentication
5284     * If it returns a string, the client is disconnected with that string as
5285       reason.
5286 * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
5287     * Called when a player joins the game
5288     * `last_login`: The timestamp of the previous login, or nil if player is new
5289 * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
5290     * Called when a player leaves the game
5291     * `timed_out`: True for timeout, false for other reasons.
5292 * `minetest.register_on_authplayer(function(name, ip, is_success))`
5293     * Called when a client attempts to log into an account.
5294     * `name`: The name of the account being authenticated.
5295     * `ip`: The IP address of the client
5296     * `is_success`: Whether the client was successfully authenticated
5297     * For newly registered accounts, `is_success` will always be true
5298 * `minetest.register_on_auth_fail(function(name, ip))`
5299     * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
5300 * `minetest.register_on_cheat(function(ObjectRef, cheat))`
5301     * Called when a player cheats
5302     * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
5303         * `moved_too_fast`
5304         * `interacted_too_far`
5305         * `interacted_with_self`
5306         * `interacted_while_dead`
5307         * `finished_unknown_dig`
5308         * `dug_unbreakable`
5309         * `dug_too_fast`
5310 * `minetest.register_on_chat_message(function(name, message))`
5311     * Called always when a player says something
5312     * Return `true` to mark the message as handled, which means that it will
5313       not be sent to other players.
5314 * `minetest.register_on_chatcommand(function(name, command, params))`
5315     * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
5316       is checked to see if the command exists, but after the input is parsed.
5317     * Return `true` to mark the command as handled, which means that the default
5318       handlers will be prevented.
5319 * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
5320     * Called when the server received input from `player` in a formspec with
5321       the given `formname`. Specifically, this is called on any of the
5322       following events:
5323           * a button was pressed,
5324           * Enter was pressed while the focus was on a text field
5325           * a checkbox was toggled,
5326           * something was selected in a dropdown list,
5327           * a different tab was selected,
5328           * selection was changed in a textlist or table,
5329           * an entry was double-clicked in a textlist or table,
5330           * a scrollbar was moved, or
5331           * the form was actively closed by the player.
5332     * Fields are sent for formspec elements which define a field. `fields`
5333       is a table containing each formspecs element value (as string), with
5334       the `name` parameter as index for each. The value depends on the
5335       formspec element type:
5336         * `animated_image`: Returns the index of the current frame.
5337         * `button` and variants: If pressed, contains the user-facing button
5338           text as value. If not pressed, is `nil`
5339         * `field`, `textarea` and variants: Text in the field
5340         * `dropdown`: Either the index or value, depending on the `index event`
5341           dropdown argument.
5342         * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
5343         * `checkbox`: `"true"` if checked, `"false"` if unchecked
5344         * `textlist`: See `minetest.explode_textlist_event`
5345         * `table`: See `minetest.explode_table_event`
5346         * `scrollbar`: See `minetest.explode_scrollbar_event`
5347         * Special case: `["quit"]="true"` is sent when the user actively
5348           closed the form by mouse click, keypress or through a button_exit[]
5349           element.
5350         * Special case: `["key_enter"]="true"` is sent when the user pressed
5351           the Enter key and the focus was either nowhere (causing the formspec
5352           to be closed) or on a button. If the focus was on a text field,
5353           additionally, the index `key_enter_field` contains the name of the
5354           text field. See also: `field_close_on_enter`.
5355     * Newest functions are called first
5356     * If function returns `true`, remaining functions are not called
5357 * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
5358     * Called when `player` crafts something
5359     * `itemstack` is the output
5360     * `old_craft_grid` contains the recipe (Note: the one in the inventory is
5361       cleared).
5362     * `craft_inv` is the inventory with the crafting grid
5363     * Return either an `ItemStack`, to replace the output, or `nil`, to not
5364       modify it.
5365 * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
5366     * The same as before, except that it is called before the player crafts, to
5367       make craft prediction, and it should not change anything.
5368 * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
5369     * Determines how much of a stack may be taken, put or moved to a
5370       player inventory.
5371     * `player` (type `ObjectRef`) is the player who modified the inventory
5372       `inventory` (type `InvRef`).
5373     * List of possible `action` (string) values and their
5374       `inventory_info` (table) contents:
5375         * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
5376         * `put`:  `{listname=string, index=number, stack=ItemStack}`
5377         * `take`: Same as `put`
5378     * Return a numeric value to limit the amount of items to be taken, put or
5379       moved. A value of `-1` for `take` will make the source stack infinite.
5380 * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
5381     * Called after a take, put or move event from/to/in a player inventory
5382     * Function arguments: see `minetest.register_allow_player_inventory_action`
5383     * Does not accept or handle any return value.
5384 * `minetest.register_on_protection_violation(function(pos, name))`
5385     * Called by `builtin` and mods when a player violates protection at a
5386       position (eg, digs a node or punches a protected entity).
5387     * The registered functions can be called using
5388       `minetest.record_protection_violation`.
5389     * The provided function should check that the position is protected by the
5390       mod calling this function before it prints a message, if it does, to
5391       allow for multiple protection mods.
5392 * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
5393     * Called when an item is eaten, by `minetest.item_eat`
5394     * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
5395 * `minetest.register_on_item_pickup(function(itemstack, picker, pointed_thing, time_from_last_punch,  ...))`
5396     * Called by `minetest.item_pickup` before an item is picked up.
5397     * Function is added to `minetest.registered_on_item_pickups`.
5398     * Oldest functions are called first.
5399     * Parameters are the same as in the `on_pickup` callback.
5400     * Return an itemstack to cancel the default item pick-up response (i.e.: adding
5401       the item into inventory).
5402 * `minetest.register_on_priv_grant(function(name, granter, priv))`
5403     * Called when `granter` grants the priv `priv` to `name`.
5404     * Note that the callback will be called twice if it's done by a player,
5405       once with granter being the player name, and again with granter being nil.
5406 * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
5407     * Called when `revoker` revokes the priv `priv` from `name`.
5408     * Note that the callback will be called twice if it's done by a player,
5409       once with revoker being the player name, and again with revoker being nil.
5410 * `minetest.register_can_bypass_userlimit(function(name, ip))`
5411     * Called when `name` user connects with `ip`.
5412     * Return `true` to by pass the player limit
5413 * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
5414     * Called when an incoming mod channel message is received
5415     * You should have joined some channels to receive events.
5416     * If message comes from a server mod, `sender` field is an empty string.
5417 * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
5418     * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
5419       engine's liquid transformation process.
5420     * `pos_list` is an array of all modified positions.
5421     * `node_list` is an array of the old node that was previously at the position
5422       with the corresponding index in pos_list.
5423 * `minetest.register_on_mapblocks_changed(function(modified_blocks, modified_block_count))`
5424     * Called soon after any nodes or node metadata have been modified. No
5425       modifications will be missed, but there may be false positives.
5426     * Will never be called more than once per server step.
5427     * `modified_blocks` is the set of modified mapblock position hashes. These
5428       are in the same format as those produced by `minetest.hash_node_position`,
5429       and can be converted to positions with `minetest.get_position_from_hash`.
5430       The set is a table where the keys are hashes and the values are `true`.
5431     * `modified_block_count` is the number of entries in the set.
5432     * Note: callbacks must be registered at mod load time.
5433
5434 Setting-related
5435 ---------------
5436
5437 * `minetest.settings`: Settings object containing all of the settings from the
5438   main config file (`minetest.conf`).
5439 * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
5440   parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
5441
5442 Authentication
5443 --------------
5444
5445 * `minetest.string_to_privs(str[, delim])`:
5446     * Converts string representation of privs into table form
5447     * `delim`: String separating the privs. Defaults to `","`.
5448     * Returns `{ priv1 = true, ... }`
5449 * `minetest.privs_to_string(privs[, delim])`:
5450     * Returns the string representation of `privs`
5451     * `delim`: String to delimit privs. Defaults to `","`.
5452 * `minetest.get_player_privs(name) -> {priv1=true,...}`
5453 * `minetest.check_player_privs(player_or_name, ...)`:
5454   returns `bool, missing_privs`
5455     * A quickhand for checking privileges.
5456     * `player_or_name`: Either a Player object or the name of a player.
5457     * `...` is either a list of strings, e.g. `"priva", "privb"` or
5458       a table, e.g. `{ priva = true, privb = true }`.
5459
5460 * `minetest.check_password_entry(name, entry, password)`
5461     * Returns true if the "password entry" for a player with name matches given
5462       password, false otherwise.
5463     * The "password entry" is the password representation generated by the
5464       engine as returned as part of a `get_auth()` call on the auth handler.
5465     * Only use this function for making it possible to log in via password from
5466       external protocols such as IRC, other uses are frowned upon.
5467 * `minetest.get_password_hash(name, raw_password)`
5468     * Convert a name-password pair to a password hash that Minetest can use.
5469     * The returned value alone is not a good basis for password checks based
5470       on comparing the password hash in the database with the password hash
5471       from the function, with an externally provided password, as the hash
5472       in the db might use the new SRP verifier format.
5473     * For this purpose, use `minetest.check_password_entry` instead.
5474 * `minetest.get_player_ip(name)`: returns an IP address string for the player
5475   `name`.
5476     * The player needs to be online for this to be successful.
5477
5478 * `minetest.get_auth_handler()`: Return the currently active auth handler
5479     * See the [Authentication handler definition]
5480     * Use this to e.g. get the authentication data for a player:
5481       `local auth_data = minetest.get_auth_handler().get_auth(playername)`
5482 * `minetest.notify_authentication_modified(name)`
5483     * Must be called by the authentication handler for privilege changes.
5484     * `name`: string; if omitted, all auth data should be considered modified
5485 * `minetest.set_player_password(name, password_hash)`: Set password hash of
5486   player `name`.
5487 * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
5488   `name`.
5489 * `minetest.auth_reload()`
5490     * See `reload()` in authentication handler definition
5491
5492 `minetest.set_player_password`, `minetest.set_player_privs`,
5493 `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
5494 handler.
5495
5496 Chat
5497 ----
5498
5499 * `minetest.chat_send_all(text)`
5500 * `minetest.chat_send_player(name, text)`
5501 * `minetest.format_chat_message(name, message)`
5502     * Used by the server to format a chat message, based on the setting `chat_message_format`.
5503       Refer to the documentation of the setting for a list of valid placeholders.
5504     * Takes player name and message, and returns the formatted string to be sent to players.
5505     * Can be redefined by mods if required, for things like colored names or messages.
5506     * **Only** the first occurrence of each placeholder will be replaced.
5507
5508 Environment access
5509 ------------------
5510
5511 * `minetest.set_node(pos, node)`
5512 * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
5513     * Set node at position `pos`
5514     * `node`: table `{name=string, param1=number, param2=number}`
5515     * If param1 or param2 is omitted, it's set to `0`.
5516     * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
5517 * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
5518     * Set node on all positions set in the first argument.
5519     * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
5520     * For node specification or position syntax see `minetest.set_node` call
5521     * Faster than set_node due to single call, but still considerably slower
5522       than Lua Voxel Manipulators (LVM) for large numbers of nodes.
5523       Unlike LVMs, this will call node callbacks. It also allows setting nodes
5524       in spread out positions which would cause LVMs to waste memory.
5525       For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
5526       times faster.
5527 * `minetest.swap_node(pos, node)`
5528     * Set node at position, but don't remove metadata
5529 * `minetest.remove_node(pos)`
5530     * By default it does the same as `minetest.set_node(pos, {name="air"})`
5531 * `minetest.get_node(pos)`
5532     * Returns the node at the given position as table in the format
5533       `{name="node_name", param1=0, param2=0}`,
5534       returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
5535 * `minetest.get_node_or_nil(pos)`
5536     * Same as `get_node` but returns `nil` for unloaded areas.
5537 * `minetest.get_node_light(pos, timeofday)`
5538     * Gets the light value at the given position. Note that the light value
5539       "inside" the node at the given position is returned, so you usually want
5540       to get the light value of a neighbor.
5541     * `pos`: The position where to measure the light.
5542     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5543     * Returns a number between `0` and `15` or `nil`
5544     * `nil` is returned e.g. when the map isn't loaded at `pos`
5545 * `minetest.get_natural_light(pos[, timeofday])`
5546     * Figures out the sunlight (or moonlight) value at pos at the given time of
5547       day.
5548     * `pos`: The position of the node
5549     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5550     * Returns a number between `0` and `15` or `nil`
5551     * This function tests 203 nodes in the worst case, which happens very
5552       unlikely
5553 * `minetest.get_artificial_light(param1)`
5554     * Calculates the artificial light (light from e.g. torches) value from the
5555       `param1` value.
5556     * `param1`: The param1 value of a `paramtype = "light"` node.
5557     * Returns a number between `0` and `15`
5558     * Currently it's the same as `math.floor(param1 / 16)`, except that it
5559       ensures compatibility.
5560 * `minetest.place_node(pos, node)`
5561     * Place node with the same effects that a player would cause
5562 * `minetest.dig_node(pos)`
5563     * Dig node with the same effects that a player would cause
5564     * Returns `true` if successful, `false` on failure (e.g. protected location)
5565 * `minetest.punch_node(pos)`
5566     * Punch node with the same effects that a player would cause
5567 * `minetest.spawn_falling_node(pos)`
5568     * Change node into falling node
5569     * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
5570
5571 * `minetest.find_nodes_with_meta(pos1, pos2)`
5572     * Get a table of positions of nodes that have metadata within a region
5573       {pos1, pos2}.
5574 * `minetest.get_meta(pos)`
5575     * Get a `NodeMetaRef` at that position
5576 * `minetest.get_node_timer(pos)`
5577     * Get `NodeTimerRef`
5578
5579 * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
5580   position.
5581     * Returns `ObjectRef`, or `nil` if failed
5582 * `minetest.add_item(pos, item)`: Spawn item
5583     * Returns `ObjectRef`, or `nil` if failed
5584 * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
5585 * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
5586   ObjectRefs.
5587     * `radius`: using a Euclidean metric
5588 * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
5589   ObjectRefs.
5590      * `pos1` and `pos2` are the min and max positions of the area to search.
5591 * `minetest.set_timeofday(val)`
5592     * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
5593 * `minetest.get_timeofday()`
5594 * `minetest.get_gametime()`: returns the time, in seconds, since the world was
5595   created.
5596 * `minetest.get_day_count()`: returns number days elapsed since world was
5597   created.
5598     * accounts for time changes.
5599 * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
5600   pos or `nil`.
5601     * `radius`: using a maximum metric
5602     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5603     * `search_center` is an optional boolean (default: `false`)
5604       If true `pos` is also checked for the nodes
5605 * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
5606     * `pos1` and `pos2` are the min and max positions of the area to search.
5607     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5608     * If `grouped` is true the return value is a table indexed by node name
5609       which contains lists of positions.
5610     * If `grouped` is false or absent the return values are as follows:
5611       first value: Table with all node positions
5612       second value: Table with the count of each node with the node name
5613       as index
5614     * Area volume is limited to 4,096,000 nodes
5615 * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
5616   list of positions.
5617     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5618     * Return value: Table with all node positions with a node air above
5619     * Area volume is limited to 4,096,000 nodes
5620 * `minetest.get_perlin(noiseparams)`
5621     * Return world-specific perlin noise.
5622     * The actual seed used is the noiseparams seed plus the world seed.
5623 * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
5624     * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
5625     * Return world-specific perlin noise.
5626 * `minetest.get_voxel_manip([pos1, pos2])`
5627     * Return voxel manipulator object.
5628     * Loads the manipulator from the map if positions are passed.
5629 * `minetest.set_gen_notify(flags, {deco_ids})`
5630     * Set the types of on-generate notifications that should be collected.
5631     * `flags` is a flag field with the available flags:
5632         * dungeon
5633         * temple
5634         * cave_begin
5635         * cave_end
5636         * large_cave_begin
5637         * large_cave_end
5638         * decoration
5639     * The second parameter is a list of IDs of decorations which notification
5640       is requested for.
5641 * `minetest.get_gen_notify()`
5642     * Returns a flagstring and a table with the `deco_id`s.
5643 * `minetest.get_decoration_id(decoration_name)`
5644     * Returns the decoration ID number for the provided decoration name string,
5645       or `nil` on failure.
5646 * `minetest.get_mapgen_object(objectname)`
5647     * Return requested mapgen object if available (see [Mapgen objects])
5648 * `minetest.get_heat(pos)`
5649     * Returns the heat at the position, or `nil` on failure.
5650 * `minetest.get_humidity(pos)`
5651     * Returns the humidity at the position, or `nil` on failure.
5652 * `minetest.get_biome_data(pos)`
5653     * Returns a table containing:
5654         * `biome` the biome id of the biome at that position
5655         * `heat` the heat at the position
5656         * `humidity` the humidity at the position
5657     * Or returns `nil` on failure.
5658 * `minetest.get_biome_id(biome_name)`
5659     * Returns the biome id, as used in the biomemap Mapgen object and returned
5660       by `minetest.get_biome_data(pos)`, for a given biome_name string.
5661 * `minetest.get_biome_name(biome_id)`
5662     * Returns the biome name string for the provided biome id, or `nil` on
5663       failure.
5664     * If no biomes have been registered, such as in mgv6, returns `default`.
5665 * `minetest.get_mapgen_params()`
5666     * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
5667     * Returns a table containing:
5668         * `mgname`
5669         * `seed`
5670         * `chunksize`
5671         * `water_level`
5672         * `flags`
5673 * `minetest.set_mapgen_params(MapgenParams)`
5674     * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
5675       instead.
5676     * Set map generation parameters.
5677     * Function cannot be called after the registration period.
5678     * Takes a table as an argument with the fields:
5679         * `mgname`
5680         * `seed`
5681         * `chunksize`
5682         * `water_level`
5683         * `flags`
5684     * Leave field unset to leave that parameter unchanged.
5685     * `flags` contains a comma-delimited string of flags to set, or if the
5686       prefix `"no"` is attached, clears instead.
5687     * `flags` is in the same format and has the same options as `mg_flags` in
5688       `minetest.conf`.
5689 * `minetest.get_mapgen_edges([mapgen_limit[, chunksize]])`
5690     * Returns the minimum and maximum possible generated node positions
5691       in that order.
5692     * `mapgen_limit` is an optional number. If it is absent, its value is that
5693       of the *active* mapgen setting `"mapgen_limit"`.
5694     * `chunksize` is an optional number. If it is absent, its value is that
5695       of the *active* mapgen setting `"chunksize"`.
5696 * `minetest.get_mapgen_setting(name)`
5697     * Gets the *active* mapgen setting (or nil if none exists) in string
5698       format with the following order of precedence:
5699         1) Settings loaded from map_meta.txt or overrides set during mod
5700            execution.
5701         2) Settings set by mods without a metafile override
5702         3) Settings explicitly set in the user config file, minetest.conf
5703         4) Settings set as the user config default
5704 * `minetest.get_mapgen_setting_noiseparams(name)`
5705     * Same as above, but returns the value as a NoiseParams table if the
5706       setting `name` exists and is a valid NoiseParams.
5707 * `minetest.set_mapgen_setting(name, value, [override_meta])`
5708     * Sets a mapgen param to `value`, and will take effect if the corresponding
5709       mapgen setting is not already present in map_meta.txt.
5710     * `override_meta` is an optional boolean (default: `false`). If this is set
5711       to true, the setting will become the active setting regardless of the map
5712       metafile contents.
5713     * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
5714 * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
5715     * Same as above, except value is a NoiseParams table.
5716 * `minetest.set_noiseparams(name, noiseparams, set_default)`
5717     * Sets the noiseparams setting of `name` to the noiseparams table specified
5718       in `noiseparams`.
5719     * `set_default` is an optional boolean (default: `true`) that specifies
5720       whether the setting should be applied to the default config or current
5721       active config.
5722 * `minetest.get_noiseparams(name)`
5723     * Returns a table of the noiseparams for name.
5724 * `minetest.generate_ores(vm, pos1, pos2)`
5725     * Generate all registered ores within the VoxelManip `vm` and in the area
5726       from `pos1` to `pos2`.
5727     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5728 * `minetest.generate_decorations(vm, pos1, pos2)`
5729     * Generate all registered decorations within the VoxelManip `vm` and in the
5730       area from `pos1` to `pos2`.
5731     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5732 * `minetest.clear_objects([options])`
5733     * Clear all objects in the environment
5734     * Takes an optional table as an argument with the field `mode`.
5735         * mode = `"full"`: Load and go through every mapblock, clearing
5736                             objects (default).
5737         * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
5738                             clear objects in unloaded mapblocks only when the
5739                             mapblocks are next activated.
5740 * `minetest.load_area(pos1[, pos2])`
5741     * Load the mapblocks containing the area from `pos1` to `pos2`.
5742       `pos2` defaults to `pos1` if not specified.
5743     * This function does not trigger map generation.
5744 * `minetest.emerge_area(pos1, pos2, [callback], [param])`
5745     * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
5746       asynchronously fetched from memory, loaded from disk, or if inexistent,
5747       generates them.
5748     * If `callback` is a valid Lua function, this will be called for each block
5749       emerged.
5750     * The function signature of callback is:
5751       `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
5752         * `blockpos` is the *block* coordinates of the block that had been
5753           emerged.
5754         * `action` could be one of the following constant values:
5755             * `minetest.EMERGE_CANCELLED`
5756             * `minetest.EMERGE_ERRORED`
5757             * `minetest.EMERGE_FROM_MEMORY`
5758             * `minetest.EMERGE_FROM_DISK`
5759             * `minetest.EMERGE_GENERATED`
5760         * `calls_remaining` is the number of callbacks to be expected after
5761           this one.
5762         * `param` is the user-defined parameter passed to emerge_area (or
5763           nil if the parameter was absent).
5764 * `minetest.delete_area(pos1, pos2)`
5765     * delete all mapblocks in the area from pos1 to pos2, inclusive
5766 * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
5767     * Checks if there is anything other than air between pos1 and pos2.
5768     * Returns false if something is blocking the sight.
5769     * Returns the position of the blocking node when `false`
5770     * `pos1`: First position
5771     * `pos2`: Second position
5772 * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
5773     * Creates a `Raycast` object.
5774     * `pos1`: start of the ray
5775     * `pos2`: end of the ray
5776     * `objects`: if false, only nodes will be returned. Default is `true`.
5777     * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
5778                  returned. Default is `false`.
5779 * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
5780     * returns table containing path that can be walked on
5781     * returns a table of 3D points representing a path from `pos1` to `pos2` or
5782       `nil` on failure.
5783     * Reasons for failure:
5784         * No path exists at all
5785         * No path exists within `searchdistance` (see below)
5786         * Start or end pos is buried in land
5787     * `pos1`: start position
5788     * `pos2`: end position
5789     * `searchdistance`: maximum distance from the search positions to search in.
5790       In detail: Path must be completely inside a cuboid. The minimum
5791       `searchdistance` of 1 will confine search between `pos1` and `pos2`.
5792       Larger values will increase the size of this cuboid in all directions
5793     * `max_jump`: maximum height difference to consider walkable
5794     * `max_drop`: maximum height difference to consider droppable
5795     * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
5796       Difference between `"A*"` and `"A*_noprefetch"` is that
5797       `"A*"` will pre-calculate the cost-data, the other will calculate it
5798       on-the-fly
5799 * `minetest.spawn_tree (pos, {treedef})`
5800     * spawns L-system tree at given `pos` with definition in `treedef` table
5801 * `minetest.transforming_liquid_add(pos)`
5802     * add node to liquid flow update queue
5803 * `minetest.get_node_max_level(pos)`
5804     * get max available level for leveled node
5805 * `minetest.get_node_level(pos)`
5806     * get level of leveled node (water, snow)
5807 * `minetest.set_node_level(pos, level)`
5808     * set level of leveled node, default `level` equals `1`
5809     * if `totallevel > maxlevel`, returns rest (`total-max`).
5810 * `minetest.add_node_level(pos, level)`
5811     * increase level of leveled node by level, default `level` equals `1`
5812     * if `totallevel > maxlevel`, returns rest (`total-max`)
5813     * `level` must be between -127 and 127
5814 * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
5815     * resets the light in a cuboid-shaped part of
5816       the map and removes lighting bugs.
5817     * Loads the area if it is not loaded.
5818     * `pos1` is the corner of the cuboid with the least coordinates
5819       (in node coordinates), inclusive.
5820     * `pos2` is the opposite corner of the cuboid, inclusive.
5821     * The actual updated cuboid might be larger than the specified one,
5822       because only whole map blocks can be updated.
5823       The actual updated area consists of those map blocks that intersect
5824       with the given cuboid.
5825     * However, the neighborhood of the updated area might change
5826       as well, as light can spread out of the cuboid, also light
5827       might be removed.
5828     * returns `false` if the area is not fully generated,
5829       `true` otherwise
5830 * `minetest.check_single_for_falling(pos)`
5831     * causes an unsupported `group:falling_node` node to fall and causes an
5832       unattached `group:attached_node` node to fall.
5833     * does not spread these updates to neighbors.
5834 * `minetest.check_for_falling(pos)`
5835     * causes an unsupported `group:falling_node` node to fall and causes an
5836       unattached `group:attached_node` node to fall.
5837     * spread these updates to neighbors and can cause a cascade
5838       of nodes to fall.
5839 * `minetest.get_spawn_level(x, z)`
5840     * Returns a player spawn y co-ordinate for the provided (x, z)
5841       co-ordinates, or `nil` for an unsuitable spawn point.
5842     * For most mapgens a 'suitable spawn point' is one with y between
5843       `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
5844       so `nil` will be returned for many (x, z) co-ordinates.
5845     * The spawn level returned is for a player spawn in unmodified terrain.
5846     * The spawn level is intentionally above terrain level to cope with
5847       full-node biome 'dust' nodes.
5848
5849 Mod channels
5850 ------------
5851
5852 You can find mod channels communication scheme in `doc/mod_channels.png`.
5853
5854 * `minetest.mod_channel_join(channel_name)`
5855     * Server joins channel `channel_name`, and creates it if necessary. You
5856       should listen for incoming messages with
5857       `minetest.register_on_modchannel_message`
5858
5859 Inventory
5860 ---------
5861
5862 `minetest.get_inventory(location)`: returns an `InvRef`
5863
5864 * `location` = e.g.
5865     * `{type="player", name="celeron55"}`
5866     * `{type="node", pos={x=, y=, z=}}`
5867     * `{type="detached", name="creative"}`
5868 * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
5869   an `InvRef`.
5870     * `callbacks`: See [Detached inventory callbacks]
5871     * `player_name`: Make detached inventory available to one player
5872       exclusively, by default they will be sent to every player (even if not
5873       used).
5874       Note that this parameter is mostly just a workaround and will be removed
5875       in future releases.
5876     * Creates a detached inventory. If it already exists, it is cleared.
5877 * `minetest.remove_detached_inventory(name)`
5878     * Returns a `boolean` indicating whether the removal succeeded.
5879 * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
5880   returns leftover ItemStack or nil to indicate no inventory change
5881     * See `minetest.item_eat` and `minetest.register_on_item_eat`
5882
5883 Formspec
5884 --------
5885
5886 * `minetest.show_formspec(playername, formname, formspec)`
5887     * `playername`: name of player to show formspec
5888     * `formname`: name passed to `on_player_receive_fields` callbacks.
5889       It should follow the `"modname:<whatever>"` naming convention
5890     * `formspec`: formspec to display
5891 * `minetest.close_formspec(playername, formname)`
5892     * `playername`: name of player to close formspec
5893     * `formname`: has to exactly match the one given in `show_formspec`, or the
5894       formspec will not close.
5895     * calling `show_formspec(playername, formname, "")` is equal to this
5896       expression.
5897     * to close a formspec regardless of the formname, call
5898       `minetest.close_formspec(playername, "")`.
5899       **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
5900 * `minetest.formspec_escape(string)`: returns a string
5901     * escapes the characters "[", "]", "\", "," and ";", which cannot be used
5902       in formspecs.
5903 * `minetest.explode_table_event(string)`: returns a table
5904     * returns e.g. `{type="CHG", row=1, column=2}`
5905     * `type` is one of:
5906         * `"INV"`: no row selected
5907         * `"CHG"`: selected
5908         * `"DCL"`: double-click
5909 * `minetest.explode_textlist_event(string)`: returns a table
5910     * returns e.g. `{type="CHG", index=1}`
5911     * `type` is one of:
5912         * `"INV"`: no row selected
5913         * `"CHG"`: selected
5914         * `"DCL"`: double-click
5915 * `minetest.explode_scrollbar_event(string)`: returns a table
5916     * returns e.g. `{type="CHG", value=500}`
5917     * `type` is one of:
5918         * `"INV"`: something failed
5919         * `"CHG"`: has been changed
5920         * `"VAL"`: not changed
5921
5922 Item handling
5923 -------------
5924
5925 * `minetest.inventorycube(img1, img2, img3)`
5926     * Returns a string for making an image of a cube (useful as an item image)
5927 * `minetest.get_pointed_thing_position(pointed_thing, above)`
5928     * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
5929       does not refer to a node or entity.
5930     * If the optional `above` parameter is true and the `pointed_thing` refers
5931       to a node, then it will return the `above` position of the `pointed_thing`.
5932 * `minetest.dir_to_facedir(dir, is6d)`
5933     * Convert a vector to a facedir value, used in `param2` for
5934       `paramtype2="facedir"`.
5935     * passing something non-`nil`/`false` for the optional second parameter
5936       causes it to take the y component into account.
5937 * `minetest.facedir_to_dir(facedir)`
5938     * Convert a facedir back into a vector aimed directly out the "back" of a
5939       node.
5940 * `minetest.dir_to_fourdir(dir)`
5941     * Convert a vector to a 4dir value, used in `param2` for
5942       `paramtype2="4dir"`.
5943 * `minetest.fourdir_to_dir(fourdir)`
5944     * Convert a 4dir back into a vector aimed directly out the "back" of a
5945       node.
5946 * `minetest.dir_to_wallmounted(dir)`
5947     * Convert a vector to a wallmounted value, used for
5948       `paramtype2="wallmounted"`.
5949 * `minetest.wallmounted_to_dir(wallmounted)`
5950     * Convert a wallmounted value back into a vector aimed directly out the
5951       "back" of a node.
5952 * `minetest.dir_to_yaw(dir)`
5953     * Convert a vector into a yaw (angle)
5954 * `minetest.yaw_to_dir(yaw)`
5955     * Convert yaw (angle) to a vector
5956 * `minetest.is_colored_paramtype(ptype)`
5957     * Returns a boolean. Returns `true` if the given `paramtype2` contains
5958       color information (`color`, `colorwallmounted`, `colorfacedir`, etc.).
5959 * `minetest.strip_param2_color(param2, paramtype2)`
5960     * Removes everything but the color information from the
5961       given `param2` value.
5962     * Returns `nil` if the given `paramtype2` does not contain color
5963       information.
5964 * `minetest.get_node_drops(node, toolname)`
5965     * Returns list of itemstrings that are dropped by `node` when dug
5966       with the item `toolname` (not limited to tools).
5967     * `node`: node as table or node name
5968     * `toolname`: name of the item used to dig (can be `nil`)
5969 * `minetest.get_craft_result(input)`: returns `output, decremented_input`
5970     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5971     * `input.width` = for example `3`
5972     * `input.items` = for example
5973       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5974     * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
5975     * `output.time` = a number, if unsuccessful: `0`
5976     * `output.replacements` = List of replacement `ItemStack`s that couldn't be
5977       placed in `decremented_input.items`. Replacements can be placed in
5978       `decremented_input` if the stack of the replaced item has a count of 1.
5979     * `decremented_input` = like `input`
5980 * `minetest.get_craft_recipe(output)`: returns input
5981     * returns last registered recipe for output item (node)
5982     * `output` is a node or item type such as `"default:torch"`
5983     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5984     * `input.width` = for example `3`
5985     * `input.items` = for example
5986       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5987         * `input.items` = `nil` if no recipe found
5988 * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
5989     * returns indexed table with all registered recipes for query item (node)
5990       or `nil` if no recipe was found.
5991     * recipe entry table:
5992         * `method`: 'normal' or 'cooking' or 'fuel'
5993         * `width`: 0-3, 0 means shapeless recipe
5994         * `items`: indexed [1-9] table with recipe items
5995         * `output`: string with item name and quantity
5996     * Example result for `"default:gold_ingot"` with two recipes:
5997
5998           {
5999               {
6000                   method = "cooking", width = 3,
6001                   output = "default:gold_ingot", items = {"default:gold_lump"}
6002               },
6003               {
6004                   method = "normal", width = 1,
6005                   output = "default:gold_ingot 9", items = {"default:goldblock"}
6006               }
6007           }
6008
6009 * `minetest.handle_node_drops(pos, drops, digger)`
6010     * `drops`: list of itemstrings
6011     * Handles drops from nodes after digging: Default action is to put them
6012       into digger's inventory.
6013     * Can be overridden to get different functionality (e.g. dropping items on
6014       ground)
6015 * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
6016   string.
6017     * Creates an item string which contains palette index information
6018       for hardware colorization. You can use the returned string
6019       as an output in a craft recipe.
6020     * `item`: the item stack which becomes colored. Can be in string,
6021       table and native form.
6022     * `palette_index`: this index is added to the item stack
6023 * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
6024     * Creates an item string which contains static color information
6025       for hardware colorization. Use this method if you wish to colorize
6026       an item that does not own a palette. You can use the returned string
6027       as an output in a craft recipe.
6028     * `item`: the item stack which becomes colored. Can be in string,
6029       table and native form.
6030     * `colorstring`: the new color of the item stack
6031
6032 Rollback
6033 --------
6034
6035 * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
6036   returns `{{actor, pos, time, oldnode, newnode}, ...}`
6037     * Find who has done something to a node, or near a node
6038     * `actor`: `"player:<name>"`, also `"liquid"`.
6039 * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
6040   `boolean, log_messages`.
6041     * Revert latest actions of someone
6042     * `actor`: `"player:<name>"`, also `"liquid"`.
6043
6044 Defaults for the `on_place` and `on_drop` item definition functions
6045 -------------------------------------------------------------------
6046
6047 * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
6048     * Place item as a node
6049     * `param2` overrides `facedir` and wallmounted `param2`
6050     * `prevent_after_place`: if set to `true`, `after_place_node` is not called
6051       for the newly placed node to prevent a callback and placement loop
6052     * returns `itemstack, position`
6053       * `position`: the location the node was placed to. `nil` if nothing was placed.
6054 * `minetest.item_place_object(itemstack, placer, pointed_thing)`
6055     * Place item as-is
6056     * returns the leftover itemstack
6057     * **Note**: This function is deprecated and will never be called.
6058 * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
6059     * Wrapper that calls `minetest.item_place_node` if appropriate
6060     * Calls `on_rightclick` of `pointed_thing.under` if defined instead
6061     * **Note**: is not called when wielded item overrides `on_place`
6062     * `param2` overrides facedir and wallmounted `param2`
6063     * returns `itemstack, position`
6064       * `position`: the location the node was placed to. `nil` if nothing was placed.
6065 * `minetest.item_pickup(itemstack, picker, pointed_thing, time_from_last_punch, ...)`
6066     * Runs callbacks registered by `minetest.register_on_item_pickup` and adds
6067       the item to the picker's `"main"` inventory list.
6068     * Parameters are the same as in `on_pickup`.
6069     * Returns the leftover itemstack.
6070 * `minetest.item_drop(itemstack, dropper, pos)`
6071     * Drop the item
6072     * returns the leftover itemstack
6073 * `minetest.item_eat(hp_change[, replace_with_item])`
6074     * Returns `function(itemstack, user, pointed_thing)` as a
6075       function wrapper for `minetest.do_item_eat`.
6076     * `replace_with_item` is the itemstring which is added to the inventory.
6077       If the player is eating a stack, then replace_with_item goes to a
6078       different spot.
6079
6080 Defaults for the `on_punch` and `on_dig` node definition callbacks
6081 ------------------------------------------------------------------
6082
6083 * `minetest.node_punch(pos, node, puncher, pointed_thing)`
6084     * Calls functions registered by `minetest.register_on_punchnode()`
6085 * `minetest.node_dig(pos, node, digger)`
6086     * Checks if node can be dug, puts item into inventory, removes node
6087     * Calls functions registered by `minetest.registered_on_dignodes()`
6088
6089 Sounds
6090 ------
6091
6092 * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
6093     * `spec` is a `SimpleSoundSpec`
6094     * `parameters` is a sound parameter table
6095     * `ephemeral` is a boolean (default: false)
6096       Ephemeral sounds will not return a handle and can't be stopped or faded.
6097       It is recommend to use this for short sounds that happen in response to
6098       player actions (e.g. door closing).
6099 * `minetest.sound_stop(handle)`
6100     * `handle` is a handle returned by `minetest.sound_play`
6101 * `minetest.sound_fade(handle, step, gain)`
6102     * `handle` is a handle returned by `minetest.sound_play`
6103     * `step` determines how fast a sound will fade.
6104       The gain will change by this much per second,
6105       until it reaches the target gain.
6106       Note: Older versions used a signed step. This is deprecated, but old
6107       code will still work. (the client uses abs(step) to correct it)
6108     * `gain` the target gain for the fade.
6109       Fading to zero will delete the sound.
6110
6111 Timing
6112 ------
6113
6114 * `minetest.after(time, func, ...)`: returns job table to use as below.
6115     * Call the function `func` after `time` seconds, may be fractional
6116     * Optional: Variable number of arguments that are passed to `func`
6117
6118 * `job:cancel()`
6119     * Cancels the job function from being called
6120
6121 Async environment
6122 -----------------
6123
6124 The engine allows you to submit jobs to be ran in an isolated environment
6125 concurrently with normal server operation.
6126 A job consists of a function to be ran in the async environment, any amount of
6127 arguments (will be serialized) and a callback that will be called with the return
6128 value of the job function once it is finished.
6129
6130 The async environment does *not* have access to the map, entities, players or any
6131 globals defined in the 'usual' environment. Consequently, functions like
6132 `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
6133
6134 Arguments and return values passed through this can contain certain userdata
6135 objects that will be seamlessly copied (not shared) to the async environment.
6136 This allows you easy interoperability for delegating work to jobs.
6137
6138 * `minetest.handle_async(func, callback, ...)`:
6139     * Queue the function `func` to be ran in an async environment.
6140       Note that there are multiple persistent workers and any of them may
6141       end up running a given job. The engine will scale the amount of
6142       worker threads automatically.
6143     * When `func` returns the callback is called (in the normal environment)
6144       with all of the return values as arguments.
6145     * Optional: Variable number of arguments that are passed to `func`
6146 * `minetest.register_async_dofile(path)`:
6147     * Register a path to a Lua file to be imported when an async environment
6148       is initialized. You can use this to preload code which you can then call
6149       later using `minetest.handle_async()`.
6150
6151 ### List of APIs available in an async environment
6152
6153 Classes:
6154 * `ItemStack`
6155 * `PerlinNoise`
6156 * `PerlinNoiseMap`
6157 * `PseudoRandom`
6158 * `PcgRandom`
6159 * `SecureRandom`
6160 * `VoxelArea`
6161 * `VoxelManip`
6162     * only if transferred into environment; can't read/write to map
6163 * `Settings`
6164
6165 Class instances that can be transferred between environments:
6166 * `ItemStack`
6167 * `PerlinNoise`
6168 * `PerlinNoiseMap`
6169 * `VoxelManip`
6170
6171 Functions:
6172 * Standalone helpers such as logging, filesystem, encoding,
6173   hashing or compression APIs
6174 * `minetest.request_insecure_environment` (same restrictions apply)
6175
6176 Variables:
6177 * `minetest.settings`
6178 * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
6179   `registered_craftitems` and `registered_aliases`
6180     * with all functions and userdata values replaced by `true`, calling any
6181       callbacks here is obviously not possible
6182
6183 Server
6184 ------
6185
6186 * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
6187   server shutdown. Will display `message` to clients.
6188     * `reconnect` == true displays a reconnect button
6189     * `delay` adds an optional delay (in seconds) before shutdown.
6190       Negative delay cancels the current active shutdown.
6191       Zero delay triggers an immediate shutdown.
6192 * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
6193 * `minetest.get_server_status(name, joined)`
6194     * Returns the server status string when a player joins or when the command
6195       `/status` is called. Returns `nil` or an empty string when the message is
6196       disabled.
6197     * `joined`: Boolean value, indicates whether the function was called when
6198       a player joined.
6199     * This function may be overwritten by mods to customize the status message.
6200 * `minetest.get_server_uptime()`: returns the server uptime in seconds
6201 * `minetest.get_server_max_lag()`: returns the current maximum lag
6202   of the server in seconds or nil if server is not fully loaded yet
6203 * `minetest.remove_player(name)`: remove player from database (if they are not
6204   connected).
6205     * As auth data is not removed, minetest.player_exists will continue to
6206       return true. Call the below method as well if you want to remove auth
6207       data too.
6208     * Returns a code (0: successful, 1: no such player, 2: player is connected)
6209 * `minetest.remove_player_auth(name)`: remove player authentication data
6210     * Returns boolean indicating success (false if player nonexistent)
6211 * `minetest.dynamic_add_media(options, callback)`
6212     * `options`: table containing the following parameters
6213         * `filepath`: path to a media file on the filesystem
6214         * `to_player`: name of the player the media should be sent to instead of
6215                        all players (optional)
6216         * `ephemeral`: boolean that marks the media as ephemeral,
6217                        it will not be cached on the client (optional, default false)
6218     * `callback`: function with arguments `name`, which is a player name
6219     * Pushes the specified media file to client(s). (details below)
6220       The file must be a supported image, sound or model format.
6221       Dynamically added media is not persisted between server restarts.
6222     * Returns false on error, true if the request was accepted
6223     * The given callback will be called for every player as soon as the
6224       media is available on the client.
6225     * Details/Notes:
6226       * If `ephemeral`=false and `to_player` is unset the file is added to the media
6227         sent to clients on startup, this means the media will appear even on
6228         old clients if they rejoin the server.
6229       * If `ephemeral`=false the file must not be modified, deleted, moved or
6230         renamed after calling this function.
6231       * Regardless of any use of `ephemeral`, adding media files with the same
6232         name twice is not possible/guaranteed to work. An exception to this is the
6233         use of `to_player` to send the same, already existent file to multiple
6234         chosen players.
6235     * Clients will attempt to fetch files added this way via remote media,
6236       this can make transfer of bigger files painless (if set up). Nevertheless
6237       it is advised not to use dynamic media for big media files.
6238
6239 Bans
6240 ----
6241
6242 * `minetest.get_ban_list()`: returns a list of all bans formatted as string
6243 * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
6244   IP address or name formatted as string
6245 * `minetest.ban_player(name)`: ban the IP of a currently connected player
6246     * Returns boolean indicating success
6247 * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
6248   IP address or name
6249 * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
6250   reason.
6251     * Returns boolean indicating success (false if player nonexistent)
6252 * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
6253   optional reason, this will not prefix with 'Kicked: ' like kick_player.
6254   If no reason is given, it will default to 'Disconnected.'
6255     * Returns boolean indicating success (false if player nonexistent)
6256
6257 Particles
6258 ---------
6259
6260 * `minetest.add_particle(particle definition)`
6261     * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
6262       expirationtime, size, collisiondetection, texture, playername)`
6263
6264 * `minetest.add_particlespawner(particlespawner definition)`
6265     * Add a `ParticleSpawner`, an object that spawns an amount of particles
6266       over `time` seconds.
6267     * Returns an `id`, and -1 if adding didn't succeed
6268     * Deprecated: `minetest.add_particlespawner(amount, time,
6269       minpos, maxpos,
6270       minvel, maxvel,
6271       minacc, maxacc,
6272       minexptime, maxexptime,
6273       minsize, maxsize,
6274       collisiondetection, texture, playername)`
6275
6276 * `minetest.delete_particlespawner(id, player)`
6277     * Delete `ParticleSpawner` with `id` (return value from
6278       `minetest.add_particlespawner`).
6279     * If playername is specified, only deletes on the player's client,
6280       otherwise on all clients.
6281
6282 Schematics
6283 ----------
6284
6285 * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
6286     * Create a schematic from the volume of map specified by the box formed by
6287       p1 and p2.
6288     * Apply the specified probability and per-node force-place to the specified
6289       nodes according to the `probability_list`.
6290         * `probability_list` is an array of tables containing two fields, `pos`
6291           and `prob`.
6292             * `pos` is the 3D vector specifying the absolute coordinates of the
6293               node being modified,
6294             * `prob` is an integer value from `0` to `255` that encodes
6295               probability and per-node force-place. Probability has levels
6296               0-127, then 128 may be added to encode per-node force-place.
6297               For probability stated as 0-255, divide by 2 and round down to
6298               get values 0-127, then add 128 to apply per-node force-place.
6299             * If there are two or more entries with the same pos value, the
6300               last entry is used.
6301             * If `pos` is not inside the box formed by `p1` and `p2`, it is
6302               ignored.
6303             * If `probability_list` equals `nil`, no probabilities are applied.
6304     * Apply the specified probability to the specified horizontal slices
6305       according to the `slice_prob_list`.
6306         * `slice_prob_list` is an array of tables containing two fields, `ypos`
6307           and `prob`.
6308             * `ypos` indicates the y position of the slice with a probability
6309               applied, the lowest slice being `ypos = 0`.
6310             * If slice probability list equals `nil`, no slice probabilities
6311               are applied.
6312     * Saves schematic in the Minetest Schematic format to filename.
6313
6314 * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
6315     * Place the schematic specified by schematic (see [Schematic specifier]) at
6316       `pos`.
6317     * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
6318     * If the `rotation` parameter is omitted, the schematic is not rotated.
6319     * `replacements` = `{["old_name"] = "convert_to", ...}`
6320     * `force_placement` is a boolean indicating whether nodes other than `air`
6321       and `ignore` are replaced by the schematic.
6322     * Returns nil if the schematic could not be loaded.
6323     * **Warning**: Once you have loaded a schematic from a file, it will be
6324       cached. Future calls will always use the cached version and the
6325       replacement list defined for it, regardless of whether the file or the
6326       replacement list parameter have changed. The only way to load the file
6327       anew is to restart the server.
6328     * `flags` is a flag field with the available flags:
6329         * place_center_x
6330         * place_center_y
6331         * place_center_z
6332
6333 * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
6334     * This function is analogous to minetest.place_schematic, but places a
6335       schematic onto the specified VoxelManip object `vmanip` instead of the
6336       map.
6337     * Returns false if any part of the schematic was cut-off due to the
6338       VoxelManip not containing the full area required, and true if the whole
6339       schematic was able to fit.
6340     * Returns nil if the schematic could not be loaded.
6341     * After execution, any external copies of the VoxelManip contents are
6342       invalidated.
6343     * `flags` is a flag field with the available flags:
6344         * place_center_x
6345         * place_center_y
6346         * place_center_z
6347
6348 * `minetest.serialize_schematic(schematic, format, options)`
6349     * Return the serialized schematic specified by schematic
6350       (see [Schematic specifier])
6351     * in the `format` of either "mts" or "lua".
6352     * "mts" - a string containing the binary MTS data used in the MTS file
6353       format.
6354     * "lua" - a string containing Lua code representing the schematic in table
6355       format.
6356     * `options` is a table containing the following optional parameters:
6357         * If `lua_use_comments` is true and `format` is "lua", the Lua code
6358           generated will have (X, Z) position comments for every X row
6359           generated in the schematic data for easier reading.
6360         * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
6361           the Lua code generated will use that number of spaces as indentation
6362           instead of a tab character.
6363
6364 * `minetest.read_schematic(schematic, options)`
6365     * Returns a Lua table representing the schematic (see: [Schematic specifier])
6366     * `schematic` is the schematic to read (see: [Schematic specifier])
6367     * `options` is a table containing the following optional parameters:
6368         * `write_yslice_prob`: string value:
6369             * `none`: no `write_yslice_prob` table is inserted,
6370             * `low`: only probabilities that are not 254 or 255 are written in
6371               the `write_ylisce_prob` table,
6372             * `all`: write all probabilities to the `write_yslice_prob` table.
6373             * The default for this option is `all`.
6374             * Any invalid value will be interpreted as `all`.
6375
6376 HTTP Requests
6377 -------------
6378
6379 * `minetest.request_http_api()`:
6380     * returns `HTTPApiTable` containing http functions if the calling mod has
6381       been granted access by being listed in the `secure.http_mods` or
6382       `secure.trusted_mods` setting, otherwise returns `nil`.
6383     * The returned table contains the functions `fetch`, `fetch_async` and
6384       `fetch_async_get` described below.
6385     * Only works at init time and must be called from the mod's main scope
6386       (not from a function).
6387     * Function only exists if minetest server was built with cURL support.
6388     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
6389       A LOCAL VARIABLE!**
6390 * `HTTPApiTable.fetch(HTTPRequest req, callback)`
6391     * Performs given request asynchronously and calls callback upon completion
6392     * callback: `function(HTTPRequestResult res)`
6393     * Use this HTTP function if you are unsure, the others are for advanced use
6394 * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
6395     * Performs given request asynchronously and returns handle for
6396       `HTTPApiTable.fetch_async_get`
6397 * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
6398     * Return response data for given asynchronous HTTP request
6399
6400 Storage API
6401 -----------
6402
6403 * `minetest.get_mod_storage()`:
6404     * returns reference to mod private `StorageRef`
6405     * must be called during mod load time
6406
6407 Misc.
6408 -----
6409
6410 * `minetest.get_connected_players()`: returns list of `ObjectRefs`
6411 * `minetest.is_player(obj)`: boolean, whether `obj` is a player
6412 * `minetest.player_exists(name)`: boolean, whether player exists
6413   (regardless of online status)
6414 * `minetest.hud_replace_builtin(name, hud_definition)`
6415     * Replaces definition of a builtin hud element
6416     * `name`: `"breath"` or `"health"`
6417     * `hud_definition`: definition to replace builtin definition
6418 * `minetest.parse_relative_number(arg, relative_to)`: returns number or nil
6419     * Helper function for chat commands.
6420     * For parsing an optionally relative number of a chat command
6421       parameter, using the chat command tilde notation.
6422     * `arg`: String snippet containing the number; possible values:
6423         * `"<number>"`: return as number
6424         * `"~<number>"`: return `relative_to + <number>`
6425         * `"~"`: return `relative_to`
6426         * Anything else will return `nil`
6427     * `relative_to`: Number to which the `arg` number might be relative to
6428     * Examples:
6429         * `minetest.parse_relative_number("5", 10)` returns 5
6430         * `minetest.parse_relative_number("~5", 10)` returns 15
6431         * `minetest.parse_relative_number("~", 10)` returns 10
6432 * `minetest.send_join_message(player_name)`
6433     * This function can be overridden by mods to change the join message.
6434 * `minetest.send_leave_message(player_name, timed_out)`
6435     * This function can be overridden by mods to change the leave message.
6436 * `minetest.hash_node_position(pos)`: returns a 48-bit integer
6437     * `pos`: table {x=number, y=number, z=number},
6438     * Gives a unique hash number for a node position (16+16+16=48bit)
6439 * `minetest.get_position_from_hash(hash)`: returns a position
6440     * Inverse transform of `minetest.hash_node_position`
6441 * `minetest.get_item_group(name, group)`: returns a rating
6442     * Get rating of a group of an item. (`0` means: not in group)
6443 * `minetest.get_node_group(name, group)`: returns a rating
6444     * Deprecated: An alias for the former.
6445 * `minetest.raillike_group(name)`: returns a rating
6446     * Returns rating of the connect_to_raillike group corresponding to name
6447     * If name is not yet the name of a connect_to_raillike group, a new group
6448       id is created, with that name.
6449 * `minetest.get_content_id(name)`: returns an integer
6450     * Gets the internal content ID of `name`
6451 * `minetest.get_name_from_content_id(content_id)`: returns a string
6452     * Gets the name of the content with that content ID
6453 * `minetest.parse_json(string[, nullvalue])`: returns something
6454     * Convert a string containing JSON data into the Lua equivalent
6455     * `nullvalue`: returned in place of the JSON null; defaults to `nil`
6456     * On success returns a table, a string, a number, a boolean or `nullvalue`
6457     * On failure outputs an error message and returns `nil`
6458     * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
6459 * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
6460   message.
6461     * Convert a Lua table into a JSON string
6462     * styled: Outputs in a human-readable format if this is set, defaults to
6463       false.
6464     * Unserializable things like functions and userdata will cause an error.
6465     * **Warning**: JSON is more strict than the Lua table format.
6466         1. You can only use strings and positive integers of at least one as
6467            keys.
6468         2. You cannot mix string and integer keys.
6469            This is due to the fact that JSON has two distinct array and object
6470            values.
6471     * Example: `write_json({10, {a = false}})`,
6472       returns `'[10, {"a": false}]'`
6473 * `minetest.serialize(table)`: returns a string
6474     * Convert a table containing tables, strings, numbers, booleans and `nil`s
6475       into string form readable by `minetest.deserialize`
6476     * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
6477 * `minetest.deserialize(string[, safe])`: returns a table
6478     * Convert a string returned by `minetest.serialize` into a table
6479     * `string` is loaded in an empty sandbox environment.
6480     * Will load functions if safe is false or omitted. Although these functions
6481       cannot directly access the global environment, they could bypass this
6482       restriction with maliciously crafted Lua bytecode if mod security is
6483       disabled.
6484     * This function should not be used on untrusted data, regardless of the
6485      value of `safe`. It is fine to serialize then deserialize user-provided
6486      data, but directly providing user input to deserialize is always unsafe.
6487     * Example: `deserialize('return { ["foo"] = "bar" }')`,
6488       returns `{foo="bar"}`
6489     * Example: `deserialize('print("foo")')`, returns `nil`
6490       (function call fails), returns
6491       `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
6492 * `minetest.compress(data, method, ...)`: returns `compressed_data`
6493     * Compress a string of data.
6494     * `method` is a string identifying the compression method to be used.
6495     * Supported compression methods:
6496         * Deflate (zlib): `"deflate"`
6497         * Zstandard: `"zstd"`
6498     * `...` indicates method-specific arguments. Currently defined arguments
6499       are:
6500         * Deflate: `level` - Compression level, `0`-`9` or `nil`.
6501         * Zstandard: `level` - Compression level. Integer or `nil`. Default `3`.
6502         Note any supported Zstandard compression level could be used here,
6503         but these are subject to change between Zstandard versions.
6504 * `minetest.decompress(compressed_data, method, ...)`: returns data
6505     * Decompress a string of data using the algorithm specified by `method`.
6506     * See documentation on `minetest.compress()` for supported compression
6507       methods.
6508     * `...` indicates method-specific arguments. Currently, no methods use this
6509 * `minetest.rgba(red, green, blue[, alpha])`: returns a string
6510     * Each argument is an 8 Bit unsigned integer
6511     * Returns the ColorString from rgb or rgba values
6512     * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
6513 * `minetest.encode_base64(string)`: returns string encoded in base64
6514     * Encodes a string in base64.
6515 * `minetest.decode_base64(string)`: returns string or nil on failure
6516     * Padding characters are only supported starting at version 5.4.0, where
6517       5.5.0 and newer perform proper checks.
6518     * Decodes a string encoded in base64.
6519 * `minetest.is_protected(pos, name)`: returns boolean
6520     * Returning `true` restricts the player `name` from modifying (i.e. digging,
6521        placing) the node at position `pos`.
6522     * `name` will be `""` for non-players or unknown players.
6523     * This function should be overridden by protection mods. It is highly
6524       recommended to grant access to players with the `protection_bypass` privilege.
6525     * Cache and call the old version of this function if the position is
6526       not protected by the mod. This will allow using multiple protection mods.
6527     * Example:
6528
6529           local old_is_protected = minetest.is_protected
6530           function minetest.is_protected(pos, name)
6531               if mymod:position_protected_from(pos, name) then
6532                   return true
6533               end
6534               return old_is_protected(pos, name)
6535           end
6536 * `minetest.record_protection_violation(pos, name)`
6537     * This function calls functions registered with
6538       `minetest.register_on_protection_violation`.
6539 * `minetest.is_creative_enabled(name)`: returns boolean
6540     * Returning `true` means that Creative Mode is enabled for player `name`.
6541     * `name` will be `""` for non-players or if the player is unknown.
6542     * This function should be overridden by Creative Mode-related mods to
6543       implement a per-player Creative Mode.
6544     * By default, this function returns `true` if the setting
6545       `creative_mode` is `true` and `false` otherwise.
6546 * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
6547     * Returns the position of the first node that `player_name` may not modify
6548       in the specified cuboid between `pos1` and `pos2`.
6549     * Returns `false` if no protections were found.
6550     * Applies `is_protected()` to a 3D lattice of points in the defined volume.
6551       The points are spaced evenly throughout the volume and have a spacing
6552       similar to, but no larger than, `interval`.
6553     * All corners and edges of the defined volume are checked.
6554     * `interval` defaults to 4.
6555     * `interval` should be carefully chosen and maximized to avoid an excessive
6556       number of points being checked.
6557     * Like `minetest.is_protected`, this function may be extended or
6558       overwritten by mods to provide a faster implementation to check the
6559       cuboid for intersections.
6560 * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
6561   orient_flags, prevent_after_place])`
6562     * Attempt to predict the desired orientation of the facedir-capable node
6563       defined by `itemstack`, and place it accordingly (on-wall, on the floor,
6564       or hanging from the ceiling).
6565     * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
6566       stacks are handled normally.
6567     * `orient_flags`: Optional table containing extra tweaks to the placement code:
6568         * `invert_wall`:   if `true`, place wall-orientation on the ground and
6569           ground-orientation on the wall.
6570         * `force_wall`:    if `true`, always place the node in wall orientation.
6571         * `force_ceiling`: if `true`, always place on the ceiling.
6572         * `force_floor`:   if `true`, always place the node on the floor.
6573         * `force_facedir`: if `true`, forcefully reset the facedir to north
6574           when placing on the floor or ceiling.
6575         * The first four options are mutually-exclusive; the last in the list
6576           takes precedence over the first.
6577     * `prevent_after_place` is directly passed to `minetest.item_place_node`
6578     * Returns the new itemstack after placement
6579 * `minetest.rotate_node(itemstack, placer, pointed_thing)`
6580     * calls `rotate_and_place()` with `infinitestacks` set according to the state
6581       of the creative mode setting, checks for "sneak" to set the `invert_wall`
6582       parameter and `prevent_after_place` set to `true`.
6583
6584 * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
6585   tool_capabilities, dir, distance, damage)`
6586     * Returns the amount of knockback applied on the punched player.
6587     * Arguments are equivalent to `register_on_punchplayer`, except the following:
6588         * `distance`: distance between puncher and punched player
6589     * This function can be overridden by mods that wish to modify this behavior.
6590     * You may want to cache and call the old function to allow multiple mods to
6591       change knockback behavior.
6592
6593 * `minetest.forceload_block(pos[, transient[, limit]])`
6594     * forceloads the position `pos`.
6595     * returns `true` if area could be forceloaded
6596     * If `transient` is `false` or absent, the forceload will be persistent
6597       (saved between server runs). If `true`, the forceload will be transient
6598       (not saved between server runs).
6599     * `limit` is an optional limit on the number of blocks that can be
6600       forceloaded at once. If `limit` is negative, there is no limit. If it is
6601       absent, the limit is the value of the setting `"max_forceloaded_blocks"`.
6602       If the call would put the number of blocks over the limit, the call fails.
6603
6604 * `minetest.forceload_free_block(pos[, transient])`
6605     * stops forceloading the position `pos`
6606     * If `transient` is `false` or absent, frees a persistent forceload.
6607       If `true`, frees a transient forceload.
6608
6609 * `minetest.compare_block_status(pos, condition)`
6610     * Checks whether the mapblock at position `pos` is in the wanted condition.
6611     * `condition` may be one of the following values:
6612         * `"unknown"`: not in memory
6613         * `"emerging"`: in the queue for loading from disk or generating
6614         * `"loaded"`: in memory but inactive (no ABMs are executed)
6615         * `"active"`: in memory and active
6616         * Other values are reserved for future functionality extensions
6617     * Return value, the comparison status:
6618         * `false`: Mapblock does not fulfill the wanted condition
6619         * `true`: Mapblock meets the requirement
6620         * `nil`: Unsupported `condition` value
6621
6622 * `minetest.request_insecure_environment()`: returns an environment containing
6623   insecure functions if the calling mod has been listed as trusted in the
6624   `secure.trusted_mods` setting or security is disabled, otherwise returns
6625   `nil`.
6626     * Only works at init time and must be called from the mod's main scope
6627       (ie: the init.lua of the mod, not from another Lua file or within a function).
6628     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
6629       IT IN A LOCAL VARIABLE!**
6630
6631 * `minetest.global_exists(name)`
6632     * Checks if a global variable has been set, without triggering a warning.
6633
6634 Global objects
6635 --------------
6636
6637 * `minetest.env`: `EnvRef` of the server environment and world.
6638     * Any function in the minetest namespace can be called using the syntax
6639       `minetest.env:somefunction(somearguments)`
6640       instead of `minetest.somefunction(somearguments)`
6641     * Deprecated, but support is not to be dropped soon
6642
6643 Global tables
6644 -------------
6645
6646 ### Registered definition tables
6647
6648 * `minetest.registered_items`
6649     * Map of registered items, indexed by name
6650 * `minetest.registered_nodes`
6651     * Map of registered node definitions, indexed by name
6652 * `minetest.registered_craftitems`
6653     * Map of registered craft item definitions, indexed by name
6654 * `minetest.registered_tools`
6655     * Map of registered tool definitions, indexed by name
6656 * `minetest.registered_entities`
6657     * Map of registered entity prototypes, indexed by name
6658     * Values in this table may be modified directly.
6659       Note: changes to initial properties will only affect entities spawned afterwards,
6660       as they are only read when spawning.
6661 * `minetest.object_refs`
6662     * Map of object references, indexed by active object id
6663 * `minetest.luaentities`
6664     * Map of Lua entities, indexed by active object id
6665 * `minetest.registered_abms`
6666     * List of ABM definitions
6667 * `minetest.registered_lbms`
6668     * List of LBM definitions
6669 * `minetest.registered_aliases`
6670     * Map of registered aliases, indexed by name
6671 * `minetest.registered_ores`
6672     * Map of registered ore definitions, indexed by the `name` field.
6673     * If `name` is nil, the key is the object handle returned by
6674       `minetest.register_ore`.
6675 * `minetest.registered_biomes`
6676     * Map of registered biome definitions, indexed by the `name` field.
6677     * If `name` is nil, the key is the object handle returned by
6678       `minetest.register_biome`.
6679 * `minetest.registered_decorations`
6680     * Map of registered decoration definitions, indexed by the `name` field.
6681     * If `name` is nil, the key is the object handle returned by
6682       `minetest.register_decoration`.
6683 * `minetest.registered_schematics`
6684     * Map of registered schematic definitions, indexed by the `name` field.
6685     * If `name` is nil, the key is the object handle returned by
6686       `minetest.register_schematic`.
6687 * `minetest.registered_chatcommands`
6688     * Map of registered chat command definitions, indexed by name
6689 * `minetest.registered_privileges`
6690     * Map of registered privilege definitions, indexed by name
6691     * Registered privileges can be modified directly in this table.
6692
6693 ### Registered callback tables
6694
6695 All callbacks registered with [Global callback registration functions] are added
6696 to corresponding `minetest.registered_*` tables.
6697
6698
6699
6700
6701 Class reference
6702 ===============
6703
6704 Sorted alphabetically.
6705
6706 `AreaStore`
6707 -----------
6708
6709 AreaStore is a data structure to calculate intersections of 3D cuboid volumes
6710 and points. The `data` field (string) may be used to store and retrieve any
6711 mod-relevant information to the specified area.
6712
6713 Despite its name, mods must take care of persisting AreaStore data. They may
6714 use the provided load and write functions for this.
6715
6716
6717 ### Methods
6718
6719 * `AreaStore(type_name)`
6720     * Returns a new AreaStore instance
6721     * `type_name`: optional, forces the internally used API.
6722         * Possible values: `"LibSpatial"` (default).
6723         * When other values are specified, or SpatialIndex is not available,
6724           the custom Minetest functions are used.
6725 * `get_area(id, include_corners, include_data)`
6726     * Returns the area information about the specified ID.
6727     * Returned values are either of these:
6728
6729             nil  -- Area not found
6730             true -- Without `include_corners` and `include_data`
6731             {
6732                 min = pos, max = pos -- `include_corners == true`
6733                 data = string        -- `include_data == true`
6734             }
6735
6736 * `get_areas_for_pos(pos, include_corners, include_data)`
6737     * Returns all areas as table, indexed by the area ID.
6738     * Table values: see `get_area`.
6739 * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
6740     * Returns all areas that contain all nodes inside the area specified by`
6741       `corner1 and `corner2` (inclusive).
6742     * `accept_overlap`: if `true`, areas are returned that have nodes in
6743       common (intersect) with the specified area.
6744     * Returns the same values as `get_areas_for_pos`.
6745 * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
6746     * Returns the new area's ID, or nil if the insertion failed.
6747     * The (inclusive) positions `corner1` and `corner2` describe the area.
6748     * `data` is a string stored with the area.
6749     * `id` (optional): will be used as the internal area ID if it is a unique
6750       number between 0 and 2^32-2.
6751 * `reserve(count)`
6752     * Requires SpatialIndex, no-op function otherwise.
6753     * Reserves resources for `count` many contained areas to improve
6754       efficiency when working with many area entries. Additional areas can still
6755       be inserted afterwards at the usual complexity.
6756 * `remove_area(id)`: removes the area with the given id from the store, returns
6757   success.
6758 * `set_cache_params(params)`: sets params for the included prefiltering cache.
6759   Calling invalidates the cache, so that its elements have to be newly
6760   generated.
6761     * `params` is a table with the following fields:
6762
6763           enabled = boolean,   -- Whether to enable, default true
6764           block_radius = int,  -- The radius (in nodes) of the areas the cache
6765                                -- generates prefiltered lists for, minimum 16,
6766                                -- default 64
6767           limit = int,         -- The cache size, minimum 20, default 1000
6768 * `to_string()`: Experimental. Returns area store serialized as a (binary)
6769   string.
6770 * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
6771   a file.
6772 * `from_string(str)`: Experimental. Deserializes string and loads it into the
6773   AreaStore.
6774   Returns success and, optionally, an error message.
6775 * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
6776   from a file.
6777
6778 `InvRef`
6779 --------
6780
6781 An `InvRef` is a reference to an inventory.
6782
6783 ### Methods
6784
6785 * `is_empty(listname)`: return `true` if list is empty
6786 * `get_size(listname)`: get size of a list
6787 * `set_size(listname, size)`: set size of a list
6788     * returns `false` on error (e.g. invalid `listname` or `size`)
6789 * `get_width(listname)`: get width of a list
6790 * `set_width(listname, width)`: set width of list; currently used for crafting
6791 * `get_stack(listname, i)`: get a copy of stack index `i` in list
6792 * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
6793 * `get_list(listname)`: return full list (list of `ItemStack`s)
6794 * `set_list(listname, list)`: set full list (size will not change)
6795 * `get_lists()`: returns table that maps listnames to inventory lists
6796 * `set_lists(lists)`: sets inventory lists (size will not change)
6797 * `add_item(listname, stack)`: add item somewhere in list, returns leftover
6798   `ItemStack`.
6799 * `room_for_item(listname, stack):` returns `true` if the stack of items
6800   can be fully added to the list
6801 * `contains_item(listname, stack, [match_meta])`: returns `true` if
6802   the stack of items can be fully taken from the list.
6803   If `match_meta` is false, only the items' names are compared
6804   (default: `false`).
6805 * `remove_item(listname, stack)`: take as many items as specified from the
6806   list, returns the items that were actually removed (as an `ItemStack`)
6807   -- note that any item metadata is ignored, so attempting to remove a specific
6808   unique item this way will likely remove the wrong one -- to do that use
6809   `set_stack` with an empty `ItemStack`.
6810 * `get_location()`: returns a location compatible to
6811   `minetest.get_inventory(location)`.
6812     * returns `{type="undefined"}` in case location is not known
6813
6814 ### Callbacks
6815
6816 Detached & nodemeta inventories provide the following callbacks for move actions:
6817
6818 #### Before
6819
6820 The `allow_*` callbacks return how many items can be moved.
6821
6822 * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
6823 * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
6824 * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
6825
6826 #### After
6827
6828 The `on_*` callbacks are called after the items have been placed in the inventories.
6829
6830 * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
6831 * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
6832 * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
6833
6834 #### Swapping
6835
6836 When a player tries to put an item to a place where another item is, the items are *swapped*.
6837 This means that all callbacks will be called twice (once for each action).
6838
6839 `ItemStack`
6840 -----------
6841
6842 An `ItemStack` is a stack of items.
6843
6844 It can be created via `ItemStack(x)`, where x is an `ItemStack`,
6845 an itemstring, a table or `nil`.
6846
6847 ### Methods
6848
6849 * `is_empty()`: returns `true` if stack is empty.
6850 * `get_name()`: returns item name (e.g. `"default:stone"`).
6851 * `set_name(item_name)`: returns a boolean indicating whether the item was
6852   cleared.
6853 * `get_count()`: Returns number of items on the stack.
6854 * `set_count(count)`: returns a boolean indicating whether the item was cleared
6855     * `count`: number, unsigned 16 bit integer
6856 * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
6857 * `set_wear(wear)`: returns boolean indicating whether item was cleared
6858     * `wear`: number, unsigned 16 bit integer
6859 * `get_meta()`: returns ItemStackMetaRef. See section for more details
6860 * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
6861   stack).
6862 * `set_metadata(metadata)`: (DEPRECATED) Returns true.
6863 * `get_description()`: returns the description shown in inventory list tooltips.
6864     * The engine uses this when showing item descriptions in tooltips.
6865     * Fields for finding the description, in order:
6866         * `description` in item metadata (See [Item Metadata].)
6867         * `description` in item definition
6868         * item name
6869 * `get_short_description()`: returns the short description or nil.
6870     * Unlike the description, this does not include new lines.
6871     * Fields for finding the short description, in order:
6872         * `short_description` in item metadata (See [Item Metadata].)
6873         * `short_description` in item definition
6874         * first line of the description (From item meta or def, see `get_description()`.)
6875         * Returns nil if none of the above are set
6876 * `clear()`: removes all items from the stack, making it empty.
6877 * `replace(item)`: replace the contents of this stack.
6878     * `item` can also be an itemstring or table.
6879 * `to_string()`: returns the stack in itemstring form.
6880 * `to_table()`: returns the stack in Lua table form.
6881 * `get_stack_max()`: returns the maximum size of the stack (depends on the
6882   item).
6883 * `get_free_space()`: returns `get_stack_max() - get_count()`.
6884 * `is_known()`: returns `true` if the item name refers to a defined item type.
6885 * `get_definition()`: returns the item definition table.
6886 * `get_tool_capabilities()`: returns the digging properties of the item,
6887   or those of the hand if none are defined for this item type
6888 * `add_wear(amount)`
6889     * Increases wear by `amount` if the item is a tool, otherwise does nothing
6890     * Valid `amount` range is [0,65536]
6891     * `amount`: number, integer
6892 * `add_wear_by_uses(max_uses)`
6893     * Increases wear in such a way that, if only this function is called,
6894       the item breaks after `max_uses` times
6895     * Valid `max_uses` range is [0,65536]
6896     * Does nothing if item is not a tool or if `max_uses` is 0
6897 * `add_item(item)`: returns leftover `ItemStack`
6898     * Put some item or stack onto this stack
6899 * `item_fits(item)`: returns `true` if item or stack can be fully added to
6900   this one.
6901 * `take_item(n)`: returns taken `ItemStack`
6902     * Take (and remove) up to `n` items from this stack
6903     * `n`: number, default: `1`
6904 * `peek_item(n)`: returns taken `ItemStack`
6905     * Copy (don't remove) up to `n` items from this stack
6906     * `n`: number, default: `1`
6907 * `equals(other)`:
6908     * returns `true` if this stack is identical to `other`.
6909     * Note: `stack1:to_string() == stack2:to_string()` is not reliable,
6910       as stack metadata can be serialized in arbitrary order.
6911     * Note: if `other` is an itemstring or table representation of an
6912       ItemStack, this will always return false, even if it is
6913       "equivalent".
6914
6915 ### Operators
6916
6917 * `stack1 == stack2`:
6918     * Returns whether `stack1` and `stack2` are identical.
6919     * Note: `stack1:to_string() == stack2:to_string()` is not reliable,
6920       as stack metadata can be serialized in arbitrary order.
6921     * Note: if `stack2` is an itemstring or table representation of an
6922       ItemStack, this will always return false, even if it is
6923       "equivalent".
6924
6925 `ItemStackMetaRef`
6926 ------------------
6927
6928 ItemStack metadata: reference extra data and functionality stored in a stack.
6929 Can be obtained via `item:get_meta()`.
6930
6931 ### Methods
6932
6933 * All methods in MetaDataRef
6934 * `set_tool_capabilities([tool_capabilities])`
6935     * Overrides the item's tool capabilities
6936     * A nil value will clear the override data and restore the original
6937       behavior.
6938
6939 `MetaDataRef`
6940 -------------
6941
6942 Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
6943 and [`PlayerMetaRef`].
6944
6945 Note: If a metadata value is in the format `${k}`, an attempt to get the value
6946 will return the value associated with key `k`. There is a low recursion limit.
6947 This behavior is **deprecated** and will be removed in a future version. Usage
6948 of the `${k}` syntax in formspecs is not deprecated.
6949
6950 ### Methods
6951
6952 * `contains(key)`: Returns true if key present, otherwise false.
6953     * Returns `nil` when the MetaData is inexistent.
6954 * `get(key)`: Returns `nil` if key not present, else the stored string.
6955 * `set_string(key, value)`: Value of `""` will delete the key.
6956 * `get_string(key)`: Returns `""` if key not present.
6957 * `set_int(key, value)`
6958 * `get_int(key)`: Returns `0` if key not present.
6959 * `set_float(key, value)`
6960 * `get_float(key)`: Returns `0` if key not present.
6961 * `get_keys()`: returns a list of all keys in the metadata.
6962 * `to_table()`: returns `nil` or a table with keys:
6963     * `fields`: key-value storage
6964     * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
6965 * `from_table(nil or {})`
6966     * Any non-table value will clear the metadata
6967     * See [Node Metadata] for an example
6968     * returns `true` on success
6969 * `equals(other)`
6970     * returns `true` if this metadata has the same key-value pairs as `other`
6971
6972 `ModChannel`
6973 ------------
6974
6975 An interface to use mod channels on client and server
6976
6977 ### Methods
6978
6979 * `leave()`: leave the mod channel.
6980     * Server leaves channel `channel_name`.
6981     * No more incoming or outgoing messages can be sent to this channel from
6982       server mods.
6983     * This invalidate all future object usage.
6984     * Ensure you set mod_channel to nil after that to free Lua resources.
6985 * `is_writeable()`: returns true if channel is writeable and mod can send over
6986   it.
6987 * `send_all(message)`: Send `message` though the mod channel.
6988     * If mod channel is not writeable or invalid, message will be dropped.
6989     * Message size is limited to 65535 characters by protocol.
6990
6991 `NodeMetaRef`
6992 -------------
6993
6994 Node metadata: reference extra data and functionality stored in a node.
6995 Can be obtained via `minetest.get_meta(pos)`.
6996
6997 ### Methods
6998
6999 * All methods in MetaDataRef
7000 * `get_inventory()`: returns `InvRef`
7001 * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
7002   This will prevent them from being sent to the client. Note that the "private"
7003   status will only be remembered if an associated key-value pair exists,
7004   meaning it's best to call this when initializing all other meta (e.g.
7005   `on_construct`).
7006
7007 `NodeTimerRef`
7008 --------------
7009
7010 Node Timers: a high resolution persistent per-node timer.
7011 Can be gotten via `minetest.get_node_timer(pos)`.
7012
7013 ### Methods
7014
7015 * `set(timeout,elapsed)`
7016     * set a timer's state
7017     * `timeout` is in seconds, and supports fractional values (0.1 etc)
7018     * `elapsed` is in seconds, and supports fractional values (0.1 etc)
7019     * will trigger the node's `on_timer` function after `(timeout - elapsed)`
7020       seconds.
7021 * `start(timeout)`
7022     * start a timer
7023     * equivalent to `set(timeout,0)`
7024 * `stop()`
7025     * stops the timer
7026 * `get_timeout()`: returns current timeout in seconds
7027     * if `timeout` equals `0`, timer is inactive
7028 * `get_elapsed()`: returns current elapsed time in seconds
7029     * the node's `on_timer` function will be called after `(timeout - elapsed)`
7030       seconds.
7031 * `is_started()`: returns boolean state of timer
7032     * returns `true` if timer is started, otherwise `false`
7033
7034 `ObjectRef`
7035 -----------
7036
7037 Moving things in the game are generally these.
7038 This is basically a reference to a C++ `ServerActiveObject`.
7039
7040 ### Advice on handling `ObjectRefs`
7041
7042 When you receive an `ObjectRef` as a callback argument or from another API
7043 function, it is possible to store the reference somewhere and keep it around.
7044 It will keep functioning until the object is unloaded or removed.
7045
7046 However, doing this is **NOT** recommended as there is (intentionally) no method
7047 to test if a previously acquired `ObjectRef` is still valid.
7048 Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
7049 Lua back to the engine.
7050 Doing so is much less error-prone and you will never need to wonder if the
7051 object you are working with still exists.
7052
7053 ### Attachments
7054
7055 It is possible to attach objects to other objects (`set_attach` method).
7056
7057 When an object is attached, it is positioned relative to the parent's position
7058 and rotation. `get_pos` and `get_rotation` will always return the parent's
7059 values and changes via their setter counterparts are ignored.
7060
7061 To change position or rotation call `set_attach` again with the new values.
7062
7063 **Note**: Just like model dimensions, the relative position in `set_attach`
7064 must be multiplied by 10 compared to world positions.
7065
7066 It is also possible to attach to a bone of the parent object. In that case the
7067 child will follow movement and rotation of that bone.
7068
7069 ### Methods
7070
7071 * `get_pos()`: returns `{x=num, y=num, z=num}`
7072 * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
7073 * `get_velocity()`: returns the velocity, a vector.
7074 * `add_velocity(vel)`
7075     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
7076     * In comparison to using get_velocity, adding the velocity and then using
7077       set_velocity, add_velocity is supposed to avoid synchronization problems.
7078       Additionally, players also do not support set_velocity.
7079     * If a player:
7080         * Does not apply during free_move.
7081         * Note that since the player speed is normalized at each move step,
7082           increasing e.g. Y velocity beyond what would usually be achieved
7083           (see: physics overrides) will cause existing X/Z velocity to be reduced.
7084         * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
7085           pressing the jump key (assuming default settings)
7086 * `move_to(pos, continuous=false)`
7087     * Does an interpolated move for Lua entities for visually smooth transitions.
7088     * If `continuous` is true, the Lua entity will not be moved to the current
7089       position before starting the interpolated move.
7090     * For players this does the same as `set_pos`,`continuous` is ignored.
7091 * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
7092     * `puncher` = another `ObjectRef`,
7093     * `time_from_last_punch` = time since last punch action of the puncher
7094     * `direction`: can be `nil`
7095 * `right_click(clicker)`; `clicker` is another `ObjectRef`
7096 * `get_hp()`: returns number of health points
7097 * `set_hp(hp, reason)`: set number of health points
7098     * See reason in register_on_player_hpchange
7099     * Is limited to the range of 0 ... 65535 (2^16 - 1)
7100     * For players: HP are also limited by `hp_max` specified in object properties
7101 * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
7102 * `get_wield_list()`: returns the name of the inventory list the wielded item
7103    is in.
7104 * `get_wield_index()`: returns the index of the wielded item
7105 * `get_wielded_item()`: returns an `ItemStack`
7106 * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
7107   successful.
7108 * `set_armor_groups({group1=rating, group2=rating, ...})`
7109 * `get_armor_groups()`: returns a table with the armor group ratings
7110 * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
7111     * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
7112     * `frame_speed`: number, default: `15.0`
7113     * `frame_blend`: number, default: `0.0`
7114     * `frame_loop`: boolean, default: `true`
7115 * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
7116   `frame_loop`.
7117 * `set_animation_frame_speed(frame_speed)`
7118     * `frame_speed`: number, default: `15.0`
7119 * `set_attach(parent[, bone, position, rotation, forced_visible])`
7120     * `parent`: `ObjectRef` to attach to
7121     * `bone`: default `""` (the root bone)
7122     * `position`: relative position, default `{x=0, y=0, z=0}`
7123     * `rotation`: relative rotation in degrees, default `{x=0, y=0, z=0}`
7124     * `forced_visible`: Boolean to control whether the attached entity
7125        should appear in first person, default `false`.
7126     * Please also read the [Attachments] section above.
7127     * This command may fail silently (do nothing) when it would result
7128       in circular attachments.
7129 * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
7130     or nil if it isn't attached.
7131 * `get_children()`: returns a list of ObjectRefs that are attached to the
7132     object.
7133 * `set_detach()`
7134 * `set_bone_position([bone, position, rotation])`
7135     * `bone`: string. Default is `""`, the root bone
7136     * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
7137     * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
7138 * `get_bone_position(bone)`: returns position and rotation of the bone
7139 * `set_properties(object property table)`
7140 * `get_properties()`: returns object property table
7141 * `is_player()`: returns true for players, false otherwise
7142 * `get_nametag_attributes()`
7143     * returns a table with the attributes of the nametag of an object
7144     * {
7145         text = "",
7146         color = {a=0..255, r=0..255, g=0..255, b=0..255},
7147         bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
7148       }
7149 * `set_nametag_attributes(attributes)`
7150     * sets the attributes of the nametag of an object
7151     * `attributes`:
7152       {
7153         text = "My Nametag",
7154         color = ColorSpec,
7155         -- ^ Text color
7156         bgcolor = ColorSpec or false,
7157         -- ^ Sets background color of nametag
7158         -- `false` will cause the background to be set automatically based on user settings
7159         -- Default: false
7160       }
7161
7162 #### Lua entity only (no-op for other objects)
7163
7164 * `remove()`: remove object
7165     * The object is removed after returning from Lua. However the `ObjectRef`
7166       itself instantly becomes unusable with all further method calls having
7167       no effect and returning `nil`.
7168 * `set_velocity(vel)`
7169     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
7170 * `set_acceleration(acc)`
7171     * `acc` is a vector
7172 * `get_acceleration()`: returns the acceleration, a vector
7173 * `set_rotation(rot)`
7174     * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
7175       and Z is roll (bank).
7176     * Does not reset rotation incurred through `automatic_rotate`.
7177       Remove & readd your objects to force a certain rotation.
7178 * `get_rotation()`: returns the rotation, a vector (radians)
7179 * `set_yaw(yaw)`: sets the yaw in radians (heading).
7180 * `get_yaw()`: returns number in radians
7181 * `set_texture_mod(mod)`
7182     * Set a texture modifier to the base texture, for sprites and meshes.
7183     * When calling `set_texture_mod` again, the previous one is discarded.
7184     * `mod` the texture modifier. See [Texture modifiers].
7185 * `get_texture_mod()` returns current texture modifier
7186 * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
7187     * Specifies and starts a sprite animation
7188     * Animations iterate along the frame `y` position.
7189     * `start_frame`: {x=column number, y=row number}, the coordinate of the
7190       first frame, default: `{x=0, y=0}`
7191     * `num_frames`: Total frames in the texture, default: `1`
7192     * `framelength`: Time per animated frame in seconds, default: `0.2`
7193     * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
7194       position according to the view direction. default: `false`.
7195         * First column:  subject facing the camera
7196         * Second column: subject looking to the left
7197         * Third column:  subject backing the camera
7198         * Fourth column: subject looking to the right
7199         * Fifth column:  subject viewed from above
7200         * Sixth column:  subject viewed from below
7201 * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
7202 * `get_luaentity()`
7203
7204 #### Player only (no-op for other objects)
7205
7206 * `get_player_name()`: returns `""` if is not a player
7207 * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
7208   table {x, y, z} representing the player's instantaneous velocity in nodes/s
7209 * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
7210 * `get_look_dir()`: get camera direction as a unit vector
7211 * `get_look_vertical()`: pitch in radians
7212     * Angle ranges between -pi/2 and pi/2, which are straight up and down
7213       respectively.
7214 * `get_look_horizontal()`: yaw in radians
7215     * Angle is counter-clockwise from the +z direction.
7216 * `set_look_vertical(radians)`: sets look pitch
7217     * radians: Angle from looking forward, where positive is downwards.
7218 * `set_look_horizontal(radians)`: sets look yaw
7219     * radians: Angle from the +z direction, where positive is counter-clockwise.
7220 * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
7221   `get_look_vertical`.
7222     * Angle ranges between -pi/2 and pi/2, which are straight down and up
7223       respectively.
7224 * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
7225   `get_look_horizontal`.
7226     * Angle is counter-clockwise from the +x direction.
7227 * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
7228   `set_look_vertical`.
7229 * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
7230   `set_look_horizontal`.
7231 * `get_breath()`: returns player's breath
7232 * `set_breath(value)`: sets player's breath
7233     * values:
7234         * `0`: player is drowning
7235         * max: bubbles bar is not shown
7236         * See [Object properties] for more information
7237     * Is limited to range 0 ... 65535 (2^16 - 1)
7238 * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
7239     * `fov`: FOV value.
7240     * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
7241       Defaults to `false`.
7242     * `transition_time`: If defined, enables smooth FOV transition.
7243       Interpreted as the time (in seconds) to reach target FOV.
7244       If set to 0, FOV change is instantaneous. Defaults to 0.
7245     * Set `fov` to 0 to clear FOV override.
7246 * `get_fov()`: Returns the following:
7247     * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
7248     * Boolean indicating whether the FOV value is a multiplier.
7249     * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
7250 * `set_attribute(attribute, value)`:  DEPRECATED, use get_meta() instead
7251     * Sets an extra attribute with value on player.
7252     * `value` must be a string, or a number which will be converted to a
7253       string.
7254     * If `value` is `nil`, remove attribute from player.
7255 * `get_attribute(attribute)`:  DEPRECATED, use get_meta() instead
7256     * Returns value (a string) for extra attribute.
7257     * Returns `nil` if no attribute found.
7258 * `get_meta()`: Returns a PlayerMetaRef.
7259 * `set_inventory_formspec(formspec)`
7260     * Redefine player's inventory form
7261     * Should usually be called in `on_joinplayer`
7262     * If `formspec` is `""`, the player's inventory is disabled.
7263 * `get_inventory_formspec()`: returns a formspec string
7264 * `set_formspec_prepend(formspec)`:
7265     * the formspec string will be added to every formspec shown to the user,
7266       except for those with a no_prepend[] tag.
7267     * This should be used to set style elements such as background[] and
7268       bgcolor[], any non-style elements (eg: label) may result in weird behavior.
7269     * Only affects formspecs shown after this is called.
7270 * `get_formspec_prepend(formspec)`: returns a formspec string.
7271 * `get_player_control()`: returns table with player pressed keys
7272     * The table consists of fields with the following boolean values
7273       representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
7274       `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
7275     * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
7276       and exist only to preserve backwards compatibility.
7277     * Returns an empty table `{}` if the object is not a player.
7278 * `get_player_control_bits()`: returns integer with bit packed player pressed
7279   keys.
7280     * Bits:
7281         * 0 - up
7282         * 1 - down
7283         * 2 - left
7284         * 3 - right
7285         * 4 - jump
7286         * 5 - aux1
7287         * 6 - sneak
7288         * 7 - dig
7289         * 8 - place
7290         * 9 - zoom
7291     * Returns `0` (no bits set) if the object is not a player.
7292 * `set_physics_override(override_table)`
7293     * `override_table` is a table with the following fields:
7294         * `speed`: multiplier to default walking speed value (default: `1`)
7295         * `jump`: multiplier to default jump value (default: `1`)
7296         * `gravity`: multiplier to default gravity value (default: `1`)
7297         * `sneak`: whether player can sneak (default: `true`)
7298         * `sneak_glitch`: whether player can use the new move code replications
7299           of the old sneak side-effects: sneak ladders and 2 node sneak jump
7300           (default: `false`)
7301         * `new_move`: use new move/sneak code. When `false` the exact old code
7302           is used for the specific old sneak behavior (default: `true`)
7303 * `get_physics_override()`: returns the table given to `set_physics_override`
7304 * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
7305    number on success
7306 * `hud_remove(id)`: remove the HUD element of the specified id
7307 * `hud_change(id, stat, value)`: change a value of a previously added HUD
7308   element.
7309     * `stat` supports the same keys as in the hud definition table except for
7310       `"hud_elem_type"`.
7311 * `hud_get(id)`: gets the HUD element definition structure of the specified ID
7312 * `hud_set_flags(flags)`: sets specified HUD flags of player.
7313     * `flags`: A table with the following fields set to boolean values
7314         * `hotbar`
7315         * `healthbar`
7316         * `crosshair`
7317         * `wielditem`
7318         * `breathbar`
7319         * `minimap`: Modifies the client's permission to view the minimap.
7320           The client may locally elect to not view the minimap.
7321         * `minimap_radar`: is only usable when `minimap` is true
7322         * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
7323           This includes map seed, player position, look direction, the pointed node and block bounds.
7324           Does not affect players with the `debug` privilege.
7325         * `chat`: Modifies the client's permission to view chat on the HUD.
7326           The client may locally elect to not view chat. Does not affect the console.
7327     * If a flag equals `nil`, the flag is not modified
7328 * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
7329     * See `hud_set_flags` for a list of flags that can be toggled.
7330 * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
7331     * `count`: number of items, must be between `1` and `32`
7332 * `hud_get_hotbar_itemcount`: returns number of visible items
7333 * `hud_set_hotbar_image(texturename)`
7334     * sets background image for hotbar
7335 * `hud_get_hotbar_image`: returns texturename
7336 * `hud_set_hotbar_selected_image(texturename)`
7337     * sets image for selected item of hotbar
7338 * `hud_get_hotbar_selected_image`: returns texturename
7339 * `set_minimap_modes({mode, mode, ...}, selected_mode)`
7340     * Overrides the available minimap modes (and toggle order), and changes the
7341     selected mode.
7342     * `mode` is a table consisting of up to four fields:
7343         * `type`: Available type:
7344             * `off`: Minimap off
7345             * `surface`: Minimap in surface mode
7346             * `radar`: Minimap in radar mode
7347             * `texture`: Texture to be displayed instead of terrain map
7348               (texture is centered around 0,0 and can be scaled).
7349               Texture size is limited to 512 x 512 pixel.
7350         * `label`: Optional label to display on minimap mode toggle
7351           The translation must be handled within the mod.
7352         * `size`: Sidelength or diameter, in number of nodes, of the terrain
7353           displayed in minimap
7354         * `texture`: Only for texture type, name of the texture to display
7355         * `scale`: Only for texture type, scale of the texture map in nodes per
7356           pixel (for example a `scale` of 2 means each pixel represents a 2x2
7357           nodes square)
7358     * `selected_mode` is the mode index to be selected after modes have been changed
7359     (0 is the first mode).
7360 * `set_sky(sky_parameters)`
7361     * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
7362       whether `set_sky` accepts this format. Check the legacy format otherwise.
7363     * Passing no arguments resets the sky to its default values.
7364     * `sky_parameters` is a table with the following optional fields:
7365         * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
7366           (default: `#ffffff`)
7367         * `body_orbit_tilt`: Float, angle of sun/moon orbit in degrees, relative to Y axis.
7368            Valid range [-60.0,60.0] (default: 0.0)
7369         * `type`: Available types:
7370             * `"regular"`: Uses 0 textures, `base_color` ignored
7371             * `"skybox"`: Uses 6 textures, `base_color` used as fog.
7372             * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
7373             (default: `"regular"`)
7374         * `textures`: A table containing up to six textures in the following
7375             order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
7376         * `clouds`: Boolean for whether clouds appear. (default: `true`)
7377         * `sky_color`: A table used in `"regular"` type only, containing the
7378           following values (alpha is ignored):
7379             * `day_sky`: ColorSpec, for the top half of the sky during the day.
7380               (default: `#61b5f5`)
7381             * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
7382               (default: `#90d3f6`)
7383             * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
7384               (default: `#b4bafa`)
7385               The resulting sky color will be a darkened version of the ColorSpec.
7386               Warning: The darkening of the ColorSpec is subject to change.
7387             * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
7388               (default: `#bac1f0`)
7389               The resulting sky color will be a darkened version of the ColorSpec.
7390               Warning: The darkening of the ColorSpec is subject to change.
7391             * `night_sky`: ColorSpec, for the top half of the sky during the night.
7392               (default: `#006bff`)
7393               The resulting sky color will be a dark version of the ColorSpec.
7394               Warning: The darkening of the ColorSpec is subject to change.
7395             * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
7396               (default: `#4090ff`)
7397               The resulting sky color will be a dark version of the ColorSpec.
7398               Warning: The darkening of the ColorSpec is subject to change.
7399             * `indoors`: ColorSpec, for when you're either indoors or underground.
7400               (default: `#646464`)
7401             * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
7402               at sunrise and sunset. (default: `#f47d1d`)
7403             * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
7404               at sunrise and sunset. (default: `#7f99cc`)
7405             * `fog_tint_type`: string, changes which mode the directional fog
7406                 abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
7407                 `"default"` uses the classic Minetest sun and moon tinting.
7408                 Will use tonemaps, if set to `"default"`. (default: `"default"`)
7409 * `set_sky(base_color, type, {texture names}, clouds)`
7410     * Deprecated. Use `set_sky(sky_parameters)`
7411     * `base_color`: ColorSpec, defaults to white
7412     * `type`: Available types:
7413         * `"regular"`: Uses 0 textures, `bgcolor` ignored
7414         * `"skybox"`: Uses 6 textures, `bgcolor` used
7415         * `"plain"`: Uses 0 textures, `bgcolor` used
7416     * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
7417       `"plain"` custom skyboxes (default: `true`)
7418 * `get_sky(as_table)`:
7419     * `as_table`: boolean that determines whether the deprecated version of this
7420     function is being used.
7421         * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
7422         * Deprecated: `false` or `nil` returns base_color, type, table of textures,
7423         clouds.
7424 * `get_sky_color()`:
7425     * Deprecated: Use `get_sky(as_table)` instead.
7426     * returns a table with the `sky_color` parameters as in `set_sky`.
7427 * `set_sun(sun_parameters)`:
7428     * Passing no arguments resets the sun to its default values.
7429     * `sun_parameters` is a table with the following optional fields:
7430         * `visible`: Boolean for whether the sun is visible.
7431             (default: `true`)
7432         * `texture`: A regular texture for the sun. Setting to `""`
7433             will re-enable the mesh sun. (default: "sun.png", if it exists)
7434             The texture appears non-rotated at sunrise and rotated 180 degrees
7435             (upside down) at sunset.
7436         * `tonemap`: A 512x1 texture containing the tonemap for the sun
7437             (default: `"sun_tonemap.png"`)
7438         * `sunrise`: A regular texture for the sunrise texture.
7439             (default: `"sunrisebg.png"`)
7440         * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
7441             (default: `true`)
7442         * `scale`: Float controlling the overall size of the sun. (default: `1`)
7443             Note: For legacy reasons, the sun is bigger than the moon by a factor
7444             of about `1.57` for equal `scale` values.
7445 * `get_sun()`: returns a table with the current sun parameters as in
7446     `set_sun`.
7447 * `set_moon(moon_parameters)`:
7448     * Passing no arguments resets the moon to its default values.
7449     * `moon_parameters` is a table with the following optional fields:
7450         * `visible`: Boolean for whether the moon is visible.
7451             (default: `true`)
7452         * `texture`: A regular texture for the moon. Setting to `""`
7453             will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
7454             The texture appears non-rotated at sunrise / moonset and rotated 180
7455             degrees (upside down) at sunset / moonrise.
7456             Note: Relative to the sun, the moon texture is hence rotated by 180°.
7457             You can use the `^[transformR180` texture modifier to achieve the same orientation.
7458         * `tonemap`: A 512x1 texture containing the tonemap for the moon
7459             (default: `"moon_tonemap.png"`)
7460         * `scale`: Float controlling the overall size of the moon (default: `1`)
7461             Note: For legacy reasons, the sun is bigger than the moon by a factor
7462             of about `1.57` for equal `scale` values.
7463 * `get_moon()`: returns a table with the current moon parameters as in
7464     `set_moon`.
7465 * `set_stars(star_parameters)`:
7466     * Passing no arguments resets stars to their default values.
7467     * `star_parameters` is a table with the following optional fields:
7468         * `visible`: Boolean for whether the stars are visible.
7469             (default: `true`)
7470         * `day_opacity`: Float for maximum opacity of stars at day.
7471             No effect if `visible` is false.
7472             (default: 0.0; maximum: 1.0; minimum: 0.0)
7473         * `count`: Integer number to set the number of stars in
7474             the skybox. Only applies to `"skybox"` and `"regular"` sky types.
7475             (default: `1000`)
7476         * `star_color`: ColorSpec, sets the colors of the stars,
7477             alpha channel is used to set overall star brightness.
7478             (default: `#ebebff69`)
7479         * `scale`: Float controlling the overall size of the stars (default: `1`)
7480 * `get_stars()`: returns a table with the current stars parameters as in
7481     `set_stars`.
7482 * `set_clouds(cloud_parameters)`: set cloud parameters
7483     * Passing no arguments resets clouds to their default values.
7484     * `cloud_parameters` is a table with the following optional fields:
7485         * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
7486         * `color`: basic cloud color with alpha channel, ColorSpec
7487           (default `#fff0f0e5`).
7488         * `ambient`: cloud color lower bound, use for a "glow at night" effect.
7489           ColorSpec (alpha ignored, default `#000000`)
7490         * `height`: cloud height, i.e. y of cloud base (default per conf,
7491           usually `120`)
7492         * `thickness`: cloud thickness in nodes (default `16`)
7493         * `speed`: 2D cloud speed + direction in nodes per second
7494           (default `{x=0, z=-2}`).
7495 * `get_clouds()`: returns a table with the current cloud parameters as in
7496   `set_clouds`.
7497 * `override_day_night_ratio(ratio or nil)`
7498     * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
7499       amount.
7500     * `nil`: Disables override, defaulting to sunlight based on day-night cycle
7501 * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
7502 * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
7503   set animation for player model in third person view.
7504     * Every animation equals to a `{x=starting frame, y=ending frame}` table.
7505     * `frame_speed` sets the animations frame speed. Default is 30.
7506 * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
7507   `frame_speed`.
7508 * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
7509   camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
7510     * in first person view
7511     * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
7512 * `get_eye_offset()`: returns first and third person offsets.
7513 * `send_mapblock(blockpos)`:
7514     * Sends an already loaded mapblock to the player.
7515     * Returns `false` if nothing was sent (note that this can also mean that
7516       the client already has the block)
7517     * Resource intensive - use sparsely
7518 * `set_lighting(light_definition)`: sets lighting for the player
7519     * `light_definition` is a table with the following optional fields:
7520       * `saturation` sets the saturation (vividness).
7521           values > 1 increase the saturation
7522           values in [0,1) decrease the saturation
7523             * This value has no effect on clients who have the "Tone Mapping" shader disabled.
7524       * `shadows` is a table that controls ambient shadows
7525         * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
7526             * This value has no effect on clients who have the "Dynamic Shadows" shader disabled.
7527       * `exposure` is a table that controls automatic exposure.
7528         The basic exposure factor equation is `e = 2^exposure_correction / clamp(luminance, 2^luminance_min, 2^luminance_max)`
7529         * `luminance_min` set the lower luminance boundary to use in the calculation
7530         * `luminance_max` set the upper luminance boundary to use in the calculation
7531         * `exposure_correction` correct observed exposure by the given EV value
7532         * `speed_dark_bright` set the speed of adapting to bright light
7533         * `speed_bright_dark` set the speed of adapting to dark scene
7534         * `center_weight_power` set the power factor for center-weighted luminance measurement
7535
7536 * `get_lighting()`: returns the current state of lighting for the player.
7537     * Result is a table with the same fields as `light_definition` in `set_lighting`.
7538 * `respawn()`: Respawns the player using the same mechanism as the death screen,
7539   including calling on_respawnplayer callbacks.
7540
7541 `PcgRandom`
7542 -----------
7543
7544 A 32-bit pseudorandom number generator.
7545 Uses PCG32, an algorithm of the permuted congruential generator family,
7546 offering very strong randomness.
7547
7548 It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
7549
7550 ### Methods
7551
7552 * `next()`: return next integer random number [`-2147483648`...`2147483647`]
7553 * `next(min, max)`: return next integer random number [`min`...`max`]
7554 * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
7555   random number [`min`...`max`].
7556     * This is only a rough approximation of a normal distribution with:
7557     * `mean = (max - min) / 2`, and
7558     * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
7559     * Increasing `num_trials` improves accuracy of the approximation
7560
7561 `PerlinNoise`
7562 -------------
7563
7564 A perlin noise generator.
7565 It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
7566 For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
7567 plus the world seed, to create world-specific noise.
7568
7569 `PerlinNoise(noiseparams)`
7570 `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
7571
7572 `minetest.get_perlin(noiseparams)`
7573 `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
7574
7575 ### Methods
7576
7577 * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
7578 * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
7579
7580 `PerlinNoiseMap`
7581 ----------------
7582
7583 A fast, bulk perlin noise generator.
7584
7585 It can be created via `PerlinNoiseMap(noiseparams, size)` or
7586 `minetest.get_perlin_map(noiseparams, size)`.
7587 For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
7588 plus the world seed, to create world-specific noise.
7589
7590 Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
7591 for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
7592 `nil` is returned).
7593
7594 For each of the functions with an optional `buffer` parameter: If `buffer` is
7595 not nil, this table will be used to store the result instead of creating a new
7596 table.
7597
7598 ### Methods
7599
7600 * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
7601   with values starting at `pos={x=,y=}`
7602 * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
7603   3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
7604 * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
7605   array of 2D noise with values starting at `pos={x=,y=}`
7606 * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
7607 * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
7608   is stored internally.
7609 * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
7610   is stored internally.
7611 * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
7612   returns a slice of the most recently computed noise results. The result slice
7613   begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
7614   E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
7615   offset y = 20:
7616   `noisevals = noise:get_map_slice({y=20}, {y=2})`
7617   It is important to note that `slice_offset` offset coordinates begin at 1,
7618   and are relative to the starting position of the most recently calculated
7619   noise.
7620   To grab a single vertical column of noise starting at map coordinates
7621   x = 1023, y=1000, z = 1000:
7622   `noise:calc_3d_map({x=1000, y=1000, z=1000})`
7623   `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
7624
7625 `PlayerMetaRef`
7626 ---------------
7627
7628 Player metadata.
7629 Uses the same method of storage as the deprecated player attribute API, so
7630 data there will also be in player meta.
7631 Can be obtained using `player:get_meta()`.
7632
7633 ### Methods
7634
7635 * All methods in MetaDataRef
7636
7637 `PseudoRandom`
7638 --------------
7639
7640 A 16-bit pseudorandom number generator.
7641 Uses a well-known LCG algorithm introduced by K&R.
7642
7643 It can be created via `PseudoRandom(seed)`.
7644
7645 ### Methods
7646
7647 * `next()`: return next integer random number [`0`...`32767`]
7648 * `next(min, max)`: return next integer random number [`min`...`max`]
7649     * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
7650       due to the simple implementation making bad distribution otherwise.
7651
7652 `Raycast`
7653 ---------
7654
7655 A raycast on the map. It works with selection boxes.
7656 Can be used as an iterator in a for loop as:
7657
7658     local ray = Raycast(...)
7659     for pointed_thing in ray do
7660         ...
7661     end
7662
7663 The map is loaded as the ray advances. If the map is modified after the
7664 `Raycast` is created, the changes may or may not have an effect on the object.
7665
7666 It can be created via `Raycast(pos1, pos2, objects, liquids)` or
7667 `minetest.raycast(pos1, pos2, objects, liquids)` where:
7668
7669 * `pos1`: start of the ray
7670 * `pos2`: end of the ray
7671 * `objects`: if false, only nodes will be returned. Default is true.
7672 * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
7673              returned. Default is false.
7674
7675 ### Limitations
7676
7677 Raycasts don't always work properly for attached objects as the server has no knowledge of models & bones.
7678
7679 **Rotated selectionboxes paired with `automatic_rotate` are not reliable** either since the server
7680 can't reliably know the total rotation of the objects on different clients (which may differ on a per-client basis).
7681 The server calculates the total rotation incurred through `automatic_rotate` as a "best guess"
7682 assuming the object was active & rotating on the client all the time since its creation.
7683 This may be significantly out of sync with what clients see.
7684 Additionally, network latency and delayed property sending may create a mismatch of client- & server rotations.
7685
7686 In singleplayer mode, raycasts on objects with rotated selectionboxes & automatic rotate will usually only be slightly off;
7687 toggling automatic rotation may however cause errors to add up.
7688
7689 In multiplayer mode, the error may be arbitrarily large.
7690
7691 ### Methods
7692
7693 * `next()`: returns a `pointed_thing` with exact pointing location
7694     * Returns the next thing pointed by the ray or nil.
7695
7696 `SecureRandom`
7697 --------------
7698
7699 Interface for the operating system's crypto-secure PRNG.
7700
7701 It can be created via `SecureRandom()`.  The constructor returns nil if a
7702 secure random device cannot be found on the system.
7703
7704 ### Methods
7705
7706 * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
7707   random bytes, as a string.
7708
7709 `Settings`
7710 ----------
7711
7712 An interface to read config files in the format of `minetest.conf`.
7713
7714 It can be created via `Settings(filename)`.
7715
7716 ### Methods
7717
7718 * `get(key)`: returns a value
7719 * `get_bool(key, [default])`: returns a boolean
7720     * `default` is the value returned if `key` is not found.
7721     * Returns `nil` if `key` is not found and `default` not specified.
7722 * `get_np_group(key)`: returns a NoiseParams table
7723 * `get_flags(key)`:
7724     * Returns `{flag = true/false, ...}` according to the set flags.
7725     * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
7726       flags like `mgv5_spflags`.
7727 * `set(key, value)`
7728     * Setting names can't contain whitespace or any of `="{}#`.
7729     * Setting values can't contain the sequence `\n"""`.
7730     * Setting names starting with "secure." can't be set on the main settings
7731       object (`minetest.settings`).
7732 * `set_bool(key, value)`
7733     * See documentation for set() above.
7734 * `set_np_group(key, value)`
7735     * `value` is a NoiseParams table.
7736     * Also, see documentation for set() above.
7737 * `remove(key)`: returns a boolean (`true` for success)
7738 * `get_names()`: returns `{key1,...}`
7739 * `write()`: returns a boolean (`true` for success)
7740     * Writes changes to file.
7741 * `to_table()`: returns `{[key1]=value1,...}`
7742
7743 ### Format
7744
7745 The settings have the format `key = value`. Example:
7746
7747     foo = example text
7748     bar = """
7749     Multiline
7750     value
7751     """
7752
7753
7754 `StorageRef`
7755 ------------
7756
7757 Mod metadata: per mod metadata, saved automatically.
7758 Can be obtained via `minetest.get_mod_storage()` during load time.
7759
7760 WARNING: This storage backend is incapable of saving raw binary data due
7761 to restrictions of JSON.
7762
7763 ### Methods
7764
7765 * All methods in MetaDataRef
7766
7767
7768
7769
7770 Definition tables
7771 =================
7772
7773 Object properties
7774 -----------------
7775
7776 Used by `ObjectRef` methods. Part of an Entity definition.
7777 These properties are not persistent, but are applied automatically to the
7778 corresponding Lua entity using the given registration fields.
7779 Player properties need to be saved manually.
7780
7781     {
7782         hp_max = 10,
7783         -- Defines the maximum and default HP of the entity
7784         -- For Lua entities the maximum is not enforced.
7785         -- For players this defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
7786
7787         breath_max = 0,
7788         -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
7789
7790         zoom_fov = 0.0,
7791         -- For players only. Zoom FOV in degrees.
7792         -- Note that zoom loads and/or generates world beyond the server's
7793         -- maximum send and generate distances, so acts like a telescope.
7794         -- Smaller zoom_fov values increase the distance loaded/generated.
7795         -- Defaults to 15 in creative mode, 0 in survival mode.
7796         -- zoom_fov = 0 disables zooming for the player.
7797
7798         eye_height = 1.625,
7799         -- For players only. Camera height above feet position in nodes.
7800
7801         physical = false,
7802         -- Collide with `walkable` nodes.
7803
7804         collide_with_objects = true,
7805         -- Collide with other objects if physical = true
7806
7807         collisionbox = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },  -- default
7808         selectionbox = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, rotate = false },
7809         -- { xmin, ymin, zmin, xmax, ymax, zmax } in nodes from object position.
7810         -- Collision boxes cannot rotate, setting `rotate = true` on it has no effect.
7811         -- If not set, the selection box copies the collision box, and will also not rotate.
7812         -- If `rotate = false`, the selection box will not rotate with the object itself, remaining fixed to the axes.
7813         -- If `rotate = true`, it will match the object's rotation and any attachment rotations.
7814         -- Raycasts use the selection box and object's rotation, but do *not* obey attachment rotations.
7815
7816
7817         pointable = true,
7818         -- Whether the object can be pointed at
7819
7820         visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
7821         -- "cube" is a node-sized cube.
7822         -- "sprite" is a flat texture always facing the player.
7823         -- "upright_sprite" is a vertical flat texture.
7824         -- "mesh" uses the defined mesh model.
7825         -- "wielditem" is used for dropped items.
7826         --   (see builtin/game/item_entity.lua).
7827         --   For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
7828         --   If the item has a 'wield_image' the object will be an extrusion of
7829         --   that, otherwise:
7830         --   If 'itemname' is a cubic node or nodebox the object will appear
7831         --   identical to 'itemname'.
7832         --   If 'itemname' is a plantlike node the object will be an extrusion
7833         --   of its texture.
7834         --   Otherwise for non-node items, the object will be an extrusion of
7835         --   'inventory_image'.
7836         --   If 'itemname' contains a ColorString or palette index (e.g. from
7837         --   `minetest.itemstring_with_palette()`), the entity will inherit the color.
7838         -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
7839
7840         visual_size = {x = 1, y = 1, z = 1},
7841         -- Multipliers for the visual size. If `z` is not specified, `x` will be used
7842         -- to scale the entity along both horizontal axes.
7843
7844         mesh = "model.obj",
7845         -- File name of mesh when using "mesh" visual
7846
7847         textures = {},
7848         -- Number of required textures depends on visual.
7849         -- "cube" uses 6 textures just like a node, but all 6 must be defined.
7850         -- "sprite" uses 1 texture.
7851         -- "upright_sprite" uses 2 textures: {front, back}.
7852         -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
7853         -- "mesh" requires one texture for each mesh buffer/material (in order)
7854
7855         colors = {},
7856         -- Number of required colors depends on visual
7857
7858         use_texture_alpha = false,
7859         -- Use texture's alpha channel.
7860         -- Excludes "upright_sprite" and "wielditem".
7861         -- Note: currently causes visual issues when viewed through other
7862         -- semi-transparent materials such as water.
7863
7864         spritediv = {x = 1, y = 1},
7865         -- Used with spritesheet textures for animation and/or frame selection
7866         -- according to position relative to player.
7867         -- Defines the number of columns and rows in the spritesheet:
7868         -- {columns, rows}.
7869
7870         initial_sprite_basepos = {x = 0, y = 0},
7871         -- Used with spritesheet textures.
7872         -- Defines the {column, row} position of the initially used frame in the
7873         -- spritesheet.
7874
7875         is_visible = true,
7876         -- If false, object is invisible and can't be pointed.
7877
7878         makes_footstep_sound = false,
7879         -- If true, is able to make footstep sounds of nodes
7880         -- (see node sound definition for details).
7881
7882         automatic_rotate = 0,
7883         -- Set constant rotation in radians per second, positive or negative.
7884         -- Object rotates along the local Y-axis, and works with set_rotation.
7885         -- Set to 0 to disable constant rotation.
7886
7887         stepheight = 0,
7888         -- If positive number, object will climb upwards when it moves
7889         -- horizontally against a `walkable` node, if the height difference
7890         -- is within `stepheight`.
7891
7892         automatic_face_movement_dir = 0.0,
7893         -- Automatically set yaw to movement direction, offset in degrees.
7894         -- 'false' to disable.
7895
7896         automatic_face_movement_max_rotation_per_sec = -1,
7897         -- Limit automatic rotation to this value in degrees per second.
7898         -- No limit if value <= 0.
7899
7900         backface_culling = true,
7901         -- Set to false to disable backface_culling for model
7902
7903         glow = 0,
7904         -- Add this much extra lighting when calculating texture color.
7905         -- Value < 0 disables light's effect on texture color.
7906         -- For faking self-lighting, UI style entities, or programmatic coloring
7907         -- in mods.
7908
7909         nametag = "",
7910         -- The name to display on the head of the object. By default empty.
7911         -- If the object is a player, a nil or empty nametag is replaced by the player's name.
7912         -- For all other objects, a nil or empty string removes the nametag.
7913         -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
7914
7915         nametag_color = <ColorSpec>,
7916         -- Sets text color of nametag
7917
7918         nametag_bgcolor = <ColorSpec>,
7919         -- Sets background color of nametag
7920         -- `false` will cause the background to be set automatically based on user settings.
7921         -- Default: false
7922
7923         infotext = "",
7924         -- Same as infotext for nodes. Empty by default
7925
7926         static_save = true,
7927         -- If false, never save this object statically. It will simply be
7928         -- deleted when the block gets unloaded.
7929         -- The get_staticdata() callback is never called then.
7930         -- Defaults to 'true'.
7931
7932         damage_texture_modifier = "^[brighten",
7933         -- Texture modifier to be applied for a short duration when object is hit
7934
7935         shaded = true,
7936         -- Setting this to 'false' disables diffuse lighting of entity
7937
7938         show_on_minimap = false,
7939         -- Defaults to true for players, false for other entities.
7940         -- If set to true the entity will show as a marker on the minimap.
7941     }
7942
7943 Entity definition
7944 -----------------
7945
7946 Used by `minetest.register_entity`.
7947
7948     {
7949         initial_properties = {
7950             visual = "mesh",
7951             mesh = "boats_boat.obj",
7952             ...,
7953         },
7954         -- A table of object properties, see the `Object properties` section.
7955         -- The properties in this table are applied to the object
7956         -- once when it is spawned.
7957
7958         -- Refer to the "Registered entities" section for explanations
7959         on_activate = function(self, staticdata, dtime_s),
7960         on_deactivate = function(self, removal),
7961         on_step = function(self, dtime, moveresult),
7962         on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage),
7963         on_death = function(self, killer),
7964         on_rightclick = function(self, clicker),
7965         on_attach_child = function(self, child),
7966         on_detach_child = function(self, child),
7967         on_detach = function(self, parent),
7968         get_staticdata = function(self),
7969
7970         _custom_field = whatever,
7971         -- You can define arbitrary member variables here (see Item definition
7972         -- for more info) by using a '_' prefix
7973     }
7974
7975
7976 ABM (ActiveBlockModifier) definition
7977 ------------------------------------
7978
7979 Used by `minetest.register_abm`.
7980
7981     {
7982         label = "Lava cooling",
7983         -- Descriptive label for profiling purposes (optional).
7984         -- Definitions with identical labels will be listed as one.
7985
7986         nodenames = {"default:lava_source"},
7987         -- Apply `action` function to these nodes.
7988         -- `group:groupname` can also be used here.
7989
7990         neighbors = {"default:water_source", "default:water_flowing"},
7991         -- Only apply `action` to nodes that have one of, or any
7992         -- combination of, these neighbors.
7993         -- If left out or empty, any neighbor will do.
7994         -- `group:groupname` can also be used here.
7995
7996         interval = 10.0,
7997         -- Operation interval in seconds
7998
7999         chance = 50,
8000         -- Chance of triggering `action` per-node per-interval is 1.0 / chance
8001
8002         min_y = -32768,
8003         max_y = 32767,
8004         -- min and max height levels where ABM will be processed (inclusive)
8005         -- can be used to reduce CPU usage
8006
8007         catch_up = true,
8008         -- If true, catch-up behavior is enabled: The `chance` value is
8009         -- temporarily reduced when returning to an area to simulate time lost
8010         -- by the area being unattended. Note that the `chance` value can often
8011         -- be reduced to 1.
8012
8013         action = function(pos, node, active_object_count, active_object_count_wider),
8014         -- Function triggered for each qualifying node.
8015         -- `active_object_count` is number of active objects in the node's
8016         -- mapblock.
8017         -- `active_object_count_wider` is number of active objects in the node's
8018         -- mapblock plus all 26 neighboring mapblocks. If any neighboring
8019         -- mapblocks are unloaded an estimate is calculated for them based on
8020         -- loaded mapblocks.
8021     }
8022
8023 LBM (LoadingBlockModifier) definition
8024 -------------------------------------
8025
8026 Used by `minetest.register_lbm`.
8027
8028 A loading block modifier (LBM) is used to define a function that is called for
8029 specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
8030 gets activated (not loaded!)
8031
8032     {
8033         label = "Upgrade legacy doors",
8034         -- Descriptive label for profiling purposes (optional).
8035         -- Definitions with identical labels will be listed as one.
8036
8037         name = "modname:replace_legacy_door",
8038         -- Identifier of the LBM, should follow the modname:<whatever> convention
8039
8040         nodenames = {"default:lava_source"},
8041         -- List of node names to trigger the LBM on.
8042         -- Names of non-registered nodes and groups (as group:groupname)
8043         -- will work as well.
8044
8045         run_at_every_load = false,
8046         -- Whether to run the LBM's action every time a block gets activated,
8047         -- and not only the first time the block gets activated after the LBM
8048         -- was introduced.
8049
8050         action = function(pos, node, dtime_s),
8051         -- Function triggered for each qualifying node.
8052         -- `dtime_s` is the in-game time (in seconds) elapsed since the block
8053         -- was last active
8054     }
8055
8056 Tile definition
8057 ---------------
8058
8059 * `"image.png"`
8060 * `{name="image.png", animation={Tile Animation definition}}`
8061 * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
8062     * backface culling enabled by default for most nodes
8063     * align style determines whether the texture will be rotated with the node
8064       or kept aligned with its surroundings. "user" means that client
8065       setting will be used, similar to `glasslike_framed_optional`.
8066       Note: supported by solid nodes and nodeboxes only.
8067     * scale is used to make texture span several (exactly `scale`) nodes,
8068       instead of just one, in each direction. Works for world-aligned
8069       textures only.
8070       Note that as the effect is applied on per-mapblock basis, `16` should
8071       be equally divisible by `scale` or you may get wrong results.
8072 * `{name="image.png", color=ColorSpec}`
8073     * the texture's color will be multiplied with this color.
8074     * the tile's color overrides the owning node's color in all cases.
8075 * deprecated, yet still supported field names:
8076     * `image` (name)
8077
8078 Tile animation definition
8079 -------------------------
8080
8081     {
8082         type = "vertical_frames",
8083
8084         aspect_w = 16,
8085         -- Width of a frame in pixels
8086
8087         aspect_h = 16,
8088         -- Height of a frame in pixels
8089
8090         length = 3.0,
8091         -- Full loop length
8092     }
8093
8094     {
8095         type = "sheet_2d",
8096
8097         frames_w = 5,
8098         -- Width in number of frames
8099
8100         frames_h = 3,
8101         -- Height in number of frames
8102
8103         frame_length = 0.5,
8104         -- Length of a single frame
8105     }
8106
8107 Item definition
8108 ---------------
8109
8110 Used by `minetest.register_node`, `minetest.register_craftitem`, and
8111 `minetest.register_tool`.
8112
8113     {
8114         description = "",
8115         -- Can contain new lines. "\n" has to be used as new line character.
8116         -- See also: `get_description` in [`ItemStack`]
8117
8118         short_description = "",
8119         -- Must not contain new lines.
8120         -- Defaults to nil.
8121         -- Use an [`ItemStack`] to get the short description, e.g.:
8122         --   ItemStack(itemname):get_short_description()
8123
8124         groups = {},
8125         -- key = name, value = rating; rating = <number>.
8126         -- If rating not applicable, use 1.
8127         -- e.g. {wool = 1, fluffy = 3}
8128         --      {soil = 2, outerspace = 1, crumbly = 1}
8129         --      {bendy = 2, snappy = 1},
8130         --      {hard = 1, metal = 1, spikes = 1}
8131
8132         inventory_image = "",
8133         -- Texture shown in the inventory GUI
8134         -- Defaults to a 3D rendering of the node if left empty.
8135
8136         inventory_overlay = "",
8137         -- An overlay texture which is not affected by colorization
8138
8139         wield_image = "",
8140         -- Texture shown when item is held in hand
8141         -- Defaults to a 3D rendering of the node if left empty.
8142
8143         wield_overlay = "",
8144         -- Like inventory_overlay but only used in the same situation as wield_image
8145
8146         wield_scale = {x = 1, y = 1, z = 1},
8147         -- Scale for the item when held in hand
8148
8149         palette = "",
8150         -- An image file containing the palette of a node.
8151         -- You can set the currently used color as the "palette_index" field of
8152         -- the item stack metadata.
8153         -- The palette is always stretched to fit indices between 0 and 255, to
8154         -- ensure compatibility with "colorfacedir" (and similar) nodes.
8155
8156         color = "#ffffffff",
8157         -- Color the item is colorized with. The palette overrides this.
8158
8159         stack_max = 99,
8160         -- Maximum amount of items that can be in a single stack.
8161         -- The default can be changed by the setting `default_stack_max`
8162
8163         range = 4.0,
8164         -- Range of node and object pointing that is possible with this item held
8165
8166         liquids_pointable = false,
8167         -- If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
8168         -- even those for which `pointable = false`
8169
8170         light_source = 0,
8171         -- When used for nodes: Defines amount of light emitted by node.
8172         -- Otherwise: Defines texture glow when viewed as a dropped item
8173         -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
8174         -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
8175         -- behavior.
8176
8177         -- See "Tool Capabilities" section for an example including explanation
8178         tool_capabilities = {
8179             full_punch_interval = 1.0,
8180             max_drop_level = 0,
8181             groupcaps = {
8182                 -- For example:
8183                 choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
8184             },
8185             damage_groups = {groupname = damage},
8186             -- Damage values must be between -32768 and 32767 (2^15)
8187
8188             punch_attack_uses = nil,
8189             -- Amount of uses this tool has for attacking players and entities
8190             -- by punching them (0 = infinite uses).
8191             -- For compatibility, this is automatically set from the first
8192             -- suitable groupcap using the formula "uses * 3^(maxlevel - 1)".
8193             -- It is recommend to set this explicitly instead of relying on the
8194             -- fallback behavior.
8195         },
8196
8197         node_placement_prediction = nil,
8198         -- If nil and item is node, prediction is made automatically.
8199         -- If nil and item is not a node, no prediction is made.
8200         -- If "" and item is anything, no prediction is made.
8201         -- Otherwise should be name of node which the client immediately places
8202         -- on ground when the player places the item. Server will always update
8203         -- with actual result shortly.
8204
8205         node_dig_prediction = "air",
8206         -- if "", no prediction is made.
8207         -- if "air", node is removed.
8208         -- Otherwise should be name of node which the client immediately places
8209         -- upon digging. Server will always update with actual result shortly.
8210
8211         sound = {
8212             -- Definition of item sounds to be played at various events.
8213             -- All fields in this table are optional.
8214
8215             breaks = <SimpleSoundSpec>,
8216             -- When tool breaks due to wear. Ignored for non-tools
8217
8218             eat = <SimpleSoundSpec>,
8219             -- When item is eaten with `minetest.do_item_eat`
8220
8221             punch_use = <SimpleSoundSpec>,
8222             -- When item is used with the 'punch/mine' key pointing at a node or entity
8223
8224             punch_use_air = <SimpleSoundSpec>,
8225             -- When item is used with the 'punch/mine' key pointing at nothing (air)
8226         },
8227
8228         on_place = function(itemstack, placer, pointed_thing),
8229         -- When the 'place' key was pressed with the item one of the hands
8230         -- and a node was pointed at.
8231         -- 'itemstack' may be the offhand item in cases where the main hand has
8232         -- no on_place handler and no node_placement_prediction.
8233         -- Shall place item and return the leftover itemstack
8234         -- or nil to not modify the inventory.
8235         -- The placer may be any ObjectRef or nil.
8236         -- default: minetest.item_place
8237
8238         on_secondary_use = function(itemstack, user, pointed_thing),
8239         -- Same as on_place but called when not pointing at a node,
8240         -- whereas `user` is the same as `placer` above.
8241         -- default: nil
8242
8243         on_drop = function(itemstack, dropper, pos),
8244         -- Shall drop item and return the leftover itemstack.
8245         -- The dropper may be any ObjectRef or nil.
8246         -- default: minetest.item_drop
8247
8248         on_pickup = function(itemstack, picker, pointed_thing, time_from_last_punch, ...),
8249         -- Called when a dropped item is punched by a player.
8250         -- Shall pick-up the item and return the leftover itemstack or nil to not
8251         -- modify the dropped item.
8252         -- Parameters:
8253         -- * `itemstack`: The `ItemStack` to be picked up.
8254         -- * `picker`: Any `ObjectRef` or `nil`.
8255         -- * `pointed_thing` (optional): The dropped item (a `"__builtin:item"`
8256         --   luaentity) as `type="object"` `pointed_thing`.
8257         -- * `time_from_last_punch, ...` (optional): Other parameters from
8258         --   `luaentity:on_punch`.
8259         -- default: `minetest.item_pickup`
8260
8261         on_use = function(itemstack, user, pointed_thing),
8262         -- default: nil
8263         -- When user pressed the 'punch/mine' key with the item in hand.
8264         -- Function must return either nil if inventory shall not be modified,
8265         -- or an itemstack to replace the original itemstack.
8266         -- e.g. itemstack:take_item(); return itemstack
8267         -- Otherwise, the function is free to do what it wants.
8268         -- The user may be any ObjectRef or nil.
8269         -- The default functions handle regular use cases.
8270
8271         after_use = function(itemstack, user, node, digparams),
8272         -- default: nil
8273         -- If defined, should return an itemstack and will be called instead of
8274         -- wearing out the item (if tool). If returns nil, does nothing.
8275         -- If after_use doesn't exist, it is the same as:
8276         --   function(itemstack, user, node, digparams)
8277         --     itemstack:add_wear(digparams.wear)
8278         --     return itemstack
8279         --   end
8280         -- The user may be any ObjectRef or nil.
8281
8282         _custom_field = whatever,
8283         -- Add your own custom fields. By convention, all custom field names
8284         -- should start with `_` to avoid naming collisions with future engine
8285         -- usage.
8286     }
8287
8288 Node definition
8289 ---------------
8290
8291 Used by `minetest.register_node`.
8292
8293     {
8294         -- <all fields allowed in item definitions>
8295
8296         drawtype = "normal",  -- See "Node drawtypes"
8297
8298         visual_scale = 1.0,
8299         -- Supported for drawtypes "plantlike", "signlike", "torchlike",
8300         -- "firelike", "mesh", "nodebox", "allfaces".
8301         -- For plantlike and firelike, the image will start at the bottom of the
8302         -- node. For torchlike, the image will start at the surface to which the
8303         -- node "attaches". For the other drawtypes the image will be centered
8304         -- on the node.
8305
8306         tiles = {tile definition 1, def2, def3, def4, def5, def6},
8307         -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
8308         -- List can be shortened to needed length.
8309
8310         overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
8311         -- Same as `tiles`, but these textures are drawn on top of the base
8312         -- tiles. You can use this to colorize only specific parts of your
8313         -- texture. If the texture name is an empty string, that overlay is not
8314         -- drawn. Since such tiles are drawn twice, it is not recommended to use
8315         -- overlays on very common nodes.
8316
8317         special_tiles = {tile definition 1, Tile definition 2},
8318         -- Special textures of node; used rarely.
8319         -- List can be shortened to needed length.
8320
8321         color = ColorSpec,
8322         -- The node's original color will be multiplied with this color.
8323         -- If the node has a palette, then this setting only has an effect in
8324         -- the inventory and on the wield item.
8325
8326         use_texture_alpha = ...,
8327         -- Specifies how the texture's alpha channel will be used for rendering.
8328         -- possible values:
8329         -- * "opaque": Node is rendered opaque regardless of alpha channel
8330         -- * "clip": A given pixel is either fully see-through or opaque
8331         --           depending on the alpha channel being below/above 50% in value
8332         -- * "blend": The alpha channel specifies how transparent a given pixel
8333         --            of the rendered node is
8334         -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
8335         -- "clip" otherwise.
8336         -- If set to a boolean value (deprecated): true either sets it to blend
8337         -- or clip, false sets it to clip or opaque mode depending on the drawtype.
8338
8339         palette = "",
8340         -- The node's `param2` is used to select a pixel from the image.
8341         -- Pixels are arranged from left to right and from top to bottom.
8342         -- The node's color will be multiplied with the selected pixel's color.
8343         -- Tiles can override this behavior.
8344         -- Only when `paramtype2` supports palettes.
8345
8346         post_effect_color = "#00000000",
8347         -- Screen tint if player is inside node, see "ColorSpec"
8348
8349         paramtype = "none",  -- See "Nodes"
8350
8351         paramtype2 = "none",  -- See "Nodes"
8352
8353         place_param2 = 0,
8354         -- Value for param2 that is set when player places node
8355
8356         is_ground_content = true,
8357         -- If false, the cave generator and dungeon generator will not carve
8358         -- through this node.
8359         -- Specifically, this stops mod-added nodes being removed by caves and
8360         -- dungeons when those generate in a neighbor mapchunk and extend out
8361         -- beyond the edge of that mapchunk.
8362
8363         sunlight_propagates = false,
8364         -- If true, sunlight will go infinitely through this node
8365
8366         walkable = true,  -- If true, objects collide with node
8367
8368         pointable = true,  -- If true, can be pointed at
8369
8370         diggable = true,  -- If false, can never be dug
8371
8372         climbable = false,  -- If true, can be climbed on like a ladder
8373
8374         move_resistance = 0,
8375         -- Slows down movement of players through this node (max. 7).
8376         -- If this is nil, it will be equal to liquid_viscosity.
8377         -- Note: If liquid movement physics apply to the node
8378         -- (see `liquid_move_physics`), the movement speed will also be
8379         -- affected by the `movement_liquid_*` settings.
8380
8381         buildable_to = false,  -- If true, placed nodes can replace this node
8382
8383         floodable = false,
8384         -- If true, liquids flow into and replace this node.
8385         -- Warning: making a liquid node 'floodable' will cause problems.
8386
8387         liquidtype = "none",  -- specifies liquid flowing physics
8388         -- * "none":    no liquid flowing physics
8389         -- * "source":  spawns flowing liquid nodes at all 4 sides and below;
8390         --              recommended drawtype: "liquid".
8391         -- * "flowing": spawned from source, spawns more flowing liquid nodes
8392         --              around it until `liquid_range` is reached;
8393         --              will drain out without a source;
8394         --              recommended drawtype: "flowingliquid".
8395         -- If it's "source" or "flowing", then the
8396         -- `liquid_alternative_*` fields _must_ be specified
8397
8398         liquid_alternative_flowing = "",
8399         liquid_alternative_source = "",
8400         -- These fields may contain node names that represent the
8401         -- flowing version (`liquid_alternative_flowing`) and
8402         -- source version (`liquid_alternative_source`) of a liquid.
8403         --
8404         -- Specifically, these fields are required if any of these is true:
8405         -- * `liquidtype ~= "none" or
8406         -- * `drawtype == "liquid" or
8407         -- * `drawtype == "flowingliquid"
8408         --
8409         -- Liquids consist of up to two nodes: source and flowing.
8410         --
8411         -- There are two ways to define a liquid:
8412         -- 1) Source node and flowing node. This requires both fields to be
8413         --    specified for both nodes.
8414         -- 2) Standalone source node (cannot flow). `liquid_alternative_source`
8415         --    must be specified and `liquid_range` must be set to 0.
8416         --
8417         -- Example:
8418         --     liquid_alternative_flowing = "example:water_flowing",
8419         --     liquid_alternative_source = "example:water_source",
8420
8421         liquid_viscosity = 0,
8422         -- Controls speed at which the liquid spreads/flows (max. 7).
8423         -- 0 is fastest, 7 is slowest.
8424         -- By default, this also slows down movement of players inside the node
8425         -- (can be overridden using `move_resistance`)
8426
8427         liquid_renewable = true,
8428         -- If true, a new liquid source can be created by placing two or more
8429         -- sources nearby
8430
8431         liquid_move_physics = nil, -- specifies movement physics if inside node
8432         -- * false: No liquid movement physics apply.
8433         -- * true: Enables liquid movement physics. Enables things like
8434         --   ability to "swim" up/down, sinking slowly if not moving,
8435         --   smoother speed change when falling into, etc. The `movement_liquid_*`
8436         --   settings apply.
8437         -- * nil: Will be treated as true if `liquidtype ~= "none"`
8438         --   and as false otherwise.
8439
8440         leveled = 0,
8441         -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
8442         -- Allows defining the nodebox height without using param2.
8443         -- The nodebox height is 'leveled' / 64 nodes.
8444         -- The maximum value of 'leveled' is `leveled_max`.
8445
8446         leveled_max = 127,
8447         -- Maximum value for `leveled` (0-127), enforced in
8448         -- `minetest.set_node_level` and `minetest.add_node_level`.
8449         -- Values above 124 might causes collision detection issues.
8450
8451         liquid_range = 8,
8452         -- Maximum distance that flowing liquid nodes can spread around
8453         -- source on flat land;
8454         -- maximum = 8; set to 0 to disable liquid flow
8455
8456         drowning = 0,
8457         -- Player will take this amount of damage if no bubbles are left
8458
8459         damage_per_second = 0,
8460         -- If player is inside node, this damage is caused
8461
8462         node_box = {type = "regular"},  -- See "Node boxes"
8463
8464         connects_to = {},
8465         -- Used for nodebox nodes with the type == "connected".
8466         -- Specifies to what neighboring nodes connections will be drawn.
8467         -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
8468
8469         connect_sides = {},
8470         -- Tells connected nodebox nodes to connect only to these sides of this
8471         -- node. possible: "top", "bottom", "front", "left", "back", "right"
8472
8473         mesh = "",
8474         -- File name of mesh when using "mesh" drawtype
8475
8476         selection_box = {
8477             -- see [Node boxes] for possibilities
8478         },
8479         -- Custom selection box definition. Multiple boxes can be defined.
8480         -- If "nodebox" drawtype is used and selection_box is nil, then node_box
8481         -- definition is used for the selection box.
8482
8483         collision_box = {
8484             -- see [Node boxes] for possibilities
8485         },
8486         -- Custom collision box definition. Multiple boxes can be defined.
8487         -- If "nodebox" drawtype is used and collision_box is nil, then node_box
8488         -- definition is used for the collision box.
8489
8490         -- Support maps made in and before January 2012
8491         legacy_facedir_simple = false,
8492         legacy_wallmounted = false,
8493
8494         waving = 0,
8495         -- Valid for drawtypes:
8496         -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
8497         -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
8498         -- 2 - wave node like leaves (whole node moves side-to-side)
8499         -- 3 - wave node like liquids (whole node moves up and down)
8500         -- Not all models will properly wave.
8501         -- plantlike drawtype can only wave like plants.
8502         -- allfaces_optional drawtype can only wave like leaves.
8503         -- liquid, flowingliquid drawtypes can only wave like liquids.
8504
8505         sounds = {
8506             -- Definition of node sounds to be played at various events.
8507             -- All fields in this table are optional.
8508
8509             footstep = <SimpleSoundSpec>,
8510             -- If walkable, played when object walks on it. If node is
8511             -- climbable or a liquid, played when object moves through it
8512
8513             dig = <SimpleSoundSpec> or "__group",
8514             -- While digging node.
8515             -- If `"__group"`, then the sound will be
8516             -- `{name = "default_dig_<groupname>", gain = 0.5}` , where `<groupname>` is the
8517             -- name of the item's digging group with the fastest digging time.
8518             -- In case of a tie, one of the sounds will be played (but we
8519             -- cannot predict which one)
8520             -- Default value: `"__group"`
8521
8522             dug = <SimpleSoundSpec>,
8523             -- Node was dug
8524
8525             place = <SimpleSoundSpec>,
8526             -- Node was placed. Also played after falling
8527
8528             place_failed = <SimpleSoundSpec>,
8529             -- When node placement failed.
8530             -- Note: This happens if the _built-in_ node placement failed.
8531             -- This sound will still be played if the node is placed in the
8532             -- `on_place` callback manually.
8533
8534             fall = <SimpleSoundSpec>,
8535             -- When node starts to fall or is detached
8536         },
8537
8538         drop = "",
8539         -- Name of dropped item when dug.
8540         -- Default dropped item is the node itself.
8541
8542         -- Using a table allows multiple items, drop chances and item filtering:
8543         drop = {
8544             max_items = 1,
8545             -- Maximum number of item lists to drop.
8546             -- The entries in 'items' are processed in order. For each:
8547             -- Item filtering is applied, chance of drop is applied, if both are
8548             -- successful the entire item list is dropped.
8549             -- Entry processing continues until the number of dropped item lists
8550             -- equals 'max_items'.
8551             -- Therefore, entries should progress from low to high drop chance.
8552             items = {
8553                 -- Examples:
8554                 {
8555                     -- 1 in 1000 chance of dropping a diamond.
8556                     -- Default rarity is '1'.
8557                     rarity = 1000,
8558                     items = {"default:diamond"},
8559                 },
8560                 {
8561                     -- Only drop if using an item whose name is identical to one
8562                     -- of these.
8563                     tools = {"default:shovel_mese", "default:shovel_diamond"},
8564                     rarity = 5,
8565                     items = {"default:dirt"},
8566                     -- Whether all items in the dropped item list inherit the
8567                     -- hardware coloring palette color from the dug node.
8568                     -- Default is 'false'.
8569                     inherit_color = true,
8570                 },
8571                 {
8572                     -- Only drop if using an item whose name contains
8573                     -- "default:shovel_" (this item filtering by string matching
8574                     -- is deprecated, use tool_groups instead).
8575                     tools = {"~default:shovel_"},
8576                     rarity = 2,
8577                     -- The item list dropped.
8578                     items = {"default:sand", "default:desert_sand"},
8579                 },
8580                 {
8581                     -- Only drop if using an item in the "magicwand" group, or
8582                     -- an item that is in both the "pickaxe" and the "lucky"
8583                     -- groups.
8584                     tool_groups = {
8585                         "magicwand",
8586                         {"pickaxe", "lucky"}
8587                     },
8588                     items = {"default:coal_lump"},
8589                 },
8590             },
8591         },
8592
8593         on_construct = function(pos),
8594         -- Node constructor; called after adding node.
8595         -- Can set up metadata and stuff like that.
8596         -- Not called for bulk node placement (i.e. schematics and VoxelManip).
8597         -- Note: Within an on_construct callback, minetest.set_node can cause an
8598         -- infinite loop if it invokes the same callback.
8599         --  Consider using minetest.swap_node instead.
8600         -- default: nil
8601
8602         on_destruct = function(pos),
8603         -- Node destructor; called before removing node.
8604         -- Not called for bulk node placement.
8605         -- default: nil
8606
8607         after_destruct = function(pos, oldnode),
8608         -- Node destructor; called after removing node.
8609         -- Not called for bulk node placement.
8610         -- default: nil
8611
8612         on_flood = function(pos, oldnode, newnode),
8613         -- Called when a liquid (newnode) is about to flood oldnode, if it has
8614         -- `floodable = true` in the nodedef. Not called for bulk node placement
8615         -- (i.e. schematics and VoxelManip) or air nodes. If return true the
8616         -- node is not flooded, but on_flood callback will most likely be called
8617         -- over and over again every liquid update interval.
8618         -- Default: nil
8619         -- Warning: making a liquid node 'floodable' will cause problems.
8620
8621         preserve_metadata = function(pos, oldnode, oldmeta, drops),
8622         -- Called when oldnode is about be converted to an item, but before the
8623         -- node is deleted from the world or the drops are added. This is
8624         -- generally the result of either the node being dug or an attached node
8625         -- becoming detached.
8626         -- oldmeta are the metadata fields (table) of the node before deletion.
8627         -- drops is a table of ItemStacks, so any metadata to be preserved can
8628         -- be added directly to one or more of the dropped items. See
8629         -- "ItemStackMetaRef".
8630         -- default: nil
8631
8632         after_place_node = function(pos, placer, itemstack, pointed_thing),
8633         -- Called after constructing node when node was placed using
8634         -- minetest.item_place_node / minetest.place_node.
8635         -- If return true no item is taken from itemstack.
8636         -- `placer` may be any valid ObjectRef or nil.
8637         -- default: nil
8638
8639         after_dig_node = function(pos, oldnode, oldmetadata, digger),
8640         -- oldmetadata is in table format.
8641         -- Called after destructing node when node was dug using
8642         -- minetest.node_dig / minetest.dig_node.
8643         -- default: nil
8644
8645         can_dig = function(pos, [player]),
8646         -- Returns true if node can be dug, or false if not.
8647         -- default: nil
8648
8649         on_punch = function(pos, node, puncher, pointed_thing),
8650         -- default: minetest.node_punch
8651         -- Called when puncher (an ObjectRef) punches the node at pos.
8652         -- By default calls minetest.register_on_punchnode callbacks.
8653
8654         on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
8655         -- default: nil
8656         -- Called when clicker (an ObjectRef) used the 'place/build' key
8657         -- (not necessarily an actual rightclick)
8658         -- while pointing at the node at pos with 'node' being the node table.
8659         -- itemstack will hold clicker's wielded item.
8660         -- Shall return the leftover itemstack.
8661         -- Note: pointed_thing can be nil, if a mod calls this function.
8662         -- This function does not get triggered by clients <=0.4.16 if the
8663         -- "formspec" node metadata field is set.
8664
8665         on_dig = function(pos, node, digger),
8666         -- default: minetest.node_dig
8667         -- By default checks privileges, wears out item (if tool) and removes node.
8668         -- return true if the node was dug successfully, false otherwise.
8669         -- Deprecated: returning nil is the same as returning true.
8670
8671         on_timer = function(pos, elapsed),
8672         -- default: nil
8673         -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
8674         -- elapsed is the total time passed since the timer was started.
8675         -- return true to run the timer for another cycle with the same timeout
8676         -- value.
8677
8678         on_receive_fields = function(pos, formname, fields, sender),
8679         -- fields = {name1 = value1, name2 = value2, ...}
8680         -- Called when an UI form (e.g. sign text input) returns data.
8681         -- See minetest.register_on_player_receive_fields for more info.
8682         -- default: nil
8683
8684         allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8685         -- Called when a player wants to move items inside the inventory.
8686         -- Return value: number of items allowed to move.
8687
8688         allow_metadata_inventory_put = function(pos, listname, index, stack, player),
8689         -- Called when a player wants to put something into the inventory.
8690         -- Return value: number of items allowed to put.
8691         -- Return value -1: Allow and don't modify item count in inventory.
8692
8693         allow_metadata_inventory_take = function(pos, listname, index, stack, player),
8694         -- Called when a player wants to take something out of the inventory.
8695         -- Return value: number of items allowed to take.
8696         -- Return value -1: Allow and don't modify item count in inventory.
8697
8698         on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8699         on_metadata_inventory_put = function(pos, listname, index, stack, player),
8700         on_metadata_inventory_take = function(pos, listname, index, stack, player),
8701         -- Called after the actual action has happened, according to what was
8702         -- allowed.
8703         -- No return value.
8704
8705         on_blast = function(pos, intensity),
8706         -- intensity: 1.0 = mid range of regular TNT.
8707         -- If defined, called when an explosion touches the node, instead of
8708         -- removing the node.
8709
8710         mod_origin = "modname",
8711         -- stores which mod actually registered a node
8712         -- If the source could not be determined it contains "??"
8713         -- Useful for getting which mod truly registered something
8714         -- example: if a node is registered as ":othermodname:nodename",
8715         -- nodename will show "othermodname", but mod_origin will say "modname"
8716     }
8717
8718 Crafting recipes
8719 ----------------
8720
8721 Crafting converts one or more inputs to one output itemstack of arbitrary
8722 count (except for fuels, which don't have an output). The conversion reduces
8723 each input ItemStack by 1.
8724
8725 Craft recipes are registered by `minetest.register_craft` and use a
8726 table format. The accepted parameters are listed below.
8727
8728 Recipe input items can either be specified by item name (item count = 1)
8729 or by group (see "Groups in crafting recipes" for details).
8730
8731 The following sections describe the types and syntaxes of recipes.
8732
8733 ### Shaped
8734
8735 This is the default recipe type (when no `type` is specified).
8736
8737 A shaped recipe takes one or multiple items as input and has
8738 a single item stack as output. The input items must be specified
8739 in a 2-dimensional matrix (see parameters below) to specify the
8740 exact arrangement (the "shape") in which the player must place them
8741 in the crafting grid.
8742
8743 For example, for a 3x3 recipe, the `recipes` table must have
8744 3 rows and 3 columns.
8745
8746 In order to craft the recipe, the players' crafting grid must
8747 have equal or larger dimensions (both width and height).
8748
8749 Parameters:
8750
8751 * `type = "shaped"`: (optional) specifies recipe type as shaped
8752 * `output`: Itemstring of output itemstack (item counts >= 1 are allowed)
8753 * `recipe`: A 2-dimensional matrix of items, with a width *w* and height *h*.
8754     * *w* and *h* are chosen by you, they don't have to be equal but must be at least 1
8755     * The matrix is specified as a table containing tables containing itemnames
8756     * The inner tables are the rows. There must be *h* tables, specified from the top to the bottom row
8757     * Values inside of the inner table are the columns.
8758       Each inner table must contain a list of *w* items, specified from left to right
8759     * Empty slots *must* be filled with the empty string
8760 * `replacements`: (optional) Allows you to replace input items with some other items
8761       when something is crafted
8762     * Provided as a list of item pairs of the form `{ old_item, new_item }` where
8763       `old_item` is the input item to replace (same syntax as for a regular input
8764       slot; groups are allowed) and `new_item` is an itemstring for the item stack
8765       it will become
8766     * When the output is crafted, Minetest iterates through the list
8767       of input items if the crafting grid. For each input item stack, it checks if
8768       it matches with an `old_item` in the item pair list.
8769         * If it matches, the item will be replaced. Also, this item pair
8770           will *not* be applied again for the remaining items
8771         * If it does not match, the item is consumed (reduced by 1) normally
8772     * The `new_item` will appear in one of 3 places:
8773         * Crafting grid, if the input stack size was exactly 1
8774         * Player inventory, if input stack size was larger
8775         * Drops as item entity, if it fits neither in craft grid or inventory
8776
8777 #### Examples
8778
8779 A typical shaped recipe:
8780
8781     -- Stone pickaxe
8782     {
8783         output = "example:stone_pickaxe",
8784         -- A 3x3 recipe which needs 3 stone in the 1st row,
8785         -- and 1 stick in the horizontal middle in each of the 2nd and 3nd row.
8786         -- The 4 remaining slots have to be empty.
8787         recipe = {
8788             {"example:stone", "example:stone", "example:stone"}, -- row 1
8789             {"",              "example:stick", ""             }, -- row 2
8790             {"",              "example:stick", ""             }, -- row 3
8791         --   ^ column 1       ^ column 2       ^ column 3
8792         },
8793         -- There is no replacements table, so every input item
8794         -- will be consumed.
8795     }
8796
8797 Simple replacement example:
8798
8799     -- Wet sponge
8800     {
8801         output = "example:wet_sponge",
8802         -- 1x2 recipe with a water bucket above a dry sponge
8803         recipe = {
8804             {"example:water_bucket"},
8805             {"example:dry_sponge"},
8806         },
8807         -- When the wet sponge is crafted, the water bucket
8808         -- in the input slot is replaced with an empty
8809         -- bucket
8810         replacements = {
8811             {"example:water_bucket", "example:empty_bucket"},
8812         },
8813     }
8814
8815 Complex replacement example 1:
8816
8817     -- Very wet sponge
8818     {
8819         output = "example:very_wet_sponge",
8820         -- 3x3 recipe with a wet sponge in the center
8821         -- and 4 water buckets around it
8822         recipe = {
8823             {"","example:water_bucket",""},
8824             {"example:water_bucket","example:wet_sponge","example:water_bucket"},
8825             {"","example:water_bucket",""},
8826         },
8827         -- When the wet sponge is crafted, all water buckets
8828         -- in the input slot become empty
8829         replacements = {
8830             -- Without these repetitions, only the first
8831             -- water bucket would be replaced.
8832             {"example:water_bucket", "example:empty_bucket"},
8833             {"example:water_bucket", "example:empty_bucket"},
8834             {"example:water_bucket", "example:empty_bucket"},
8835             {"example:water_bucket", "example:empty_bucket"},
8836         },
8837     }
8838
8839 Complex replacement example 2:
8840
8841     -- Magic book:
8842     -- 3 magic orbs + 1 book crafts a magic book,
8843     -- and the orbs will be replaced with 3 different runes.
8844     {
8845         output = "example:magic_book",
8846         -- 3x2 recipe
8847         recipe = {
8848             -- 3 items in the group `magic_orb` on top of a book in the middle
8849             {"group:magic_orb", "group:magic_orb", "group:magic_orb"},
8850             {"", "example:book", ""},
8851         },
8852         -- When the book is crafted, the 3 magic orbs will be turned into
8853         -- 3 runes: ice rune, earth rune and fire rune (from left to right)
8854         replacements = {
8855             {"group:magic_orb", "example:ice_rune"},
8856             {"group:magic_orb", "example:earth_rune"},
8857             {"group:magic_orb", "example:fire_rune"},
8858         },
8859     }
8860
8861 ### Shapeless
8862
8863 Takes a list of input items (at least 1). The order or arrangement
8864 of input items does not matter.
8865
8866 In order to craft the recipe, the players' crafting grid must have matching or
8867 larger *count* of slots. The grid dimensions do not matter.
8868
8869 Parameters:
8870
8871 * `type = "shapeless"`: Mandatory
8872 * `output`: Same as for shaped recipe
8873 * `recipe`: List of item names
8874 * `replacements`: Same as for shaped recipe
8875
8876 #### Example
8877
8878     {
8879         -- Craft a mushroom stew from a bowl, a brown mushroom and a red mushroom
8880         -- (no matter where in the input grid the items are placed)
8881         type = "shapeless",
8882         output = "example:mushroom_stew",
8883         recipe = {
8884             "example:bowl",
8885             "example:mushroom_brown",
8886             "example:mushroom_red",
8887         },
8888     }
8889
8890 ### Tool repair
8891
8892 Syntax:
8893
8894     {
8895         type = "toolrepair",
8896         additional_wear = -0.02, -- multiplier of 65536
8897     }
8898
8899 Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
8900 group. If this recipe is used, repairing is possible with any crafting grid
8901 with at least 2 slots.
8902 The player can put 2 equal tools in the craft grid to get one "repaired" tool
8903 back.
8904 The wear of the output is determined by the wear of both tools, plus a
8905 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
8906 you want `additional_wear` to be negative.
8907
8908 The formula used to calculate the resulting wear is:
8909
8910     65536 * (1 - ( (1 - tool_1_wear) + (1 - tool_2_wear) + additional_wear))
8911
8912 The result is rounded and can't be lower than 0. If the result is 65536 or higher,
8913 no crafting is possible.
8914
8915 ### Cooking
8916
8917 A cooking recipe has a single input item, a single output item stack
8918 and a cooking time. It represents cooking/baking/smelting/etc. items in
8919 an oven, furnace, or something similar; the exact meaning is up for games
8920 to decide, if they choose to use cooking at all.
8921
8922 The engine does not implement anything specific to cooking recipes, but
8923 the recipes can be retrieved later using `minetest.get_craft_result` to
8924 have a consistent interface across different games/mods.
8925
8926 Parameters:
8927
8928 * `type = "cooking"`: Mandatory
8929 * `output`: Same as for shaped recipe
8930 * `recipe`: An itemname of the single input item
8931 * `cooktime`: (optional) Time it takes to cook this item, in seconds.
8932               A floating-point number. (default: 3.0)
8933 * `replacements`: Same meaning as for shaped recipes, but the mods
8934                   that utilize cooking recipes (e.g. for adding a furnace
8935                   node) need to implement replacements on their own
8936
8937 Note: Games and mods are free to re-interpret the cooktime in special
8938 cases, e.g. for a super furnace that cooks items twice as fast.
8939
8940 #### Example
8941
8942 Cooking sand to glass in 3 seconds:
8943
8944     {
8945         type = "cooking",
8946         output = "example:glass",
8947         recipe = "example:sand",
8948         cooktime = 3.0,
8949     }
8950
8951 ### Fuel
8952
8953 A fuel recipe is an item associated with a "burning time" and an optional
8954 item replacement. There is no output. This is usually used as fuel for
8955 furnaces, ovens, stoves, etc.
8956
8957 Like with cooking recipes, the engine does not do anything specific with
8958 fuel recipes and it's up to games and mods to use them by retrieving
8959 them via `minetest.get_craft_result`.
8960
8961 Parameters:
8962
8963 * `type = "fuel"`: Mandatory
8964 * `recipe`: Itemname of the item to be used as fuel
8965 * `burntime`: (optional) Burning time this item provides, in seconds.
8966               A floating-point number. (default: 1.0)
8967 * `replacements`: Same meaning as for shaped recipes, but the mods
8968                   that utilize fuels need to implement replacements
8969                   on their own
8970
8971 Note: Games and mods are free to re-interpret the burntime in special
8972 cases, e.g. for an efficient furnace in which fuels burn twice as
8973 long.
8974
8975 #### Examples
8976
8977 Coal lump with a burntime of 20 seconds. Will be consumed when used.
8978
8979     {
8980         type = "fuel",
8981         recipe = "example:coal_lump",
8982         burntime = 20.0,
8983     }
8984
8985 Lava bucket with a burn time of 60 seconds. Will become an empty bucket
8986 if used:
8987
8988     {
8989         type = "fuel",
8990         recipe = "example:lava_bucket",
8991         burntime = 60.0,
8992         replacements = {{"example:lava_bucket", "example:empty_bucket"}},
8993     }
8994
8995 Ore definition
8996 --------------
8997
8998 Used by `minetest.register_ore`.
8999
9000 See [Ores] section above for essential information.
9001
9002     {
9003         ore_type = "",
9004         -- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
9005
9006         ore = "",
9007         -- Ore node to place
9008
9009         ore_param2 = 0,
9010         -- Param2 to set for ore (e.g. facedir rotation)
9011
9012         wherein = "",
9013         -- Node to place ore in. Multiple are possible by passing a list.
9014
9015         clust_scarcity = 8 * 8 * 8,
9016         -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
9017         -- If the desired average distance between ores is 'd', set this to
9018         -- d * d * d.
9019
9020         clust_num_ores = 8,
9021         -- Number of ores in a cluster
9022
9023         clust_size = 3,
9024         -- Size of the bounding box of the cluster.
9025         -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
9026         -- nodes are coal ore.
9027
9028         y_min = -31000,
9029         y_max = 31000,
9030         -- Lower and upper limits for ore (inclusive)
9031
9032         flags = "",
9033         -- Attributes for the ore generation, see 'Ore attributes' section above
9034
9035         noise_threshold = 0,
9036         -- If noise is above this threshold, ore is placed. Not needed for a
9037         -- uniform distribution.
9038
9039         noise_params = {
9040             offset = 0,
9041             scale = 1,
9042             spread = {x = 100, y = 100, z = 100},
9043             seed = 23,
9044             octaves = 3,
9045             persistence = 0.7
9046         },
9047         -- NoiseParams structure describing one of the perlin noises used for
9048         -- ore distribution.
9049         -- Needed by "sheet", "puff", "blob" and "vein" ores.
9050         -- Omit from "scatter" ore for a uniform ore distribution.
9051         -- Omit from "stratum" ore for a simple horizontal strata from y_min to
9052         -- y_max.
9053
9054         biomes = {"desert", "rainforest"},
9055         -- List of biomes in which this ore occurs.
9056         -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
9057         -- being used does not support biomes.
9058         -- Can be a list of (or a single) biome names, IDs, or definitions.
9059
9060         -- Type-specific parameters
9061
9062         -- "sheet"
9063         column_height_min = 1,
9064         column_height_max = 16,
9065         column_midpoint_factor = 0.5,
9066
9067         -- "puff"
9068         np_puff_top = {
9069             offset = 4,
9070             scale = 2,
9071             spread = {x = 100, y = 100, z = 100},
9072             seed = 47,
9073             octaves = 3,
9074             persistence = 0.7
9075         },
9076         np_puff_bottom = {
9077             offset = 4,
9078             scale = 2,
9079             spread = {x = 100, y = 100, z = 100},
9080             seed = 11,
9081             octaves = 3,
9082             persistence = 0.7
9083         },
9084
9085         -- "vein"
9086         random_factor = 1.0,
9087
9088         -- "stratum"
9089         np_stratum_thickness = {
9090             offset = 8,
9091             scale = 4,
9092             spread = {x = 100, y = 100, z = 100},
9093             seed = 17,
9094             octaves = 3,
9095             persistence = 0.7
9096         },
9097         stratum_thickness = 8, -- only used if no noise defined
9098     }
9099
9100 Biome definition
9101 ----------------
9102
9103 Used by `minetest.register_biome`.
9104
9105 The maximum number of biomes that can be used is 65535. However, using an
9106 excessive number of biomes will slow down map generation. Depending on desired
9107 performance and computing power the practical limit is much lower.
9108
9109     {
9110         name = "tundra",
9111
9112         node_dust = "default:snow",
9113         -- Node dropped onto upper surface after all else is generated
9114
9115         node_top = "default:dirt_with_snow",
9116         depth_top = 1,
9117         -- Node forming surface layer of biome and thickness of this layer
9118
9119         node_filler = "default:permafrost",
9120         depth_filler = 3,
9121         -- Node forming lower layer of biome and thickness of this layer
9122
9123         node_stone = "default:bluestone",
9124         -- Node that replaces all stone nodes between roughly y_min and y_max.
9125
9126         node_water_top = "default:ice",
9127         depth_water_top = 10,
9128         -- Node forming a surface layer in seawater with the defined thickness
9129
9130         node_water = "",
9131         -- Node that replaces all seawater nodes not in the surface layer
9132
9133         node_river_water = "default:ice",
9134         -- Node that replaces river water in mapgens that use
9135         -- default:river_water
9136
9137         node_riverbed = "default:gravel",
9138         depth_riverbed = 2,
9139         -- Node placed under river water and thickness of this layer
9140
9141         node_cave_liquid = "default:lava_source",
9142         node_cave_liquid = {"default:water_source", "default:lava_source"},
9143         -- Nodes placed inside 50% of the medium size caves.
9144         -- Multiple nodes can be specified, each cave will use a randomly
9145         -- chosen node from the list.
9146         -- If this field is left out or 'nil', cave liquids fall back to
9147         -- classic behavior of lava and water distributed using 3D noise.
9148         -- For no cave liquid, specify "air".
9149
9150         node_dungeon = "default:cobble",
9151         -- Node used for primary dungeon structure.
9152         -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
9153         -- alias, if that is also absent, dungeon nodes fall back to the biome
9154         -- 'node_stone'.
9155         -- If present, the following two nodes are also used.
9156
9157         node_dungeon_alt = "default:mossycobble",
9158         -- Node used for randomly-distributed alternative structure nodes.
9159         -- If alternative structure nodes are not wanted leave this absent.
9160
9161         node_dungeon_stair = "stairs:stair_cobble",
9162         -- Node used for dungeon stairs.
9163         -- If absent, stairs fall back to 'node_dungeon'.
9164
9165         y_max = 31000,
9166         y_min = 1,
9167         -- Upper and lower limits for biome.
9168         -- Alternatively you can use xyz limits as shown below.
9169
9170         max_pos = {x = 31000, y = 128, z = 31000},
9171         min_pos = {x = -31000, y = 9, z = -31000},
9172         -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
9173         -- Biome is limited to a cuboid defined by these positions.
9174         -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
9175         -- 31000 in 'max_pos'.
9176
9177         vertical_blend = 8,
9178         -- Vertical distance in nodes above 'y_max' over which the biome will
9179         -- blend with the biome above.
9180         -- Set to 0 for no vertical blend. Defaults to 0.
9181
9182         heat_point = 0,
9183         humidity_point = 50,
9184         -- Characteristic temperature and humidity for the biome.
9185         -- These values create 'biome points' on a voronoi diagram with heat and
9186         -- humidity as axes. The resulting voronoi cells determine the
9187         -- distribution of the biomes.
9188         -- Heat and humidity have average values of 50, vary mostly between
9189         -- 0 and 100 but can exceed these values.
9190     }
9191
9192 Decoration definition
9193 ---------------------
9194
9195 See [Decoration types]. Used by `minetest.register_decoration`.
9196
9197     {
9198         deco_type = "simple",
9199         -- Type. "simple" or "schematic" supported
9200
9201         place_on = "default:dirt_with_grass",
9202         -- Node (or list of nodes) that the decoration can be placed on
9203
9204         sidelen = 8,
9205         -- Size of the square (X / Z) divisions of the mapchunk being generated.
9206         -- Determines the resolution of noise variation if used.
9207         -- If the chunk size is not evenly divisible by sidelen, sidelen is made
9208         -- equal to the chunk size.
9209
9210         fill_ratio = 0.02,
9211         -- The value determines 'decorations per surface node'.
9212         -- Used only if noise_params is not specified.
9213         -- If >= 10.0 complete coverage is enabled and decoration placement uses
9214         -- a different and much faster method.
9215
9216         noise_params = {
9217             offset = 0,
9218             scale = 0.45,
9219             spread = {x = 100, y = 100, z = 100},
9220             seed = 354,
9221             octaves = 3,
9222             persistence = 0.7,
9223             lacunarity = 2.0,
9224             flags = "absvalue"
9225         },
9226         -- NoiseParams structure describing the perlin noise used for decoration
9227         -- distribution.
9228         -- A noise value is calculated for each square division and determines
9229         -- 'decorations per surface node' within each division.
9230         -- If the noise value >= 10.0 complete coverage is enabled and
9231         -- decoration placement uses a different and much faster method.
9232
9233         biomes = {"Oceanside", "Hills", "Plains"},
9234         -- List of biomes in which this decoration occurs. Occurs in all biomes
9235         -- if this is omitted, and ignored if the Mapgen being used does not
9236         -- support biomes.
9237         -- Can be a list of (or a single) biome names, IDs, or definitions.
9238
9239         y_min = -31000,
9240         y_max = 31000,
9241         -- Lower and upper limits for decoration (inclusive).
9242         -- These parameters refer to the Y co-ordinate of the 'place_on' node.
9243
9244         spawn_by = "default:water",
9245         -- Node (or list of nodes) that the decoration only spawns next to.
9246         -- Checks the 8 neighboring nodes on the same Y, and also the ones
9247         -- at Y+1, excluding both center nodes.
9248
9249         num_spawn_by = 1,
9250         -- Number of spawn_by nodes that must be surrounding the decoration
9251         -- position to occur.
9252         -- If absent or -1, decorations occur next to any nodes.
9253
9254         flags = "liquid_surface, force_placement, all_floors, all_ceilings",
9255         -- Flags for all decoration types.
9256         -- "liquid_surface": Instead of placement on the highest solid surface
9257         --   in a mapchunk column, placement is on the highest liquid surface.
9258         --   Placement is disabled if solid nodes are found above the liquid
9259         --   surface.
9260         -- "force_placement": Nodes other than "air" and "ignore" are replaced
9261         --   by the decoration.
9262         -- "all_floors", "all_ceilings": Instead of placement on the highest
9263         --   surface in a mapchunk the decoration is placed on all floor and/or
9264         --   ceiling surfaces, for example in caves and dungeons.
9265         --   Ceiling decorations act as an inversion of floor decorations so the
9266         --   effect of 'place_offset_y' is inverted.
9267         --   Y-slice probabilities do not function correctly for ceiling
9268         --   schematic decorations as the behavior is unchanged.
9269         --   If a single decoration registration has both flags the floor and
9270         --   ceiling decorations will be aligned vertically.
9271
9272         ----- Simple-type parameters
9273
9274         decoration = "default:grass",
9275         -- The node name used as the decoration.
9276         -- If instead a list of strings, a randomly selected node from the list
9277         -- is placed as the decoration.
9278
9279         height = 1,
9280         -- Decoration height in nodes.
9281         -- If height_max is not 0, this is the lower limit of a randomly
9282         -- selected height.
9283
9284         height_max = 0,
9285         -- Upper limit of the randomly selected height.
9286         -- If absent, the parameter 'height' is used as a constant.
9287
9288         param2 = 0,
9289         -- Param2 value of decoration nodes.
9290         -- If param2_max is not 0, this is the lower limit of a randomly
9291         -- selected param2.
9292
9293         param2_max = 0,
9294         -- Upper limit of the randomly selected param2.
9295         -- If absent, the parameter 'param2' is used as a constant.
9296
9297         place_offset_y = 0,
9298         -- Y offset of the decoration base node relative to the standard base
9299         -- node position.
9300         -- Can be positive or negative. Default is 0.
9301         -- Effect is inverted for "all_ceilings" decorations.
9302         -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
9303         -- to the 'place_on' node.
9304
9305         ----- Schematic-type parameters
9306
9307         schematic = "foobar.mts",
9308         -- If schematic is a string, it is the filepath relative to the current
9309         -- working directory of the specified Minetest schematic file.
9310         -- Could also be the ID of a previously registered schematic.
9311
9312         schematic = {
9313             size = {x = 4, y = 6, z = 4},
9314             data = {
9315                 {name = "default:cobble", param1 = 255, param2 = 0},
9316                 {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
9317                 {name = "air", param1 = 255, param2 = 0},
9318                  ...
9319             },
9320             yslice_prob = {
9321                 {ypos = 2, prob = 128},
9322                 {ypos = 5, prob = 64},
9323                  ...
9324             },
9325         },
9326         -- Alternative schematic specification by supplying a table. The fields
9327         -- size and data are mandatory whereas yslice_prob is optional.
9328         -- See 'Schematic specifier' for details.
9329
9330         replacements = {["oldname"] = "convert_to", ...},
9331         -- Map of node names to replace in the schematic after reading it.
9332
9333         flags = "place_center_x, place_center_y, place_center_z",
9334         -- Flags for schematic decorations. See 'Schematic attributes'.
9335
9336         rotation = "90",
9337         -- Rotation can be "0", "90", "180", "270", or "random"
9338
9339         place_offset_y = 0,
9340         -- If the flag 'place_center_y' is set this parameter is ignored.
9341         -- Y offset of the schematic base node layer relative to the 'place_on'
9342         -- node.
9343         -- Can be positive or negative. Default is 0.
9344         -- Effect is inverted for "all_ceilings" decorations.
9345         -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
9346         -- to the 'place_on' node.
9347     }
9348
9349 Chat command definition
9350 -----------------------
9351
9352 Used by `minetest.register_chatcommand`.
9353
9354 Specifies the function to be called and the privileges required when a player
9355 issues the command.  A help message that is the concatenation of the params and
9356 description fields is shown when the "/help" chatcommand is issued.
9357
9358     {
9359         params = "",
9360         -- Short parameter description.  See the below note.
9361
9362         description = "",
9363         -- General description of the command's purpose.
9364
9365         privs = {},
9366         -- Required privileges to run. See `minetest.check_player_privs()` for
9367         -- the format and see [Privileges] for an overview of privileges.
9368
9369         func = function(name, param),
9370         -- Called when command is run.
9371         -- * `name` is the name of the player who issued the command.
9372         -- * `param` is a string with the full arguments to the command.
9373         -- Returns a boolean for success and a string value.
9374         -- The string is shown to the issuing player upon exit of `func` or,
9375         -- if `func` returns `false` and no string, the help message is shown.
9376     }
9377
9378 Note that in params, the conventional use of symbols is as follows:
9379
9380 * `<>` signifies a placeholder to be replaced when the command is used. For
9381   example, when a player name is needed: `<name>`
9382 * `[]` signifies param is optional and not required when the command is used.
9383   For example, if you require param1 but param2 is optional:
9384   `<param1> [<param2>]`
9385 * `|` signifies exclusive or. The command requires one param from the options
9386   provided. For example: `<param1> | <param2>`
9387 * `()` signifies grouping. For example, when param1 and param2 are both
9388   required, or only param3 is required: `(<param1> <param2>) | <param3>`
9389
9390 Example:
9391
9392     {
9393         params = "<name> <privilege>",
9394
9395         description = "Remove privilege from player",
9396
9397         privs = {privs=true},  -- Require the "privs" privilege to run
9398
9399         func = function(name, param),
9400     }
9401
9402 Privilege definition
9403 --------------------
9404
9405 Used by `minetest.register_privilege`.
9406
9407     {
9408         description = "",
9409         -- Privilege description
9410
9411         give_to_singleplayer = true,
9412         -- Whether to grant the privilege to singleplayer.
9413
9414         give_to_admin = true,
9415         -- Whether to grant the privilege to the server admin.
9416         -- Uses value of 'give_to_singleplayer' by default.
9417
9418         on_grant = function(name, granter_name),
9419         -- Called when given to player 'name' by 'granter_name'.
9420         -- 'granter_name' will be nil if the priv was granted by a mod.
9421
9422         on_revoke = function(name, revoker_name),
9423         -- Called when taken from player 'name' by 'revoker_name'.
9424         -- 'revoker_name' will be nil if the priv was revoked by a mod.
9425
9426         -- Note that the above two callbacks will be called twice if a player is
9427         -- responsible, once with the player name, and then with a nil player
9428         -- name.
9429         -- Return true in the above callbacks to stop register_on_priv_grant or
9430         -- revoke being called.
9431     }
9432
9433 Detached inventory callbacks
9434 ----------------------------
9435
9436 Used by `minetest.create_detached_inventory`.
9437
9438     {
9439         allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
9440         -- Called when a player wants to move items inside the inventory.
9441         -- Return value: number of items allowed to move.
9442
9443         allow_put = function(inv, listname, index, stack, player),
9444         -- Called when a player wants to put something into the inventory.
9445         -- Return value: number of items allowed to put.
9446         -- Return value -1: Allow and don't modify item count in inventory.
9447
9448         allow_take = function(inv, listname, index, stack, player),
9449         -- Called when a player wants to take something out of the inventory.
9450         -- Return value: number of items allowed to take.
9451         -- Return value -1: Allow and don't modify item count in inventory.
9452
9453         on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
9454         on_put = function(inv, listname, index, stack, player),
9455         on_take = function(inv, listname, index, stack, player),
9456         -- Called after the actual action has happened, according to what was
9457         -- allowed.
9458         -- No return value.
9459     }
9460
9461 HUD Definition
9462 --------------
9463
9464 Since most values have multiple different functions, please see the
9465 documentation in [HUD] section.
9466
9467 Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
9468
9469     {
9470         hud_elem_type = "image",
9471         -- Type of element, can be "image", "text", "statbar", "inventory",
9472         -- "waypoint", "image_waypoint", "compass" or "minimap"
9473
9474         position = {x=0.5, y=0.5},
9475         -- Top left corner position of element
9476
9477         name = "<name>",
9478
9479         scale = {x = 1, y = 1},
9480
9481         text = "<text>",
9482
9483         text2 = "<text>",
9484
9485         number = 0,
9486
9487         item = 0,
9488
9489         direction = 0,
9490         -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
9491
9492         alignment = {x=0, y=0},
9493
9494         offset = {x=0, y=0},
9495
9496         world_pos = {x=0, y=0, z=0},
9497
9498         size = {x=0, y=0},
9499
9500         z_index = 0,
9501         -- Z index: lower z-index HUDs are displayed behind higher z-index HUDs
9502
9503         style = 0,
9504     }
9505
9506 Particle definition
9507 -------------------
9508
9509 Used by `minetest.add_particle`.
9510
9511     {
9512         pos = {x=0, y=0, z=0},
9513         velocity = {x=0, y=0, z=0},
9514         acceleration = {x=0, y=0, z=0},
9515         -- Spawn particle at pos with velocity and acceleration
9516
9517         expirationtime = 1,
9518         -- Disappears after expirationtime seconds
9519
9520         size = 1,
9521         -- Scales the visual size of the particle texture.
9522         -- If `node` is set, size can be set to 0 to spawn a randomly-sized
9523         -- particle (just like actual node dig particles).
9524
9525         collisiondetection = false,
9526         -- If true collides with `walkable` nodes and, depending on the
9527         -- `object_collision` field, objects too.
9528
9529         collision_removal = false,
9530         -- If true particle is removed when it collides.
9531         -- Requires collisiondetection = true to have any effect.
9532
9533         object_collision = false,
9534         -- If true particle collides with objects that are defined as
9535         -- `physical = true,` and `collide_with_objects = true,`.
9536         -- Requires collisiondetection = true to have any effect.
9537
9538         vertical = false,
9539         -- If true faces player using y axis only
9540
9541         texture = "image.png",
9542         -- The texture of the particle
9543         -- v5.6.0 and later: also supports the table format described in the
9544         -- following section
9545
9546         playername = "singleplayer",
9547         -- Optional, if specified spawns particle only on the player's client
9548
9549         animation = {Tile Animation definition},
9550         -- Optional, specifies how to animate the particle texture
9551
9552         glow = 0
9553         -- Optional, specify particle self-luminescence in darkness.
9554         -- Values 0-14.
9555
9556         node = {name = "ignore", param2 = 0},
9557         -- Optional, if specified the particle will have the same appearance as
9558         -- node dig particles for the given node.
9559         -- `texture` and `animation` will be ignored if this is set.
9560
9561         node_tile = 0,
9562         -- Optional, only valid in combination with `node`
9563         -- If set to a valid number 1-6, specifies the tile from which the
9564         -- particle texture is picked.
9565         -- Otherwise, the default behavior is used. (currently: any random tile)
9566
9567         drag = {x=0, y=0, z=0},
9568         -- v5.6.0 and later: Optional drag value, consult the following section
9569
9570         bounce = {min = ..., max = ..., bias = 0},
9571         -- v5.6.0 and later: Optional bounce range, consult the following section
9572     }
9573
9574
9575 `ParticleSpawner` definition
9576 ----------------------------
9577
9578 Used by `minetest.add_particlespawner`.
9579
9580 Before v5.6.0, particlespawners used a different syntax and had a more limited set
9581 of features. Definition fields that are the same in both legacy and modern versions
9582 are shown in the next listing, and the fields that are used by legacy versions are
9583 shown separated by a comment; the modern fields are too complex to compactly
9584 describe in this manner and are documented after the listing.
9585
9586 The older syntax can be used in combination with the newer syntax (e.g. having
9587 `minpos`, `maxpos`, and `pos` all set) to support older servers. On newer servers,
9588 the new syntax will override the older syntax; on older servers, the newer syntax
9589 will be ignored.
9590
9591     {
9592         -- Common fields (same name and meaning in both new and legacy syntax)
9593
9594         amount = 1,
9595         -- Number of particles spawned over the time period `time`.
9596
9597         time = 1,
9598         -- Lifespan of spawner in seconds.
9599         -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
9600         -- a per-second basis.
9601
9602         collisiondetection = false,
9603         -- If true collide with `walkable` nodes and, depending on the
9604         -- `object_collision` field, objects too.
9605
9606         collision_removal = false,
9607         -- If true particles are removed when they collide.
9608         -- Requires collisiondetection = true to have any effect.
9609
9610         object_collision = false,
9611         -- If true particles collide with objects that are defined as
9612         -- `physical = true,` and `collide_with_objects = true,`.
9613         -- Requires collisiondetection = true to have any effect.
9614
9615         attached = ObjectRef,
9616         -- If defined, particle positions, velocities and accelerations are
9617         -- relative to this object's position and yaw
9618
9619         vertical = false,
9620         -- If true face player using y axis only
9621
9622         texture = "image.png",
9623         -- The texture of the particle
9624
9625         playername = "singleplayer",
9626         -- Optional, if specified spawns particles only on the player's client
9627
9628         animation = {Tile Animation definition},
9629         -- Optional, specifies how to animate the particles' texture
9630         -- v5.6.0 and later: set length to -1 to synchronize the length
9631         -- of the animation with the expiration time of individual particles.
9632         -- (-2 causes the animation to be played twice, and so on)
9633
9634         glow = 0,
9635         -- Optional, specify particle self-luminescence in darkness.
9636         -- Values 0-14.
9637
9638         node = {name = "ignore", param2 = 0},
9639         -- Optional, if specified the particles will have the same appearance as
9640         -- node dig particles for the given node.
9641         -- `texture` and `animation` will be ignored if this is set.
9642
9643         node_tile = 0,
9644         -- Optional, only valid in combination with `node`
9645         -- If set to a valid number 1-6, specifies the tile from which the
9646         -- particle texture is picked.
9647         -- Otherwise, the default behavior is used. (currently: any random tile)
9648
9649         -- Legacy definition fields
9650
9651         minpos = {x=0, y=0, z=0},
9652         maxpos = {x=0, y=0, z=0},
9653         minvel = {x=0, y=0, z=0},
9654         maxvel = {x=0, y=0, z=0},
9655         minacc = {x=0, y=0, z=0},
9656         maxacc = {x=0, y=0, z=0},
9657         minexptime = 1,
9658         maxexptime = 1,
9659         minsize = 1,
9660         maxsize = 1,
9661         -- The particles' properties are random values between the min and max
9662         -- values.
9663         -- applies to: pos, velocity, acceleration, expirationtime, size
9664         -- If `node` is set, min and maxsize can be set to 0 to spawn
9665         -- randomly-sized particles (just like actual node dig particles).
9666     }
9667
9668 ### Modern definition fields
9669
9670 After v5.6.0, spawner properties can be defined in several different ways depending
9671 on the level of control you need. `pos` for instance can be set as a single vector,
9672 in which case all particles will appear at that exact point throughout the lifetime
9673 of the spawner. Alternately, it can be specified as a min-max pair, specifying a
9674 cubic range the particles can appear randomly within. Finally, some properties can
9675 be animated by suffixing their key with `_tween` (e.g. `pos_tween`) and supplying
9676 a tween table.
9677
9678 The following definitions are all equivalent, listed in order of precedence from
9679 lowest (the legacy syntax) to highest (tween tables). If multiple forms of a
9680 property definition are present, the highest-precedence form will be selected
9681 and all lower-precedence fields will be ignored, allowing for graceful
9682 degradation in older clients).
9683
9684     {
9685       -- old syntax
9686       maxpos = {x = 0, y = 0, z = 0},
9687       minpos = {x = 0, y = 0, z = 0},
9688
9689       -- absolute value
9690       pos = 0,
9691       -- all components of every particle's position vector will be set to this
9692       -- value
9693
9694       -- vec3
9695       pos = vector.new(0,0,0),
9696       -- all particles will appear at this exact position throughout the lifetime
9697       -- of the particlespawner
9698
9699       -- vec3 range
9700       pos = {
9701             -- the particle will appear at a position that is picked at random from
9702             -- within a cubic range
9703
9704             min = vector.new(0,0,0),
9705             -- `min` is the minimum value this property will be set to in particles
9706             -- spawned by the generator
9707
9708             max = vector.new(0,0,0),
9709             -- `max` is the minimum value this property will be set to in particles
9710             -- spawned by the generator
9711
9712             bias = 0,
9713             -- when `bias` is 0, all random values are exactly as likely as any
9714             -- other. when it is positive, the higher it is, the more likely values
9715             -- will appear towards the minimum end of the allowed spectrum. when
9716             -- it is negative, the lower it is, the more likely values will appear
9717             -- towards the maximum end of the allowed spectrum. the curve is
9718             -- exponential and there is no particular maximum or minimum value
9719         },
9720
9721         -- tween table
9722         pos_tween = {...},
9723         -- a tween table should consist of a list of frames in the same form as the
9724         -- untweened pos property above, which the engine will interpolate between,
9725         -- and optionally a number of properties that control how the interpolation
9726         -- takes place. currently **only two frames**, the first and the last, are
9727         -- used, but extra frames are accepted for the sake of forward compatibility.
9728         -- any of the above definition styles can be used here as well in any combination
9729         -- supported by the property type
9730
9731         pos_tween = {
9732             style = "fwd",
9733             -- linear animation from first to last frame (default)
9734             style = "rev",
9735             -- linear animation from last to first frame
9736             style = "pulse",
9737             -- linear animation from first to last then back to first again
9738             style = "flicker",
9739             -- like "pulse", but slightly randomized to add a bit of stutter
9740
9741             reps = 1,
9742             -- number of times the animation is played over the particle's lifespan
9743
9744             start = 0.0,
9745             -- point in the spawner's lifespan at which the animation begins. 0 is
9746             -- the very beginning, 1 is the very end
9747
9748             -- frames can be defined in a number of different ways, depending on the
9749             -- underlying type of the property. for now, all but the first and last
9750             -- frame are ignored
9751
9752             -- frames
9753
9754                 -- floats
9755                 0, 0,
9756
9757                 -- vec3s
9758                 vector.new(0,0,0),
9759                 vector.new(0,0,0),
9760
9761                 -- vec3 ranges
9762                 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9763                 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9764
9765                 -- mixed
9766                 0, { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9767         },
9768     }
9769
9770 All of the properties that can be defined in this way are listed in the next
9771 section, along with the datatypes they accept.
9772
9773 #### List of particlespawner properties
9774 All of the properties in this list can be animated with `*_tween` tables
9775 unless otherwise specified. For example, `jitter` can be tweened by setting
9776 a `jitter_tween` table instead of (or in addition to) a `jitter` table/value.
9777 In this section, a float range is a table defined as so: { min = A, max = B }
9778 A and B are your supplemented values. For a vec3 range this means they are vectors.
9779 Types used are defined in the previous section.
9780
9781 * vec3 range `pos`: the position at which particles can appear
9782 * vec3 range `vel`: the initial velocity of the particle
9783 * vec3 range `acc`: the direction and speed with which the particle
9784   accelerates
9785 * vec3 range `jitter`: offsets the velocity of each particle by a random
9786   amount within the specified range each frame. used to create Brownian motion.
9787 * vec3 range `drag`: the amount by which absolute particle velocity along
9788   each axis is decreased per second.  a value of 1.0 means that the particle
9789   will be slowed to a stop over the space of a second; a value of -1.0 means
9790   that the particle speed will be doubled every second. to avoid interfering
9791   with gravity provided by `acc`, a drag vector like `vector.new(1,0,1)` can
9792   be used instead of a uniform value.
9793 * float range `bounce`: how bouncy the particles are when `collisiondetection`
9794   is turned on. values less than or equal to `0` turn off particle bounce;
9795   `1` makes the particles bounce without losing any velocity, and `2` makes
9796   them double their velocity with every bounce.  `bounce` is not bounded but
9797   values much larger than `1.0` probably aren't very useful.
9798 * float range `exptime`: the number of seconds after which the particle
9799   disappears.
9800 * table `attract`: sets the birth orientation of particles relative to various
9801   shapes defined in world coordinate space. this is an alternative means of
9802   setting the velocity which allows particles to emerge from or enter into
9803   some entity or node on the map, rather than simply being assigned random
9804   velocity values within a range. the velocity calculated by this method will
9805   be **added** to that specified by `vel` if `vel` is also set, so in most
9806   cases **`vel` should be set to 0**. `attract` has the fields:
9807   * string `kind`: selects the kind of shape towards which the particles will
9808     be oriented. it must have one of the following values:
9809     * `"none"`: no attractor is set and the `attractor` table is ignored
9810     * `"point"`: the particles are attracted to a specific point in space.
9811       use this also if you want a sphere-like effect, in combination with
9812       the `radius` property.
9813     * `"line"`: the particles are attracted to an (infinite) line passing
9814       through the points `origin` and `angle`. use this for e.g. beacon
9815       effects, energy beam effects, etc.
9816     * `"plane"`: the particles are attracted to an (infinite) plane on whose
9817       surface `origin` designates a point in world coordinate space. use this
9818       for e.g. particles entering or emerging from a portal.
9819   * float range `strength`: the speed with which particles will move towards
9820     `attractor`. If negative, the particles will instead move away from that
9821     point.
9822   * vec3 `origin`: the origin point of the shape towards which particles will
9823     initially be oriented. functions as an offset if `origin_attached` is also
9824     set.
9825   * vec3 `direction`: sets the direction in which the attractor shape faces. for
9826     lines, this sets the angle of the line; e.g. a vector of (0,1,0) will
9827     create a vertical line that passes through `origin`. for planes, `direction`
9828     is the surface normal of an infinite plane on whose surface `origin` is
9829     a point. functions as an offset if `direction_attached` is also set.
9830   * entity `origin_attached`: allows the origin to be specified as an offset
9831     from the position of an entity rather than a coordinate in world space.
9832   * entity `direction_attached`: allows the direction to be specified as an offset
9833     from the position of an entity rather than a coordinate in world space.
9834   * bool `die_on_contact`: if true, the particles' lifetimes are adjusted so
9835     that they will die as they cross the attractor threshold. this behavior
9836     is the default but is undesirable for some kinds of animations; set it to
9837     false to allow particles to live out their natural lives.
9838 * vec3 range `radius`: if set, particles will be arranged in a sphere around
9839   `pos`. A constant can be used to create a spherical shell of particles, a
9840   vector to create an ovoid shell, and a range to create a volume; e.g.
9841   `{min = 0.5, max = 1, bias = 1}` will allow particles to appear between 0.5
9842   and 1 nodes away from `pos` but will cluster them towards the center of the
9843   sphere. Usually if `radius` is used, `pos` should be a single point, but it
9844   can still be a range if you really know what you're doing (e.g. to create a
9845   "roundcube" emitter volume).
9846
9847 ### Textures
9848
9849 In versions before v5.6.0, particlespawner textures could only be specified as a single
9850 texture string. After v5.6.0, textures can now be specified as a table as well. This
9851 table contains options that allow simple animations to be applied to the texture.
9852
9853     texture = {
9854         name = "mymod_particle_texture.png",
9855         -- the texture specification string
9856
9857         alpha = 1.0,
9858         -- controls how visible the particle is; at 1.0 the particle is fully
9859         -- visible, at 0, it is completely invisible.
9860
9861         alpha_tween = {1, 0},
9862         -- can be used instead of `alpha` to animate the alpha value over the
9863         -- particle's lifetime. these tween tables work identically to the tween
9864         -- tables used in particlespawner properties, except that time references
9865         -- are understood with respect to the particle's lifetime, not the
9866         -- spawner's. {1,0} fades the particle out over its lifetime.
9867
9868         scale = 1,
9869         scale = {x = 1, y = 1},
9870         -- scales the texture onscreen
9871
9872         scale_tween = {
9873             {x = 1, y = 1},
9874             {x = 0, y = 1},
9875         },
9876         -- animates the scale over the particle's lifetime. works like the
9877         -- alpha_tween table, but can accept two-dimensional vectors as well as
9878         -- integer values. the example value would cause the particle to shrink
9879         -- in one dimension over the course of its life until it disappears
9880
9881         blend = "alpha",
9882         -- (default) blends transparent pixels with those they are drawn atop
9883         -- according to the alpha channel of the source texture. useful for
9884         -- e.g. material objects like rocks, dirt, smoke, or node chunks
9885         blend = "add",
9886         -- adds the value of pixels to those underneath them, modulo the sources
9887         -- alpha channel. useful for e.g. bright light effects like sparks or fire
9888         blend = "screen",
9889         -- like "add" but less bright. useful for subtler light effects. note that
9890         -- this is NOT formally equivalent to the "screen" effect used in image
9891         -- editors and compositors, as it does not respect the alpha channel of
9892         -- of the image being blended
9893         blend = "sub",
9894         -- the inverse of "add"; the value of the source pixel is subtracted from
9895         -- the pixel underneath it. a white pixel will turn whatever is underneath
9896         -- it black; a black pixel will be "transparent". useful for creating
9897         -- darkening effects
9898
9899         animation = {Tile Animation definition},
9900         -- overrides the particlespawner's global animation property for a single
9901         -- specific texture
9902     }
9903
9904 Instead of setting a single texture definition, it is also possible to set a
9905 `texpool` property. A `texpool` consists of a list of possible particle textures.
9906 Every time a particle is spawned, the engine will pick a texture at random from
9907 the `texpool` and assign it as that particle's texture. You can also specify a
9908 `texture` in addition to a `texpool`; the `texture` value will be ignored on newer
9909 clients but will be sent to older (pre-v5.6.0) clients that do not implement
9910 texpools.
9911
9912     texpool = {
9913         "mymod_particle_texture.png";
9914         { name = "mymod_spark.png", fade = "out" },
9915         {
9916           name = "mymod_dust.png",
9917           alpha = 0.3,
9918           scale = 1.5,
9919           animation = {
9920                 type = "vertical_frames",
9921                 aspect_w = 16, aspect_h = 16,
9922
9923                 length = 3,
9924                 -- the animation lasts for 3s and then repeats
9925                 length = -3,
9926                 -- repeat the animation three times over the particle's lifetime
9927                 -- (post-v5.6.0 clients only)
9928           },
9929         },
9930   }
9931
9932 #### List of animatable texture properties
9933
9934 While animated particlespawner values vary over the course of the particlespawner's
9935 lifetime, animated texture properties vary over the lifespans of the individual
9936 particles spawned with that texture. So a particle with the texture property
9937
9938     alpha_tween = {
9939         0.0, 1.0,
9940         style = "pulse",
9941         reps = 4,
9942     }
9943
9944 would be invisible at its spawning, pulse visible four times throughout its
9945 lifespan, and then vanish again before expiring.
9946
9947 * float `alpha` (0.0 - 1.0): controls the visibility of the texture
9948 * vec2 `scale`: controls the size of the displayed billboard onscreen. Its units
9949   are multiples of the parent particle's assigned size (see the `size` property above)
9950
9951 `HTTPRequest` definition
9952 ------------------------
9953
9954 Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
9955
9956     {
9957         url = "http://example.org",
9958
9959         timeout = 10,
9960         -- Timeout for request to be completed in seconds. Default depends on engine settings.
9961
9962         method = "GET", "POST", "PUT" or "DELETE"
9963         -- The http method to use. Defaults to "GET".
9964
9965         data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
9966         -- Data for the POST, PUT or DELETE request.
9967         -- Accepts both a string and a table. If a table is specified, encodes
9968         -- table as x-www-form-urlencoded key-value pairs.
9969
9970         user_agent = "ExampleUserAgent",
9971         -- Optional, if specified replaces the default minetest user agent with
9972         -- given string
9973
9974         extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
9975         -- Optional, if specified adds additional headers to the HTTP request.
9976         -- You must make sure that the header strings follow HTTP specification
9977         -- ("Key: Value").
9978
9979         multipart = boolean
9980         -- Optional, if true performs a multipart HTTP request.
9981         -- Default is false.
9982         -- Post only, data must be array
9983
9984         post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
9985         -- Deprecated, use `data` instead. Forces `method = "POST"`.
9986     }
9987
9988 `HTTPRequestResult` definition
9989 ------------------------------
9990
9991 Passed to `HTTPApiTable.fetch` callback. Returned by
9992 `HTTPApiTable.fetch_async_get`.
9993
9994     {
9995         completed = true,
9996         -- If true, the request has finished (either succeeded, failed or timed
9997         -- out)
9998
9999         succeeded = true,
10000         -- If true, the request was successful
10001
10002         timeout = false,
10003         -- If true, the request timed out
10004
10005         code = 200,
10006         -- HTTP status code
10007
10008         data = "response"
10009     }
10010
10011 Authentication handler definition
10012 ---------------------------------
10013
10014 Used by `minetest.register_authentication_handler`.
10015
10016     {
10017         get_auth = function(name),
10018         -- Get authentication data for existing player `name` (`nil` if player
10019         -- doesn't exist).
10020         -- Returns following structure:
10021         -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
10022
10023         create_auth = function(name, password),
10024         -- Create new auth data for player `name`.
10025         -- Note that `password` is not plain-text but an arbitrary
10026         -- representation decided by the engine.
10027
10028         delete_auth = function(name),
10029         -- Delete auth data of player `name`.
10030         -- Returns boolean indicating success (false if player is nonexistent).
10031
10032         set_password = function(name, password),
10033         -- Set password of player `name` to `password`.
10034         -- Auth data should be created if not present.
10035
10036         set_privileges = function(name, privileges),
10037         -- Set privileges of player `name`.
10038         -- `privileges` is in table form, auth data should be created if not
10039         -- present.
10040
10041         reload = function(),
10042         -- Reload authentication data from the storage location.
10043         -- Returns boolean indicating success.
10044
10045         record_login = function(name),
10046         -- Called when player joins, used for keeping track of last_login
10047
10048         iterate = function(),
10049         -- Returns an iterator (use with `for` loops) for all player names
10050         -- currently in the auth database
10051     }
10052
10053 Bit Library
10054 -----------
10055
10056 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
10057
10058 See http://bitop.luajit.org/ for advanced information.
10059
10060 Error Handling
10061 --------------
10062
10063 When an error occurs that is not caught, Minetest calls the function
10064 `minetest.error_handler` with the error object as its first argument. The second
10065 argument is the stack level where the error occurred. The return value is the
10066 error string that should be shown. By default this is a backtrace from
10067 `debug.traceback`. If the error object is not a string, it is first converted
10068 with `tostring` before being displayed. This means that you can use tables as
10069 error objects so long as you give them `__tostring` metamethods.
10070
10071 You can override `minetest.error_handler`. You should call the previous handler
10072 with the correct stack level in your implementation.