]> git.lizzy.rs Git - minetest.git/blob - doc/lua_api.txt
4e3d1230cc942ded812208d6427891ee043fc379
[minetest.git] / doc / lua_api.txt
1 Minetest Lua Modding API Reference
2 ==================================
3
4 * More information at <http://www.minetest.net/>
5 * Developer Wiki: <http://dev.minetest.net/>
6 * (Unofficial) Minetest Modding Book by rubenwardy: <https://rubenwardy.com/minetest_modding_book/>
7
8 Introduction
9 ------------
10
11 Content and functionality can be added to Minetest using Lua scripting
12 in run-time loaded mods.
13
14 A mod is a self-contained bunch of scripts, textures and other related
15 things, which is loaded by and interfaces with Minetest.
16
17 Mods are contained and ran solely on the server side. Definitions and media
18 files are automatically transferred to the client.
19
20 If you see a deficiency in the API, feel free to attempt to add the
21 functionality in the engine and API, and to document it here.
22
23 Programming in Lua
24 ------------------
25
26 If you have any difficulty in understanding this, please read
27 [Programming in Lua](http://www.lua.org/pil/).
28
29 Startup
30 -------
31
32 Mods are loaded during server startup from the mod load paths by running
33 the `init.lua` scripts in a shared environment.
34
35 Paths
36 -----
37
38 Minetest keeps and looks for files mostly in two paths. `path_share` or `path_user`.
39
40 `path_share` contains possibly read-only content for the engine (incl. games and mods).
41 `path_user` contains mods or games installed by the user but also the users
42 worlds or settings.
43
44 With a local build (`RUN_IN_PLACE=1`) `path_share` and `path_user` both point to
45 the build directory. For system-wide builds on Linux the share path is usually at
46 `/usr/share/minetest` while the user path resides in `.minetest` in the home directory.
47 Paths on other operating systems will differ.
48
49 Games
50 =====
51
52 Games are looked up from:
53
54 * `$path_share/games/<gameid>/`
55 * `$path_user/games/<gameid>/`
56
57 Where `<gameid>` is unique to each game.
58
59 The game directory can contain the following files:
60
61 * `game.conf`, with the following keys:
62     * `title`: Required, a human-readable title to address the game, e.g. `title = Minetest Game`.
63     * `name`: (Deprecated) same as title.
64     * `description`: Short description to be shown in the content tab
65     * `allowed_mapgens = <comma-separated mapgens>`
66       e.g. `allowed_mapgens = v5,v6,flat`
67       Mapgens not in this list are removed from the list of mapgens for the
68       game.
69       If not specified, all mapgens are allowed.
70     * `disallowed_mapgens = <comma-separated mapgens>`
71       e.g. `disallowed_mapgens = v5,v6,flat`
72       These mapgens are removed from the list of mapgens for the game.
73       When both `allowed_mapgens` and `disallowed_mapgens` are
74       specified, `allowed_mapgens` is applied before
75       `disallowed_mapgens`.
76     * `disallowed_mapgen_settings= <comma-separated mapgen settings>`
77       e.g. `disallowed_mapgen_settings = mgv5_spflags`
78       These mapgen settings are hidden for this game in the world creation
79       dialog and game start menu. Add `seed` to hide the seed input field.
80     * `disabled_settings = <comma-separated settings>`
81       e.g. `disabled_settings = enable_damage, creative_mode`
82       These settings are hidden for this game in the "Start game" tab
83       and will be initialized as `false` when the game is started.
84       Prepend a setting name with an exclamation mark to initialize it to `true`
85       (this does not work for `enable_server`).
86       Only these settings are supported:
87           `enable_damage`, `creative_mode`, `enable_server`.
88     * `author`: The author of the game. It only appears when downloaded from
89                 ContentDB.
90     * `release`: Ignore this: Should only ever be set by ContentDB, as it is
91                  an internal ID used to track versions.
92 * `minetest.conf`:
93   Used to set default settings when running this game.
94 * `settingtypes.txt`:
95   In the same format as the one in builtin.
96   This settingtypes.txt will be parsed by the menu and the settings will be
97   displayed in the "Games" category in the advanced settings tab.
98 * If the game contains a folder called `textures` the server will load it as a
99   texturepack, overriding mod textures.
100   Any server texturepack will override mod textures and the game texturepack.
101
102 Menu images
103 -----------
104
105 Games can provide custom main menu images. They are put inside a `menu`
106 directory inside the game directory.
107
108 The images are named `$identifier.png`, where `$identifier` is one of
109 `overlay`, `background`, `footer`, `header`.
110 If you want to specify multiple images for one identifier, add additional
111 images named like `$identifier.$n.png`, with an ascending number $n starting
112 with 1, and a random image will be chosen from the provided ones.
113
114 Menu music
115 -----------
116
117 Games can provide custom main menu music. They are put inside a `menu`
118 directory inside the game directory.
119
120 The music files are named `theme.ogg`.
121 If you want to specify multiple music files for one game, add additional
122 images named like `theme.$n.ogg`, with an ascending number $n starting
123 with 1 (max 10), and a random music file will be chosen from the provided ones.
124
125 Mods
126 ====
127
128 Mod load path
129 -------------
130
131 Paths are relative to the directories listed in the [Paths] section above.
132
133 * `games/<gameid>/mods/`
134 * `mods/`
135 * `worlds/<worldname>/worldmods/`
136
137 World-specific games
138 --------------------
139
140 It is possible to include a game in a world; in this case, no mods or
141 games are loaded or checked from anywhere else.
142
143 This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
144 directory exists.
145
146 Mods should then be placed in `<worldname>/game/mods/`.
147
148 Modpacks
149 --------
150
151 Mods can be put in a subdirectory, if the parent directory, which otherwise
152 should be a mod, contains a file named `modpack.conf`.
153 The file is a key-value store of modpack details.
154
155 * `name`: The modpack name. Allows Minetest to determine the modpack name even
156           if the folder is wrongly named.
157 * `description`: Description of mod to be shown in the Mods tab of the main
158                  menu.
159 * `author`: The author of the modpack. It only appears when downloaded from
160             ContentDB.
161 * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
162              internal ID used to track versions.
163 * `title`: A human-readable title to address the modpack.
164
165 Note: to support 0.4.x, please also create an empty modpack.txt file.
166
167 Mod directory structure
168 -----------------------
169
170     mods
171     ├── modname
172     │   ├── mod.conf
173     │   ├── screenshot.png
174     │   ├── settingtypes.txt
175     │   ├── init.lua
176     │   ├── models
177     │   ├── textures
178     │   │   ├── modname_stuff.png
179     │   │   ├── modname_stuff_normal.png
180     │   │   ├── modname_something_else.png
181     │   │   ├── subfolder_foo
182     │   │   │   ├── modname_more_stuff.png
183     │   │   │   └── another_subfolder
184     │   │   └── bar_subfolder
185     │   ├── sounds
186     │   ├── media
187     │   ├── locale
188     │   └── <custom data>
189     └── another
190
191 ### modname
192
193 The location of this directory can be fetched by using
194 `minetest.get_modpath(modname)`.
195
196 ### mod.conf
197
198 A `Settings` file that provides meta information about the mod.
199
200 * `name`: The mod name. Allows Minetest to determine the mod name even if the
201           folder is wrongly named.
202 * `description`: Description of mod to be shown in the Mods tab of the main
203                  menu.
204 * `depends`: A comma separated list of dependencies. These are mods that must be
205              loaded before this mod.
206 * `optional_depends`: A comma separated list of optional dependencies.
207                       Like a dependency, but no error if the mod doesn't exist.
208 * `author`: The author of the mod. It only appears when downloaded from
209             ContentDB.
210 * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
211              internal ID used to track versions.
212 * `title`: A human-readable title to address the mod.
213
214 ### `screenshot.png`
215
216 A screenshot shown in the mod manager within the main menu. It should
217 have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
218
219 ### `depends.txt`
220
221 **Deprecated:** you should use mod.conf instead.
222
223 This file is used if there are no dependencies in mod.conf.
224
225 List of mods that have to be loaded before loading this mod.
226
227 A single line contains a single modname.
228
229 Optional dependencies can be defined by appending a question mark
230 to a single modname. This means that if the specified mod
231 is missing, it does not prevent this mod from being loaded.
232
233 ### `description.txt`
234
235 **Deprecated:** you should use mod.conf instead.
236
237 This file is used if there is no description in mod.conf.
238
239 A file containing a description to be shown in the Mods tab of the main menu.
240
241 ### `settingtypes.txt`
242
243 The format is documented in `builtin/settingtypes.txt`.
244 It is parsed by the main menu settings dialogue to list mod-specific
245 settings in the "Mods" category.
246
247 ### `init.lua`
248
249 The main Lua script. Running this script should register everything it
250 wants to register. Subsequent execution depends on minetest calling the
251 registered callbacks.
252
253 `minetest.settings` can be used to read custom or existing settings at load
254 time, if necessary. (See [`Settings`])
255
256 ### `textures`, `sounds`, `media`, `models`, `locale`
257
258 Media files (textures, sounds, whatever) that will be transferred to the
259 client and will be available for use by the mod and translation files for
260 the clients (see [Translations]).
261
262 It is suggested to use the folders for the purpose they are thought for,
263 eg. put textures into `textures`, translation files into `locale`,
264 models for entities or meshnodes into `models` et cetera.
265
266 These folders and subfolders can contain subfolders.
267 Subfolders with names starting with `_` or `.` are ignored.
268 If a subfolder contains a media file with the same name as a media file
269 in one of its parents, the parent's file is used.
270
271 Although it is discouraged, a mod can overwrite a media file of any mod that it
272 depends on by supplying a file with an equal name.
273
274 Naming conventions
275 ------------------
276
277 Registered names should generally be in this format:
278
279     modname:<whatever>
280
281 `<whatever>` can have these characters:
282
283     a-zA-Z0-9_
284
285 This is to prevent conflicting names from corrupting maps and is
286 enforced by the mod loader.
287
288 Registered names can be overridden by prefixing the name with `:`. This can
289 be used for overriding the registrations of some other mod.
290
291 The `:` prefix can also be used for maintaining backwards compatibility.
292
293 ### Example
294
295 In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
296 So the name should be `experimental:tnt`.
297
298 Any mod can redefine `experimental:tnt` by using the name
299
300     :experimental:tnt
301
302 when registering it. For this to work correctly, that mod must have
303 `experimental` as a dependency.
304
305
306
307
308 Aliases
309 =======
310
311 Aliases of itemnames can be added by using
312 `minetest.register_alias(alias, original_name)` or
313 `minetest.register_alias_force(alias, original_name)`.
314
315 This adds an alias `alias` for the item called `original_name`.
316 From now on, you can use `alias` to refer to the item `original_name`.
317
318 The only difference between `minetest.register_alias` and
319 `minetest.register_alias_force` is that if an item named `alias` already exists,
320 `minetest.register_alias` will do nothing while
321 `minetest.register_alias_force` will unregister it.
322
323 This can be used for maintaining backwards compatibility.
324
325 This can also set quick access names for things, e.g. if
326 you have an item called `epiclylongmodname:stuff`, you could do
327
328     minetest.register_alias("stuff", "epiclylongmodname:stuff")
329
330 and be able to use `/giveme stuff`.
331
332 Mapgen aliases
333 --------------
334
335 In a game, a certain number of these must be set to tell core mapgens which
336 of the game's nodes are to be used for core mapgen generation. For example:
337
338     minetest.register_alias("mapgen_stone", "default:stone")
339
340 ### Aliases for non-V6 mapgens
341
342 #### Essential aliases
343
344 * `mapgen_stone`
345 * `mapgen_water_source`
346 * `mapgen_river_water_source`
347
348 `mapgen_river_water_source` is required for mapgens with sloping rivers where
349 it is necessary to have a river liquid node with a short `liquid_range` and
350 `liquid_renewable = false` to avoid flooding.
351
352 #### Optional aliases
353
354 * `mapgen_lava_source`
355
356 Fallback lava node used if cave liquids are not defined in biome definitions.
357 Deprecated, define cave liquids in biome definitions instead.
358
359 * `mapgen_cobble`
360
361 Fallback node used if dungeon nodes are not defined in biome definitions.
362 Deprecated, define dungeon nodes in biome definitions instead.
363
364 ### Aliases for Mapgen V6
365
366 #### Essential
367
368 * `mapgen_stone`
369 * `mapgen_water_source`
370 * `mapgen_lava_source`
371 * `mapgen_dirt`
372 * `mapgen_dirt_with_grass`
373 * `mapgen_sand`
374
375 * `mapgen_tree`
376 * `mapgen_leaves`
377 * `mapgen_apple`
378
379 * `mapgen_cobble`
380
381 #### Optional
382
383 * `mapgen_gravel` (falls back to stone)
384 * `mapgen_desert_stone` (falls back to stone)
385 * `mapgen_desert_sand` (falls back to sand)
386 * `mapgen_dirt_with_snow` (falls back to dirt_with_grass)
387 * `mapgen_snowblock` (falls back to dirt_with_grass)
388 * `mapgen_snow` (not placed if missing)
389 * `mapgen_ice` (falls back to water_source)
390
391 * `mapgen_jungletree` (falls back to tree)
392 * `mapgen_jungleleaves` (falls back to leaves)
393 * `mapgen_junglegrass` (not placed if missing)
394 * `mapgen_pine_tree` (falls back to tree)
395 * `mapgen_pine_needles` (falls back to leaves)
396
397 * `mapgen_stair_cobble` (falls back to cobble)
398 * `mapgen_mossycobble` (falls back to cobble)
399 * `mapgen_stair_desert_stone` (falls back to desert_stone)
400
401 ### Setting the node used in Mapgen Singlenode
402
403 By default the world is filled with air nodes. To set a different node use e.g.:
404
405     minetest.register_alias("mapgen_singlenode", "default:stone")
406
407
408
409
410 Textures
411 ========
412
413 Mods should generally prefix their textures with `modname_`, e.g. given
414 the mod name `foomod`, a texture could be called:
415
416     foomod_foothing.png
417
418 Textures are referred to by their complete name, or alternatively by
419 stripping out the file extension:
420
421 * e.g. `foomod_foothing.png`
422 * e.g. `foomod_foothing`
423
424 Supported texture formats are PNG (`.png`), JPEG (`.jpg`), Bitmap (`.bmp`)
425 and Targa (`.tga`).
426 Since better alternatives exist, the latter two may be removed in the future.
427
428 Texture modifiers
429 -----------------
430
431 There are various texture modifiers that can be used
432 to let the client generate textures on-the-fly.
433 The modifiers are applied directly in sRGB colorspace,
434 i.e. without gamma-correction.
435
436 ### Texture overlaying
437
438 Textures can be overlaid by putting a `^` between them.
439
440 Example:
441
442     default_dirt.png^default_grass_side.png
443
444 `default_grass_side.png` is overlaid over `default_dirt.png`.
445 The texture with the lower resolution will be automatically upscaled to
446 the higher resolution texture.
447
448 ### Texture grouping
449
450 Textures can be grouped together by enclosing them in `(` and `)`.
451
452 Example: `cobble.png^(thing1.png^thing2.png)`
453
454 A texture for `thing1.png^thing2.png` is created and the resulting
455 texture is overlaid on top of `cobble.png`.
456
457 ### Escaping
458
459 Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
460 passing complex texture names as arguments. Escaping is done with backslash and
461 is required for `^` and `:`.
462
463 Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
464
465 The lower 50 percent of `color.png^[mask:trans.png` are overlaid
466 on top of `cobble.png`.
467
468 ### Advanced texture modifiers
469
470 #### Crack
471
472 * `[crack:<n>:<p>`
473 * `[cracko:<n>:<p>`
474 * `[crack:<t>:<n>:<p>`
475 * `[cracko:<t>:<n>:<p>`
476
477 Parameters:
478
479 * `<t>`: tile count (in each direction)
480 * `<n>`: animation frame count
481 * `<p>`: current animation frame
482
483 Draw a step of the crack animation on the texture.
484 `crack` draws it normally, while `cracko` lays it over, keeping transparent
485 pixels intact.
486
487 Example:
488
489     default_cobble.png^[crack:10:1
490
491 #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
492
493 * `<w>`: width
494 * `<h>`: height
495 * `<x>`: x position
496 * `<y>`: y position
497 * `<file>`: texture to combine
498
499 Creates a texture of size `<w>` times `<h>` and blits the listed files to their
500 specified coordinates.
501
502 Example:
503
504     [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
505
506 #### `[resize:<w>x<h>`
507
508 Resizes the texture to the given dimensions.
509
510 Example:
511
512     default_sandstone.png^[resize:16x16
513
514 #### `[opacity:<r>`
515
516 Makes the base image transparent according to the given ratio.
517
518 `r` must be between 0 (transparent) and 255 (opaque).
519
520 Example:
521
522     default_sandstone.png^[opacity:127
523
524 #### `[invert:<mode>`
525
526 Inverts the given channels of the base image.
527 Mode may contain the characters "r", "g", "b", "a".
528 Only the channels that are mentioned in the mode string will be inverted.
529
530 Example:
531
532     default_apple.png^[invert:rgb
533
534 #### `[brighten`
535
536 Brightens the texture.
537
538 Example:
539
540     tnt_tnt_side.png^[brighten
541
542 #### `[noalpha`
543
544 Makes the texture completely opaque.
545
546 Example:
547
548     default_leaves.png^[noalpha
549
550 #### `[makealpha:<r>,<g>,<b>`
551
552 Convert one color to transparency.
553
554 Example:
555
556     default_cobble.png^[makealpha:128,128,128
557
558 #### `[transform<t>`
559
560 * `<t>`: transformation(s) to apply
561
562 Rotates and/or flips the image.
563
564 `<t>` can be a number (between 0 and 7) or a transform name.
565 Rotations are counter-clockwise.
566
567     0  I      identity
568     1  R90    rotate by 90 degrees
569     2  R180   rotate by 180 degrees
570     3  R270   rotate by 270 degrees
571     4  FX     flip X
572     5  FXR90  flip X then rotate by 90 degrees
573     6  FY     flip Y
574     7  FYR90  flip Y then rotate by 90 degrees
575
576 Example:
577
578     default_stone.png^[transformFXR90
579
580 #### `[inventorycube{<top>{<left>{<right>`
581
582 Escaping does not apply here and `^` is replaced by `&` in texture names
583 instead.
584
585 Create an inventory cube texture using the side textures.
586
587 Example:
588
589     [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
590
591 Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
592 `dirt.png^grass_side.png` textures
593
594 #### `[lowpart:<percent>:<file>`
595
596 Blit the lower `<percent>`% part of `<file>` on the texture.
597
598 Example:
599
600     base.png^[lowpart:25:overlay.png
601
602 #### `[verticalframe:<t>:<n>`
603
604 * `<t>`: animation frame count
605 * `<n>`: current animation frame
606
607 Crops the texture to a frame of a vertical animation.
608
609 Example:
610
611     default_torch_animated.png^[verticalframe:16:8
612
613 #### `[mask:<file>`
614
615 Apply a mask to the base image.
616
617 The mask is applied using binary AND.
618
619 #### `[sheet:<w>x<h>:<x>,<y>`
620
621 Retrieves a tile at position x,y from the base image
622 which it assumes to be a tilesheet with dimensions w,h.
623
624 #### `[colorize:<color>:<ratio>`
625
626 Colorize the textures with the given color.
627 `<color>` is specified as a `ColorString`.
628 `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`".  If
629 it is an int, then it specifies how far to interpolate between the
630 colors where 0 is only the texture color and 255 is only `<color>`. If
631 omitted, the alpha of `<color>` will be used as the ratio.  If it is
632 the word "`alpha`", then each texture pixel will contain the RGB of
633 `<color>` and the alpha of `<color>` multiplied by the alpha of the
634 texture pixel.
635
636 #### `[multiply:<color>`
637
638 Multiplies texture colors with the given color.
639 `<color>` is specified as a `ColorString`.
640 Result is more like what you'd expect if you put a color on top of another
641 color, meaning white surfaces get a lot of your new color while black parts
642 don't change very much.
643
644 #### `[png:<base64>`
645
646 Embed a base64 encoded PNG image in the texture string.
647 You can produce a valid string for this by calling
648 `minetest.encode_base64(minetest.encode_png(tex))`,
649 refer to the documentation of these functions for details.
650 You can use this to send disposable images such as captchas
651 to individual clients, or render things that would be too
652 expensive to compose with `[combine:`.
653
654 IMPORTANT: Avoid sending large images this way.
655 This is not a replacement for asset files, do not use it to do anything
656 that you could instead achieve by just using a file.
657 In particular consider `minetest.dynamic_add_media` and test whether
658 using other texture modifiers could result in a shorter string than
659 embedding a whole image, this may vary by use case.
660
661 Hardware coloring
662 -----------------
663
664 The goal of hardware coloring is to simplify the creation of
665 colorful nodes. If your textures use the same pattern, and they only
666 differ in their color (like colored wool blocks), you can use hardware
667 coloring instead of creating and managing many texture files.
668 All of these methods use color multiplication (so a white-black texture
669 with red coloring will result in red-black color).
670
671 ### Static coloring
672
673 This method is useful if you wish to create nodes/items with
674 the same texture, in different colors, each in a new node/item definition.
675
676 #### Global color
677
678 When you register an item or node, set its `color` field (which accepts a
679 `ColorSpec`) to the desired color.
680
681 An `ItemStack`'s static color can be overwritten by the `color` metadata
682 field. If you set that field to a `ColorString`, that color will be used.
683
684 #### Tile color
685
686 Each tile may have an individual static color, which overwrites every
687 other coloring method. To disable the coloring of a face,
688 set its color to white (because multiplying with white does nothing).
689 You can set the `color` property of the tiles in the node's definition
690 if the tile is in table format.
691
692 ### Palettes
693
694 For nodes and items which can have many colors, a palette is more
695 suitable. A palette is a texture, which can contain up to 256 pixels.
696 Each pixel is one possible color for the node/item.
697 You can register one node/item, which can have up to 256 colors.
698
699 #### Palette indexing
700
701 When using palettes, you always provide a pixel index for the given
702 node or `ItemStack`. The palette is read from left to right and from
703 top to bottom. If the palette has less than 256 pixels, then it is
704 stretched to contain exactly 256 pixels (after arranging the pixels
705 to one line). The indexing starts from 0.
706
707 Examples:
708
709 * 16x16 palette, index = 0: the top left corner
710 * 16x16 palette, index = 4: the fifth pixel in the first row
711 * 16x16 palette, index = 16: the pixel below the top left corner
712 * 16x16 palette, index = 255: the bottom right corner
713 * 2 (width) x 4 (height) palette, index = 31: the top left corner.
714   The palette has 8 pixels, so each pixel is stretched to 32 pixels,
715   to ensure the total 256 pixels.
716 * 2x4 palette, index = 32: the top right corner
717 * 2x4 palette, index = 63: the top right corner
718 * 2x4 palette, index = 64: the pixel below the top left corner
719
720 #### Using palettes with items
721
722 When registering an item, set the item definition's `palette` field to
723 a texture. You can also use texture modifiers.
724
725 The `ItemStack`'s color depends on the `palette_index` field of the
726 stack's metadata. `palette_index` is an integer, which specifies the
727 index of the pixel to use.
728
729 #### Linking palettes with nodes
730
731 When registering a node, set the item definition's `palette` field to
732 a texture. You can also use texture modifiers.
733 The node's color depends on its `param2`, so you also must set an
734 appropriate `paramtype2`:
735
736 * `paramtype2 = "color"` for nodes which use their full `param2` for
737   palette indexing. These nodes can have 256 different colors.
738   The palette should contain 256 pixels.
739 * `paramtype2 = "colorwallmounted"` for nodes which use the first
740   five bits (most significant) of `param2` for palette indexing.
741   The remaining three bits are describing rotation, as in `wallmounted`
742   paramtype2. Division by 8 yields the palette index (without stretching the
743   palette). These nodes can have 32 different colors, and the palette
744   should contain 32 pixels.
745   Examples:
746     * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
747       pixel will be picked from the palette.
748     * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
749       pixel will be picked from the palette.
750 * `paramtype2 = "colorfacedir"` for nodes which use the first
751   three bits of `param2` for palette indexing. The remaining
752   five bits are describing rotation, as in `facedir` paramtype2.
753   Division by 32 yields the palette index (without stretching the
754   palette). These nodes can have 8 different colors, and the
755   palette should contain 8 pixels.
756   Examples:
757     * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
758       first (= 0 + 1) pixel will be picked from the palette.
759     * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
760       second (= 1 + 1) pixel will be picked from the palette.
761 * `paramtype2 = "color4dir"` for nodes which use the first
762   six bits of `param2` for palette indexing. The remaining
763   two bits are describing rotation, as in `4dir` paramtype2.
764   Division by 4 yields the palette index (without stretching the
765   palette). These nodes can have 64 different colors, and the
766   palette should contain 64 pixels.
767   Examples:
768     * `param2 = 17` is 4 * 4 + 1, so the rotation is 1 and the
769       fifth (= 4 + 1) pixel will be picked from the palette.
770     * `param2 = 35` is 8 * 4 + 3, so the rotation is 3 and the
771       ninth (= 8 + 1) pixel will be picked from the palette.
772
773 To colorize a node on the map, set its `param2` value (according
774 to the node's paramtype2).
775
776 ### Conversion between nodes in the inventory and on the map
777
778 Static coloring is the same for both cases, there is no need
779 for conversion.
780
781 If the `ItemStack`'s metadata contains the `color` field, it will be
782 lost on placement, because nodes on the map can only use palettes.
783
784 If the `ItemStack`'s metadata contains the `palette_index` field, it is
785 automatically transferred between node and item forms by the engine,
786 when a player digs or places a colored node.
787 You can disable this feature by setting the `drop` field of the node
788 to itself (without metadata).
789 To transfer the color to a special drop, you need a drop table.
790
791 Example:
792
793     minetest.register_node("mod:stone", {
794         description = "Stone",
795         tiles = {"default_stone.png"},
796         paramtype2 = "color",
797         palette = "palette.png",
798         drop = {
799             items = {
800                 -- assume that mod:cobblestone also has the same palette
801                 {items = {"mod:cobblestone"}, inherit_color = true },
802             }
803         }
804     })
805
806 ### Colored items in craft recipes
807
808 Craft recipes only support item strings, but fortunately item strings
809 can also contain metadata. Example craft recipe registration:
810
811     minetest.register_craft({
812         output = minetest.itemstring_with_palette("wool:block", 3),
813         type = "shapeless",
814         recipe = {
815             "wool:block",
816             "dye:red",
817         },
818     })
819
820 To set the `color` field, you can use `minetest.itemstring_with_color`.
821
822 Metadata field filtering in the `recipe` field are not supported yet,
823 so the craft output is independent of the color of the ingredients.
824
825 Soft texture overlay
826 --------------------
827
828 Sometimes hardware coloring is not enough, because it affects the
829 whole tile. Soft texture overlays were added to Minetest to allow
830 the dynamic coloring of only specific parts of the node's texture.
831 For example a grass block may have colored grass, while keeping the
832 dirt brown.
833
834 These overlays are 'soft', because unlike texture modifiers, the layers
835 are not merged in the memory, but they are simply drawn on top of each
836 other. This allows different hardware coloring, but also means that
837 tiles with overlays are drawn slower. Using too much overlays might
838 cause FPS loss.
839
840 For inventory and wield images you can specify overlays which
841 hardware coloring does not modify. You have to set `inventory_overlay`
842 and `wield_overlay` fields to an image name.
843
844 To define a node overlay, simply set the `overlay_tiles` field of the node
845 definition. These tiles are defined in the same way as plain tiles:
846 they can have a texture name, color etc.
847 To skip one face, set that overlay tile to an empty string.
848
849 Example (colored grass block):
850
851     minetest.register_node("default:dirt_with_grass", {
852         description = "Dirt with Grass",
853         -- Regular tiles, as usual
854         -- The dirt tile disables palette coloring
855         tiles = {{name = "default_grass.png"},
856             {name = "default_dirt.png", color = "white"}},
857         -- Overlay tiles: define them in the same style
858         -- The top and bottom tile does not have overlay
859         overlay_tiles = {"", "",
860             {name = "default_grass_side.png"}},
861         -- Global color, used in inventory
862         color = "green",
863         -- Palette in the world
864         paramtype2 = "color",
865         palette = "default_foilage.png",
866     })
867
868
869
870
871 Sounds
872 ======
873
874 Only Ogg Vorbis files are supported.
875
876 For positional playing of sounds, only single-channel (mono) files are
877 supported. Otherwise OpenAL will play them non-positionally.
878
879 Mods should generally prefix their sounds with `modname_`, e.g. given
880 the mod name "`foomod`", a sound could be called:
881
882     foomod_foosound.ogg
883
884 Sounds are referred to by their name with a dot, a single digit and the
885 file extension stripped out. When a sound is played, the actual sound file
886 is chosen randomly from the matching sounds.
887
888 When playing the sound `foomod_foosound`, the sound is chosen randomly
889 from the available ones of the following files:
890
891 * `foomod_foosound.ogg`
892 * `foomod_foosound.0.ogg`
893 * `foomod_foosound.1.ogg`
894 * (...)
895 * `foomod_foosound.9.ogg`
896
897 Examples of sound parameter tables:
898
899     -- Play locationless on all clients
900     {
901         gain = 1.0,   -- default
902         fade = 0.0,   -- default, change to a value > 0 to fade the sound in
903         pitch = 1.0,  -- default
904     }
905     -- Play locationless to one player
906     {
907         to_player = name,
908         gain = 1.0,   -- default
909         fade = 0.0,   -- default, change to a value > 0 to fade the sound in
910         pitch = 1.0,  -- default
911     }
912     -- Play locationless to one player, looped
913     {
914         to_player = name,
915         gain = 1.0,  -- default
916         loop = true,
917     }
918     -- Play at a location
919     {
920         pos = {x = 1, y = 2, z = 3},
921         gain = 1.0,  -- default
922         max_hear_distance = 32,  -- default, uses a Euclidean metric
923     }
924     -- Play connected to an object, looped
925     {
926         object = <an ObjectRef>,
927         gain = 1.0,  -- default
928         max_hear_distance = 32,  -- default, uses a Euclidean metric
929         loop = true,
930     }
931     -- Play at a location, heard by anyone *but* the given player
932     {
933         pos = {x = 32, y = 0, z = 100},
934         max_hear_distance = 40,
935         exclude_player = name,
936     }
937
938 Looped sounds must either be connected to an object or played locationless to
939 one player using `to_player = name`.
940
941 A positional sound will only be heard by players that are within
942 `max_hear_distance` of the sound position, at the start of the sound.
943
944 `exclude_player = name` can be applied to locationless, positional and object-
945 bound sounds to exclude a single player from hearing them.
946
947 `SimpleSoundSpec`
948 -----------------
949
950 Specifies a sound name, gain (=volume) and pitch.
951 This is either a string or a table.
952
953 In string form, you just specify the sound name or
954 the empty string for no sound.
955
956 Table form has the following fields:
957
958 * `name`: Sound name
959 * `gain`: Volume (`1.0` = 100%)
960 * `pitch`: Pitch (`1.0` = 100%)
961
962 `gain` and `pitch` are optional and default to `1.0`.
963
964 Examples:
965
966 * `""`: No sound
967 * `{}`: No sound
968 * `"default_place_node"`: Play e.g. `default_place_node.ogg`
969 * `{name = "default_place_node"}`: Same as above
970 * `{name = "default_place_node", gain = 0.5}`: 50% volume
971 * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
972
973 Special sound files
974 -------------------
975
976 These sound files are played back by the engine if provided.
977
978  * `player_damage`: Played when the local player takes damage (gain = 0.5)
979  * `player_falling_damage`: Played when the local player takes
980    damage by falling (gain = 0.5)
981  * `player_jump`: Played when the local player jumps
982  * `default_dig_<groupname>`: Default node digging sound
983    (see node sound definition for details)
984
985 Registered definitions
986 ======================
987
988 Anything added using certain [Registration functions] gets added to one or more
989 of the global [Registered definition tables].
990
991 Note that in some cases you will stumble upon things that are not contained
992 in these tables (e.g. when a mod has been removed). Always check for
993 existence before trying to access the fields.
994
995 Example:
996
997 All nodes registered with `minetest.register_node` get added to the table
998 `minetest.registered_nodes`.
999
1000 If you want to check the drawtype of a node, you could do it like this:
1001
1002     local def = minetest.registered_nodes[nodename]
1003     local drawtype = def and def.drawtype
1004
1005
1006
1007
1008 Nodes
1009 =====
1010
1011 Nodes are the bulk data of the world: cubes and other things that take the
1012 space of a cube. Huge amounts of them are handled efficiently, but they
1013 are quite static.
1014
1015 The definition of a node is stored and can be accessed by using
1016
1017     minetest.registered_nodes[node.name]
1018
1019 See [Registered definitions].
1020
1021 Nodes are passed by value between Lua and the engine.
1022 They are represented by a table:
1023
1024     {name="name", param1=num, param2=num}
1025
1026 `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
1027 them for certain automated functions. If you don't use these functions, you can
1028 use them to store arbitrary values.
1029
1030 Node paramtypes
1031 ---------------
1032
1033 The functions of `param1` and `param2` are determined by certain fields in the
1034 node definition.
1035
1036 The function of `param1` is determined by `paramtype` in node definition.
1037 `param1` is reserved for the engine when `paramtype != "none"`.
1038
1039 * `paramtype = "light"`
1040     * The value stores light with and without sun in its lower and upper 4 bits
1041       respectively.
1042     * Required by a light source node to enable spreading its light.
1043     * Required by the following drawtypes as they determine their visual
1044       brightness from their internal light value:
1045         * torchlike
1046         * signlike
1047         * firelike
1048         * fencelike
1049         * raillike
1050         * nodebox
1051         * mesh
1052         * plantlike
1053         * plantlike_rooted
1054 * `paramtype = "none"`
1055     * `param1` will not be used by the engine and can be used to store
1056       an arbitrary value
1057
1058 The function of `param2` is determined by `paramtype2` in node definition.
1059 `param2` is reserved for the engine when `paramtype2 != "none"`.
1060
1061 * `paramtype2 = "flowingliquid"`
1062     * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
1063     * The liquid level and a flag of the liquid are stored in `param2`
1064     * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
1065       see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
1066       to access/manipulate the content of this field
1067     * Bit 3: If set, liquid is flowing downwards (no graphical effect)
1068 * `paramtype2 = "wallmounted"`
1069     * Supported drawtypes: "torchlike", "signlike", "plantlike",
1070       "plantlike_rooted", "normal", "nodebox", "mesh"
1071     * The rotation of the node is stored in `param2`
1072     * Node is 'mounted'/facing towards one of 6 directions
1073     * You can make this value by using `minetest.dir_to_wallmounted()`
1074     * Values range 0 - 5
1075     * The value denotes at which direction the node is "mounted":
1076       0 = y+,   1 = y-,   2 = x+,   3 = x-,   4 = z+,   5 = z-
1077     * By default, on placement the param2 is automatically set to the
1078       appropriate rotation, depending on which side was pointed at
1079 * `paramtype2 = "facedir"`
1080     * Supported drawtypes: "normal", "nodebox", "mesh"
1081     * The rotation of the node is stored in `param2`.
1082     * Node is rotated around face and axis; 24 rotations in total.
1083     * Can be made by using `minetest.dir_to_facedir()`.
1084     * Chests and furnaces can be rotated that way, and also 'flipped'
1085     * Values range 0 - 23
1086     * facedir / 4 = axis direction:
1087       0 = y+,   1 = z+,   2 = z-,   3 = x+,   4 = x-,   5 = y-
1088     * The node is rotated 90 degrees around the X or Z axis so that its top face
1089       points in the desired direction. For the y- direction, it's rotated 180
1090       degrees around the Z axis.
1091     * facedir modulo 4 = left-handed rotation around the specified axis, in 90° steps.
1092     * By default, on placement the param2 is automatically set to the
1093       horizontal direction the player was looking at (values 0-3)
1094     * Special case: If the node is a connected nodebox, the nodebox
1095       will NOT rotate, only the textures will.
1096 * `paramtype2 = "4dir"`
1097     * Supported drawtypes: "normal", "nodebox", "mesh"
1098     * The rotation of the node is stored in `param2`.
1099     * Allows node to be rotated horizontally, 4 rotations in total
1100     * Can be made by using `minetest.dir_to_fourdir()`.
1101     * Chests and furnaces can be rotated that way, but not flipped
1102     * Values range 0 - 3
1103     * 4dir modulo 4 = rotation
1104     * Otherwise, behavior is identical to facedir
1105 * `paramtype2 = "leveled"`
1106     * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
1107         * Leveled nodebox:
1108             * The level of the top face of the nodebox is stored in `param2`.
1109             * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
1110               nodeboxes.
1111             * The nodebox height is (`param2` / 64) nodes.
1112             * The maximum accepted value of `param2` is 127.
1113         * Rooted plantlike:
1114             * The height of the 'plantlike' section is stored in `param2`.
1115             * The height is (`param2` / 16) nodes.
1116 * `paramtype2 = "degrotate"`
1117     * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
1118       stored in `param2`.
1119     * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
1120       get the actual rotation in degrees of the node.
1121 * `paramtype2 = "meshoptions"`
1122     * Only valid for "plantlike" drawtype. `param2` encodes the shape and
1123       optional modifiers of the "plant". `param2` is a bitfield.
1124     * Bits 0 to 2 select the shape.
1125       Use only one of the values below:
1126         * 0 = an "x" shaped plant (ordinary plant)
1127         * 1 = a "+" shaped plant (just rotated 45 degrees)
1128         * 2 = a "*" shaped plant with 3 faces instead of 2
1129         * 3 = a "#" shaped plant with 4 faces instead of 2
1130         * 4 = a "#" shaped plant with 4 faces that lean outwards
1131         * 5-7 are unused and reserved for future meshes.
1132     * Bits 3 to 7 are used to enable any number of optional modifiers.
1133       Just add the corresponding value(s) below to `param2`:
1134         * 8  - Makes the plant slightly vary placement horizontally
1135         * 16 - Makes the plant mesh 1.4x larger
1136         * 32 - Moves each face randomly a small bit down (1/8 max)
1137         * values 64 and 128 (bits 6-7) are reserved for future use.
1138     * Example: `param2 = 0` selects a normal "x" shaped plant
1139     * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
1140 * `paramtype2 = "color"`
1141     * `param2` tells which color is picked from the palette.
1142       The palette should have 256 pixels.
1143 * `paramtype2 = "colorfacedir"`
1144     * Same as `facedir`, but with colors.
1145     * The first three bits of `param2` tells which color is picked from the
1146       palette. The palette should have 8 pixels.
1147 * `paramtype2 = "color4dir"`
1148     * Same as `facedir`, but with colors.
1149     * The first six bits of `param2` tells which color is picked from the
1150       palette. The palette should have 64 pixels.
1151 * `paramtype2 = "colorwallmounted"`
1152     * Same as `wallmounted`, but with colors.
1153     * The first five bits of `param2` tells which color is picked from the
1154       palette. The palette should have 32 pixels.
1155 * `paramtype2 = "glasslikeliquidlevel"`
1156     * Only valid for "glasslike_framed" or "glasslike_framed_optional"
1157       drawtypes. "glasslike_framed_optional" nodes are only affected if the
1158       "Connected Glass" setting is enabled.
1159     * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
1160       full.
1161     * Bits 6 and 7 modify the appearance of the frame and node faces. One or
1162       both of these values may be added to `param2`:
1163         * 64  - Makes the node not connect with neighbors above or below it.
1164         * 128 - Makes the node not connect with neighbors to its sides.
1165     * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
1166 * `paramtype2 = "colordegrotate"`
1167     * Same as `degrotate`, but with colors.
1168     * The first (most-significant) three bits of `param2` tells which color
1169       is picked from the palette. The palette should have 8 pixels.
1170     * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
1171 * `paramtype2 = "none"`
1172     * `param2` will not be used by the engine and can be used to store
1173       an arbitrary value
1174
1175 Nodes can also contain extra data. See [Node Metadata].
1176
1177 Node drawtypes
1178 --------------
1179
1180 There are a bunch of different looking node types.
1181
1182 Look for examples in `games/devtest` or `games/minetest_game`.
1183
1184 * `normal`
1185     * A node-sized cube.
1186 * `airlike`
1187     * Invisible, uses no texture.
1188 * `liquid`
1189     * The cubic source node for a liquid.
1190     * Faces bordering to the same node are never rendered.
1191     * Connects to node specified in `liquid_alternative_flowing`.
1192     * You *must* set `liquid_alternative_source` to the node's own name.
1193     * Use `backface_culling = false` for the tiles you want to make
1194       visible when inside the node.
1195 * `flowingliquid`
1196     * The flowing version of a liquid, appears with various heights and slopes.
1197     * Faces bordering to the same node are never rendered.
1198     * Connects to node specified in `liquid_alternative_source`.
1199     * You *must* set `liquid_alternative_flowing` to the node's own name.
1200     * Node textures are defined with `special_tiles` where the first tile
1201       is for the top and bottom faces and the second tile is for the side
1202       faces.
1203     * `tiles` is used for the item/inventory/wield image rendering.
1204     * Use `backface_culling = false` for the special tiles you want to make
1205       visible when inside the node
1206 * `glasslike`
1207     * Often used for partially-transparent nodes.
1208     * Only external sides of textures are visible.
1209 * `glasslike_framed`
1210     * All face-connected nodes are drawn as one volume within a surrounding
1211       frame.
1212     * The frame appearance is generated from the edges of the first texture
1213       specified in `tiles`. The width of the edges used are 1/16th of texture
1214       size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
1215     * The glass 'shine' (or other desired detail) on each node face is supplied
1216       by the second texture specified in `tiles`.
1217 * `glasslike_framed_optional`
1218     * This switches between the above 2 drawtypes according to the menu setting
1219       'Connected Glass'.
1220 * `allfaces`
1221     * Often used for partially-transparent nodes.
1222     * External and internal sides of textures are visible.
1223 * `allfaces_optional`
1224     * Often used for leaves nodes.
1225     * This switches between `normal`, `glasslike` and `allfaces` according to
1226       the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
1227     * With 'Simple Leaves' selected, the texture specified in `special_tiles`
1228       is used instead, if present. This allows a visually thicker texture to be
1229       used to compensate for how `glasslike` reduces visual thickness.
1230 * `torchlike`
1231     * A single vertical texture.
1232     * If `paramtype2="[color]wallmounted"`:
1233         * If placed on top of a node, uses the first texture specified in `tiles`.
1234         * If placed against the underside of a node, uses the second texture
1235           specified in `tiles`.
1236         * If placed on the side of a node, uses the third texture specified in
1237           `tiles` and is perpendicular to that node.
1238     * If `paramtype2="none"`:
1239         * Will be rendered as if placed on top of a node (see
1240           above) and only the first texture is used.
1241 * `signlike`
1242     * A single texture parallel to, and mounted against, the top, underside or
1243       side of a node.
1244     * If `paramtype2="[color]wallmounted"`, it rotates according to `param2`
1245     * If `paramtype2="none"`, it will always be on the floor.
1246 * `plantlike`
1247     * Two vertical and diagonal textures at right-angles to each other.
1248     * See `paramtype2 = "meshoptions"` above for other options.
1249 * `firelike`
1250     * When above a flat surface, appears as 6 textures, the central 2 as
1251       `plantlike` plus 4 more surrounding those.
1252     * If not above a surface the central 2 do not appear, but the texture
1253       appears against the faces of surrounding nodes if they are present.
1254 * `fencelike`
1255     * A 3D model suitable for a wooden fence.
1256     * One placed node appears as a single vertical post.
1257     * Adjacently-placed nodes cause horizontal bars to appear between them.
1258 * `raillike`
1259     * Often used for tracks for mining carts.
1260     * Requires 4 textures to be specified in `tiles`, in order: Straight,
1261       curved, t-junction, crossing.
1262     * Each placed node automatically switches to a suitable rotated texture
1263       determined by the adjacent `raillike` nodes, in order to create a
1264       continuous track network.
1265     * Becomes a sloping node if placed against stepped nodes.
1266 * `nodebox`
1267     * Often used for stairs and slabs.
1268     * Allows defining nodes consisting of an arbitrary number of boxes.
1269     * See [Node boxes] below for more information.
1270 * `mesh`
1271     * Uses models for nodes.
1272     * Tiles should hold model materials textures.
1273     * Only static meshes are implemented.
1274     * For supported model formats see Irrlicht engine documentation.
1275 * `plantlike_rooted`
1276     * Enables underwater `plantlike` without air bubbles around the nodes.
1277     * Consists of a base cube at the co-ordinates of the node plus a
1278       `plantlike` extension above
1279     * If `paramtype2="leveled", the `plantlike` extension has a height
1280       of `param2 / 16` nodes, otherwise it's the height of 1 node
1281     * If `paramtype2="wallmounted"`, the `plantlike` extension
1282       will be at one of the corresponding 6 sides of the base cube.
1283       Also, the base cube rotates like a `normal` cube would
1284     * The `plantlike` extension visually passes through any nodes above the
1285       base cube without affecting them.
1286     * The base cube texture tiles are defined as normal, the `plantlike`
1287       extension uses the defined special tile, for example:
1288       `special_tiles = {{name = "default_papyrus.png"}},`
1289
1290 `*_optional` drawtypes need less rendering time if deactivated
1291 (always client-side).
1292
1293 Node boxes
1294 ----------
1295
1296 Node selection boxes are defined using "node boxes".
1297
1298 A nodebox is defined as any of:
1299
1300     {
1301         -- A normal cube; the default in most things
1302         type = "regular"
1303     }
1304     {
1305         -- A fixed box (or boxes) (facedir param2 is used, if applicable)
1306         type = "fixed",
1307         fixed = box OR {box1, box2, ...}
1308     }
1309     {
1310         -- A variable height box (or boxes) with the top face position defined
1311         -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
1312         -- by param2.
1313         -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
1314         type = "leveled",
1315         fixed = box OR {box1, box2, ...}
1316     }
1317     {
1318         -- A box like the selection box for torches
1319         -- (wallmounted param2 is used, if applicable)
1320         type = "wallmounted",
1321         wall_top = box,
1322         wall_bottom = box,
1323         wall_side = box
1324     }
1325     {
1326         -- A node that has optional boxes depending on neighboring nodes'
1327         -- presence and type. See also `connects_to`.
1328         type = "connected",
1329         fixed = box OR {box1, box2, ...}
1330         connect_top = box OR {box1, box2, ...}
1331         connect_bottom = box OR {box1, box2, ...}
1332         connect_front = box OR {box1, box2, ...}
1333         connect_left = box OR {box1, box2, ...}
1334         connect_back = box OR {box1, box2, ...}
1335         connect_right = box OR {box1, box2, ...}
1336         -- The following `disconnected_*` boxes are the opposites of the
1337         -- `connect_*` ones above, i.e. when a node has no suitable neighbor
1338         -- on the respective side, the corresponding disconnected box is drawn.
1339         disconnected_top = box OR {box1, box2, ...}
1340         disconnected_bottom = box OR {box1, box2, ...}
1341         disconnected_front = box OR {box1, box2, ...}
1342         disconnected_left = box OR {box1, box2, ...}
1343         disconnected_back = box OR {box1, box2, ...}
1344         disconnected_right = box OR {box1, box2, ...}
1345         disconnected = box OR {box1, box2, ...} -- when there is *no* neighbor
1346         disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
1347                                                       -- neighbors to the sides
1348     }
1349
1350 A `box` is defined as:
1351
1352     {x1, y1, z1, x2, y2, z2}
1353
1354 A box of a regular node would look like:
1355
1356     {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
1357
1358 To avoid collision issues, keep each value within the range of +/- 1.45.
1359 This also applies to leveled nodeboxes, where the final height shall not
1360 exceed this soft limit.
1361
1362
1363
1364 Map terminology and coordinates
1365 ===============================
1366
1367 Nodes, mapblocks, mapchunks
1368 ---------------------------
1369
1370 A 'node' is the fundamental cubic unit of a world and appears to a player as
1371 roughly 1x1x1 meters in size.
1372
1373 A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
1374 fundamental region of a world that is stored in the world database, sent to
1375 clients and handled by many parts of the engine.
1376 'mapblock' is preferred terminology to 'block' to help avoid confusion with
1377 'node', however 'block' often appears in the API.
1378
1379 A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
1380 (80x80x80 nodes) and is the volume of world generated in one operation by
1381 the map generator.
1382 The size in mapblocks has been chosen to optimize map generation.
1383
1384 Coordinates
1385 -----------
1386
1387 ### Orientation of axes
1388
1389 For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
1390
1391 ### Node coordinates
1392
1393 Almost all positions used in the API use node coordinates.
1394
1395 ### Mapblock coordinates
1396
1397 Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
1398 specify a particular mapblock.
1399 For example blockpos (0,0,0) specifies the mapblock that extends from
1400 node position (0,0,0) to node position (15,15,15).
1401
1402 #### Converting node position to the containing blockpos
1403
1404 To calculate the blockpos of the mapblock that contains the node at 'nodepos',
1405 for each axis:
1406
1407 * blockpos = math.floor(nodepos / 16)
1408
1409 #### Converting blockpos to min/max node positions
1410
1411 To calculate the min/max node positions contained in the mapblock at 'blockpos',
1412 for each axis:
1413
1414 * Minimum:
1415   nodepos = blockpos * 16
1416 * Maximum:
1417   nodepos = blockpos * 16 + 15
1418
1419
1420
1421
1422 HUD
1423 ===
1424
1425 HUD element types
1426 -----------------
1427
1428 The position field is used for all element types.
1429 To account for differing resolutions, the position coordinates are the
1430 percentage of the screen, ranging in value from `0` to `1`.
1431
1432 The `name` field is not yet used, but should contain a description of what the
1433 HUD element represents.
1434
1435 The `direction` field is the direction in which something is drawn.
1436 `0` draws from left to right, `1` draws from right to left, `2` draws from
1437 top to bottom, and `3` draws from bottom to top.
1438
1439 The `alignment` field specifies how the item will be aligned. It is a table
1440 where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
1441 moved to the left/up, and `1` is to the right/down. Fractional values can be
1442 used.
1443
1444 The `offset` field specifies a pixel offset from the position. Contrary to
1445 position, the offset is not scaled to screen size. This allows for some
1446 precisely positioned items in the HUD.
1447
1448 **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
1449 factor!
1450
1451 The `z_index` field specifies the order of HUD elements from back to front.
1452 Lower z-index elements are displayed behind higher z-index elements. Elements
1453 with same z-index are displayed in an arbitrary order. Default 0.
1454 Supports negative values. By convention, the following values are recommended:
1455
1456 *  -400: Graphical effects, such as vignette
1457 *  -300: Name tags, waypoints
1458 *  -200: Wieldhand
1459 *  -100: Things that block the player's view, e.g. masks
1460 *     0: Default. For standard in-game HUD elements like crosshair, hotbar,
1461          minimap, builtin statbars, etc.
1462 *   100: Temporary text messages or notification icons
1463 *  1000: Full-screen effects such as full-black screen or credits.
1464          This includes effects that cover the entire screen
1465
1466 If your HUD element doesn't fit into any category, pick a number
1467 between the suggested values
1468
1469 Below are the specific uses for fields in each type; fields not listed for that
1470 type are ignored.
1471
1472 ### `image`
1473
1474 Displays an image on the HUD.
1475
1476 * `scale`: The scale of the image, with 1 being the original texture size.
1477   Only the X coordinate scale is used (positive values).
1478   Negative values represent that percentage of the screen it
1479   should take; e.g. `x=-100` means 100% (width).
1480 * `text`: The name of the texture that is displayed.
1481 * `alignment`: The alignment of the image.
1482 * `offset`: offset in pixels from position.
1483
1484 ### `text`
1485
1486 Displays text on the HUD.
1487
1488 * `scale`: Defines the bounding rectangle of the text.
1489   A value such as `{x=100, y=100}` should work.
1490 * `text`: The text to be displayed in the HUD element.
1491 * `number`: An integer containing the RGB value of the color used to draw the
1492   text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
1493 * `alignment`: The alignment of the text.
1494 * `offset`: offset in pixels from position.
1495 * `size`: size of the text.
1496   The player-set font size is multiplied by size.x (y value isn't used).
1497 * `style`: determines font style
1498   Bitfield with 1 = bold, 2 = italic, 4 = monospace
1499
1500 ### `statbar`
1501
1502 Displays a horizontal bar made up of half-images with an optional background.
1503
1504 * `text`: The name of the texture to use.
1505 * `text2`: Optional texture name to enable a background / "off state"
1506   texture (useful to visualize the maximal value). Both textures
1507   must have the same size.
1508 * `number`: The number of half-textures that are displayed.
1509   If odd, will end with a vertically center-split texture.
1510 * `item`: Same as `number` but for the "off state" texture
1511 * `direction`: To which direction the images will extend to
1512 * `offset`: offset in pixels from position.
1513 * `size`: If used, will force full-image size to this value (override texture
1514   pack image size)
1515
1516 ### `inventory`
1517
1518 * `text`: The name of the inventory list to be displayed.
1519 * `number`: Number of items in the inventory to be displayed.
1520 * `item`: Position of item that is selected.
1521 * `direction`: Direction the list will be displayed in
1522 * `offset`: offset in pixels from position.
1523
1524 ### `waypoint`
1525
1526 Displays distance to selected world position.
1527
1528 * `name`: The name of the waypoint.
1529 * `text`: Distance suffix. Can be blank.
1530 * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
1531   If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
1532   When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
1533   `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
1534   `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
1535   `precision = n` will show multiples of `1/n`
1536 * `number:` An integer containing the RGB value of the color used to draw the
1537   text.
1538 * `world_pos`: World position of the waypoint.
1539 * `offset`: offset in pixels from position.
1540 * `alignment`: The alignment of the waypoint.
1541
1542 ### `image_waypoint`
1543
1544 Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
1545
1546 * `scale`: The scale of the image, with 1 being the original texture size.
1547   Only the X coordinate scale is used (positive values).
1548   Negative values represent that percentage of the screen it
1549   should take; e.g. `x=-100` means 100% (width).
1550 * `text`: The name of the texture that is displayed.
1551 * `alignment`: The alignment of the image.
1552 * `world_pos`: World position of the waypoint.
1553 * `offset`: offset in pixels from position.
1554
1555 ### `compass`
1556
1557 Displays an image oriented or translated according to current heading direction.
1558
1559 * `size`: The size of this element. Negative values represent percentage
1560   of the screen; e.g. `x=-100` means 100% (width).
1561 * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
1562 * `text`: The name of the texture to use.
1563 * `alignment`: The alignment of the image.
1564 * `offset`: Offset in pixels from position.
1565 * `direction`: How the image is rotated/translated:
1566   * 0 - Rotate as heading direction
1567   * 1 - Rotate in reverse direction
1568   * 2 - Translate as landscape direction
1569   * 3 - Translate in reverse direction
1570
1571 If translation is chosen, texture is repeated horizontally to fill the whole element.
1572
1573 ### `minimap`
1574
1575 Displays a minimap on the HUD.
1576
1577 * `size`: Size of the minimap to display. Minimap should be a square to avoid
1578   distortion.
1579 * `alignment`: The alignment of the minimap.
1580 * `offset`: offset in pixels from position.
1581
1582 Representations of simple things
1583 ================================
1584
1585 Vector (ie. a position)
1586 -----------------------
1587
1588     vector.new(x, y, z)
1589
1590 See [Spatial Vectors] for details.
1591
1592 `pointed_thing`
1593 ---------------
1594
1595 * `{type="nothing"}`
1596 * `{type="node", under=pos, above=pos}`
1597     * Indicates a pointed node selection box.
1598     * `under` refers to the node position behind the pointed face.
1599     * `above` refers to the node position in front of the pointed face.
1600 * `{type="object", ref=ObjectRef}`
1601
1602 Exact pointing location (currently only `Raycast` supports these fields):
1603
1604 * `pointed_thing.intersection_point`: The absolute world coordinates of the
1605   point on the selection box which is pointed at. May be in the selection box
1606   if the pointer is in the box too.
1607 * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
1608   from 1).
1609 * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
1610   selected selection box. This specifies which face is pointed at.
1611   Is a null vector `vector.zero()` when the pointer is inside the selection box.
1612
1613
1614
1615
1616 Flag Specifier Format
1617 =====================
1618
1619 Flags using the standardized flag specifier format can be specified in either
1620 of two ways, by string or table.
1621
1622 The string format is a comma-delimited set of flag names; whitespace and
1623 unrecognized flag fields are ignored. Specifying a flag in the string sets the
1624 flag, and specifying a flag prefixed by the string `"no"` explicitly
1625 clears the flag from whatever the default may be.
1626
1627 In addition to the standard string flag format, the schematic flags field can
1628 also be a table of flag names to boolean values representing whether or not the
1629 flag is set. Additionally, if a field with the flag name prefixed with `"no"`
1630 is present, mapped to a boolean of any value, the specified flag is unset.
1631
1632 E.g. A flag field of value
1633
1634     {place_center_x = true, place_center_y=false, place_center_z=true}
1635
1636 is equivalent to
1637
1638     {place_center_x = true, noplace_center_y=true, place_center_z=true}
1639
1640 which is equivalent to
1641
1642     "place_center_x, noplace_center_y, place_center_z"
1643
1644 or even
1645
1646     "place_center_x, place_center_z"
1647
1648 since, by default, no schematic attributes are set.
1649
1650
1651
1652
1653 Items
1654 =====
1655
1656 Items are things that can be held by players, dropped in the map and
1657 stored in inventories.
1658 Items come in the form of item stacks, which are collections of equal
1659 items that occupy a single inventory slot.
1660
1661 Item types
1662 ----------
1663
1664 There are three kinds of items: nodes, tools and craftitems.
1665
1666 * Node: Placeable item form of a node in the world's voxel grid
1667 * Tool: Has a changeable wear property but cannot be stacked
1668 * Craftitem: Has no special properties
1669
1670 Every registered node (the voxel in the world) has a corresponding
1671 item form (the thing in your inventory) that comes along with it.
1672 This item form can be placed which will create a node in the
1673 world (by default).
1674 Both the 'actual' node and its item form share the same identifier.
1675 For all practical purposes, you can treat the node and its item form
1676 interchangeably. We usually just say 'node' to the item form of
1677 the node as well.
1678
1679 Note the definition of tools is purely technical. The only really
1680 unique thing about tools is their wear, and that's basically it.
1681 Beyond that, you can't make any gameplay-relevant assumptions
1682 about tools or non-tools. It is perfectly valid to register something
1683 that acts as tool in a gameplay sense as a craftitem, and vice-versa.
1684
1685 Craftitems can be used for items that neither need to be a node
1686 nor a tool.
1687
1688 Amount and wear
1689 ---------------
1690
1691 All item stacks have an amount between 0 and 65535. It is 1 by
1692 default. Tool item stacks can not have an amount greater than 1.
1693
1694 Tools use a wear (damage) value ranging from 0 to 65535. The
1695 value 0 is the default and is used for unworn tools. The values
1696 1 to 65535 are used for worn tools, where a higher value stands for
1697 a higher wear. Non-tools technically also have a wear property,
1698 but it is always 0. There is also a special 'toolrepair' crafting
1699 recipe that is only available to tools.
1700
1701 Item formats
1702 ------------
1703
1704 Items and item stacks can exist in three formats: Serializes, table format
1705 and `ItemStack`.
1706
1707 When an item must be passed to a function, it can usually be in any of
1708 these formats.
1709
1710 ### Serialized
1711
1712 This is called "stackstring" or "itemstring". It is a simple string with
1713 1-4 components:
1714
1715 1. Full item identifier ("item name")
1716 2. Optional amount
1717 3. Optional wear value
1718 4. Optional item metadata
1719
1720 Syntax:
1721
1722     <identifier> [<amount>[ <wear>[ <metadata>]]]
1723
1724 Examples:
1725
1726 * `"default:apple"`: 1 apple
1727 * `"default:dirt 5"`: 5 dirt
1728 * `"default:pick_stone"`: a new stone pickaxe
1729 * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
1730 * `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`:
1731   * a wooden pickaxe from the `default` mod,
1732   * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool),
1733   * with the `description` field set to `"My worn out pick"` in its metadata
1734 * `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`:
1735   * analogous to the above example
1736   * note how the wear is set to `0` as dirt is not a tool
1737
1738 You should ideally use the `ItemStack` format to build complex item strings
1739 (especially if they use item metadata)
1740 without relying on the serialization format. Example:
1741
1742     local stack = ItemStack("default:pick_wood")
1743     stack:set_wear(21323)
1744     stack:get_meta():set_string("description", "My worn out pick")
1745     local itemstring = stack:to_string()
1746
1747 Additionally the methods `minetest.itemstring_with_palette(item, palette_index)`
1748 and `minetest.itemstring_with_color(item, colorstring)` may be used to create
1749 item strings encoding color information in their metadata.
1750
1751 ### Table format
1752
1753 Examples:
1754
1755 5 dirt nodes:
1756
1757     {name="default:dirt", count=5, wear=0, metadata=""}
1758
1759 A wooden pick about 1/3 worn out:
1760
1761     {name="default:pick_wood", count=1, wear=21323, metadata=""}
1762
1763 An apple:
1764
1765     {name="default:apple", count=1, wear=0, metadata=""}
1766
1767 ### `ItemStack`
1768
1769 A native C++ format with many helper methods. Useful for converting
1770 between formats. See the [Class reference] section for details.
1771
1772
1773
1774
1775 Groups
1776 ======
1777
1778 In a number of places, there is a group table. Groups define the
1779 properties of a thing (item, node, armor of entity, tool capabilities)
1780 in such a way that the engine and other mods can can interact with
1781 the thing without actually knowing what the thing is.
1782
1783 Usage
1784 -----
1785
1786 Groups are stored in a table, having the group names with keys and the
1787 group ratings as values. Group ratings are integer values within the
1788 range [-32767, 32767]. For example:
1789
1790     -- Default dirt
1791     groups = {crumbly=3, soil=1}
1792
1793     -- A more special dirt-kind of thing
1794     groups = {crumbly=2, soil=1, level=2, outerspace=1}
1795
1796 Groups always have a rating associated with them. If there is no
1797 useful meaning for a rating for an enabled group, it shall be `1`.
1798
1799 When not defined, the rating of a group defaults to `0`. Thus when you
1800 read groups, you must interpret `nil` and `0` as the same value, `0`.
1801
1802 You can read the rating of a group for an item or a node by using
1803
1804     minetest.get_item_group(itemname, groupname)
1805
1806 Groups of items
1807 ---------------
1808
1809 Groups of items can define what kind of an item it is (e.g. wool).
1810
1811 Groups of nodes
1812 ---------------
1813
1814 In addition to the general item things, groups are used to define whether
1815 a node is destroyable and how long it takes to destroy by a tool.
1816
1817 Groups of entities
1818 ------------------
1819
1820 For entities, groups are, as of now, used only for calculating damage.
1821 The rating is the percentage of damage caused by items with this damage group.
1822 See [Entity damage mechanism].
1823
1824     object:get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
1825     object:set_armor_groups({fleshy=30, cracky=80})
1826
1827 Groups of tool capabilities
1828 ---------------------------
1829
1830 Groups in tool capabilities define which groups of nodes and entities they
1831 are effective towards.
1832
1833 Groups in crafting recipes
1834 --------------------------
1835
1836 In crafting recipes, you can specify a group as an input item.
1837 This means that any item in that group will be accepted as input.
1838
1839 The basic syntax is:
1840
1841     "group:<group_name>"
1842
1843 For example, `"group:meat"` will accept any item in the `meat` group.
1844
1845 It is also possible to require an input item to be in
1846 multiple groups at once. The syntax for that is:
1847
1848     "group:<group_name_1>,<group_name_2>,(...),<group_name_n>"
1849
1850 For example, `"group:leaves,birch,trimmed"` accepts any item which is member
1851 of *all* the groups `leaves` *and* `birch` *and* `trimmed`.
1852
1853 An example recipe: Craft a raw meat soup from any meat, any water and any bowl:
1854
1855     {
1856         output = "food:meat_soup_raw",
1857         recipe = {
1858             {"group:meat"},
1859             {"group:water"},
1860             {"group:bowl"},
1861         },
1862     }
1863
1864 Another example: Craft red wool from white wool and red dye
1865 (here, "red dye" is defined as any item which is member of
1866 *both* the groups `dye` and `basecolor_red`).
1867
1868     {
1869         type = "shapeless",
1870         output = "wool:red",
1871         recipe = {"wool:white", "group:dye,basecolor_red"},
1872     }
1873
1874 Special groups
1875 --------------
1876
1877 The asterisk `(*)` after a group name describes that there is no engine
1878 functionality bound to it, and implementation is left up as a suggestion
1879 to games.
1880
1881 ### Node and item groups
1882
1883 * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
1884   that the item should be hidden in item lists.
1885
1886
1887 ### Node-only groups
1888
1889 * `attached_node`: if the node under it is not a walkable block the node will be
1890   dropped as an item. If the node is wallmounted the wallmounted direction is
1891   checked.
1892 * `bouncy`: value is bounce speed in percent.
1893   If positive, jump/sneak on floor impact will increase/decrease bounce height.
1894   Negative value is the same bounciness, but non-controllable.
1895 * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1896   connect to each other
1897 * `dig_immediate`: Player can always pick up node without reducing tool wear
1898     * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
1899     * `3`: the node always gets the digging time 0 seconds (torch)
1900 * `disable_jump`: Player (and possibly other things) cannot jump from node
1901   or if their feet are in the node. Note: not supported for `new_move = false`
1902 * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
1903   the top of this node. There's also an armor group with the same name.
1904   The final player damage is determined by the following formula:
1905     damage =
1906       collision speed
1907       * ((node_fall_damage_add_percent   + 100) / 100) -- node group
1908       * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
1909       - (14)                                           -- constant tolerance
1910   Negative damage values are discarded as no damage.
1911 * `falling_node`: if there is no walkable block under the node it will fall
1912 * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
1913 * `level`: Can be used to give an additional sense of progression in the game.
1914      * A larger level will cause e.g. a weapon of a lower level make much less
1915        damage, and get worn out much faster, or not be able to get drops
1916        from destroyed nodes.
1917      * `0` is something that is directly accessible at the start of gameplay
1918      * There is no upper limit
1919      * See also: `leveldiff` in [Tool Capabilities]
1920 * `slippery`: Players and items will slide on the node.
1921   Slipperiness rises steadily with `slippery` value, starting at 1.
1922
1923
1924 ### Tool-only groups
1925
1926 * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
1927   `"toolrepair"` crafting recipe
1928
1929
1930 ### `ObjectRef` armor groups
1931
1932 * `immortal`: Skips all damage and breath handling for an object. This group
1933   will also hide the integrated HUD status bars for players. It is
1934   automatically set to all players when damage is disabled on the server and
1935   cannot be reset (subject to change).
1936 * `fall_damage_add_percent`: Modifies the fall damage suffered by players
1937   when they hit the ground. It is analog to the node group with the same
1938   name. See the node group above for the exact calculation.
1939 * `punch_operable`: For entities; disables the regular damage mechanism for
1940   players punching it by hand or a non-tool item, so that it can do something
1941   else than take damage.
1942
1943
1944
1945 Known damage and digging time defining groups
1946 ---------------------------------------------
1947
1948 * `crumbly`: dirt, sand
1949 * `cracky`: tough but crackable stuff like stone.
1950 * `snappy`: something that can be cut using things like scissors, shears,
1951   bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
1952 * `choppy`: something that can be cut using force; e.g. trees, wooden planks
1953 * `fleshy`: Living things like animals and the player. This could imply
1954   some blood effects when hitting.
1955 * `explody`: Especially prone to explosions
1956 * `oddly_breakable_by_hand`:
1957    Can be added to nodes that shouldn't logically be breakable by the
1958    hand but are. Somewhat similar to `dig_immediate`, but times are more
1959    like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
1960    digging speed of an item if it can dig at a faster speed than this
1961    suggests for the hand.
1962
1963 Examples of custom groups
1964 -------------------------
1965
1966 Item groups are often used for defining, well, _groups of items_.
1967
1968 * `meat`: any meat-kind of a thing (rating might define the size or healing
1969   ability or be irrelevant -- it is not defined as of yet)
1970 * `eatable`: anything that can be eaten. Rating might define HP gain in half
1971   hearts.
1972 * `flammable`: can be set on fire. Rating might define the intensity of the
1973   fire, affecting e.g. the speed of the spreading of an open fire.
1974 * `wool`: any wool (any origin, any color)
1975 * `metal`: any metal
1976 * `weapon`: any weapon
1977 * `heavy`: anything considerably heavy
1978
1979 Digging time calculation specifics
1980 ----------------------------------
1981
1982 Groups such as `crumbly`, `cracky` and `snappy` are used for this
1983 purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
1984 faster digging time.
1985
1986 The `level` group is used to limit the toughness of nodes an item capable
1987 of digging can dig and to scale the digging times / damage to a greater extent.
1988
1989 **Please do understand this**, otherwise you cannot use the system to it's
1990 full potential.
1991
1992 Items define their properties by a list of parameters for groups. They
1993 cannot dig other groups; thus it is important to use a standard bunch of
1994 groups to enable interaction with items.
1995
1996
1997
1998
1999 Tool Capabilities
2000 =================
2001
2002 'Tool capabilities' is a property of items that defines two things:
2003
2004 1) Which nodes it can dig and how fast
2005 2) Which objects it can hurt by punching and by how much
2006
2007 Tool capabilities are available for all items, not just tools.
2008 But only tools can receive wear from digging and punching.
2009
2010 Missing or incomplete tool capabilities will default to the
2011 player's hand.
2012
2013 Tool capabilities definition
2014 ----------------------------
2015
2016 Tool capabilities define:
2017
2018 * Full punch interval
2019 * Maximum drop level
2020 * For an arbitrary list of node groups:
2021     * Uses (until the tool breaks)
2022     * Maximum level (usually `0`, `1`, `2` or `3`)
2023     * Digging times
2024 * Damage groups
2025 * Punch attack uses (until the tool breaks)
2026
2027 ### Full punch interval `full_punch_interval`
2028
2029 When used as a weapon, the item will do full damage if this time is spent
2030 between punches. If e.g. half the time is spent, the item will do half
2031 damage.
2032
2033 ### Maximum drop level `max_drop_level`
2034
2035 Suggests the maximum level of node, when dug with the item, that will drop
2036 its useful item. (e.g. iron ore to drop a lump of iron).
2037
2038 This value is not used in the engine; it is the responsibility of the game/mod
2039 code to implement this.
2040
2041 ### Uses `uses` (tools only)
2042
2043 Determines how many uses the tool has when it is used for digging a node,
2044 of this group, of the maximum level. The maximum supported number of
2045 uses is 65535. The special number 0 is used for infinite uses.
2046 For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
2047 `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
2048 node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
2049
2050 * `uses=10, leveldiff=0`: actual uses: 10
2051 * `uses=10, leveldiff=1`: actual uses: 30
2052 * `uses=10, leveldiff=2`: actual uses: 90
2053
2054 For non-tools, this has no effect.
2055
2056 ### Maximum level `maxlevel`
2057
2058 Tells what is the maximum level of a node of this group that the item will
2059 be able to dig.
2060
2061 ### Digging times `times`
2062
2063 List of digging times for different ratings of the group, for nodes of the
2064 maximum level.
2065
2066 For example, as a Lua table, `times={[2]=2.00, [3]=0.70}`. This would
2067 result in the item to be able to dig nodes that have a rating of `2` or `3`
2068 for this group, and unable to dig the rating `1`, which is the toughest.
2069 Unless there is a matching group that enables digging otherwise.
2070
2071 If the result digging time is 0, a delay of 0.15 seconds is added between
2072 digging nodes; If the player releases LMB after digging, this delay is set to 0,
2073 i.e. players can more quickly click the nodes away instead of holding LMB.
2074
2075 ### Damage groups
2076
2077 List of damage for groups of entities. See [Entity damage mechanism].
2078
2079 ### Punch attack uses (tools only)
2080
2081 Determines how many uses (before breaking) the tool has when dealing damage
2082 to an object, when the full punch interval (see above) was always
2083 waited out fully.
2084
2085 Wear received by the tool is proportional to the time spent, scaled by
2086 the full punch interval.
2087
2088 For non-tools, this has no effect.
2089
2090 Example definition of the capabilities of an item
2091 -------------------------------------------------
2092
2093     tool_capabilities = {
2094         groupcaps={
2095             crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
2096         },
2097     }
2098
2099 This makes the item capable of digging nodes that fulfill both of these:
2100
2101 * Have the `crumbly` group
2102 * Have a `level` group less or equal to `2`
2103
2104 Table of resulting digging times:
2105
2106     crumbly        0     1     2     3     4  <- level
2107          ->  0     -     -     -     -     -
2108              1  0.80  1.60  1.60     -     -
2109              2  0.60  1.20  1.20     -     -
2110              3  0.40  0.80  0.80     -     -
2111
2112     level diff:    2     1     0    -1    -2
2113
2114 Table of resulting tool uses:
2115
2116     ->  0     -     -     -     -     -
2117         1   180    60    20     -     -
2118         2   180    60    20     -     -
2119         3   180    60    20     -     -
2120
2121 **Notes**:
2122
2123 * At `crumbly==0`, the node is not diggable.
2124 * At `crumbly==3`, the level difference digging time divider kicks in and makes
2125   easy nodes to be quickly breakable.
2126 * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
2127
2128
2129
2130
2131 Entity damage mechanism
2132 =======================
2133
2134 Damage calculation:
2135
2136     damage = 0
2137     foreach group in cap.damage_groups:
2138         damage += cap.damage_groups[group]
2139             * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
2140             * (object.armor_groups[group] / 100.0)
2141             -- Where object.armor_groups[group] is 0 for inexistent values
2142     return damage
2143
2144 Client predicts damage based on damage groups. Because of this, it is able to
2145 give an immediate response when an entity is damaged or dies; the response is
2146 pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
2147 TODO).
2148 Currently a smoke puff will appear when an entity dies.
2149
2150 The group `immortal` completely disables normal damage.
2151
2152 Entities can define a special armor group, which is `punch_operable`. This
2153 group disables the regular damage mechanism for players punching it by hand or
2154 a non-tool item, so that it can do something else than take damage.
2155
2156 On the Lua side, every punch calls:
2157
2158     entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
2159                     damage)
2160
2161 This should never be called directly, because damage is usually not handled by
2162 the entity itself.
2163
2164 * `puncher` is the object performing the punch. Can be `nil`. Should never be
2165   accessed unless absolutely required, to encourage interoperability.
2166 * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
2167 * `tool_capabilities` can be `nil`.
2168 * `direction` is a unit vector, pointing from the source of the punch to
2169    the punched object.
2170 * `damage` damage that will be done to entity
2171 Return value of this function will determine if damage is done by this function
2172 (retval true) or shall be done by engine (retval false)
2173
2174 To punch an entity/object in Lua, call:
2175
2176   object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
2177
2178 * Return value is tool wear.
2179 * Parameters are equal to the above callback.
2180 * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
2181   will be automatically filled in based on the location of `puncher`.
2182
2183
2184
2185
2186 Metadata
2187 ========
2188
2189 Node Metadata
2190 -------------
2191
2192 The instance of a node in the world normally only contains the three values
2193 mentioned in [Nodes]. However, it is possible to insert extra data into a node.
2194 It is called "node metadata"; See `NodeMetaRef`.
2195
2196 Node metadata contains two things:
2197
2198 * A key-value store
2199 * An inventory
2200
2201 Some of the values in the key-value store are handled specially:
2202
2203 * `formspec`: Defines an inventory menu that is opened with the
2204               'place/use' key. Only works if no `on_rightclick` was
2205               defined for the node. See also [Formspec].
2206 * `infotext`: Text shown on the screen when the node is pointed at.
2207               Line-breaks will be applied automatically.
2208               If the infotext is very long, it will be truncated.
2209
2210 Example:
2211
2212     local meta = minetest.get_meta(pos)
2213     meta:set_string("formspec",
2214             "size[8,9]"..
2215             "list[context;main;0,0;8,4;]"..
2216             "list[current_player;main;0,5;8,4;]")
2217     meta:set_string("infotext", "Chest");
2218     local inv = meta:get_inventory()
2219     inv:set_size("main", 8*4)
2220     print(dump(meta:to_table()))
2221     meta:from_table({
2222         inventory = {
2223             main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
2224                     [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
2225                     [10] = "", [11] = "", [12] = "", [13] = "",
2226                     [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
2227                     [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
2228                     [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
2229                     [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
2230                     [32] = ""}
2231         },
2232         fields = {
2233             formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
2234             infotext = "Chest"
2235         }
2236     })
2237
2238 Item Metadata
2239 -------------
2240
2241 Item stacks can store metadata too. See [`ItemStackMetaRef`].
2242
2243 Item metadata only contains a key-value store.
2244
2245 Some of the values in the key-value store are handled specially:
2246
2247 * `description`: Set the item stack's description.
2248   See also: `get_description` in [`ItemStack`]
2249 * `short_description`: Set the item stack's short description.
2250   See also: `get_short_description` in [`ItemStack`]
2251 * `color`: A `ColorString`, which sets the stack's color.
2252 * `palette_index`: If the item has a palette, this is used to get the
2253   current color from the palette.
2254 * `count_meta`: Replace the displayed count with any string.
2255 * `count_alignment`: Set the alignment of the displayed count value. This is an
2256   int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
2257   4th bit specify the alignment in y-direction:
2258   0 = default, 1 = left / up, 2 = middle, 3 = right / down
2259   The default currently is the same as right/down.
2260   Example: 6 = 2 + 1*4 = middle,up
2261
2262 Example:
2263
2264     local meta = stack:get_meta()
2265     meta:set_string("key", "value")
2266     print(dump(meta:to_table()))
2267
2268 Example manipulations of "description" and expected output behaviors:
2269
2270     print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
2271     print(ItemStack("foobar"):get_description()) --> Unknown Item
2272
2273     local stack = ItemStack("default:stone")
2274     stack:get_meta():set_string("description", "Custom description\nAnother line")
2275     print(stack:get_description()) --> Custom description\nAnother line
2276     print(stack:get_short_description()) --> Custom description
2277
2278     stack:get_meta():set_string("short_description", "Short")
2279     print(stack:get_description()) --> Custom description\nAnother line
2280     print(stack:get_short_description()) --> Short
2281
2282     print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
2283
2284
2285
2286 Formspec
2287 ========
2288
2289 Formspec defines a menu. This supports inventories and some of the
2290 typical widgets like buttons, checkboxes, text input fields, etc.
2291 It is a string, with a somewhat strange format.
2292
2293 A formspec is made out of formspec elements, which includes widgets
2294 like buttons but also can be used to set stuff like background color.
2295
2296 Many formspec elements have a `name`, which is a unique identifier which
2297 is used when the server receives user input. You must not use the name
2298 "quit" for formspec elements.
2299
2300 Spaces and newlines can be inserted between the blocks, as is used in the
2301 examples.
2302
2303 Position and size units are inventory slots unless the new coordinate system
2304 is enabled. `X` and `Y` position the formspec element relative to the top left
2305 of the menu or container. `W` and `H` are its width and height values.
2306
2307 If the new system is enabled, all elements have unified coordinates for all
2308 elements with no padding or spacing in between. This is highly recommended
2309 for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
2310 Coordinates`.
2311
2312 Inventories with a `player:<name>` inventory location are only sent to the
2313 player named `<name>`.
2314
2315 When displaying text which can contain formspec code, e.g. text set by a player,
2316 use `minetest.formspec_escape`.
2317 For colored text you can use `minetest.colorize`.
2318
2319 Since formspec version 3, elements drawn in the order they are defined. All
2320 background elements are drawn before all other elements.
2321
2322 **WARNING**: do _not_ use an element name starting with `key_`; those names are
2323 reserved to pass key press events to formspec!
2324
2325 **WARNING**: Minetest allows you to add elements to every single formspec instance
2326 using `player:set_formspec_prepend()`, which may be the reason backgrounds are
2327 appearing when you don't expect them to, or why things are styled differently
2328 to normal. See [`no_prepend[]`] and [Styling Formspecs].
2329
2330 Examples
2331 --------
2332
2333 ### Chest
2334
2335     size[8,9]
2336     list[context;main;0,0;8,4;]
2337     list[current_player;main;0,5;8,4;]
2338
2339 ### Furnace
2340
2341     size[8,9]
2342     list[context;fuel;2,3;1,1;]
2343     list[context;src;2,1;1,1;]
2344     list[context;dst;5,1;2,2;]
2345     list[current_player;main;0,5;8,4;]
2346
2347 ### Minecraft-like player inventory
2348
2349     size[8,7.5]
2350     image[1,0.6;1,2;player.png]
2351     list[current_player;main;0,3.5;8,4;]
2352     list[current_player;craft;3,0;3,3;]
2353     list[current_player;craftpreview;7,1;1,1;]
2354
2355 Version History
2356 ---------------
2357
2358 * Formspec version 1 (pre-5.1.0):
2359   * (too much)
2360 * Formspec version 2 (5.1.0):
2361   * Forced real coordinates
2362   * background9[]: 9-slice scaling parameters
2363 * Formspec version 3 (5.2.0):
2364   * Formspec elements are drawn in the order of definition
2365   * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
2366   * box[] and image[] elements enable clipping by default
2367   * new element: scroll_container[]
2368 * Formspec version 4 (5.4.0):
2369   * Allow dropdown indexing events
2370 * Formspec version 5 (5.5.0):
2371   * Added padding[] element
2372 * Formspec version 6 (5.6.0):
2373   * Add nine-slice images, animated_image, and fgimg_middle
2374
2375 Elements
2376 --------
2377
2378 ### `formspec_version[<version>]`
2379
2380 * Set the formspec version to a certain number. If not specified,
2381   version 1 is assumed.
2382 * Must be specified before `size` element.
2383 * Clients older than this version can neither show newer elements nor display
2384   elements with new arguments correctly.
2385 * Available since feature `formspec_version_element`.
2386 * See also: [Version History]
2387
2388 ### `size[<W>,<H>,<fixed_size>]`
2389
2390 * Define the size of the menu in inventory slots
2391 * `fixed_size`: `true`/`false` (optional)
2392 * deprecated: `invsize[<W>,<H>;]`
2393
2394 ### `position[<X>,<Y>]`
2395
2396 * Must be used after `size` element.
2397 * Defines the position on the game window of the formspec's `anchor` point.
2398 * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
2399   for example:
2400     * [0.0, 0.0] sets the position to the top left corner of the game window.
2401     * [1.0, 1.0] sets the position to the bottom right of the game window.
2402 * Defaults to the center of the game window [0.5, 0.5].
2403
2404 ### `anchor[<X>,<Y>]`
2405
2406 * Must be used after both `size` and `position` (if present) elements.
2407 * Defines the location of the anchor point within the formspec.
2408 * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
2409   for example:
2410     * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
2411     * [1.0, 0.0] sets the anchor to the top right of the formspec.
2412 * Defaults to the center of the formspec [0.5, 0.5].
2413
2414 * `position` and `anchor` elements need suitable values to avoid a formspec
2415   extending off the game window due to particular game window sizes.
2416
2417 ### `padding[<X>,<Y>]`
2418
2419 * Must be used after the `size`, `position`, and `anchor` elements (if present).
2420 * Defines how much space is padded around the formspec if the formspec tries to
2421   increase past the size of the screen and coordinates have to be shrunk.
2422 * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
2423   screen), and 0.5 represents half the screen (which forces the coordinate size
2424   to 0). If negative, the formspec can extend off the edge of the screen.
2425 * Defaults to [0.05, 0.05].
2426
2427 ### `no_prepend[]`
2428
2429 * Must be used after the `size`, `position`, `anchor`, and `padding` elements
2430   (if present).
2431 * Disables player:set_formspec_prepend() from applying to this formspec.
2432
2433 ### `real_coordinates[<bool>]`
2434
2435 * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
2436 * When set to true, all following formspec elements will use the new coordinate system.
2437 * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
2438   (if present), the form size will use the new coordinate system.
2439 * **Note**: Formspec prepends are not affected by the coordinates in the main form.
2440   They must enable it explicitly.
2441 * For information on converting forms to the new coordinate system, see `Migrating
2442   to Real Coordinates`.
2443
2444 ### `container[<X>,<Y>]`
2445
2446 * Start of a container block, moves all physical elements in the container by
2447   (X, Y).
2448 * Must have matching `container_end`
2449 * Containers can be nested, in which case the offsets are added
2450   (child containers are relative to parent containers)
2451
2452 ### `container_end[]`
2453
2454 * End of a container, following elements are no longer relative to this
2455   container.
2456
2457 ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
2458
2459 * Start of a scroll_container block. All contained elements will ...
2460   * take the scroll_container coordinate as position origin,
2461   * be additionally moved by the current value of the scrollbar with the name
2462     `scrollbar name` times `scroll factor` along the orientation `orientation` and
2463   * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
2464 * `orientation`: possible values are `vertical` and `horizontal`.
2465 * `scroll factor`: optional, defaults to `0.1`.
2466 * Nesting is possible.
2467 * Some elements might work a little different if they are in a scroll_container.
2468 * Note: If you want the scroll_container to actually work, you also need to add a
2469   scrollbar element with the specified name. Furthermore, it is highly recommended
2470   to use a scrollbaroptions element on this scrollbar.
2471
2472 ### `scroll_container_end[]`
2473
2474 * End of a scroll_container, following elements are no longer bound to this
2475   container.
2476
2477 ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
2478
2479 * Show an inventory list if it has been sent to the client.
2480 * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
2481   are moved) while the formspec is open, the formspec element may (but is not guaranteed
2482   to) adapt to the new inventory list.
2483 * Item slots are drawn in a grid from left to right, then up to down, ordered
2484   according to the slot index.
2485 * `W` and `H` are in inventory slots, not in coordinates.
2486 * `starting item index` (Optional): The index of the first (upper-left) item to draw.
2487   Indices start at `0`. Default is `0`.
2488 * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
2489   `starting item index`.
2490 * **Note**: With the new coordinate system, the spacing between inventory
2491   slots is one-fourth the size of an inventory slot by default. Also see
2492   [Styling Formspecs] for changing the size of slots and spacing.
2493
2494 ### `listring[<inventory location>;<list name>]`
2495
2496 * Appends to an internal ring of inventory lists.
2497 * Shift-clicking on items in one element of the ring
2498   will send them to the next inventory list inside the ring
2499 * The first occurrence of an element inside the ring will
2500   determine the inventory where items will be sent to
2501
2502 ### `listring[]`
2503
2504 * Shorthand for doing `listring[<inventory location>;<list name>]`
2505   for the last two inventory lists added by list[...]
2506
2507 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
2508
2509 * Sets background color of slots as `ColorString`
2510 * Sets background color of slots on mouse hovering
2511
2512 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
2513
2514 * Sets background color of slots as `ColorString`
2515 * Sets background color of slots on mouse hovering
2516 * Sets color of slots border
2517
2518 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
2519
2520 * Sets background color of slots as `ColorString`
2521 * Sets background color of slots on mouse hovering
2522 * Sets color of slots border
2523 * Sets default background color of tooltips
2524 * Sets default font color of tooltips
2525
2526 ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2527
2528 * Adds tooltip for an element
2529 * `bgcolor` tooltip background color as `ColorString` (optional)
2530 * `fontcolor` tooltip font color as `ColorString` (optional)
2531
2532 ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2533
2534 * Adds tooltip for an area. Other tooltips will take priority when present.
2535 * `bgcolor` tooltip background color as `ColorString` (optional)
2536 * `fontcolor` tooltip font color as `ColorString` (optional)
2537
2538 ### `image[<X>,<Y>;<W>,<H>;<texture name>;<middle>]`
2539
2540 * Show an image.
2541 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2542     * Requires formspec version >= 6.
2543     * See `background9[]` documentation for more information.
2544
2545 ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
2546
2547 * Show an animated image. The image is drawn like a "vertical_frames" tile
2548   animation (See [Tile animation definition]), but uses a frame count/duration for simplicity
2549 * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
2550 * `texture name`: The image to use.
2551 * `frame count`: The number of frames animating the image.
2552 * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
2553 * `frame start` (optional): The index of the frame to start on. Default `1`.
2554 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2555     * Requires formspec version >= 6.
2556     * See `background9[]` documentation for more information.
2557
2558 ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
2559
2560 * Show a mesh model.
2561 * `name`: Element name that can be used for styling
2562 * `mesh`: The mesh model to use.
2563 * `textures`: The mesh textures to use according to the mesh materials.
2564    Texture names must be separated by commas.
2565 * `rotation {X,Y}` (Optional): Initial rotation of the camera.
2566   The axes are euler angles in degrees.
2567 * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
2568 * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
2569 * `frame loop range` (Optional): Range of the animation frames.
2570     * Defaults to the full range of all available frames.
2571     * Syntax: `<begin>,<end>`
2572 * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
2573
2574 ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
2575
2576 * Show an inventory image of registered item/node
2577
2578 ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
2579
2580 * Sets background color of formspec.
2581 * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
2582   of the non-fullscreen and the fullscreen background.
2583 * `fullscreen` (optional) can be one of the following:
2584   * `false`: Only the non-fullscreen background color is drawn. (default)
2585   * `true`: Only the fullscreen background color is drawn.
2586   * `both`: The non-fullscreen and the fullscreen background color are drawn.
2587   * `neither`: No background color is drawn.
2588 * Note: Leave a parameter empty to not modify the value.
2589 * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
2590   are not bools are only available since formspec version 3.
2591
2592 ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
2593
2594 * Example for formspec 8x4 in 16x resolution: image shall be sized
2595   8 times 16px  times  4 times 16px.
2596
2597 ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
2598
2599 * Example for formspec 8x4 in 16x resolution:
2600   image shall be sized 8 times 16px  times  4 times 16px
2601 * If `auto_clip` is `true`, the background is clipped to the formspec size
2602   (`x` and `y` are used as offset values, `w` and `h` are ignored)
2603
2604 ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
2605
2606 * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
2607 * Middle is a rect which defines the middle of the 9-slice.
2608     * `x` - The middle will be x pixels from all sides.
2609     * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
2610     * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
2611         will be added to the width and height of the texture, allowing it to be used as the
2612         distance from the far end.
2613     * All numbers in middle are integers.
2614 * If `auto_clip` is `true`, the background is clipped to the formspec size
2615   (`x` and `y` are used as offset values, `w` and `h` are ignored)
2616 * Available since formspec version 2
2617
2618 ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
2619
2620 * Textual password style field; will be sent to server when a button is clicked
2621 * When enter is pressed in field, fields.key_enter_field will be sent with the
2622   name of this field.
2623 * With the old coordinate system, fields are a set height, but will be vertically
2624   centered on `H`. With the new coordinate system, `H` will modify the height.
2625 * `name` is the name of the field as returned in fields to `on_receive_fields`
2626 * `label`, if not blank, will be text printed on the top left above the field
2627 * See `field_close_on_enter` to stop enter closing the formspec
2628
2629 ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2630
2631 * Textual 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
2633   the 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 * `default` is the default value of the field
2639     * `default` may contain variable references such as `${text}` which
2640       will fill the value from the metadata value `text`
2641     * **Note**: no extra text or more than a single variable is supported ATM.
2642 * See `field_close_on_enter` to stop enter closing the formspec
2643
2644 ### `field[<name>;<label>;<default>]`
2645
2646 * As above, but without position/size units
2647 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2648   the name of this field.
2649 * Special field for creating simple forms, such as sign text input
2650 * Must be used without a `size[]` element
2651 * A "Proceed" button will be added automatically
2652 * See `field_close_on_enter` to stop enter closing the formspec
2653
2654 ### `field_close_on_enter[<name>;<close_on_enter>]`
2655
2656 * <name> is the name of the field
2657 * if <close_on_enter> is false, pressing enter in the field will submit the
2658   form but not close it.
2659 * defaults to true when not specified (ie: no tag for a field)
2660
2661 ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2662
2663 * Same as fields above, but with multi-line input
2664 * If the text overflows, a vertical scrollbar is added.
2665 * If the name is empty, the textarea is read-only and
2666   the background is not shown, which corresponds to a multi-line label.
2667
2668 ### `label[<X>,<Y>;<label>]`
2669
2670 * The label formspec element displays the text set in `label`
2671   at the specified position.
2672 * **Note**: If the new coordinate system is enabled, labels are
2673   positioned from the center of the text, not the top.
2674 * The text is displayed directly without automatic line breaking,
2675   so label should not be used for big text chunks.  Newlines can be
2676   used to make labels multiline.
2677 * **Note**: With the new coordinate system, newlines are spaced with
2678   half a coordinate.  With the old system, newlines are spaced 2/5 of
2679   an inventory slot.
2680
2681 ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
2682 * Displays a static formatted text with hyperlinks.
2683 * **Note**: This element is currently unstable and subject to change.
2684 * `x`, `y`, `w` and `h` work as per field
2685 * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
2686 * `text` is the formatted text using `Markup Language` described below.
2687
2688 ### `vertlabel[<X>,<Y>;<label>]`
2689 * Textual label drawn vertically
2690 * `label` is the text on the label
2691 * **Note**: If the new coordinate system is enabled, vertlabels are
2692   positioned from the center of the text, not the left.
2693
2694 ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
2695
2696 * Clickable button. When clicked, fields will be sent.
2697 * With the old coordinate system, buttons are a set height, but will be vertically
2698   centered on `H`. With the new coordinate system, `H` will modify the height.
2699 * `label` is the text on the button
2700
2701 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2702
2703 * `texture name` is the filename of an image
2704 * **Note**: Height is supported on both the old and new coordinate systems
2705   for image_buttons.
2706
2707 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
2708
2709 * `texture name` is the filename of an image
2710 * `noclip=true` means the image button doesn't need to be within specified
2711   formsize.
2712 * `drawborder`: draw button border or not
2713 * `pressed texture name` is the filename of an image on pressed state
2714
2715 ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
2716
2717 * `item name` is the registered name of an item/node
2718 * The item description will be used as the tooltip. This can be overridden with
2719   a tooltip element.
2720
2721 ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
2722
2723 * When clicked, fields will be sent and the form will quit.
2724 * Same as `button` in all other respects.
2725
2726 ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2727
2728 * When clicked, fields will be sent and the form will quit.
2729 * Same as `image_button` in all other respects.
2730
2731 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
2732
2733 * Scrollable item list showing arbitrary text elements
2734 * `name` fieldname sent to server on doubleclick value is current selected
2735   element.
2736 * `listelements` can be prepended by #color in hexadecimal format RRGGBB
2737   (only).
2738     * if you want a listelement to start with "#" write "##".
2739
2740 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
2741
2742 * Scrollable itemlist showing arbitrary text elements
2743 * `name` fieldname sent to server on doubleclick value is current selected
2744   element.
2745 * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
2746     * if you want a listelement to start with "#" write "##"
2747 * Index to be selected within textlist
2748 * `true`/`false`: draw transparent background
2749 * See also `minetest.explode_textlist_event`
2750   (main menu: `core.explode_textlist_event`).
2751
2752 ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2753
2754 * Show a tab**header** at specific position (ignores formsize)
2755 * `X` and `Y`: position of the tabheader
2756 * *Note*: Width and height are automatically chosen with this syntax
2757 * `name` fieldname data is transferred to Lua
2758 * `caption 1`...: name shown on top of tab
2759 * `current_tab`: index of selected tab 1...
2760 * `transparent` (optional): if true, tabs are semi-transparent
2761 * `draw_border` (optional): if true, draw a thin line at tab base
2762
2763 ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2764
2765 * Show a tab**header** at specific position (ignores formsize)
2766 * **Important note**: This syntax for tabheaders can only be used with the
2767   new coordinate system.
2768 * `X` and `Y`: position of the tabheader
2769 * `H`: height of the tabheader. Width is automatically determined with this syntax.
2770 * `name` fieldname data is transferred to Lua
2771 * `caption 1`...: name shown on top of tab
2772 * `current_tab`: index of selected tab 1...
2773 * `transparent` (optional): show transparent
2774 * `draw_border` (optional): draw border
2775
2776 ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2777
2778 * Show a tab**header** at specific position (ignores formsize)
2779 * **Important note**: This syntax for tabheaders can only be used with the
2780   new coordinate system.
2781 * `X` and `Y`: position of the tabheader
2782 * `W` and `H`: width and height of the tabheader
2783 * `name` fieldname data is transferred to Lua
2784 * `caption 1`...: name shown on top of tab
2785 * `current_tab`: index of selected tab 1...
2786 * `transparent` (optional): show transparent
2787 * `draw_border` (optional): draw border
2788
2789 ### `box[<X>,<Y>;<W>,<H>;<color>]`
2790
2791 * Simple colored box
2792 * `color` is color specified as a `ColorString`.
2793   If the alpha component is left blank, the box will be semitransparent.
2794   If the color is not specified, the box will use the options specified by
2795   its style. If the color is specified, all styling options will be ignored.
2796
2797 ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2798
2799 * Show a dropdown field
2800 * **Important note**: There are two different operation modes:
2801     1. handle directly on change (only changed dropdown is submitted)
2802     2. read the value on pressing a button (all dropdown values are available)
2803 * `X` and `Y`: position of the dropdown
2804 * `W`: width of the dropdown. Height is automatically chosen with this syntax.
2805 * Fieldname data is transferred to Lua
2806 * Items to be shown in dropdown
2807 * Index of currently selected dropdown item
2808 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2809   event field value for selected items.
2810     * `true`: Selected item index
2811     * `false` (default): Selected item value
2812
2813 ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2814
2815 * Show a dropdown field
2816 * **Important note**: This syntax for dropdowns can only be used with the
2817   new coordinate system.
2818 * **Important note**: There are two different operation modes:
2819     1. handle directly on change (only changed dropdown is submitted)
2820     2. read the value on pressing a button (all dropdown values are available)
2821 * `X` and `Y`: position of the dropdown
2822 * `W` and `H`: width and height of the dropdown
2823 * Fieldname data is transferred to Lua
2824 * Items to be shown in dropdown
2825 * Index of currently selected dropdown item
2826 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2827   event field value for selected items.
2828     * `true`: Selected item index
2829     * `false` (default): Selected item value
2830
2831 ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
2832
2833 * Show a checkbox
2834 * `name` fieldname data is transferred to Lua
2835 * `label` to be shown left of checkbox
2836 * `selected` (optional): `true`/`false`
2837 * **Note**: If the new coordinate system is enabled, checkboxes are
2838   positioned from the center of the checkbox, not the top.
2839
2840 ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
2841
2842 * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
2843 * There are two ways to use it:
2844     1. handle the changed event (only changed scrollbar is available)
2845     2. read the value on pressing a button (all scrollbars are available)
2846 * `orientation`: `vertical`/`horizontal`. Default horizontal.
2847 * Fieldname data is transferred to Lua
2848 * Value of this trackbar is set to (`0`-`1000`) by default
2849 * See also `minetest.explode_scrollbar_event`
2850   (main menu: `core.explode_scrollbar_event`).
2851
2852 ### `scrollbaroptions[opt1;opt2;...]`
2853 * Sets options for all following `scrollbar[]` elements
2854 * `min=<int>`
2855     * Sets scrollbar minimum value, defaults to `0`.
2856 * `max=<int>`
2857     * Sets scrollbar maximum value, defaults to `1000`.
2858       If the max is equal to the min, the scrollbar will be disabled.
2859 * `smallstep=<int>`
2860     * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
2861       scrolled.
2862     * If this is set to a negative number, the value will be reset to `10`.
2863 * `largestep=<int>`
2864     * Sets scrollbar step value used by page up and page down.
2865     * If this is set to a negative number, the value will be reset to `100`.
2866 * `thumbsize=<int>`
2867     * Sets size of the thumb on the scrollbar. Size is calculated in the number of
2868       units the thumb spans out of the range of the scrollbar values.
2869     * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
2870       would span a tenth of the scrollbar space.
2871     * If this is set to zero or less, the value will be reset to `1`.
2872 * `arrows=<show/hide/default>`
2873     * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
2874       when the scrollbar gets too small, but shows them otherwise.
2875
2876 ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
2877
2878 * Show scrollable table using options defined by the previous `tableoptions[]`
2879 * Displays cells as defined by the previous `tablecolumns[]`
2880 * `name`: fieldname sent to server on row select or doubleclick
2881 * `cell 1`...`cell n`: cell contents given in row-major order
2882 * `selected idx`: index of row to be selected within table (first row = `1`)
2883 * See also `minetest.explode_table_event`
2884   (main menu: `core.explode_table_event`).
2885
2886 ### `tableoptions[<opt 1>;<opt 2>;...]`
2887
2888 * Sets options for `table[]`
2889 * `color=#RRGGBB`
2890     * default text color (`ColorString`), defaults to `#FFFFFF`
2891 * `background=#RRGGBB`
2892     * table background color (`ColorString`), defaults to `#000000`
2893 * `border=<true/false>`
2894     * should the table be drawn with a border? (default: `true`)
2895 * `highlight=#RRGGBB`
2896     * highlight background color (`ColorString`), defaults to `#466432`
2897 * `highlight_text=#RRGGBB`
2898     * highlight text color (`ColorString`), defaults to `#FFFFFF`
2899 * `opendepth=<value>`
2900     * all subtrees up to `depth < value` are open (default value = `0`)
2901     * only useful when there is a column of type "tree"
2902
2903 ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
2904
2905 * Sets columns for `table[]`
2906 * Types: `text`, `image`, `color`, `indent`, `tree`
2907     * `text`:   show cell contents as text
2908     * `image`:  cell contents are an image index, use column options to define
2909                 images.
2910     * `color`:  cell contents are a ColorString and define color of following
2911                 cell.
2912     * `indent`: cell contents are a number and define indentation of following
2913                 cell.
2914     * `tree`:   same as indent, but user can open and close subtrees
2915                 (treeview-like).
2916 * Column options:
2917     * `align=<value>`
2918         * for `text` and `image`: content alignment within cells.
2919           Available values: `left` (default), `center`, `right`, `inline`
2920     * `width=<value>`
2921         * for `text` and `image`: minimum width in em (default: `0`)
2922         * for `indent` and `tree`: indent width in em (default: `1.5`)
2923     * `padding=<value>`: padding left of the column, in em (default `0.5`).
2924       Exception: defaults to 0 for indent columns
2925     * `tooltip=<value>`: tooltip text (default: empty)
2926     * `image` column options:
2927         * `0=<value>` sets image for image index 0
2928         * `1=<value>` sets image for image index 1
2929         * `2=<value>` sets image for image index 2
2930         * and so on; defined indices need not be contiguous empty or
2931           non-numeric cells are treated as `0`.
2932     * `color` column options:
2933         * `span=<value>`: number of following columns to affect
2934           (default: infinite).
2935
2936 ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2937
2938 * Set the style for the element(s) matching `selector` by name.
2939 * `selector` can be one of:
2940     * `<name>` - An element name. Includes `*`, which represents every element.
2941     * `<name>:<state>` - An element name, a colon, and one or more states.
2942 * `state` is a list of states separated by the `+` character.
2943     * If a state is provided, the style will only take effect when the element is in that state.
2944     * All provided states must be active for the style to apply.
2945 * Note: this **must** be before the element is defined.
2946 * See [Styling Formspecs].
2947
2948
2949 ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2950
2951 * Set the style for the element(s) matching `selector` by type.
2952 * `selector` can be one of:
2953     * `<type>` - An element type. Includes `*`, which represents every element.
2954     * `<type>:<state>` - An element type, a colon, and one or more states.
2955 * `state` is a list of states separated by the `+` character.
2956     * If a state is provided, the style will only take effect when the element is in that state.
2957     * All provided states must be active for the style to apply.
2958 * See [Styling Formspecs].
2959
2960 ### `set_focus[<name>;<force>]`
2961
2962 * Sets the focus to the element with the same `name` parameter.
2963 * **Note**: This element must be placed before the element it focuses.
2964 * `force` (optional, default `false`): By default, focus is not applied for
2965   re-sent formspecs with the same name so that player-set focus is kept.
2966   `true` sets the focus to the specified element for every sent formspec.
2967 * The following elements have the ability to be focused:
2968     * checkbox
2969     * button
2970     * button_exit
2971     * image_button
2972     * image_button_exit
2973     * item_image_button
2974     * table
2975     * textlist
2976     * dropdown
2977     * field
2978     * pwdfield
2979     * textarea
2980     * scrollbar
2981
2982 Migrating to Real Coordinates
2983 -----------------------------
2984
2985 In the old system, positions included padding and spacing. Padding is a gap between
2986 the formspec window edges and content, and spacing is the gaps between items. For
2987 example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
2988 and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
2989 in the new coordinate system from scratch.
2990
2991 To recreate an old layout with padding, you'll need to pass the positions and sizes
2992 through the following formula to re-introduce padding:
2993
2994 ```
2995 pos = (oldpos + 1)*spacing + padding
2996 where
2997     padding = 3/8
2998     spacing = 5/4
2999 ```
3000
3001 You'll need to change the `size[]` tag like this:
3002
3003 ```
3004 size = (oldsize-1)*spacing + padding*2 + 1
3005 ```
3006
3007 A few elements had random offsets in the old system. Here is a table which shows these
3008 offsets when migrating:
3009
3010 | Element |  Position  |  Size   | Notes
3011 |---------|------------|---------|-------
3012 | box     | +0.3, +0.1 | 0, -0.4 |
3013 | button  |            |         | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
3014 | list    |            |         | Spacing is now 0.25 for both directions, meaning lists will be taller in height
3015 | label   | 0, +0.3    |         | The first line of text is now positioned centered exactly at the position specified
3016
3017 Styling Formspecs
3018 -----------------
3019
3020 Formspec elements can be themed using the style elements:
3021
3022     style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
3023     style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
3024     style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
3025     style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
3026
3027 Where a prop is:
3028
3029     property_name=property_value
3030
3031 For example:
3032
3033     style_type[button;bgcolor=#006699]
3034     style[world_delete;bgcolor=red;textcolor=yellow]
3035     button[4,3.95;2.6,1;world_delete;Delete]
3036
3037 A name/type can optionally be a comma separated list of names/types, like so:
3038
3039     world_delete,world_create,world_configure
3040     button,image_button
3041
3042 A `*` type can be used to select every element in the formspec.
3043
3044 Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
3045
3046     world_delete:hovered+pressed
3047     button:pressed
3048
3049 States allow you to apply styles in response to changes in the element, instead of applying at all times.
3050
3051 Setting a property to nothing will reset it to the default value. For example:
3052
3053     style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
3054     style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
3055
3056
3057 ### Supported Element Types
3058
3059 Some types may inherit styles from parent types.
3060
3061 * animated_image, inherits from image
3062 * box
3063 * button
3064 * button_exit, inherits from button
3065 * checkbox
3066 * dropdown
3067 * field
3068 * image
3069 * image_button
3070 * item_image_button
3071 * label
3072 * list
3073 * model
3074 * pwdfield, inherits from field
3075 * scrollbar
3076 * tabheader
3077 * table
3078 * textarea
3079 * textlist
3080 * vertlabel, inherits from label
3081
3082
3083 ### Valid Properties
3084
3085 * animated_image
3086     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3087 * box
3088     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3089         * Defaults to false in formspec_version version 3 or higher
3090     * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
3091         * Single value (e.g. `#FF0`): All corners/borders.
3092         * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
3093           top and bottom,left and right.
3094         * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
3095         * These work similarly to CSS borders.
3096     * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
3097     * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
3098     * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
3099       negative, the border will extend inside the box, whereas positive extends outside
3100       the box. A width of zero results in no border; this is default.
3101 * button, button_exit, image_button, item_image_button
3102     * alpha - boolean, whether to draw alpha in bgimg. Default true.
3103     * bgcolor - color, sets button tint.
3104     * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
3105         * This is deprecated, use states instead.
3106     * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
3107         * This is deprecated, use states instead.
3108     * bgimg - standard background image. Defaults to none.
3109     * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
3110         * This is deprecated, use states instead.
3111     * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
3112                      See background9[] documentation for more details. This property also pads the
3113                      button's content when set.
3114     * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
3115         * This is deprecated, use states instead.
3116     * font - Sets font type. This is a comma separated list of options. Valid options:
3117       * Main font type options. These cannot be combined with each other:
3118         * `normal`: Default font
3119         * `mono`: Monospaced font
3120       * Font modification options. If used without a main font type, `normal` is used:
3121         * `bold`: Makes font bold.
3122         * `italic`: Makes font italic.
3123       Default `normal`.
3124     * font_size - Sets font size. Default is user-set. Can have multiple values:
3125       * `<number>`: Sets absolute font size to `number`.
3126       * `+<number>`/`-<number>`: Offsets default font size by `number` points.
3127       * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
3128     * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
3129     * content_offset - 2d vector, shifts the position of the button's content without resizing it.
3130     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3131     * padding - rect, adds space between the edges of the button and the content. This value is
3132                 relative to bgimg_middle.
3133     * sound - a sound to be played when triggered.
3134     * textcolor - color, default white.
3135 * checkbox
3136     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3137     * sound - a sound to be played when triggered.
3138 * dropdown
3139     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3140     * sound - a sound to be played when the entry is changed.
3141 * field, pwdfield, textarea
3142     * border - set to false to hide the textbox background and border. Default true.
3143     * font - Sets font type. See button `font` property for more information.
3144     * font_size - Sets font size. See button `font_size` property for more information.
3145     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3146     * textcolor - color. Default white.
3147 * model
3148     * bgcolor - color, sets background color.
3149     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3150         * Default to false in formspec_version version 3 or higher
3151 * image
3152     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3153         * Default to false in formspec_version version 3 or higher
3154 * item_image
3155     * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
3156 * label, vertlabel
3157     * font - Sets font type. See button `font` property for more information.
3158     * font_size - Sets font size. See button `font_size` property for more information.
3159     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3160 * list
3161     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3162     * size - 2d vector, sets the size of inventory slots in coordinates.
3163     * spacing - 2d vector, sets the space between inventory slots in coordinates.
3164 * image_button (additional properties)
3165     * fgimg - standard image. Defaults to none.
3166     * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
3167         * This is deprecated, use states instead.
3168     * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
3169         * This is deprecated, use states instead.
3170     * fgimg_middle - Makes the fgimg textures render in 9-sliced mode and defines the middle rect.
3171                      See background9[] documentation for more details.
3172     * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
3173     * sound - a sound to be played when triggered.
3174 * scrollbar
3175     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3176 * tabheader
3177     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3178     * sound - a sound to be played when a different tab is selected.
3179     * textcolor - color. Default white.
3180 * table, textlist
3181     * font - Sets font type. See button `font` property for more information.
3182     * font_size - Sets font size. See button `font_size` property for more information.
3183     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3184
3185 ### Valid States
3186
3187 * *all elements*
3188     * default - Equivalent to providing no states
3189 * button, button_exit, image_button, item_image_button
3190     * hovered - Active when the mouse is hovering over the element
3191     * pressed - Active when the button is pressed
3192
3193 Markup Language
3194 ---------------
3195
3196 Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
3197 The markup language is currently unstable and subject to change. Use with caution.
3198 Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
3199 Tags can have attributes, in that case, attributes are in the opening tag in
3200 form of a key/value separated with equal signs. Attribute values should not be quoted.
3201
3202 If you want to insert a literal greater-than sign or a backslash into the text,
3203 you must escape it by preceding it with a backslash.
3204
3205 These are the technically basic tags but see below for usual tags. Base tags are:
3206
3207 `<style color=... font=... size=...>...</style>`
3208
3209 Changes the style of the text.
3210
3211 * `color`: Text color. Given color is a `colorspec`.
3212 * `size`: Text size.
3213 * `font`: Text font (`mono` or `normal`).
3214
3215 `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
3216
3217 Sets global style.
3218
3219 Global only styles:
3220 * `background`: Text background, a `colorspec` or `none`.
3221 * `margin`: Page margins in pixel.
3222 * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
3223
3224 Inheriting styles (affects child elements):
3225 * `color`: Default text color. Given color is a `colorspec`.
3226 * `hovercolor`: Color of <action> tags when mouse is over.
3227 * `size`: Default text size.
3228 * `font`: Default text font (`mono` or `normal`).
3229 * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
3230
3231 This tag needs to be placed only once as it changes the global settings of the
3232 text. Anyway, if several tags are placed, each changed will be made in the order
3233 tags appear.
3234
3235 `<tag name=... color=... hovercolor=... font=... size=...>`
3236
3237 Defines or redefines tag style. This can be used to define new tags.
3238 * `name`: Name of the tag to define or change.
3239 * `color`: Text color. Given color is a `colorspec`.
3240 * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
3241 * `size`: Text size.
3242 * `font`: Text font (`mono` or `normal`).
3243
3244 Following tags are the usual tags for text layout. They are defined by default.
3245 Other tags can be added using `<tag ...>` tag.
3246
3247 `<normal>...</normal>`: Normal size text
3248
3249 `<big>...</big>`: Big text
3250
3251 `<bigger>...</bigger>`: Bigger text
3252
3253 `<center>...</center>`: Centered text
3254
3255 `<left>...</left>`: Left-aligned text
3256
3257 `<right>...</right>`: Right-aligned text
3258
3259 `<justify>...</justify>`: Justified text
3260
3261 `<mono>...</mono>`: Monospaced font
3262
3263 `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
3264
3265 `<action name=...>...</action>`
3266
3267 Make that text a clickable text triggering an action.
3268
3269 * `name`: Name of the action (mandatory).
3270
3271 When clicked, the formspec is send to the server. The value of the text field
3272 sent to `on_player_receive_fields` will be "action:" concatenated to the action
3273 name.
3274
3275 `<img name=... float=... width=... height=...>`
3276
3277 Draws an image which is present in the client media cache.
3278
3279 * `name`: Name of the texture (mandatory).
3280 * `float`: If present, makes the image floating (`left` or `right`).
3281 * `width`: Force image width instead of taking texture width.
3282 * `height`: Force image height instead of taking texture height.
3283
3284 If only width or height given, texture aspect is kept.
3285
3286 `<item name=... float=... width=... height=... rotate=...>`
3287
3288 Draws an item image.
3289
3290 * `name`: Item string of the item to draw (mandatory).
3291 * `float`: If present, makes the image floating (`left` or `right`).
3292 * `width`: Item image width.
3293 * `height`: Item image height.
3294 * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
3295 rotation speeds in percent of standard speed (-1000 to 1000). Works only if
3296 `inventory_items_animations` is set to true.
3297 * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
3298 X, Y and Z being angles around each three axes. Works only if
3299 `inventory_items_animations` is set to true.
3300
3301 Inventory
3302 =========
3303
3304 Inventory locations
3305 -------------------
3306
3307 * `"context"`: Selected node metadata (deprecated: `"current_name"`)
3308 * `"current_player"`: Player to whom the menu is shown
3309 * `"player:<name>"`: Any player
3310 * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
3311 * `"detached:<name>"`: A detached inventory
3312
3313 Player Inventory lists
3314 ----------------------
3315
3316 * `main`: list containing the default inventory
3317 * `craft`: list containing the craft input
3318 * `craftpreview`: list containing the craft prediction
3319 * `craftresult`: list containing the crafted output
3320 * `hand`: list containing an override for the empty hand
3321     * Is not created automatically, use `InvRef:set_size`
3322     * Is only used to enhance the empty hand's tool capabilities
3323
3324 Colors
3325 ======
3326
3327 `ColorString`
3328 -------------
3329
3330 `#RGB` defines a color in hexadecimal format.
3331
3332 `#RGBA` defines a color in hexadecimal format and alpha channel.
3333
3334 `#RRGGBB` defines a color in hexadecimal format.
3335
3336 `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
3337
3338 Named colors are also supported and are equivalent to
3339 [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
3340 To specify the value of the alpha channel, append `#A` or `#AA` to the end of
3341 the color name (e.g. `colorname#08`).
3342
3343 `ColorSpec`
3344 -----------
3345
3346 A ColorSpec specifies a 32-bit color. It can be written in any of the following
3347 forms:
3348
3349 * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
3350     * `colorspec = {a=255, r=0, g=255, b=0}`
3351 * numerical form: The raw integer value of an ARGB8 quad:
3352     * `colorspec = 0xFF00FF00`
3353 * string form: A ColorString (defined above):
3354     * `colorspec = "green"`
3355
3356
3357
3358
3359 Escape sequences
3360 ================
3361
3362 Most text can contain escape sequences, that can for example color the text.
3363 There are a few exceptions: tab headers, dropdowns and vertical labels can't.
3364 The following functions provide escape sequences:
3365
3366 * `minetest.get_color_escape_sequence(color)`:
3367     * `color` is a ColorString
3368     * The escape sequence sets the text color to `color`
3369 * `minetest.colorize(color, message)`:
3370     * Equivalent to:
3371       `minetest.get_color_escape_sequence(color) ..
3372       message ..
3373       minetest.get_color_escape_sequence("#ffffff")`
3374 * `minetest.get_background_escape_sequence(color)`
3375     * `color` is a ColorString
3376     * The escape sequence sets the background of the whole text element to
3377       `color`. Only defined for item descriptions and tooltips.
3378 * `minetest.strip_foreground_colors(str)`
3379     * Removes foreground colors added by `get_color_escape_sequence`.
3380 * `minetest.strip_background_colors(str)`
3381     * Removes background colors added by `get_background_escape_sequence`.
3382 * `minetest.strip_colors(str)`
3383     * Removes all color escape sequences.
3384
3385
3386
3387
3388 Spatial Vectors
3389 ===============
3390
3391 Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
3392 and has a class to represent them (`vector.*`), which this chapter is about.
3393 For details on what a spatial vectors is, please refer to Wikipedia:
3394 https://en.wikipedia.org/wiki/Euclidean_vector.
3395
3396 Spatial vectors are used for various things, including, but not limited to:
3397
3398 * any 3D spatial vector (x/y/z-directions)
3399 * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
3400   meaning here. Therefore, most vector operations make no sense in this use case.)
3401
3402 Note that they are *not* used for:
3403
3404 * n-dimensional vectors where n is not 3 (ie. n=2)
3405 * arrays of the form `{num, num, num}`
3406
3407 The API documentation may refer to spatial vectors, as produced by `vector.new`,
3408 by any of the following notations:
3409
3410 * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
3411 * `vector.new(x, y, z)`
3412 * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
3413
3414 Compatibility notes
3415 -------------------
3416
3417 Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
3418 Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
3419 Note: Those old-style vectors can still be found in old mod code. Hence, mod and
3420 engine APIs still need to be able to cope with them in many places.
3421
3422 Manually constructed tables are deprecated and highly discouraged. This interface
3423 should be used to ensure seamless compatibility between mods and the Minetest API.
3424 This is especially important to callback function parameters and functions overwritten
3425 by mods.
3426 Also, though not likely, the internal implementation of a vector might change in
3427 the future.
3428 In your own code, or if you define your own API, you can, of course, still use
3429 other representations of vectors.
3430
3431 Vectors provided by API functions will provide an instance of this class if not
3432 stated otherwise. Mods should adapt this for convenience reasons.
3433
3434 Special properties of the class
3435 -------------------------------
3436
3437 Vectors can be indexed with numbers and allow method and operator syntax.
3438
3439 All these forms of addressing a vector `v` are valid:
3440 `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
3441 Note: Prefer letter over number indexing for performance and compatibility reasons.
3442
3443 Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
3444 the same as `vector.foo(v, ...)`, apart from deprecated functionality.
3445
3446 `tostring` is defined for vectors, see `vector.to_string`.
3447
3448 The metatable that is used for vectors can be accessed via `vector.metatable`.
3449 Do not modify it!
3450
3451 All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
3452 Returned vectors always have a metatable set.
3453
3454 Common functions and methods
3455 ----------------------------
3456
3457 For the following functions (and subchapters),
3458 `v`, `v1`, `v2` are vectors,
3459 `p1`, `p2` are position vectors,
3460 `s` is a scalar (a number),
3461 vectors are written like this: `(x, y, z)`:
3462
3463 * `vector.new([a[, b, c]])`:
3464     * Returns a new vector `(a, b, c)`.
3465     * Deprecated: `vector.new()` does the same as `vector.zero()` and
3466       `vector.new(v)` does the same as `vector.copy(v)`
3467 * `vector.zero()`:
3468     * Returns a new vector `(0, 0, 0)`.
3469 * `vector.copy(v)`:
3470     * Returns a copy of the vector `v`.
3471 * `vector.from_string(s[, init])`:
3472     * Returns `v, np`, where `v` is a vector read from the given string `s` and
3473       `np` is the next position in the string after the vector.
3474     * Returns `nil` on failure.
3475     * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
3476            spaces, leaving away commas and adding an additional comma to the end
3477            is allowed.
3478     * `init`: If given starts looking for the vector at this string index.
3479 * `vector.to_string(v)`:
3480     * Returns a string of the form `"(x, y, z)"`.
3481     *  `tostring(v)` does the same.
3482 * `vector.direction(p1, p2)`:
3483     * Returns a vector of length 1 with direction `p1` to `p2`.
3484     * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
3485 * `vector.distance(p1, p2)`:
3486     * Returns zero or a positive number, the distance between `p1` and `p2`.
3487 * `vector.length(v)`:
3488     * Returns zero or a positive number, the length of vector `v`.
3489 * `vector.normalize(v)`:
3490     * Returns a vector of length 1 with direction of vector `v`.
3491     * If `v` has zero length, returns `(0, 0, 0)`.
3492 * `vector.floor(v)`:
3493     * Returns a vector, each dimension rounded down.
3494 * `vector.round(v)`:
3495     * Returns a vector, each dimension rounded to nearest integer.
3496     * At a multiple of 0.5, rounds away from zero.
3497 * `vector.apply(v, func)`:
3498     * Returns a vector where the function `func` has been applied to each
3499       component.
3500 * `vector.combine(v, w, func)`:
3501         * Returns a vector where the function `func` has combined both components of `v` and `w`
3502           for each component
3503 * `vector.equals(v1, v2)`:
3504     * Returns a boolean, `true` if the vectors are identical.
3505 * `vector.sort(v1, v2)`:
3506     * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
3507 * `vector.angle(v1, v2)`:
3508     * Returns the angle between `v1` and `v2` in radians.
3509 * `vector.dot(v1, v2)`:
3510     * Returns the dot product of `v1` and `v2`.
3511 * `vector.cross(v1, v2)`:
3512     * Returns the cross product of `v1` and `v2`.
3513 * `vector.offset(v, x, y, z)`:
3514     * Returns the sum of the vectors `v` and `(x, y, z)`.
3515 * `vector.check(v)`:
3516     * Returns a boolean value indicating whether `v` is a real vector, eg. created
3517       by a `vector.*` function.
3518     * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
3519
3520 For the following functions `x` can be either a vector or a number:
3521
3522 * `vector.add(v, x)`:
3523     * Returns a vector.
3524     * If `x` is a vector: Returns the sum of `v` and `x`.
3525     * If `x` is a number: Adds `x` to each component of `v`.
3526 * `vector.subtract(v, x)`:
3527     * Returns a vector.
3528     * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
3529     * If `x` is a number: Subtracts `x` from each component of `v`.
3530 * `vector.multiply(v, s)`:
3531     * Returns a scaled vector.
3532     * Deprecated: If `s` is a vector: Returns the Schur product.
3533 * `vector.divide(v, s)`:
3534     * Returns a scaled vector.
3535     * Deprecated: If `s` is a vector: Returns the Schur quotient.
3536
3537 Operators
3538 ---------
3539
3540 Operators can be used if all of the involved vectors have metatables:
3541 * `v1 == v2`:
3542     * Returns whether `v1` and `v2` are identical.
3543 * `-v`:
3544     * Returns the additive inverse of v.
3545 * `v1 + v2`:
3546     * Returns the sum of both vectors.
3547     * Note: `+` can not be used together with scalars.
3548 * `v1 - v2`:
3549     * Returns the difference of `v1` subtracted by `v2`.
3550     * Note: `-` can not be used together with scalars.
3551 * `v * s` or `s * v`:
3552     * Returns `v` scaled by `s`.
3553 * `v / s`:
3554     * Returns `v` scaled by `1 / s`.
3555
3556 Rotation-related functions
3557 --------------------------
3558
3559 For the following functions `a` is an angle in radians and `r` is a rotation
3560 vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
3561 angles in radians.
3562
3563 * `vector.rotate(v, r)`:
3564     * Applies the rotation `r` to `v` and returns the result.
3565     * `vector.rotate(vector.new(0, 0, 1), r)` and
3566       `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
3567       forward and up relative to an entity's rotation `r`.
3568 * `vector.rotate_around_axis(v1, v2, a)`:
3569     * Returns `v1` rotated around axis `v2` by `a` radians according to
3570       the right hand rule.
3571 * `vector.dir_to_rotation(direction[, up])`:
3572     * Returns a rotation vector for `direction` pointing forward using `up`
3573       as the up vector.
3574     * If `up` is omitted, the roll of the returned vector defaults to zero.
3575     * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
3576
3577 Further helpers
3578 ---------------
3579
3580 There are more helper functions involving vectors, but they are listed elsewhere
3581 because they only work on specific sorts of vectors or involve things that are not
3582 vectors.
3583
3584 For example:
3585
3586 * `minetest.hash_node_position` (Only works on node positions.)
3587 * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
3588
3589
3590
3591
3592 Helper functions
3593 ================
3594
3595 * `dump2(obj, name, dumped)`: returns a string which makes `obj`
3596   human-readable, handles reference loops.
3597     * `obj`: arbitrary variable
3598     * `name`: string, default: `"_"`
3599     * `dumped`: table, default: `{}`
3600 * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
3601     * `obj`: arbitrary variable
3602     * `dumped`: table, default: `{}`
3603 * `math.hypot(x, y)`
3604     * Get the hypotenuse of a triangle with legs x and y.
3605       Useful for distance calculation.
3606 * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
3607     * Get the sign of a number.
3608     * tolerance: number, default: `0.0`
3609     * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
3610       `0` is returned.
3611 * `math.factorial(x)`: returns the factorial of `x`
3612 * `math.round(x)`: Returns `x` rounded to the nearest integer.
3613     * At a multiple of 0.5, rounds away from zero.
3614 * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
3615     * `separator`: string, default: `","`
3616     * `include_empty`: boolean, default: `false`
3617     * `max_splits`: number, if it's negative, splits aren't limited,
3618       default: `-1`
3619     * `sep_is_pattern`: boolean, it specifies whether separator is a plain
3620       string or a pattern (regex), default: `false`
3621     * e.g. `"a,b":split","` returns `{"a","b"}`
3622 * `string:trim()`: returns the string without whitespace pre- and suffixes
3623     * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
3624 * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
3625     * Adds newlines to the string to keep it within the specified character
3626       limit
3627     * Note that the returned lines may be longer than the limit since it only
3628       splits at word borders.
3629     * `limit`: number, maximal amount of characters in one line
3630     * `as_table`: boolean, if set to true, a table of lines instead of a string
3631       is returned, default: `false`
3632 * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
3633     * `pos`: table {x=X, y=Y, z=Z}
3634     * Converts the position `pos` to a human-readable, printable string
3635     * `decimal_places`: number, if specified, the x, y and z values of
3636       the position are rounded to the given decimal place.
3637 * `minetest.string_to_pos(string)`: returns a position or `nil`
3638     * Same but in reverse.
3639     * If the string can't be parsed to a position, nothing is returned.
3640 * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`:
3641     * returns two positions
3642     * Converts a string representing an area box into two positions
3643     * X1, Y1, ... Z2 are coordinates
3644     * `relative_to`: Optional. If set to a position, each coordinate
3645       can use the tilde notation for relative positions
3646     * Tilde notation: "~": Relative coordinate
3647                       "~<number>": Relative coordinate plus <number>
3648     * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
3649       returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
3650 * `minetest.formspec_escape(string)`: returns a string
3651     * escapes the characters "[", "]", "\", "," and ";", which can not be used
3652       in formspecs.
3653 * `minetest.is_yes(arg)`
3654     * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
3655 * `minetest.is_nan(arg)`
3656     * returns true when the passed number represents NaN.
3657 * `minetest.get_us_time()`
3658     * returns time with microsecond precision. May not return wall time.
3659 * `table.copy(table)`: returns a table
3660     * returns a deep copy of `table`
3661 * `table.indexof(list, val)`: returns the smallest numerical index containing
3662       the value `val` in the table `list`. Non-numerical indices are ignored.
3663       If `val` could not be found, `-1` is returned. `list` must not have
3664       negative indices.
3665 * `table.insert_all(table, other_table)`:
3666     * Appends all values in `other_table` to `table` - uses `#table + 1` to
3667       find new indices.
3668 * `table.key_value_swap(t)`: returns a table with keys and values swapped
3669     * If multiple keys in `t` map to the same value, it is unspecified which
3670       value maps to that key.
3671 * `table.shuffle(table, [from], [to], [random_func])`:
3672     * Shuffles elements `from` to `to` in `table` in place
3673     * `from` defaults to `1`
3674     * `to` defaults to `#table`
3675     * `random_func` defaults to `math.random`. This function receives two
3676       integers as arguments and should return a random integer inclusively
3677       between them.
3678 * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
3679   position.
3680     * returns the exact position on the surface of a pointed node
3681 * `minetest.get_tool_wear_after_use(uses [, initial_wear])`
3682     * Simulates a tool being used once and returns the added wear,
3683       such that, if only this function is used to calculate wear,
3684       the tool will break exactly after `uses` times of uses
3685     * `uses`: Number of times the tool can be used
3686     * `initial_wear`: The initial wear the tool starts with (default: 0)
3687 * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
3688     Simulates an item that digs a node.
3689     Returns a table with the following fields:
3690     * `diggable`: `true` if node can be dug, `false` otherwise.
3691     * `time`: Time it would take to dig the node.
3692     * `wear`: How much wear would be added to the tool (ignored for non-tools).
3693     `time` and `wear` are meaningless if node's not diggable
3694     Parameters:
3695     * `groups`: Table of the node groups of the node that would be dug
3696     * `tool_capabilities`: Tool capabilities table of the item
3697     * `wear`: Amount of wear the tool starts with (default: 0)
3698 * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
3699     Simulates an item that punches an object.
3700     Returns a table with the following fields:
3701     * `hp`: How much damage the punch would cause (between -65535 and 65535).
3702     * `wear`: How much wear would be added to the tool (ignored for non-tools).
3703     Parameters:
3704     * `groups`: Damage groups of the object
3705     * `tool_capabilities`: Tool capabilities table of the item
3706     * `time_from_last_punch`: time in seconds since last punch action
3707     * `wear`: Amount of wear the item starts with (default: 0)
3708
3709
3710
3711
3712 Translations
3713 ============
3714
3715 Texts can be translated client-side with the help of `minetest.translate` and
3716 translation files.
3717
3718 Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
3719 to generate and update translation files automatically from the Lua source.
3720
3721 Translating a string
3722 --------------------
3723
3724 Two functions are provided to translate strings: `minetest.translate` and
3725 `minetest.get_translator`.
3726
3727 * `minetest.get_translator(textdomain)` is a simple wrapper around
3728   `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
3729   equivalent to `minetest.translate(textdomain, str, ...)`.
3730   It is intended to be used in the following way, so that it avoids verbose
3731   repetitions of `minetest.translate`:
3732
3733       local S = minetest.get_translator(textdomain)
3734       S(str, ...)
3735
3736   As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
3737
3738 * `minetest.translate(textdomain, str, ...)` translates the string `str` with
3739   the given `textdomain` for disambiguation. The textdomain must match the
3740   textdomain specified in the translation file in order to get the string
3741   translated. This can be used so that a string is translated differently in
3742   different contexts.
3743   It is advised to use the name of the mod as textdomain whenever possible, to
3744   avoid clashes with other mods.
3745   This function must be given a number of arguments equal to the number of
3746   arguments the translated string expects.
3747   Arguments are literal strings -- they will not be translated, so if you want
3748   them to be, they need to come as outputs of `minetest.translate` as well.
3749
3750   For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
3751   by the translation of "Red". We can do the following:
3752
3753       local S = minetest.get_translator()
3754       S("@1 Wool", S("Red"))
3755
3756   This will be displayed as "Red Wool" on old clients and on clients that do
3757   not have localization enabled. However, if we have for instance a translation
3758   file named `wool.fr.tr` containing the following:
3759
3760       @1 Wool=Laine @1
3761       Red=Rouge
3762
3763   this will be displayed as "Laine Rouge" on clients with a French locale.
3764
3765 Operations on translated strings
3766 --------------------------------
3767
3768 The output of `minetest.translate` is a string, with escape sequences adding
3769 additional information to that string so that it can be translated on the
3770 different clients. In particular, you can't expect operations like string.length
3771 to work on them like you would expect them to, or string.gsub to work in the
3772 expected manner. However, string concatenation will still work as expected
3773 (note that you should only use this for things like formspecs; do not translate
3774 sentences by breaking them into parts; arguments should be used instead), and
3775 operations such as `minetest.colorize` which are also concatenation.
3776
3777 Translation file format
3778 -----------------------
3779
3780 A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
3781 it corresponds to. It must be put into the `locale` subdirectory of the mod.
3782 The file should be a text file, with the following format:
3783
3784 * Lines beginning with `# textdomain:` (the space is significant) can be used
3785   to specify the text domain of all following translations in the file.
3786 * All other empty lines or lines beginning with `#` are ignored.
3787 * Other lines should be in the format `original=translated`. Both `original`
3788   and `translated` can contain escape sequences beginning with `@` to insert
3789   arguments, literal `@`, `=` or newline (See [Escapes] below).
3790   There must be no extraneous whitespace around the `=` or at the beginning or
3791   the end of the line.
3792
3793 Escapes
3794 -------
3795
3796 Strings that need to be translated can contain several escapes, preceded by `@`.
3797
3798 * `@@` acts as a literal `@`.
3799 * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
3800   string that will be inlined when translated. Due to how translations are
3801   implemented, the original translation string **must** have its arguments in
3802   increasing order, without gaps or repetitions, starting from 1.
3803 * `@=` acts as a literal `=`. It is not required in strings given to
3804   `minetest.translate`, but is in translation files to avoid being confused
3805   with the `=` separating the original from the translation.
3806 * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
3807   As with `@=`, this escape is not required in strings given to
3808   `minetest.translate`, but is in translation files.
3809 * `@n` acts as a literal newline as well.
3810
3811 Server side translations
3812 ------------------------
3813
3814 On some specific cases, server translation could be useful. For example, filter
3815 a list on labels and send results to client. A method is supplied to achieve
3816 that:
3817
3818 `minetest.get_translated_string(lang_code, string)`: Translates `string` using
3819 translations for `lang_code` language. It gives the same result as if the string
3820 was translated by the client.
3821
3822 The `lang_code` to use for a given player can be retrieved from
3823 the table returned by `minetest.get_player_information(name)`.
3824
3825 IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
3826 You do not need to use this to get translated strings to show up on the client.
3827
3828 Perlin noise
3829 ============
3830
3831 Perlin noise creates a continuously-varying value depending on the input values.
3832 Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
3833 The result is used during map generation to create the terrain shape, vary heat
3834 and humidity to distribute biomes, vary the density of decorations or vary the
3835 structure of ores.
3836
3837 Structure of perlin noise
3838 -------------------------
3839
3840 An 'octave' is a simple noise generator that outputs a value between -1 and 1.
3841 The smooth wavy noise it generates has a single characteristic scale, almost
3842 like a 'wavelength', so on its own does not create fine detail.
3843 Due to this perlin noise combines several octaves to create variation on
3844 multiple scales. Each additional octave has a smaller 'wavelength' than the
3845 previous.
3846
3847 This combination results in noise varying very roughly between -2.0 and 2.0 and
3848 with an average value of 0.0, so `scale` and `offset` are then used to multiply
3849 and offset the noise variation.
3850
3851 The final perlin noise variation is created as follows:
3852
3853 noise = offset + scale * (octave1 +
3854                           octave2 * persistence +
3855                           octave3 * persistence ^ 2 +
3856                           octave4 * persistence ^ 3 +
3857                           ...)
3858
3859 Noise Parameters
3860 ----------------
3861
3862 Noise Parameters are commonly called `NoiseParams`.
3863
3864 ### `offset`
3865
3866 After the multiplication by `scale` this is added to the result and is the final
3867 step in creating the noise value.
3868 Can be positive or negative.
3869
3870 ### `scale`
3871
3872 Once all octaves have been combined, the result is multiplied by this.
3873 Can be positive or negative.
3874
3875 ### `spread`
3876
3877 For octave1, this is roughly the change of input value needed for a very large
3878 variation in the noise value generated by octave1. It is almost like a
3879 'wavelength' for the wavy noise variation.
3880 Each additional octave has a 'wavelength' that is smaller than the previous
3881 octave, to create finer detail. `spread` will therefore roughly be the typical
3882 size of the largest structures in the final noise variation.
3883
3884 `spread` is a vector with values for x, y, z to allow the noise variation to be
3885 stretched or compressed in the desired axes.
3886 Values are positive numbers.
3887
3888 ### `seed`
3889
3890 This is a whole number that determines the entire pattern of the noise
3891 variation. Altering it enables different noise patterns to be created.
3892 With other parameters equal, different seeds produce different noise patterns
3893 and identical seeds produce identical noise patterns.
3894
3895 For this parameter you can randomly choose any whole number. Usually it is
3896 preferable for this to be different from other seeds, but sometimes it is useful
3897 to be able to create identical noise patterns.
3898
3899 In some noise APIs the world seed is added to the seed specified in noise
3900 parameters. This is done to make the resulting noise pattern vary in different
3901 worlds, and be 'world-specific'.
3902
3903 ### `octaves`
3904
3905 The number of simple noise generators that are combined.
3906 A whole number, 1 or more.
3907 Each additional octave adds finer detail to the noise but also increases the
3908 noise calculation load.
3909 3 is a typical minimum for a high quality, complex and natural-looking noise
3910 variation. 1 octave has a slight 'gridlike' appearance.
3911
3912 Choose the number of octaves according to the `spread` and `lacunarity`, and the
3913 size of the finest detail you require. For example:
3914 if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
3915 nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
3916 512, 256, 128, 64, 32, 16 nodes.
3917 Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
3918
3919 ### `persistence`
3920
3921 Each additional octave has an amplitude that is the amplitude of the previous
3922 octave multiplied by `persistence`, to reduce the amplitude of finer details,
3923 as is often helpful and natural to do so.
3924 Since this controls the balance of fine detail to large-scale detail
3925 `persistence` can be thought of as the 'roughness' of the noise.
3926
3927 A positive or negative non-zero number, often between 0.3 and 1.0.
3928 A common medium value is 0.5, such that each octave has half the amplitude of
3929 the previous octave.
3930 This may need to be tuned when altering `lacunarity`; when doing so consider
3931 that a common medium value is 1 / lacunarity.
3932
3933 ### `lacunarity`
3934
3935 Each additional octave has a 'wavelength' that is the 'wavelength' of the
3936 previous octave multiplied by 1 / lacunarity, to create finer detail.
3937 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
3938
3939 A positive number no smaller than 1.0.
3940 Values below 2.0 create higher quality noise at the expense of requiring more
3941 octaves to cover a particular range of 'wavelengths'.
3942
3943 ### `flags`
3944
3945 Leave this field unset for no special handling.
3946 Currently supported are `defaults`, `eased` and `absvalue`:
3947
3948 #### `defaults`
3949
3950 Specify this if you would like to keep auto-selection of eased/not-eased while
3951 specifying some other flags.
3952
3953 #### `eased`
3954
3955 Maps noise gradient values onto a quintic S-curve before performing
3956 interpolation. This results in smooth, rolling noise.
3957 Disable this (`noeased`) for sharp-looking noise with a slightly gridded
3958 appearance.
3959 If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
3960 not eased.
3961 Easing a 3D noise significantly increases the noise calculation load, so use
3962 with restraint.
3963
3964 #### `absvalue`
3965
3966 The absolute value of each octave's noise variation is used when combining the
3967 octaves. The final perlin noise variation is created as follows:
3968
3969 noise = offset + scale * (abs(octave1) +
3970                           abs(octave2) * persistence +
3971                           abs(octave3) * persistence ^ 2 +
3972                           abs(octave4) * persistence ^ 3 +
3973                           ...)
3974
3975 ### Format example
3976
3977 For 2D or 3D perlin noise or perlin noise maps:
3978
3979     np_terrain = {
3980         offset = 0,
3981         scale = 1,
3982         spread = {x = 500, y = 500, z = 500},
3983         seed = 571347,
3984         octaves = 5,
3985         persistence = 0.63,
3986         lacunarity = 2.0,
3987         flags = "defaults, absvalue",
3988     }
3989
3990 For 2D noise the Z component of `spread` is still defined but is ignored.
3991 A single noise parameter table can be used for 2D or 3D noise.
3992
3993
3994
3995
3996 Ores
3997 ====
3998
3999 Ore types
4000 ---------
4001
4002 These tell in what manner the ore is generated.
4003
4004 All default ores are of the uniformly-distributed scatter type.
4005
4006 ### `scatter`
4007
4008 Randomly chooses a location and generates a cluster of ore.
4009
4010 If `noise_params` is specified, the ore will be placed if the 3D perlin noise
4011 at that point is greater than the `noise_threshold`, giving the ability to
4012 create a non-equal distribution of ore.
4013
4014 ### `sheet`
4015
4016 Creates a sheet of ore in a blob shape according to the 2D perlin noise
4017 described by `noise_params` and `noise_threshold`. This is essentially an
4018 improved version of the so-called "stratus" ore seen in some unofficial mods.
4019
4020 This sheet consists of vertical columns of uniform randomly distributed height,
4021 varying between the inclusive range `column_height_min` and `column_height_max`.
4022 If `column_height_min` is not specified, this parameter defaults to 1.
4023 If `column_height_max` is not specified, this parameter defaults to `clust_size`
4024 for reverse compatibility. New code should prefer `column_height_max`.
4025
4026 The `column_midpoint_factor` parameter controls the position of the column at
4027 which ore emanates from.
4028 If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
4029 equally starting from each direction.
4030 `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
4031 this parameter is not specified, the default is 0.5.
4032
4033 The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
4034 ore type.
4035
4036 ### `puff`
4037
4038 Creates a sheet of ore in a cloud-like puff shape.
4039
4040 As with the `sheet` ore type, the size and shape of puffs are described by
4041 `noise_params` and `noise_threshold` and are placed at random vertical
4042 positions within the currently generated chunk.
4043
4044 The vertical top and bottom displacement of each puff are determined by the
4045 noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
4046
4047 ### `blob`
4048
4049 Creates a deformed sphere of ore according to 3d perlin noise described by
4050 `noise_params`. The maximum size of the blob is `clust_size`, and
4051 `clust_scarcity` has the same meaning as with the `scatter` type.
4052
4053 ### `vein`
4054
4055 Creates veins of ore varying in density by according to the intersection of two
4056 instances of 3d perlin noise with different seeds, both described by
4057 `noise_params`.
4058
4059 `random_factor` varies the influence random chance has on placement of an ore
4060 inside the vein, which is `1` by default. Note that modifying this parameter
4061 may require adjusting `noise_threshold`.
4062
4063 The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
4064 by this ore type.
4065
4066 This ore type is difficult to control since it is sensitive to small changes.
4067 The following is a decent set of parameters to work from:
4068
4069     noise_params = {
4070         offset  = 0,
4071         scale   = 3,
4072         spread  = {x=200, y=200, z=200},
4073         seed    = 5390,
4074         octaves = 4,
4075         persistence = 0.5,
4076         lacunarity = 2.0,
4077         flags = "eased",
4078     },
4079     noise_threshold = 1.6
4080
4081 **WARNING**: Use this ore type *very* sparingly since it is ~200x more
4082 computationally expensive than any other ore.
4083
4084 ### `stratum`
4085
4086 Creates a single undulating ore stratum that is continuous across mapchunk
4087 borders and horizontally spans the world.
4088
4089 The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
4090 the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
4091 defines the stratum's vertical thickness (in units of nodes). Due to being
4092 continuous across mapchunk borders the stratum's vertical thickness is
4093 unlimited.
4094
4095 If the noise parameter `noise_params` is omitted the ore will occur from y_min
4096 to y_max in a simple horizontal stratum.
4097
4098 A parameter `stratum_thickness` can be provided instead of the noise parameter
4099 `np_stratum_thickness`, to create a constant thickness.
4100
4101 Leaving out one or both noise parameters makes the ore generation less
4102 intensive, useful when adding multiple strata.
4103
4104 `y_min` and `y_max` define the limits of the ore generation and for performance
4105 reasons should be set as close together as possible but without clipping the
4106 stratum's Y variation.
4107
4108 Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
4109 solid-ore stratum would require a `clust_scarcity` of 1.
4110
4111 The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
4112 `random_factor` are ignored by this ore type.
4113
4114 Ore attributes
4115 --------------
4116
4117 See section [Flag Specifier Format].
4118
4119 Currently supported flags:
4120 `puff_cliffs`, `puff_additive_composition`.
4121
4122 ### `puff_cliffs`
4123
4124 If set, puff ore generation will not taper down large differences in
4125 displacement when approaching the edge of a puff. This flag has no effect for
4126 ore types other than `puff`.
4127
4128 ### `puff_additive_composition`
4129
4130 By default, when noise described by `np_puff_top` or `np_puff_bottom` results
4131 in a negative displacement, the sub-column at that point is not generated. With
4132 this attribute set, puff ore generation will instead generate the absolute
4133 difference in noise displacement values. This flag has no effect for ore types
4134 other than `puff`.
4135
4136
4137
4138
4139 Decoration types
4140 ================
4141
4142 The varying types of decorations that can be placed.
4143
4144 `simple`
4145 --------
4146
4147 Creates a 1 times `H` times 1 column of a specified node (or a random node from
4148 a list, if a decoration list is specified). Can specify a certain node it must
4149 spawn next to, such as water or lava, for example. Can also generate a
4150 decoration of random height between a specified lower and upper bound.
4151 This type of decoration is intended for placement of grass, flowers, cacti,
4152 papyri, waterlilies and so on.
4153
4154 `schematic`
4155 -----------
4156
4157 Copies a box of `MapNodes` from a specified schematic file (or raw description).
4158 Can specify a probability of a node randomly appearing when placed.
4159 This decoration type is intended to be used for multi-node sized discrete
4160 structures, such as trees, cave spikes, rocks, and so on.
4161
4162
4163
4164
4165 Schematics
4166 ==========
4167
4168 Schematic specifier
4169 --------------------
4170
4171 A schematic specifier identifies a schematic by either a filename to a
4172 Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
4173 in the form of a table.  This table specifies the following fields:
4174
4175 * The `size` field is a 3D vector containing the dimensions of the provided
4176   schematic. (required field)
4177 * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
4178   sets the probability of a particular horizontal slice of the schematic being
4179   placed. (optional field)
4180   `ypos` = 0 for the lowest horizontal slice of a schematic.
4181   The default of `prob` is 255.
4182 * The `data` field is a flat table of MapNode tables making up the schematic,
4183   in the order of `[z [y [x]]]`. (required field)
4184   Each MapNode table contains:
4185     * `name`: the name of the map node to place (required)
4186     * `prob` (alias `param1`): the probability of this node being placed
4187       (default: 255)
4188     * `param2`: the raw param2 value of the node being placed onto the map
4189       (default: 0)
4190     * `force_place`: boolean representing if the node should forcibly overwrite
4191       any previous contents (default: false)
4192
4193 About probability values:
4194
4195 * A probability value of `0` or `1` means that node will never appear
4196   (0% chance).
4197 * A probability value of `254` or `255` means the node will always appear
4198   (100% chance).
4199 * If the probability value `p` is greater than `1`, then there is a
4200   `(p / 256 * 100)` percent chance that node will appear when the schematic is
4201   placed on the map.
4202
4203 Schematic attributes
4204 --------------------
4205
4206 See section [Flag Specifier Format].
4207
4208 Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
4209                            `force_placement`.
4210
4211 * `place_center_x`: Placement of this decoration is centered along the X axis.
4212 * `place_center_y`: Placement of this decoration is centered along the Y axis.
4213 * `place_center_z`: Placement of this decoration is centered along the Z axis.
4214 * `force_placement`: Schematic nodes other than "ignore" will replace existing
4215   nodes.
4216
4217
4218
4219
4220 Lua Voxel Manipulator
4221 =====================
4222
4223 About VoxelManip
4224 ----------------
4225
4226 VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
4227 facility. The purpose of this object is for fast, low-level, bulk access to
4228 reading and writing Map content. As such, setting map nodes through VoxelManip
4229 will lack many of the higher level features and concepts you may be used to
4230 with other methods of setting nodes. For example, nodes will not have their
4231 construction and destruction callbacks run, and no rollback information is
4232 logged.
4233
4234 It is important to note that VoxelManip is designed for speed, and *not* ease
4235 of use or flexibility. If your mod requires a map manipulation facility that
4236 will handle 100% of all edge cases, or the use of high level node placement
4237 features, perhaps `minetest.set_node()` is better suited for the job.
4238
4239 In addition, VoxelManip might not be faster, or could even be slower, for your
4240 specific use case. VoxelManip is most effective when setting large areas of map
4241 at once - for example, if only setting a 3x3x3 node area, a
4242 `minetest.set_node()` loop may be more optimal. Always profile code using both
4243 methods of map manipulation to determine which is most appropriate for your
4244 usage.
4245
4246 A recent simple test of setting cubic areas showed that `minetest.set_node()`
4247 is faster than a VoxelManip for a 3x3x3 node cube or smaller.
4248
4249 Using VoxelManip
4250 ----------------
4251
4252 A VoxelManip object can be created any time using either:
4253 `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
4254
4255 If the optional position parameters are present for either of these routines,
4256 the specified region will be pre-loaded into the VoxelManip object on creation.
4257 Otherwise, the area of map you wish to manipulate must first be loaded into the
4258 VoxelManip object using `VoxelManip:read_from_map()`.
4259
4260 Note that `VoxelManip:read_from_map()` returns two position vectors. The region
4261 formed by these positions indicate the minimum and maximum (respectively)
4262 positions of the area actually loaded in the VoxelManip, which may be larger
4263 than the area requested. For convenience, the loaded area coordinates can also
4264 be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
4265
4266 Now that the VoxelManip object is populated with map data, your mod can fetch a
4267 copy of this data using either of two methods. `VoxelManip:get_node_at()`,
4268 which retrieves an individual node in a MapNode formatted table at the position
4269 requested is the simplest method to use, but also the slowest.
4270
4271 Nodes in a VoxelManip object may also be read in bulk to a flat array table
4272 using:
4273
4274 * `VoxelManip:get_data()` for node content (in Content ID form, see section
4275   [Content IDs]),
4276 * `VoxelManip:get_light_data()` for node light levels, and
4277 * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
4278
4279 See section [Flat array format] for more details.
4280
4281 It is very important to understand that the tables returned by any of the above
4282 three functions represent a snapshot of the VoxelManip's internal state at the
4283 time of the call. This copy of the data will not magically update itself if
4284 another function modifies the internal VoxelManip state.
4285 Any functions that modify a VoxelManip's contents work on the VoxelManip's
4286 internal state unless otherwise explicitly stated.
4287
4288 Once the bulk data has been edited to your liking, the internal VoxelManip
4289 state can be set using:
4290
4291 * `VoxelManip:set_data()` for node content (in Content ID form, see section
4292   [Content IDs]),
4293 * `VoxelManip:set_light_data()` for node light levels, and
4294 * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
4295
4296 The parameter to each of the above three functions can use any table at all in
4297 the same flat array format as produced by `get_data()` etc. and is not required
4298 to be a table retrieved from `get_data()`.
4299
4300 Once the internal VoxelManip state has been modified to your liking, the
4301 changes can be committed back to the map by calling `VoxelManip:write_to_map()`
4302
4303 ### Flat array format
4304
4305 Let
4306     `Nx = p2.X - p1.X + 1`,
4307     `Ny = p2.Y - p1.Y + 1`, and
4308     `Nz = p2.Z - p1.Z + 1`.
4309
4310 Then, for a loaded region of p1..p2, this array ranges from `1` up to and
4311 including the value of the expression `Nx * Ny * Nz`.
4312
4313 Positions offset from p1 are present in the array with the format of:
4314
4315     [
4316         (0, 0, 0),   (1, 0, 0),   (2, 0, 0),   ... (Nx, 0, 0),
4317         (0, 1, 0),   (1, 1, 0),   (2, 1, 0),   ... (Nx, 1, 0),
4318         ...
4319         (0, Ny, 0),  (1, Ny, 0),  (2, Ny, 0),  ... (Nx, Ny, 0),
4320         (0, 0, 1),   (1, 0, 1),   (2, 0, 1),   ... (Nx, 0, 1),
4321         ...
4322         (0, Ny, 2),  (1, Ny, 2),  (2, Ny, 2),  ... (Nx, Ny, 2),
4323         ...
4324         (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
4325     ]
4326
4327 and the array index for a position p contained completely in p1..p2 is:
4328
4329 `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
4330
4331 Note that this is the same "flat 3D array" format as
4332 `PerlinNoiseMap:get3dMap_flat()`.
4333 VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
4334 of the index for a single point in a flat VoxelManip array.
4335
4336 ### Content IDs
4337
4338 A Content ID is a unique integer identifier for a specific node type.
4339 These IDs are used by VoxelManip in place of the node name string for
4340 `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
4341 `minetest.get_content_id()` to look up the Content ID for the specified node
4342 name, and `minetest.get_name_from_content_id()` to look up the node name string
4343 for a given Content ID.
4344 After registration of a node, its Content ID will remain the same throughout
4345 execution of the mod.
4346 Note that the node being queried needs to have already been been registered.
4347
4348 The following builtin node types have their Content IDs defined as constants:
4349
4350 * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
4351 * `minetest.CONTENT_AIR`:     ID for "air" nodes
4352 * `minetest.CONTENT_IGNORE`:  ID for "ignore" nodes
4353
4354 ### Mapgen VoxelManip objects
4355
4356 Inside of `on_generated()` callbacks, it is possible to retrieve the same
4357 VoxelManip object used by the core's Map Generator (commonly abbreviated
4358 Mapgen). Most of the rules previously described still apply but with a few
4359 differences:
4360
4361 * The Mapgen VoxelManip object is retrieved using:
4362   `minetest.get_mapgen_object("voxelmanip")`
4363 * This VoxelManip object already has the region of map just generated loaded
4364   into it; it's not necessary to call `VoxelManip:read_from_map()`.
4365   Note that the region of map it has loaded is NOT THE SAME as the `minp`, `maxp`
4366   parameters of `on_generated()`. Refer to `minetest.get_mapgen_object` docs.
4367 * The `on_generated()` callbacks of some mods may place individual nodes in the
4368   generated area using non-VoxelManip map modification methods. Because the
4369   same Mapgen VoxelManip object is passed through each `on_generated()`
4370   callback, it becomes necessary for the Mapgen VoxelManip object to maintain
4371   consistency with the current map state. For this reason, calling any of
4372   `minetest.add_node()`, `minetest.set_node()` or `minetest.swap_node()`
4373   will also update the Mapgen VoxelManip object's internal state active on the
4374   current thread.
4375 * After modifying the Mapgen VoxelManip object's internal buffer, it may be
4376   necessary to update lighting information using either:
4377   `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
4378
4379 ### Other API functions operating on a VoxelManip
4380
4381 If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
4382 `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
4383 flowing. It is recommended to call this function only after having written all
4384 buffered data back to the VoxelManip object, save for special situations where
4385 the modder desires to only have certain liquid nodes begin flowing.
4386
4387 The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
4388 will generate all registered decorations and ores throughout the full area
4389 inside of the specified VoxelManip object.
4390
4391 `minetest.place_schematic_on_vmanip()` is otherwise identical to
4392 `minetest.place_schematic()`, except instead of placing the specified schematic
4393 directly on the map at the specified position, it will place the schematic
4394 inside the VoxelManip.
4395
4396 ### Notes
4397
4398 * Attempting to read data from a VoxelManip object before map is read will
4399   result in a zero-length array table for `VoxelManip:get_data()`, and an
4400   "ignore" node at any position for `VoxelManip:get_node_at()`.
4401 * If either a region of map has not yet been generated or is out-of-bounds of
4402   the map, that region is filled with "ignore" nodes.
4403 * Other mods, or the core itself, could possibly modify the area of map
4404   currently loaded into a VoxelManip object. With the exception of Mapgen
4405   VoxelManips (see above section), the internal buffers are not updated. For
4406   this reason, it is strongly encouraged to complete the usage of a particular
4407   VoxelManip object in the same callback it had been created.
4408 * If a VoxelManip object will be used often, such as in an `on_generated()`
4409   callback, consider passing a file-scoped table as the optional parameter to
4410   `VoxelManip:get_data()`, which serves as a static buffer the function can use
4411   to write map data to instead of returning a new table each call. This greatly
4412   enhances performance by avoiding unnecessary memory allocations.
4413
4414 Methods
4415 -------
4416
4417 * `read_from_map(p1, p2)`:  Loads a chunk of map into the VoxelManip object
4418   containing the region formed by `p1` and `p2`.
4419     * returns actual emerged `pmin`, actual emerged `pmax`
4420 * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
4421   the map.
4422     * **important**: data must be set using `VoxelManip:set_data()` before
4423       calling this.
4424     * if `light` is true, then lighting is automatically recalculated.
4425       The default value is true.
4426       If `light` is false, no light calculations happen, and you should correct
4427       all modified blocks with `minetest.fix_light()` as soon as possible.
4428       Keep in mind that modifying the map where light is incorrect can cause
4429       more lighting bugs.
4430 * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
4431   the `VoxelManip` at that position
4432 * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
4433   that position.
4434 * `get_data([buffer])`: Retrieves the node content data loaded into the
4435   `VoxelManip` object.
4436     * returns raw node data in the form of an array of node content IDs
4437     * if the param `buffer` is present, this table will be used to store the
4438       result instead.
4439 * `set_data(data)`: Sets the data contents of the `VoxelManip` object
4440 * `update_map()`: Does nothing, kept for compatibility.
4441 * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
4442   a uniform value.
4443     * `light` is a table, `{day=<0...15>, night=<0...15>}`
4444     * To be used only by a `VoxelManip` object from
4445       `minetest.get_mapgen_object`.
4446     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4447       area if left out.
4448 * `get_light_data([buffer])`: Gets the light data read into the
4449   `VoxelManip` object
4450     * Returns an array (indices 1 to volume) of integers ranging from `0` to
4451       `255`.
4452     * Each value is the bitwise combination of day and night light values
4453       (`0` to `15` each).
4454     * `light = day + (night * 16)`
4455     * If the param `buffer` is present, this table will be used to store the
4456       result instead.
4457 * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
4458   in the `VoxelManip`.
4459     * expects lighting data in the same format that `get_light_data()` returns
4460 * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
4461   `VoxelManip` object.
4462     * Returns an array (indices 1 to volume) of integers ranging from `0` to
4463       `255`.
4464     * If the param `buffer` is present, this table will be used to store the
4465       result instead.
4466 * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
4467   the `VoxelManip`.
4468 * `calc_lighting([p1, p2], [propagate_shadow])`:  Calculate lighting within the
4469   `VoxelManip`.
4470     * To be used only by a `VoxelManip` object from
4471       `minetest.get_mapgen_object`.
4472     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4473       area if left out or nil. For almost all uses these should be left out
4474       or nil to use the default.
4475     * `propagate_shadow` is an optional boolean deciding whether shadows in a
4476       generated mapchunk above are propagated down into the mapchunk, defaults
4477       to `true` if left out.
4478 * `update_liquids()`: Update liquid flow
4479 * `was_modified()`: Returns `true` or `false` if the data in the voxel
4480   manipulator had been modified since the last read from map, due to a call to
4481   `minetest.set_data()` on the loaded area elsewhere.
4482 * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
4483
4484 `VoxelArea`
4485 -----------
4486
4487 A helper class for voxel areas.
4488 It can be created via `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
4489 The coordinates are *inclusive*, like most other things in Minetest.
4490
4491 ### Methods
4492
4493 * `getExtent()`: returns a 3D vector containing the size of the area formed by
4494   `MinEdge` and `MaxEdge`.
4495 * `getVolume()`: returns the volume of the area formed by `MinEdge` and
4496   `MaxEdge`.
4497 * `index(x, y, z)`: returns the index of an absolute position in a flat array
4498   starting at `1`.
4499     * `x`, `y` and `z` must be integers to avoid an incorrect index result.
4500     * The position (x, y, z) is not checked for being inside the area volume,
4501       being outside can cause an incorrect index result.
4502     * Useful for things like `VoxelManip`, raw Schematic specifiers,
4503       `PerlinNoiseMap:get2d`/`3dMap`, and so on.
4504 * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
4505     * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
4506       is not checked for being inside the area volume.
4507 * `position(i)`: returns the absolute position vector corresponding to index
4508   `i`.
4509 * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
4510   `MinEdge` and `MaxEdge`.
4511 * `containsp(p)`: same as above, except takes a vector
4512 * `containsi(i)`: same as above, except takes an index `i`
4513 * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
4514   indices.
4515     * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
4516       `[z [y [x]]]`.
4517 * `iterp(minp, maxp)`: same as above, except takes a vector
4518
4519 ### Y stride and z stride of a flat array
4520
4521 For a particular position in a voxel area, whose flat array index is known,
4522 it is often useful to know the index of a neighboring or nearby position.
4523 The table below shows the changes of index required for 1 node movements along
4524 the axes in a voxel area:
4525
4526     Movement    Change of index
4527     +x          +1
4528     -x          -1
4529     +y          +ystride
4530     -y          -ystride
4531     +z          +zstride
4532     -z          -zstride
4533
4534 If, for example:
4535
4536     local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
4537
4538 The values of `ystride` and `zstride` can be obtained using `area.ystride` and
4539 `area.zstride`.
4540
4541
4542
4543
4544 Mapgen objects
4545 ==============
4546
4547 A mapgen object is a construct used in map generation. Mapgen objects can be
4548 used by an `on_generate` callback to speed up operations by avoiding
4549 unnecessary recalculations, these can be retrieved using the
4550 `minetest.get_mapgen_object()` function. If the requested Mapgen object is
4551 unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
4552 callback, `nil` is returned.
4553
4554 The following Mapgen objects are currently available:
4555
4556 ### `voxelmanip`
4557
4558 This returns three values; the `VoxelManip` object to be used, minimum and
4559 maximum emerged position, in that order. All mapgens support this object.
4560
4561 ### `heightmap`
4562
4563 Returns an array containing the y coordinates of the ground levels of nodes in
4564 the most recently generated chunk by the current mapgen.
4565
4566 ### `biomemap`
4567
4568 Returns an array containing the biome IDs of nodes in the most recently
4569 generated chunk by the current mapgen.
4570
4571 ### `heatmap`
4572
4573 Returns an array containing the temperature values of nodes in the most
4574 recently generated chunk by the current mapgen.
4575
4576 ### `humiditymap`
4577
4578 Returns an array containing the humidity values of nodes in the most recently
4579 generated chunk by the current mapgen.
4580
4581 ### `gennotify`
4582
4583 Returns a table mapping requested generation notification types to arrays of
4584 positions at which the corresponding generated structures are located within
4585 the current chunk. To enable the capture of positions of interest to be recorded
4586 call `minetest.set_gen_notify()` first.
4587
4588 Possible fields of the returned table are:
4589
4590 * `dungeon`: bottom center position of dungeon rooms
4591 * `temple`: as above but for desert temples (mgv6 only)
4592 * `cave_begin`
4593 * `cave_end`
4594 * `large_cave_begin`
4595 * `large_cave_end`
4596 * `decoration#id` (see below)
4597
4598 Decorations have a key in the format of `"decoration#id"`, where `id` is the
4599 numeric unique decoration ID as returned by `minetest.get_decoration_id()`.
4600 For example, `decoration#123`.
4601
4602 The returned positions are the ground surface 'place_on' nodes,
4603 not the decorations themselves. A 'simple' type decoration is often 1
4604 node above the returned position and possibly displaced by 'place_offset_y'.
4605
4606
4607 Registered entities
4608 ===================
4609
4610 Functions receive a "luaentity" table as `self`:
4611
4612 * It has the member `name`, which is the registered name `("mod:thing")`
4613 * It has the member `object`, which is an `ObjectRef` pointing to the object
4614 * The original prototype is visible directly via a metatable
4615
4616 Callbacks:
4617
4618 * `on_activate(self, staticdata, dtime_s)`
4619     * Called when the object is instantiated.
4620     * `dtime_s` is the time passed since the object was unloaded, which can be
4621       used for updating the entity state.
4622 * `on_deactivate(self, removal)`
4623     * Called when the object is about to get removed or unloaded.
4624         * `removal`: boolean indicating whether the object is about to get removed.
4625           Calling `object:remove()` on an active object will call this with `removal=true`.
4626           The mapblock the entity resides in being unloaded will call this with `removal=false`.
4627         * Note that this won't be called if the object hasn't been activated in the first place.
4628           In particular, `minetest.clear_objects({mode = "full"})` won't call this,
4629           whereas `minetest.clear_objects({mode = "quick"})` might call this.
4630 * `on_step(self, dtime, moveresult)`
4631     * Called on every server tick, after movement and collision processing.
4632     * `dtime`: elapsed time since last call
4633     * `moveresult`: table with collision info (only available if physical=true)
4634 * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
4635     * Called when somebody punches the object.
4636     * Note that you probably want to handle most punches using the automatic
4637       armor group system.
4638     * `puncher`: an `ObjectRef` (can be `nil`)
4639     * `time_from_last_punch`: Meant for disallowing spamming of clicks
4640       (can be `nil`).
4641     * `tool_capabilities`: capability table of used item (can be `nil`)
4642     * `dir`: unit vector of direction of punch. Always defined. Points from the
4643       puncher to the punched.
4644     * `damage`: damage that will be done to entity.
4645     * Can return `true` to prevent the default damage mechanism.
4646 * `on_death(self, killer)`
4647     * Called when the object dies.
4648     * `killer`: an `ObjectRef` (can be `nil`)
4649 * `on_rightclick(self, clicker)`
4650     * Called when `clicker` pressed the 'place/use' key while pointing
4651       to the object (not necessarily an actual rightclick)
4652     * `clicker`: an `ObjectRef` (may or may not be a player)
4653 * `on_attach_child(self, child)`
4654     * `child`: an `ObjectRef` of the child that attaches
4655 * `on_detach_child(self, child)`
4656     * `child`: an `ObjectRef` of the child that detaches
4657 * `on_detach(self, parent)`
4658     * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
4659     * This happens before the parent object is removed from the world
4660 * `get_staticdata(self)`
4661     * Should return a string that will be passed to `on_activate` when the
4662       object is instantiated the next time.
4663
4664 Collision info passed to `on_step` (`moveresult` argument):
4665
4666     {
4667         touching_ground = boolean,
4668         -- Note that touching_ground is only true if the entity was moving and
4669         -- collided with ground.
4670
4671         collides = boolean,
4672         standing_on_object = boolean,
4673
4674         collisions = {
4675             {
4676                 type = string, -- "node" or "object",
4677                 axis = string, -- "x", "y" or "z"
4678                 node_pos = vector, -- if type is "node"
4679                 object = ObjectRef, -- if type is "object"
4680                 old_velocity = vector,
4681                 new_velocity = vector,
4682             },
4683             ...
4684         }
4685         -- `collisions` does not contain data of unloaded mapblock collisions
4686         -- or when the velocity changes are negligibly small
4687     }
4688
4689
4690
4691 L-system trees
4692 ==============
4693
4694 Tree definition
4695 ---------------
4696
4697     treedef={
4698         axiom,         --string  initial tree axiom
4699         rules_a,       --string  rules set A
4700         rules_b,       --string  rules set B
4701         rules_c,       --string  rules set C
4702         rules_d,       --string  rules set D
4703         trunk,         --string  trunk node name
4704         leaves,        --string  leaves node name
4705         leaves2,       --string  secondary leaves node name
4706         leaves2_chance,--num     chance (0-100) to replace leaves with leaves2
4707         angle,         --num     angle in deg
4708         iterations,    --num     max # of iterations, usually 2 -5
4709         random_level,  --num     factor to lower number of iterations, usually 0 - 3
4710         trunk_type,    --string  single/double/crossed) type of trunk: 1 node,
4711                        --        2x2 nodes or 3x3 in cross shape
4712         thin_branches, --boolean true -> use thin (1 node) branches
4713         fruit,         --string  fruit node name
4714         fruit_chance,  --num     chance (0-100) to replace leaves with fruit node
4715         seed,          --num     random seed, if no seed is provided, the engine
4716                                  will create one.
4717     }
4718
4719 Key for special L-System symbols used in axioms
4720 -----------------------------------------------
4721
4722 * `G`: move forward one unit with the pen up
4723 * `F`: move forward one unit with the pen down drawing trunks and branches
4724 * `f`: move forward one unit with the pen down drawing leaves (100% chance)
4725 * `T`: move forward one unit with the pen down drawing trunks only
4726 * `R`: move forward one unit with the pen down placing fruit
4727 * `A`: replace with rules set A
4728 * `B`: replace with rules set B
4729 * `C`: replace with rules set C
4730 * `D`: replace with rules set D
4731 * `a`: replace with rules set A, chance 90%
4732 * `b`: replace with rules set B, chance 80%
4733 * `c`: replace with rules set C, chance 70%
4734 * `d`: replace with rules set D, chance 60%
4735 * `+`: yaw the turtle right by `angle` parameter
4736 * `-`: yaw the turtle left by `angle` parameter
4737 * `&`: pitch the turtle down by `angle` parameter
4738 * `^`: pitch the turtle up by `angle` parameter
4739 * `/`: roll the turtle to the right by `angle` parameter
4740 * `*`: roll the turtle to the left by `angle` parameter
4741 * `[`: save in stack current state info
4742 * `]`: recover from stack state info
4743
4744 Example
4745 -------
4746
4747 Spawn a small apple tree:
4748
4749     pos = {x=230,y=20,z=4}
4750     apple_tree={
4751         axiom="FFFFFAFFBF",
4752         rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
4753         rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
4754         trunk="default:tree",
4755         leaves="default:leaves",
4756         angle=30,
4757         iterations=2,
4758         random_level=0,
4759         trunk_type="single",
4760         thin_branches=true,
4761         fruit_chance=10,
4762         fruit="default:apple"
4763     }
4764     minetest.spawn_tree(pos,apple_tree)
4765
4766
4767 Privileges
4768 ==========
4769
4770 Privileges provide a means for server administrators to give certain players
4771 access to special abilities in the engine, games or mods.
4772 For example, game moderators may need to travel instantly to any place in the world,
4773 this ability is implemented in `/teleport` command which requires `teleport` privilege.
4774
4775 Registering privileges
4776 ----------------------
4777
4778 A mod can register a custom privilege using `minetest.register_privilege` function
4779 to give server administrators fine-grained access control over mod functionality.
4780
4781 For consistency and practical reasons, privileges should strictly increase the abilities of the user.
4782 Do not register custom privileges that e.g. restrict the player from certain in-game actions.
4783
4784 Checking privileges
4785 -------------------
4786
4787 A mod can call `minetest.check_player_privs` to test whether a player has privileges
4788 to perform an operation.
4789 Also, when registering a chat command with `minetest.register_chatcommand` a mod can
4790 declare privileges that the command requires using the `privs` field of the command
4791 definition.
4792
4793 Managing player privileges
4794 --------------------------
4795
4796 A mod can update player privileges using `minetest.set_player_privs` function.
4797 Players holding the `privs` privilege can see and manage privileges for all
4798 players on the server.
4799
4800 A mod can subscribe to changes in player privileges using `minetest.register_on_priv_grant`
4801 and `minetest.register_on_priv_revoke` functions.
4802
4803 Built-in privileges
4804 -------------------
4805
4806 Minetest includes a set of built-in privileges that control capabilities
4807 provided by the Minetest engine and can be used by mods:
4808
4809   * Basic privileges are normally granted to all players:
4810       * `shout`: can communicate using the in-game chat.
4811       * `interact`: can modify the world by digging, building and interacting
4812         with the nodes, entities and other players. Players without the `interact`
4813         privilege can only travel and observe the world.
4814
4815   * Advanced privileges allow bypassing certain aspects of the gameplay:
4816       * `fast`: can use "fast mode" to move with maximum speed.
4817       * `fly`: can use "fly mode" to move freely above the ground without falling.
4818       * `noclip`: can use "noclip mode" to fly through solid nodes (e.g. walls).
4819       * `teleport`: can use `/teleport` command to move to any point in the world.
4820       * `creative`: can access creative inventory.
4821       * `bring`: can teleport other players to oneself.
4822       * `give`: can use `/give` and `/giveme` commands to give any item
4823         in the game to oneself or others.
4824       * `settime`: can use `/time` command to change current in-game time.
4825       * `debug`: can enable wireframe rendering mode.
4826
4827   * Security-related privileges:
4828       * `privs`: can modify privileges of the players using `/grant[me]` and
4829         `/revoke[me]` commands.
4830       * `basic_privs`: can grant and revoke basic privileges as defined by
4831         the `basic_privs` setting.
4832       * `kick`: can kick other players from the server using `/kick` command.
4833       * `ban`: can ban other players using `/ban` command.
4834       * `password`: can use `/setpassword` and `/clearpassword` commands
4835         to manage players' passwords.
4836       * `protection_bypass`: can bypass node protection. Note that the engine does not act upon this privilege,
4837         it is only an implementation suggestion for games.
4838
4839   * Administrative privileges:
4840       * `server`: can use `/fixlight`, `/deleteblocks` and `/deleteobjects`
4841         commands. Can clear inventory of other players using `/clearinv` command.
4842       * `rollback`: can use `/rollback_check` and `/rollback` commands.
4843
4844 Related settings
4845 ----------------
4846
4847 Minetest includes the following settings to control behavior of privileges:
4848
4849    * `default_privs`: defines privileges granted to new players.
4850    * `basic_privs`: defines privileges that can be granted/revoked by players having
4851     the `basic_privs` privilege. This can be used, for example, to give
4852     limited moderation powers to selected users.
4853
4854 'minetest' namespace reference
4855 ==============================
4856
4857 Utilities
4858 ---------
4859
4860 * `minetest.get_current_modname()`: returns the currently loading mod's name,
4861   when loading a mod.
4862 * `minetest.get_modpath(modname)`: returns the directory path for a mod,
4863   e.g. `"/home/user/.minetest/usermods/modname"`.
4864     * Returns nil if the mod is not enabled or does not exist (not installed).
4865     * Works regardless of whether the mod has been loaded yet.
4866     * Useful for loading additional `.lua` modules or static data from a mod,
4867   or checking if a mod is enabled.
4868 * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
4869     * Does not include disabled mods, even if they are installed.
4870 * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
4871     * Useful for storing custom data
4872 * `minetest.is_singleplayer()`
4873 * `minetest.features`: Table containing API feature flags
4874
4875       {
4876           glasslike_framed = true,  -- 0.4.7
4877           nodebox_as_selectionbox = true,  -- 0.4.7
4878           get_all_craft_recipes_works = true,  -- 0.4.7
4879           -- The transparency channel of textures can optionally be used on
4880           -- nodes (0.4.7)
4881           use_texture_alpha = true,
4882           -- Tree and grass ABMs are no longer done from C++ (0.4.8)
4883           no_legacy_abms = true,
4884           -- Texture grouping is possible using parentheses (0.4.11)
4885           texture_names_parens = true,
4886           -- Unique Area ID for AreaStore:insert_area (0.4.14)
4887           area_store_custom_ids = true,
4888           -- add_entity supports passing initial staticdata to on_activate
4889           -- (0.4.16)
4890           add_entity_with_staticdata = true,
4891           -- Chat messages are no longer predicted (0.4.16)
4892           no_chat_message_prediction = true,
4893           -- The transparency channel of textures can optionally be used on
4894           -- objects (ie: players and lua entities) (5.0.0)
4895           object_use_texture_alpha = true,
4896           -- Object selectionbox is settable independently from collisionbox
4897           -- (5.0.0)
4898           object_independent_selectionbox = true,
4899           -- Specifies whether binary data can be uploaded or downloaded using
4900           -- the HTTP API (5.1.0)
4901           httpfetch_binary_data = true,
4902           -- Whether formspec_version[<version>] may be used (5.1.0)
4903           formspec_version_element = true,
4904           -- Whether AreaStore's IDs are kept on save/load (5.1.0)
4905           area_store_persistent_ids = true,
4906           -- Whether minetest.find_path is functional (5.2.0)
4907           pathfinder_works = true,
4908           -- Whether Collision info is available to an objects' on_step (5.3.0)
4909           object_step_has_moveresult = true,
4910           -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
4911           direct_velocity_on_players = true,
4912           -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
4913           use_texture_alpha_string_modes = true,
4914           -- degrotate param2 rotates in units of 1.5° instead of 2°
4915           -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
4916           degrotate_240_steps = true,
4917           -- ABM supports min_y and max_y fields in definition (5.5.0)
4918           abm_min_max_y = true,
4919           -- dynamic_add_media supports passing a table with options (5.5.0)
4920           dynamic_add_media_table = true,
4921           -- particlespawners support texpools and animation of properties,
4922           -- particle textures support smooth fade and scale animations, and
4923           -- sprite-sheet particle animations can by synced to the lifetime
4924           -- of individual particles (5.6.0)
4925           particlespawner_tweenable = true,
4926           -- allows get_sky to return a table instead of separate values (5.6.0)
4927           get_sky_as_table = true,
4928           -- VoxelManip:get_light_data accepts an optional buffer argument (5.7.0)
4929           get_light_data_buffer = true,
4930           -- When using a mod storage backend that is not "files" or "dummy",
4931           -- the amount of data in mod storage is not constrained by
4932           -- the amount of RAM available. (5.7.0)
4933           mod_storage_on_disk = true,
4934           -- "zstd" method for compress/decompress (5.7.0)
4935           compress_zstd = true,
4936       }
4937
4938 * `minetest.has_feature(arg)`: returns `boolean, missing_features`
4939     * `arg`: string or table in format `{foo=true, bar=true}`
4940     * `missing_features`: `{foo=true, bar=true}`
4941 * `minetest.get_player_information(player_name)`: Table containing information
4942   about a player. Example return value:
4943
4944       {
4945           address = "127.0.0.1",     -- IP address of client
4946           ip_version = 4,            -- IPv4 / IPv6
4947           connection_uptime = 200,   -- seconds since client connected
4948           protocol_version = 32,     -- protocol version used by client
4949           formspec_version = 2,      -- supported formspec version
4950           lang_code = "fr"           -- Language code used for translation
4951           -- the following keys can be missing if no stats have been collected yet
4952           min_rtt = 0.01,            -- minimum round trip time
4953           max_rtt = 0.2,             -- maximum round trip time
4954           avg_rtt = 0.02,            -- average round trip time
4955           min_jitter = 0.01,         -- minimum packet time jitter
4956           max_jitter = 0.5,          -- maximum packet time jitter
4957           avg_jitter = 0.03,         -- average packet time jitter
4958           -- the following information is available in a debug build only!!!
4959           -- DO NOT USE IN MODS
4960           --ser_vers = 26,             -- serialization version used by client
4961           --major = 0,                 -- major version number
4962           --minor = 4,                 -- minor version number
4963           --patch = 10,                -- patch version number
4964           --vers_string = "0.4.9-git", -- full version string
4965           --state = "Active"           -- current client state
4966       }
4967
4968 * `minetest.mkdir(path)`: returns success.
4969     * Creates a directory specified by `path`, creating parent directories
4970       if they don't exist.
4971 * `minetest.rmdir(path, recursive)`: returns success.
4972     * Removes a directory specified by `path`.
4973     * If `recursive` is set to `true`, the directory is recursively removed.
4974       Otherwise, the directory will only be removed if it is empty.
4975     * Returns true on success, false on failure.
4976 * `minetest.cpdir(source, destination)`: returns success.
4977     * Copies a directory specified by `path` to `destination`
4978     * Any files in `destination` will be overwritten if they already exist.
4979     * Returns true on success, false on failure.
4980 * `minetest.mvdir(source, destination)`: returns success.
4981     * Moves a directory specified by `path` to `destination`.
4982     * If the `destination` is a non-empty directory, then the move will fail.
4983     * Returns true on success, false on failure.
4984 * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
4985     * is_dir is one of:
4986         * nil: return all entries,
4987         * true: return only subdirectory names, or
4988         * false: return only file names.
4989 * `minetest.safe_file_write(path, content)`: returns boolean indicating success
4990     * Replaces contents of file at path with new contents in a safe (atomic)
4991       way. Use this instead of below code when writing e.g. database files:
4992       `local f = io.open(path, "wb"); f:write(content); f:close()`
4993 * `minetest.get_version()`: returns a table containing components of the
4994    engine version.  Components:
4995     * `project`: Name of the project, eg, "Minetest"
4996     * `string`: Simple version, eg, "1.2.3-dev"
4997     * `hash`: Full git version (only set if available),
4998       eg, "1.2.3-dev-01234567-dirty".
4999     * `is_dev`: Boolean value indicating whether it's a development build
5000   Use this for informational purposes only. The information in the returned
5001   table does not represent the capabilities of the engine, nor is it
5002   reliable or verifiable. Compatible forks will have a different name and
5003   version entirely. To check for the presence of engine features, test
5004   whether the functions exported by the wanted features exist. For example:
5005   `if minetest.check_for_falling then ... end`.
5006 * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
5007     * `data`: string of data to hash
5008     * `raw`: return raw bytes instead of hex digits, default: false
5009 * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
5010   ColorString. If the ColorSpec is invalid, returns `nil`.
5011     * `colorspec`: The ColorSpec to convert
5012 * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
5013   string of four bytes in an RGBA layout, returned as a string.
5014   * `colorspec`: The ColorSpec to convert
5015 * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
5016   image and return it in string form.
5017     * `width`: Width of the image
5018     * `height`: Height of the image
5019     * `data`: Image data, one of:
5020         * array table of ColorSpec, length must be width*height
5021         * string with raw RGBA pixels, length must be width*height*4
5022     * `compression`: Optional zlib compression level, number in range 0 to 9.
5023   The data is one-dimensional, starting in the upper left corner of the image
5024   and laid out in scanlines going from left to right, then top to bottom.
5025   Please note that it's not safe to use string.char to generate raw data,
5026   use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
5027   The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
5028   You may use this to procedurally generate textures during server init.
5029
5030 Logging
5031 -------
5032
5033 * `minetest.debug(...)`
5034     * Equivalent to `minetest.log(table.concat({...}, "\t"))`
5035 * `minetest.log([level,] text)`
5036     * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
5037       `"info"`, or `"verbose"`.  Default is `"none"`.
5038
5039 Registration functions
5040 ----------------------
5041
5042 Call these functions only at load time!
5043
5044 ### Environment
5045
5046 * `minetest.register_node(name, node definition)`
5047 * `minetest.register_craftitem(name, item definition)`
5048 * `minetest.register_tool(name, item definition)`
5049 * `minetest.override_item(name, redefinition)`
5050     * Overrides fields of an item registered with register_node/tool/craftitem.
5051     * Note: Item must already be defined, (opt)depend on the mod defining it.
5052     * Example: `minetest.override_item("default:mese",
5053       {light_source=minetest.LIGHT_MAX})`
5054 * `minetest.unregister_item(name)`
5055     * Unregisters the item from the engine, and deletes the entry with key
5056       `name` from `minetest.registered_items` and from the associated item table
5057       according to its nature: `minetest.registered_nodes`, etc.
5058 * `minetest.register_entity(name, entity definition)`
5059 * `minetest.register_abm(abm definition)`
5060 * `minetest.register_lbm(lbm definition)`
5061 * `minetest.register_alias(alias, original_name)`
5062     * Also use this to set the 'mapgen aliases' needed in a game for the core
5063       mapgens. See [Mapgen aliases] section above.
5064 * `minetest.register_alias_force(alias, original_name)`
5065 * `minetest.register_ore(ore definition)`
5066     * Returns an integer object handle uniquely identifying the registered
5067       ore on success.
5068     * The order of ore registrations determines the order of ore generation.
5069 * `minetest.register_biome(biome definition)`
5070     * Returns an integer object handle uniquely identifying the registered
5071       biome on success. To get the biome ID, use `minetest.get_biome_id`.
5072 * `minetest.unregister_biome(name)`
5073     * Unregisters the biome from the engine, and deletes the entry with key
5074       `name` from `minetest.registered_biomes`.
5075     * Warning: This alters the biome to biome ID correspondences, so any
5076       decorations or ores using the 'biomes' field must afterwards be cleared
5077       and re-registered.
5078 * `minetest.register_decoration(decoration definition)`
5079     * Returns an integer object handle uniquely identifying the registered
5080       decoration on success. To get the decoration ID, use
5081       `minetest.get_decoration_id`.
5082     * The order of decoration registrations determines the order of decoration
5083       generation.
5084 * `minetest.register_schematic(schematic definition)`
5085     * Returns an integer object handle uniquely identifying the registered
5086       schematic on success.
5087     * If the schematic is loaded from a file, the `name` field is set to the
5088       filename.
5089     * If the function is called when loading the mod, and `name` is a relative
5090       path, then the current mod path will be prepended to the schematic
5091       filename.
5092 * `minetest.clear_registered_biomes()`
5093     * Clears all biomes currently registered.
5094     * Warning: Clearing and re-registering biomes alters the biome to biome ID
5095       correspondences, so any decorations or ores using the 'biomes' field must
5096       afterwards be cleared and re-registered.
5097 * `minetest.clear_registered_decorations()`
5098     * Clears all decorations currently registered.
5099 * `minetest.clear_registered_ores()`
5100     * Clears all ores currently registered.
5101 * `minetest.clear_registered_schematics()`
5102     * Clears all schematics currently registered.
5103
5104 ### Gameplay
5105
5106 * `minetest.register_craft(recipe)`
5107     * Check recipe table syntax for different types below.
5108 * `minetest.clear_craft(recipe)`
5109     * Will erase existing craft based either on output item or on input recipe.
5110     * Specify either output or input only. If you specify both, input will be
5111       ignored. For input use the same recipe table syntax as for
5112       `minetest.register_craft(recipe)`. For output specify only the item,
5113       without a quantity.
5114     * Returns false if no erase candidate could be found, otherwise returns true.
5115     * **Warning**! The type field ("shaped", "cooking" or any other) will be
5116       ignored if the recipe contains output. Erasing is then done independently
5117       from the crafting method.
5118 * `minetest.register_chatcommand(cmd, chatcommand definition)`
5119 * `minetest.override_chatcommand(name, redefinition)`
5120     * Overrides fields of a chatcommand registered with `register_chatcommand`.
5121 * `minetest.unregister_chatcommand(name)`
5122     * Unregisters a chatcommands registered with `register_chatcommand`.
5123 * `minetest.register_privilege(name, definition)`
5124     * `definition` can be a description or a definition table (see [Privilege
5125       definition]).
5126     * If it is a description, the priv will be granted to singleplayer and admin
5127       by default.
5128     * To allow players with `basic_privs` to grant, see the `basic_privs`
5129       minetest.conf setting.
5130 * `minetest.register_authentication_handler(authentication handler definition)`
5131     * Registers an auth handler that overrides the builtin one.
5132     * This function can be called by a single mod once only.
5133
5134 Global callback registration functions
5135 --------------------------------------
5136
5137 Call these functions only at load time!
5138
5139 * `minetest.register_globalstep(function(dtime))`
5140     * Called every server step, usually interval of 0.1s
5141 * `minetest.register_on_mods_loaded(function())`
5142     * Called after mods have finished loading and before the media is cached or the
5143       aliases handled.
5144 * `minetest.register_on_shutdown(function())`
5145     * Called before server shutdown
5146     * **Warning**: If the server terminates abnormally (i.e. crashes), the
5147       registered callbacks **will likely not be run**. Data should be saved at
5148       semi-frequent intervals as well as on server shutdown.
5149 * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
5150     * Called when a node has been placed
5151     * If return `true` no item is taken from `itemstack`
5152     * `placer` may be any valid ObjectRef or nil.
5153     * **Not recommended**; use `on_construct` or `after_place_node` in node
5154       definition whenever possible.
5155 * `minetest.register_on_dignode(function(pos, oldnode, digger))`
5156     * Called when a node has been dug.
5157     * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
5158       definition whenever possible.
5159 * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
5160     * Called when a node is punched
5161 * `minetest.register_on_generated(function(minp, maxp, blockseed))`
5162     * Called after generating a piece of world. Modifying nodes inside the area
5163       is a bit faster than usual.
5164 * `minetest.register_on_newplayer(function(ObjectRef))`
5165     * Called when a new player enters the world for the first time
5166 * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
5167     * Called when a player is punched
5168     * Note: This callback is invoked even if the punched player is dead.
5169     * `player`: ObjectRef - Player that was punched
5170     * `hitter`: ObjectRef - Player that hit
5171     * `time_from_last_punch`: Meant for disallowing spamming of clicks
5172       (can be nil).
5173     * `tool_capabilities`: Capability table of used item (can be nil)
5174     * `dir`: Unit vector of direction of punch. Always defined. Points from
5175       the puncher to the punched.
5176     * `damage`: Number that represents the damage calculated by the engine
5177     * should return `true` to prevent the default damage mechanism
5178 * `minetest.register_on_rightclickplayer(function(player, clicker))`
5179     * Called when the 'place/use' key was used while pointing a player
5180       (not necessarily an actual rightclick)
5181     * `player`: ObjectRef - Player that is acted upon
5182     * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
5183 * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
5184     * Called when the player gets damaged or healed
5185     * `player`: ObjectRef of the player
5186     * `hp_change`: the amount of change. Negative when it is damage.
5187     * `reason`: a PlayerHPChangeReason table.
5188         * The `type` field will have one of the following values:
5189             * `set_hp`: A mod or the engine called `set_hp` without
5190                         giving a type - use this for custom damage types.
5191             * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
5192             * `fall`
5193             * `node_damage`: `damage_per_second` from a neighboring node.
5194                              `reason.node` will hold the node name or nil.
5195             * `drown`
5196             * `respawn`
5197         * Any of the above types may have additional fields from mods.
5198         * `reason.from` will be `mod` or `engine`.
5199     * `modifier`: when true, the function should return the actual `hp_change`.
5200        Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
5201        Modifiers can return true as a second argument to stop the execution of further functions.
5202        Non-modifiers receive the final HP change calculated by the modifiers.
5203 * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
5204     * Called when a player dies
5205     * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
5206 * `minetest.register_on_respawnplayer(function(ObjectRef))`
5207     * Called when player is to be respawned
5208     * Called _before_ repositioning of player occurs
5209     * return true in func to disable regular player placement
5210 * `minetest.register_on_prejoinplayer(function(name, ip))`
5211     * Called when a client connects to the server, prior to authentication
5212     * If it returns a string, the client is disconnected with that string as
5213       reason.
5214 * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
5215     * Called when a player joins the game
5216     * `last_login`: The timestamp of the previous login, or nil if player is new
5217 * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
5218     * Called when a player leaves the game
5219     * `timed_out`: True for timeout, false for other reasons.
5220 * `minetest.register_on_authplayer(function(name, ip, is_success))`
5221     * Called when a client attempts to log into an account.
5222     * `name`: The name of the account being authenticated.
5223     * `ip`: The IP address of the client
5224     * `is_success`: Whether the client was successfully authenticated
5225     * For newly registered accounts, `is_success` will always be true
5226 * `minetest.register_on_auth_fail(function(name, ip))`
5227     * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
5228 * `minetest.register_on_cheat(function(ObjectRef, cheat))`
5229     * Called when a player cheats
5230     * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
5231         * `moved_too_fast`
5232         * `interacted_too_far`
5233         * `interacted_with_self`
5234         * `interacted_while_dead`
5235         * `finished_unknown_dig`
5236         * `dug_unbreakable`
5237         * `dug_too_fast`
5238 * `minetest.register_on_chat_message(function(name, message))`
5239     * Called always when a player says something
5240     * Return `true` to mark the message as handled, which means that it will
5241       not be sent to other players.
5242 * `minetest.register_on_chatcommand(function(name, command, params))`
5243     * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
5244       is checked to see if the command exists, but after the input is parsed.
5245     * Return `true` to mark the command as handled, which means that the default
5246       handlers will be prevented.
5247 * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
5248     * Called when the server received input from `player` in a formspec with
5249       the given `formname`. Specifically, this is called on any of the
5250       following events:
5251           * a button was pressed,
5252           * Enter was pressed while the focus was on a text field
5253           * a checkbox was toggled,
5254           * something was selected in a dropdown list,
5255           * a different tab was selected,
5256           * selection was changed in a textlist or table,
5257           * an entry was double-clicked in a textlist or table,
5258           * a scrollbar was moved, or
5259           * the form was actively closed by the player.
5260     * Fields are sent for formspec elements which define a field. `fields`
5261       is a table containing each formspecs element value (as string), with
5262       the `name` parameter as index for each. The value depends on the
5263       formspec element type:
5264         * `animated_image`: Returns the index of the current frame.
5265         * `button` and variants: If pressed, contains the user-facing button
5266           text as value. If not pressed, is `nil`
5267         * `field`, `textarea` and variants: Text in the field
5268         * `dropdown`: Either the index or value, depending on the `index event`
5269           dropdown argument.
5270         * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
5271         * `checkbox`: `"true"` if checked, `"false"` if unchecked
5272         * `textlist`: See `minetest.explode_textlist_event`
5273         * `table`: See `minetest.explode_table_event`
5274         * `scrollbar`: See `minetest.explode_scrollbar_event`
5275         * Special case: `["quit"]="true"` is sent when the user actively
5276           closed the form by mouse click, keypress or through a button_exit[]
5277           element.
5278         * Special case: `["key_enter"]="true"` is sent when the user pressed
5279           the Enter key and the focus was either nowhere (causing the formspec
5280           to be closed) or on a button. If the focus was on a text field,
5281           additionally, the index `key_enter_field` contains the name of the
5282           text field. See also: `field_close_on_enter`.
5283     * Newest functions are called first
5284     * If function returns `true`, remaining functions are not called
5285 * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
5286     * Called when `player` crafts something
5287     * `itemstack` is the output
5288     * `old_craft_grid` contains the recipe (Note: the one in the inventory is
5289       cleared).
5290     * `craft_inv` is the inventory with the crafting grid
5291     * Return either an `ItemStack`, to replace the output, or `nil`, to not
5292       modify it.
5293 * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
5294     * The same as before, except that it is called before the player crafts, to
5295       make craft prediction, and it should not change anything.
5296 * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
5297     * Determines how much of a stack may be taken, put or moved to a
5298       player inventory.
5299     * `player` (type `ObjectRef`) is the player who modified the inventory
5300       `inventory` (type `InvRef`).
5301     * List of possible `action` (string) values and their
5302       `inventory_info` (table) contents:
5303         * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
5304         * `put`:  `{listname=string, index=number, stack=ItemStack}`
5305         * `take`: Same as `put`
5306     * Return a numeric value to limit the amount of items to be taken, put or
5307       moved. A value of `-1` for `take` will make the source stack infinite.
5308 * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
5309     * Called after a take, put or move event from/to/in a player inventory
5310     * Function arguments: see `minetest.register_allow_player_inventory_action`
5311     * Does not accept or handle any return value.
5312 * `minetest.register_on_protection_violation(function(pos, name))`
5313     * Called by `builtin` and mods when a player violates protection at a
5314       position (eg, digs a node or punches a protected entity).
5315     * The registered functions can be called using
5316       `minetest.record_protection_violation`.
5317     * The provided function should check that the position is protected by the
5318       mod calling this function before it prints a message, if it does, to
5319       allow for multiple protection mods.
5320 * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
5321     * Called when an item is eaten, by `minetest.item_eat`
5322     * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
5323 * `minetest.register_on_item_pickup(function(itemstack, picker, pointed_thing, time_from_last_punch,  ...))`
5324     * Called by `minetest.item_pickup` before an item is picked up.
5325     * Function is added to `minetest.registered_on_item_pickups`.
5326     * Oldest functions are called first.
5327     * Parameters are the same as in the `on_pickup` callback.
5328     * Return an itemstack to cancel the default item pick-up response (i.e.: adding
5329       the item into inventory).
5330 * `minetest.register_on_priv_grant(function(name, granter, priv))`
5331     * Called when `granter` grants the priv `priv` to `name`.
5332     * Note that the callback will be called twice if it's done by a player,
5333       once with granter being the player name, and again with granter being nil.
5334 * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
5335     * Called when `revoker` revokes the priv `priv` from `name`.
5336     * Note that the callback will be called twice if it's done by a player,
5337       once with revoker being the player name, and again with revoker being nil.
5338 * `minetest.register_can_bypass_userlimit(function(name, ip))`
5339     * Called when `name` user connects with `ip`.
5340     * Return `true` to by pass the player limit
5341 * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
5342     * Called when an incoming mod channel message is received
5343     * You should have joined some channels to receive events.
5344     * If message comes from a server mod, `sender` field is an empty string.
5345 * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
5346     * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
5347       engine's liquid transformation process.
5348     * `pos_list` is an array of all modified positions.
5349     * `node_list` is an array of the old node that was previously at the position
5350       with the corresponding index in pos_list.
5351
5352 Setting-related
5353 ---------------
5354
5355 * `minetest.settings`: Settings object containing all of the settings from the
5356   main config file (`minetest.conf`).
5357 * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
5358   parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
5359
5360 Authentication
5361 --------------
5362
5363 * `minetest.string_to_privs(str[, delim])`:
5364     * Converts string representation of privs into table form
5365     * `delim`: String separating the privs. Defaults to `","`.
5366     * Returns `{ priv1 = true, ... }`
5367 * `minetest.privs_to_string(privs[, delim])`:
5368     * Returns the string representation of `privs`
5369     * `delim`: String to delimit privs. Defaults to `","`.
5370 * `minetest.get_player_privs(name) -> {priv1=true,...}`
5371 * `minetest.check_player_privs(player_or_name, ...)`:
5372   returns `bool, missing_privs`
5373     * A quickhand for checking privileges.
5374     * `player_or_name`: Either a Player object or the name of a player.
5375     * `...` is either a list of strings, e.g. `"priva", "privb"` or
5376       a table, e.g. `{ priva = true, privb = true }`.
5377
5378 * `minetest.check_password_entry(name, entry, password)`
5379     * Returns true if the "password entry" for a player with name matches given
5380       password, false otherwise.
5381     * The "password entry" is the password representation generated by the
5382       engine as returned as part of a `get_auth()` call on the auth handler.
5383     * Only use this function for making it possible to log in via password from
5384       external protocols such as IRC, other uses are frowned upon.
5385 * `minetest.get_password_hash(name, raw_password)`
5386     * Convert a name-password pair to a password hash that Minetest can use.
5387     * The returned value alone is not a good basis for password checks based
5388       on comparing the password hash in the database with the password hash
5389       from the function, with an externally provided password, as the hash
5390       in the db might use the new SRP verifier format.
5391     * For this purpose, use `minetest.check_password_entry` instead.
5392 * `minetest.get_player_ip(name)`: returns an IP address string for the player
5393   `name`.
5394     * The player needs to be online for this to be successful.
5395
5396 * `minetest.get_auth_handler()`: Return the currently active auth handler
5397     * See the [Authentication handler definition]
5398     * Use this to e.g. get the authentication data for a player:
5399       `local auth_data = minetest.get_auth_handler().get_auth(playername)`
5400 * `minetest.notify_authentication_modified(name)`
5401     * Must be called by the authentication handler for privilege changes.
5402     * `name`: string; if omitted, all auth data should be considered modified
5403 * `minetest.set_player_password(name, password_hash)`: Set password hash of
5404   player `name`.
5405 * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
5406   `name`.
5407 * `minetest.auth_reload()`
5408     * See `reload()` in authentication handler definition
5409
5410 `minetest.set_player_password`, `minetest.set_player_privs`,
5411 `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
5412 handler.
5413
5414 Chat
5415 ----
5416
5417 * `minetest.chat_send_all(text)`
5418 * `minetest.chat_send_player(name, text)`
5419 * `minetest.format_chat_message(name, message)`
5420     * Used by the server to format a chat message, based on the setting `chat_message_format`.
5421       Refer to the documentation of the setting for a list of valid placeholders.
5422     * Takes player name and message, and returns the formatted string to be sent to players.
5423     * Can be redefined by mods if required, for things like colored names or messages.
5424     * **Only** the first occurrence of each placeholder will be replaced.
5425
5426 Environment access
5427 ------------------
5428
5429 * `minetest.set_node(pos, node)`
5430 * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
5431     * Set node at position `pos`
5432     * `node`: table `{name=string, param1=number, param2=number}`
5433     * If param1 or param2 is omitted, it's set to `0`.
5434     * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
5435 * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
5436     * Set node on all positions set in the first argument.
5437     * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
5438     * For node specification or position syntax see `minetest.set_node` call
5439     * Faster than set_node due to single call, but still considerably slower
5440       than Lua Voxel Manipulators (LVM) for large numbers of nodes.
5441       Unlike LVMs, this will call node callbacks. It also allows setting nodes
5442       in spread out positions which would cause LVMs to waste memory.
5443       For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
5444       times faster.
5445 * `minetest.swap_node(pos, node)`
5446     * Set node at position, but don't remove metadata
5447 * `minetest.remove_node(pos)`
5448     * By default it does the same as `minetest.set_node(pos, {name="air"})`
5449 * `minetest.get_node(pos)`
5450     * Returns the node at the given position as table in the format
5451       `{name="node_name", param1=0, param2=0}`,
5452       returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
5453 * `minetest.get_node_or_nil(pos)`
5454     * Same as `get_node` but returns `nil` for unloaded areas.
5455 * `minetest.get_node_light(pos, timeofday)`
5456     * Gets the light value at the given position. Note that the light value
5457       "inside" the node at the given position is returned, so you usually want
5458       to get the light value of a neighbor.
5459     * `pos`: The position where to measure the light.
5460     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5461     * Returns a number between `0` and `15` or `nil`
5462     * `nil` is returned e.g. when the map isn't loaded at `pos`
5463 * `minetest.get_natural_light(pos[, timeofday])`
5464     * Figures out the sunlight (or moonlight) value at pos at the given time of
5465       day.
5466     * `pos`: The position of the node
5467     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5468     * Returns a number between `0` and `15` or `nil`
5469     * This function tests 203 nodes in the worst case, which happens very
5470       unlikely
5471 * `minetest.get_artificial_light(param1)`
5472     * Calculates the artificial light (light from e.g. torches) value from the
5473       `param1` value.
5474     * `param1`: The param1 value of a `paramtype = "light"` node.
5475     * Returns a number between `0` and `15`
5476     * Currently it's the same as `math.floor(param1 / 16)`, except that it
5477       ensures compatibility.
5478 * `minetest.place_node(pos, node)`
5479     * Place node with the same effects that a player would cause
5480 * `minetest.dig_node(pos)`
5481     * Dig node with the same effects that a player would cause
5482     * Returns `true` if successful, `false` on failure (e.g. protected location)
5483 * `minetest.punch_node(pos)`
5484     * Punch node with the same effects that a player would cause
5485 * `minetest.spawn_falling_node(pos)`
5486     * Change node into falling node
5487     * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
5488
5489 * `minetest.find_nodes_with_meta(pos1, pos2)`
5490     * Get a table of positions of nodes that have metadata within a region
5491       {pos1, pos2}.
5492 * `minetest.get_meta(pos)`
5493     * Get a `NodeMetaRef` at that position
5494 * `minetest.get_node_timer(pos)`
5495     * Get `NodeTimerRef`
5496
5497 * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
5498   position.
5499     * Returns `ObjectRef`, or `nil` if failed
5500 * `minetest.add_item(pos, item)`: Spawn item
5501     * Returns `ObjectRef`, or `nil` if failed
5502 * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
5503 * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
5504   ObjectRefs.
5505     * `radius`: using a Euclidean metric
5506 * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
5507   ObjectRefs.
5508      * `pos1` and `pos2` are the min and max positions of the area to search.
5509 * `minetest.set_timeofday(val)`
5510     * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
5511 * `minetest.get_timeofday()`
5512 * `minetest.get_gametime()`: returns the time, in seconds, since the world was
5513   created.
5514 * `minetest.get_day_count()`: returns number days elapsed since world was
5515   created.
5516     * accounts for time changes.
5517 * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
5518   pos or `nil`.
5519     * `radius`: using a maximum metric
5520     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5521     * `search_center` is an optional boolean (default: `false`)
5522       If true `pos` is also checked for the nodes
5523 * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
5524     * `pos1` and `pos2` are the min and max positions of the area to search.
5525     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5526     * If `grouped` is true the return value is a table indexed by node name
5527       which contains lists of positions.
5528     * If `grouped` is false or absent the return values are as follows:
5529       first value: Table with all node positions
5530       second value: Table with the count of each node with the node name
5531       as index
5532     * Area volume is limited to 4,096,000 nodes
5533 * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
5534   list of positions.
5535     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5536     * Return value: Table with all node positions with a node air above
5537     * Area volume is limited to 4,096,000 nodes
5538 * `minetest.get_perlin(noiseparams)`
5539     * Return world-specific perlin noise.
5540     * The actual seed used is the noiseparams seed plus the world seed.
5541 * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
5542     * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
5543     * Return world-specific perlin noise.
5544 * `minetest.get_voxel_manip([pos1, pos2])`
5545     * Return voxel manipulator object.
5546     * Loads the manipulator from the map if positions are passed.
5547 * `minetest.set_gen_notify(flags, {deco_ids})`
5548     * Set the types of on-generate notifications that should be collected.
5549     * `flags` is a flag field with the available flags:
5550         * dungeon
5551         * temple
5552         * cave_begin
5553         * cave_end
5554         * large_cave_begin
5555         * large_cave_end
5556         * decoration
5557     * The second parameter is a list of IDs of decorations which notification
5558       is requested for.
5559 * `minetest.get_gen_notify()`
5560     * Returns a flagstring and a table with the `deco_id`s.
5561 * `minetest.get_decoration_id(decoration_name)`
5562     * Returns the decoration ID number for the provided decoration name string,
5563       or `nil` on failure.
5564 * `minetest.get_mapgen_object(objectname)`
5565     * Return requested mapgen object if available (see [Mapgen objects])
5566 * `minetest.get_heat(pos)`
5567     * Returns the heat at the position, or `nil` on failure.
5568 * `minetest.get_humidity(pos)`
5569     * Returns the humidity at the position, or `nil` on failure.
5570 * `minetest.get_biome_data(pos)`
5571     * Returns a table containing:
5572         * `biome` the biome id of the biome at that position
5573         * `heat` the heat at the position
5574         * `humidity` the humidity at the position
5575     * Or returns `nil` on failure.
5576 * `minetest.get_biome_id(biome_name)`
5577     * Returns the biome id, as used in the biomemap Mapgen object and returned
5578       by `minetest.get_biome_data(pos)`, for a given biome_name string.
5579 * `minetest.get_biome_name(biome_id)`
5580     * Returns the biome name string for the provided biome id, or `nil` on
5581       failure.
5582     * If no biomes have been registered, such as in mgv6, returns `default`.
5583 * `minetest.get_mapgen_params()`
5584     * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
5585     * Returns a table containing:
5586         * `mgname`
5587         * `seed`
5588         * `chunksize`
5589         * `water_level`
5590         * `flags`
5591 * `minetest.set_mapgen_params(MapgenParams)`
5592     * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
5593       instead.
5594     * Set map generation parameters.
5595     * Function cannot be called after the registration period.
5596     * Takes a table as an argument with the fields:
5597         * `mgname`
5598         * `seed`
5599         * `chunksize`
5600         * `water_level`
5601         * `flags`
5602     * Leave field unset to leave that parameter unchanged.
5603     * `flags` contains a comma-delimited string of flags to set, or if the
5604       prefix `"no"` is attached, clears instead.
5605     * `flags` is in the same format and has the same options as `mg_flags` in
5606       `minetest.conf`.
5607 * `minetest.get_mapgen_setting(name)`
5608     * Gets the *active* mapgen setting (or nil if none exists) in string
5609       format with the following order of precedence:
5610         1) Settings loaded from map_meta.txt or overrides set during mod
5611            execution.
5612         2) Settings set by mods without a metafile override
5613         3) Settings explicitly set in the user config file, minetest.conf
5614         4) Settings set as the user config default
5615 * `minetest.get_mapgen_setting_noiseparams(name)`
5616     * Same as above, but returns the value as a NoiseParams table if the
5617       setting `name` exists and is a valid NoiseParams.
5618 * `minetest.set_mapgen_setting(name, value, [override_meta])`
5619     * Sets a mapgen param to `value`, and will take effect if the corresponding
5620       mapgen setting is not already present in map_meta.txt.
5621     * `override_meta` is an optional boolean (default: `false`). If this is set
5622       to true, the setting will become the active setting regardless of the map
5623       metafile contents.
5624     * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
5625 * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
5626     * Same as above, except value is a NoiseParams table.
5627 * `minetest.set_noiseparams(name, noiseparams, set_default)`
5628     * Sets the noiseparams setting of `name` to the noiseparams table specified
5629       in `noiseparams`.
5630     * `set_default` is an optional boolean (default: `true`) that specifies
5631       whether the setting should be applied to the default config or current
5632       active config.
5633 * `minetest.get_noiseparams(name)`
5634     * Returns a table of the noiseparams for name.
5635 * `minetest.generate_ores(vm, pos1, pos2)`
5636     * Generate all registered ores within the VoxelManip `vm` and in the area
5637       from `pos1` to `pos2`.
5638     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5639 * `minetest.generate_decorations(vm, pos1, pos2)`
5640     * Generate all registered decorations within the VoxelManip `vm` and in the
5641       area from `pos1` to `pos2`.
5642     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5643 * `minetest.clear_objects([options])`
5644     * Clear all objects in the environment
5645     * Takes an optional table as an argument with the field `mode`.
5646         * mode = `"full"`: Load and go through every mapblock, clearing
5647                             objects (default).
5648         * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
5649                             clear objects in unloaded mapblocks only when the
5650                             mapblocks are next activated.
5651 * `minetest.load_area(pos1[, pos2])`
5652     * Load the mapblocks containing the area from `pos1` to `pos2`.
5653       `pos2` defaults to `pos1` if not specified.
5654     * This function does not trigger map generation.
5655 * `minetest.emerge_area(pos1, pos2, [callback], [param])`
5656     * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
5657       asynchronously fetched from memory, loaded from disk, or if inexistent,
5658       generates them.
5659     * If `callback` is a valid Lua function, this will be called for each block
5660       emerged.
5661     * The function signature of callback is:
5662       `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
5663         * `blockpos` is the *block* coordinates of the block that had been
5664           emerged.
5665         * `action` could be one of the following constant values:
5666             * `minetest.EMERGE_CANCELLED`
5667             * `minetest.EMERGE_ERRORED`
5668             * `minetest.EMERGE_FROM_MEMORY`
5669             * `minetest.EMERGE_FROM_DISK`
5670             * `minetest.EMERGE_GENERATED`
5671         * `calls_remaining` is the number of callbacks to be expected after
5672           this one.
5673         * `param` is the user-defined parameter passed to emerge_area (or
5674           nil if the parameter was absent).
5675 * `minetest.delete_area(pos1, pos2)`
5676     * delete all mapblocks in the area from pos1 to pos2, inclusive
5677 * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
5678     * Checks if there is anything other than air between pos1 and pos2.
5679     * Returns false if something is blocking the sight.
5680     * Returns the position of the blocking node when `false`
5681     * `pos1`: First position
5682     * `pos2`: Second position
5683 * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
5684     * Creates a `Raycast` object.
5685     * `pos1`: start of the ray
5686     * `pos2`: end of the ray
5687     * `objects`: if false, only nodes will be returned. Default is `true`.
5688     * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
5689                  returned. Default is `false`.
5690 * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
5691     * returns table containing path that can be walked on
5692     * returns a table of 3D points representing a path from `pos1` to `pos2` or
5693       `nil` on failure.
5694     * Reasons for failure:
5695         * No path exists at all
5696         * No path exists within `searchdistance` (see below)
5697         * Start or end pos is buried in land
5698     * `pos1`: start position
5699     * `pos2`: end position
5700     * `searchdistance`: maximum distance from the search positions to search in.
5701       In detail: Path must be completely inside a cuboid. The minimum
5702       `searchdistance` of 1 will confine search between `pos1` and `pos2`.
5703       Larger values will increase the size of this cuboid in all directions
5704     * `max_jump`: maximum height difference to consider walkable
5705     * `max_drop`: maximum height difference to consider droppable
5706     * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
5707       Difference between `"A*"` and `"A*_noprefetch"` is that
5708       `"A*"` will pre-calculate the cost-data, the other will calculate it
5709       on-the-fly
5710 * `minetest.spawn_tree (pos, {treedef})`
5711     * spawns L-system tree at given `pos` with definition in `treedef` table
5712 * `minetest.transforming_liquid_add(pos)`
5713     * add node to liquid flow update queue
5714 * `minetest.get_node_max_level(pos)`
5715     * get max available level for leveled node
5716 * `minetest.get_node_level(pos)`
5717     * get level of leveled node (water, snow)
5718 * `minetest.set_node_level(pos, level)`
5719     * set level of leveled node, default `level` equals `1`
5720     * if `totallevel > maxlevel`, returns rest (`total-max`).
5721 * `minetest.add_node_level(pos, level)`
5722     * increase level of leveled node by level, default `level` equals `1`
5723     * if `totallevel > maxlevel`, returns rest (`total-max`)
5724     * `level` must be between -127 and 127
5725 * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
5726     * resets the light in a cuboid-shaped part of
5727       the map and removes lighting bugs.
5728     * Loads the area if it is not loaded.
5729     * `pos1` is the corner of the cuboid with the least coordinates
5730       (in node coordinates), inclusive.
5731     * `pos2` is the opposite corner of the cuboid, inclusive.
5732     * The actual updated cuboid might be larger than the specified one,
5733       because only whole map blocks can be updated.
5734       The actual updated area consists of those map blocks that intersect
5735       with the given cuboid.
5736     * However, the neighborhood of the updated area might change
5737       as well, as light can spread out of the cuboid, also light
5738       might be removed.
5739     * returns `false` if the area is not fully generated,
5740       `true` otherwise
5741 * `minetest.check_single_for_falling(pos)`
5742     * causes an unsupported `group:falling_node` node to fall and causes an
5743       unattached `group:attached_node` node to fall.
5744     * does not spread these updates to neighbors.
5745 * `minetest.check_for_falling(pos)`
5746     * causes an unsupported `group:falling_node` node to fall and causes an
5747       unattached `group:attached_node` node to fall.
5748     * spread these updates to neighbors and can cause a cascade
5749       of nodes to fall.
5750 * `minetest.get_spawn_level(x, z)`
5751     * Returns a player spawn y co-ordinate for the provided (x, z)
5752       co-ordinates, or `nil` for an unsuitable spawn point.
5753     * For most mapgens a 'suitable spawn point' is one with y between
5754       `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
5755       so `nil` will be returned for many (x, z) co-ordinates.
5756     * The spawn level returned is for a player spawn in unmodified terrain.
5757     * The spawn level is intentionally above terrain level to cope with
5758       full-node biome 'dust' nodes.
5759
5760 Mod channels
5761 ------------
5762
5763 You can find mod channels communication scheme in `doc/mod_channels.png`.
5764
5765 * `minetest.mod_channel_join(channel_name)`
5766     * Server joins channel `channel_name`, and creates it if necessary. You
5767       should listen for incoming messages with
5768       `minetest.register_on_modchannel_message`
5769
5770 Inventory
5771 ---------
5772
5773 `minetest.get_inventory(location)`: returns an `InvRef`
5774
5775 * `location` = e.g.
5776     * `{type="player", name="celeron55"}`
5777     * `{type="node", pos={x=, y=, z=}}`
5778     * `{type="detached", name="creative"}`
5779 * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
5780   an `InvRef`.
5781     * `callbacks`: See [Detached inventory callbacks]
5782     * `player_name`: Make detached inventory available to one player
5783       exclusively, by default they will be sent to every player (even if not
5784       used).
5785       Note that this parameter is mostly just a workaround and will be removed
5786       in future releases.
5787     * Creates a detached inventory. If it already exists, it is cleared.
5788 * `minetest.remove_detached_inventory(name)`
5789     * Returns a `boolean` indicating whether the removal succeeded.
5790 * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
5791   returns leftover ItemStack or nil to indicate no inventory change
5792     * See `minetest.item_eat` and `minetest.register_on_item_eat`
5793
5794 Formspec
5795 --------
5796
5797 * `minetest.show_formspec(playername, formname, formspec)`
5798     * `playername`: name of player to show formspec
5799     * `formname`: name passed to `on_player_receive_fields` callbacks.
5800       It should follow the `"modname:<whatever>"` naming convention
5801     * `formspec`: formspec to display
5802 * `minetest.close_formspec(playername, formname)`
5803     * `playername`: name of player to close formspec
5804     * `formname`: has to exactly match the one given in `show_formspec`, or the
5805       formspec will not close.
5806     * calling `show_formspec(playername, formname, "")` is equal to this
5807       expression.
5808     * to close a formspec regardless of the formname, call
5809       `minetest.close_formspec(playername, "")`.
5810       **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
5811 * `minetest.formspec_escape(string)`: returns a string
5812     * escapes the characters "[", "]", "\", "," and ";", which can not be used
5813       in formspecs.
5814 * `minetest.explode_table_event(string)`: returns a table
5815     * returns e.g. `{type="CHG", row=1, column=2}`
5816     * `type` is one of:
5817         * `"INV"`: no row selected
5818         * `"CHG"`: selected
5819         * `"DCL"`: double-click
5820 * `minetest.explode_textlist_event(string)`: returns a table
5821     * returns e.g. `{type="CHG", index=1}`
5822     * `type` is one of:
5823         * `"INV"`: no row selected
5824         * `"CHG"`: selected
5825         * `"DCL"`: double-click
5826 * `minetest.explode_scrollbar_event(string)`: returns a table
5827     * returns e.g. `{type="CHG", value=500}`
5828     * `type` is one of:
5829         * `"INV"`: something failed
5830         * `"CHG"`: has been changed
5831         * `"VAL"`: not changed
5832
5833 Item handling
5834 -------------
5835
5836 * `minetest.inventorycube(img1, img2, img3)`
5837     * Returns a string for making an image of a cube (useful as an item image)
5838 * `minetest.get_pointed_thing_position(pointed_thing, above)`
5839     * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
5840       does not refer to a node or entity.
5841     * If the optional `above` parameter is true and the `pointed_thing` refers
5842       to a node, then it will return the `above` position of the `pointed_thing`.
5843 * `minetest.dir_to_facedir(dir, is6d)`
5844     * Convert a vector to a facedir value, used in `param2` for
5845       `paramtype2="facedir"`.
5846     * passing something non-`nil`/`false` for the optional second parameter
5847       causes it to take the y component into account.
5848 * `minetest.facedir_to_dir(facedir)`
5849     * Convert a facedir back into a vector aimed directly out the "back" of a
5850       node.
5851 * `minetest.dir_to_fourdir(dir)`
5852     * Convert a vector to a 4dir value, used in `param2` for
5853       `paramtype2="4dir"`.
5854 * `minetest.fourdir_to_dir(fourdir)`
5855     * Convert a 4dir back into a vector aimed directly out the "back" of a
5856       node.
5857 * `minetest.dir_to_wallmounted(dir)`
5858     * Convert a vector to a wallmounted value, used for
5859       `paramtype2="wallmounted"`.
5860 * `minetest.wallmounted_to_dir(wallmounted)`
5861     * Convert a wallmounted value back into a vector aimed directly out the
5862       "back" of a node.
5863 * `minetest.dir_to_yaw(dir)`
5864     * Convert a vector into a yaw (angle)
5865 * `minetest.yaw_to_dir(yaw)`
5866     * Convert yaw (angle) to a vector
5867 * `minetest.is_colored_paramtype(ptype)`
5868     * Returns a boolean. Returns `true` if the given `paramtype2` contains
5869       color information (`color`, `colorwallmounted`, `colorfacedir`, etc.).
5870 * `minetest.strip_param2_color(param2, paramtype2)`
5871     * Removes everything but the color information from the
5872       given `param2` value.
5873     * Returns `nil` if the given `paramtype2` does not contain color
5874       information.
5875 * `minetest.get_node_drops(node, toolname)`
5876     * Returns list of itemstrings that are dropped by `node` when dug
5877       with the item `toolname` (not limited to tools).
5878     * `node`: node as table or node name
5879     * `toolname`: name of the item used to dig (can be `nil`)
5880 * `minetest.get_craft_result(input)`: returns `output, decremented_input`
5881     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5882     * `input.width` = for example `3`
5883     * `input.items` = for example
5884       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5885     * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
5886     * `output.time` = a number, if unsuccessful: `0`
5887     * `output.replacements` = List of replacement `ItemStack`s that couldn't be
5888       placed in `decremented_input.items`. Replacements can be placed in
5889       `decremented_input` if the stack of the replaced item has a count of 1.
5890     * `decremented_input` = like `input`
5891 * `minetest.get_craft_recipe(output)`: returns input
5892     * returns last registered recipe for output item (node)
5893     * `output` is a node or item type such as `"default:torch"`
5894     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5895     * `input.width` = for example `3`
5896     * `input.items` = for example
5897       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5898         * `input.items` = `nil` if no recipe found
5899 * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
5900     * returns indexed table with all registered recipes for query item (node)
5901       or `nil` if no recipe was found.
5902     * recipe entry table:
5903         * `method`: 'normal' or 'cooking' or 'fuel'
5904         * `width`: 0-3, 0 means shapeless recipe
5905         * `items`: indexed [1-9] table with recipe items
5906         * `output`: string with item name and quantity
5907     * Example result for `"default:gold_ingot"` with two recipes:
5908
5909           {
5910               {
5911                   method = "cooking", width = 3,
5912                   output = "default:gold_ingot", items = {"default:gold_lump"}
5913               },
5914               {
5915                   method = "normal", width = 1,
5916                   output = "default:gold_ingot 9", items = {"default:goldblock"}
5917               }
5918           }
5919
5920 * `minetest.handle_node_drops(pos, drops, digger)`
5921     * `drops`: list of itemstrings
5922     * Handles drops from nodes after digging: Default action is to put them
5923       into digger's inventory.
5924     * Can be overridden to get different functionality (e.g. dropping items on
5925       ground)
5926 * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
5927   string.
5928     * Creates an item string which contains palette index information
5929       for hardware colorization. You can use the returned string
5930       as an output in a craft recipe.
5931     * `item`: the item stack which becomes colored. Can be in string,
5932       table and native form.
5933     * `palette_index`: this index is added to the item stack
5934 * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
5935     * Creates an item string which contains static color information
5936       for hardware colorization. Use this method if you wish to colorize
5937       an item that does not own a palette. You can use the returned string
5938       as an output in a craft recipe.
5939     * `item`: the item stack which becomes colored. Can be in string,
5940       table and native form.
5941     * `colorstring`: the new color of the item stack
5942
5943 Rollback
5944 --------
5945
5946 * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
5947   returns `{{actor, pos, time, oldnode, newnode}, ...}`
5948     * Find who has done something to a node, or near a node
5949     * `actor`: `"player:<name>"`, also `"liquid"`.
5950 * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
5951   `boolean, log_messages`.
5952     * Revert latest actions of someone
5953     * `actor`: `"player:<name>"`, also `"liquid"`.
5954
5955 Defaults for the `on_place` and `on_drop` item definition functions
5956 -------------------------------------------------------------------
5957
5958 * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
5959     * Place item as a node
5960     * `param2` overrides `facedir` and wallmounted `param2`
5961     * `prevent_after_place`: if set to `true`, `after_place_node` is not called
5962       for the newly placed node to prevent a callback and placement loop
5963     * returns `itemstack, position`
5964       * `position`: the location the node was placed to. `nil` if nothing was placed.
5965 * `minetest.item_place_object(itemstack, placer, pointed_thing)`
5966     * Place item as-is
5967     * returns the leftover itemstack
5968     * **Note**: This function is deprecated and will never be called.
5969 * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
5970     * Wrapper that calls `minetest.item_place_node` if appropriate
5971     * Calls `on_rightclick` of `pointed_thing.under` if defined instead
5972     * **Note**: is not called when wielded item overrides `on_place`
5973     * `param2` overrides facedir and wallmounted `param2`
5974     * returns `itemstack, position`
5975       * `position`: the location the node was placed to. `nil` if nothing was placed.
5976 * `minetest.item_pickup(itemstack, picker, pointed_thing, time_from_last_punch, ...)`
5977     * Runs callbacks registered by `minetest.register_on_item_pickup` and adds
5978       the item to the picker's `"main"` inventory list.
5979     * Parameters are the same as in `on_pickup`.
5980     * Returns the leftover itemstack.
5981 * `minetest.item_drop(itemstack, dropper, pos)`
5982     * Drop the item
5983     * returns the leftover itemstack
5984 * `minetest.item_eat(hp_change[, replace_with_item])`
5985     * Returns `function(itemstack, user, pointed_thing)` as a
5986       function wrapper for `minetest.do_item_eat`.
5987     * `replace_with_item` is the itemstring which is added to the inventory.
5988       If the player is eating a stack, then replace_with_item goes to a
5989       different spot.
5990
5991 Defaults for the `on_punch` and `on_dig` node definition callbacks
5992 ------------------------------------------------------------------
5993
5994 * `minetest.node_punch(pos, node, puncher, pointed_thing)`
5995     * Calls functions registered by `minetest.register_on_punchnode()`
5996 * `minetest.node_dig(pos, node, digger)`
5997     * Checks if node can be dug, puts item into inventory, removes node
5998     * Calls functions registered by `minetest.registered_on_dignodes()`
5999
6000 Sounds
6001 ------
6002
6003 * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
6004     * `spec` is a `SimpleSoundSpec`
6005     * `parameters` is a sound parameter table
6006     * `ephemeral` is a boolean (default: false)
6007       Ephemeral sounds will not return a handle and can't be stopped or faded.
6008       It is recommend to use this for short sounds that happen in response to
6009       player actions (e.g. door closing).
6010 * `minetest.sound_stop(handle)`
6011     * `handle` is a handle returned by `minetest.sound_play`
6012 * `minetest.sound_fade(handle, step, gain)`
6013     * `handle` is a handle returned by `minetest.sound_play`
6014     * `step` determines how fast a sound will fade.
6015       The gain will change by this much per second,
6016       until it reaches the target gain.
6017       Note: Older versions used a signed step. This is deprecated, but old
6018       code will still work. (the client uses abs(step) to correct it)
6019     * `gain` the target gain for the fade.
6020       Fading to zero will delete the sound.
6021
6022 Timing
6023 ------
6024
6025 * `minetest.after(time, func, ...)`: returns job table to use as below.
6026     * Call the function `func` after `time` seconds, may be fractional
6027     * Optional: Variable number of arguments that are passed to `func`
6028
6029 * `job:cancel()`
6030     * Cancels the job function from being called
6031
6032 Async environment
6033 -----------------
6034
6035 The engine allows you to submit jobs to be ran in an isolated environment
6036 concurrently with normal server operation.
6037 A job consists of a function to be ran in the async environment, any amount of
6038 arguments (will be serialized) and a callback that will be called with the return
6039 value of the job function once it is finished.
6040
6041 The async environment does *not* have access to the map, entities, players or any
6042 globals defined in the 'usual' environment. Consequently, functions like
6043 `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
6044
6045 Arguments and return values passed through this can contain certain userdata
6046 objects that will be seamlessly copied (not shared) to the async environment.
6047 This allows you easy interoperability for delegating work to jobs.
6048
6049 * `minetest.handle_async(func, callback, ...)`:
6050     * Queue the function `func` to be ran in an async environment.
6051       Note that there are multiple persistent workers and any of them may
6052       end up running a given job. The engine will scale the amount of
6053       worker threads automatically.
6054     * When `func` returns the callback is called (in the normal environment)
6055       with all of the return values as arguments.
6056     * Optional: Variable number of arguments that are passed to `func`
6057 * `minetest.register_async_dofile(path)`:
6058     * Register a path to a Lua file to be imported when an async environment
6059       is initialized. You can use this to preload code which you can then call
6060       later using `minetest.handle_async()`.
6061
6062 ### List of APIs available in an async environment
6063
6064 Classes:
6065 * `ItemStack`
6066 * `PerlinNoise`
6067 * `PerlinNoiseMap`
6068 * `PseudoRandom`
6069 * `PcgRandom`
6070 * `SecureRandom`
6071 * `VoxelArea`
6072 * `VoxelManip`
6073     * only if transferred into environment; can't read/write to map
6074 * `Settings`
6075
6076 Class instances that can be transferred between environments:
6077 * `ItemStack`
6078 * `PerlinNoise`
6079 * `PerlinNoiseMap`
6080 * `VoxelManip`
6081
6082 Functions:
6083 * Standalone helpers such as logging, filesystem, encoding,
6084   hashing or compression APIs
6085 * `minetest.request_insecure_environment` (same restrictions apply)
6086
6087 Variables:
6088 * `minetest.settings`
6089 * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
6090   `registered_craftitems` and `registered_aliases`
6091     * with all functions and userdata values replaced by `true`, calling any
6092       callbacks here is obviously not possible
6093
6094 Server
6095 ------
6096
6097 * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
6098   server shutdown. Will display `message` to clients.
6099     * `reconnect` == true displays a reconnect button
6100     * `delay` adds an optional delay (in seconds) before shutdown.
6101       Negative delay cancels the current active shutdown.
6102       Zero delay triggers an immediate shutdown.
6103 * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
6104 * `minetest.get_server_status(name, joined)`
6105     * Returns the server status string when a player joins or when the command
6106       `/status` is called. Returns `nil` or an empty string when the message is
6107       disabled.
6108     * `joined`: Boolean value, indicates whether the function was called when
6109       a player joined.
6110     * This function may be overwritten by mods to customize the status message.
6111 * `minetest.get_server_uptime()`: returns the server uptime in seconds
6112 * `minetest.get_server_max_lag()`: returns the current maximum lag
6113   of the server in seconds or nil if server is not fully loaded yet
6114 * `minetest.remove_player(name)`: remove player from database (if they are not
6115   connected).
6116     * As auth data is not removed, minetest.player_exists will continue to
6117       return true. Call the below method as well if you want to remove auth
6118       data too.
6119     * Returns a code (0: successful, 1: no such player, 2: player is connected)
6120 * `minetest.remove_player_auth(name)`: remove player authentication data
6121     * Returns boolean indicating success (false if player nonexistent)
6122 * `minetest.dynamic_add_media(options, callback)`
6123     * `options`: table containing the following parameters
6124         * `filepath`: path to a media file on the filesystem
6125         * `to_player`: name of the player the media should be sent to instead of
6126                        all players (optional)
6127         * `ephemeral`: boolean that marks the media as ephemeral,
6128                        it will not be cached on the client (optional, default false)
6129     * `callback`: function with arguments `name`, which is a player name
6130     * Pushes the specified media file to client(s). (details below)
6131       The file must be a supported image, sound or model format.
6132       Dynamically added media is not persisted between server restarts.
6133     * Returns false on error, true if the request was accepted
6134     * The given callback will be called for every player as soon as the
6135       media is available on the client.
6136     * Details/Notes:
6137       * If `ephemeral`=false and `to_player` is unset the file is added to the media
6138         sent to clients on startup, this means the media will appear even on
6139         old clients if they rejoin the server.
6140       * If `ephemeral`=false the file must not be modified, deleted, moved or
6141         renamed after calling this function.
6142       * Regardless of any use of `ephemeral`, adding media files with the same
6143         name twice is not possible/guaranteed to work. An exception to this is the
6144         use of `to_player` to send the same, already existent file to multiple
6145         chosen players.
6146     * Clients will attempt to fetch files added this way via remote media,
6147       this can make transfer of bigger files painless (if set up). Nevertheless
6148       it is advised not to use dynamic media for big media files.
6149
6150 Bans
6151 ----
6152
6153 * `minetest.get_ban_list()`: returns a list of all bans formatted as string
6154 * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
6155   IP address or name formatted as string
6156 * `minetest.ban_player(name)`: ban the IP of a currently connected player
6157     * Returns boolean indicating success
6158 * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
6159   IP address or name
6160 * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
6161   reason.
6162     * Returns boolean indicating success (false if player nonexistent)
6163 * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
6164   optional reason, this will not prefix with 'Kicked: ' like kick_player.
6165   If no reason is given, it will default to 'Disconnected.'
6166     * Returns boolean indicating success (false if player nonexistent)
6167
6168 Particles
6169 ---------
6170
6171 * `minetest.add_particle(particle definition)`
6172     * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
6173       expirationtime, size, collisiondetection, texture, playername)`
6174
6175 * `minetest.add_particlespawner(particlespawner definition)`
6176     * Add a `ParticleSpawner`, an object that spawns an amount of particles
6177       over `time` seconds.
6178     * Returns an `id`, and -1 if adding didn't succeed
6179     * Deprecated: `minetest.add_particlespawner(amount, time,
6180       minpos, maxpos,
6181       minvel, maxvel,
6182       minacc, maxacc,
6183       minexptime, maxexptime,
6184       minsize, maxsize,
6185       collisiondetection, texture, playername)`
6186
6187 * `minetest.delete_particlespawner(id, player)`
6188     * Delete `ParticleSpawner` with `id` (return value from
6189       `minetest.add_particlespawner`).
6190     * If playername is specified, only deletes on the player's client,
6191       otherwise on all clients.
6192
6193 Schematics
6194 ----------
6195
6196 * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
6197     * Create a schematic from the volume of map specified by the box formed by
6198       p1 and p2.
6199     * Apply the specified probability and per-node force-place to the specified
6200       nodes according to the `probability_list`.
6201         * `probability_list` is an array of tables containing two fields, `pos`
6202           and `prob`.
6203             * `pos` is the 3D vector specifying the absolute coordinates of the
6204               node being modified,
6205             * `prob` is an integer value from `0` to `255` that encodes
6206               probability and per-node force-place. Probability has levels
6207               0-127, then 128 may be added to encode per-node force-place.
6208               For probability stated as 0-255, divide by 2 and round down to
6209               get values 0-127, then add 128 to apply per-node force-place.
6210             * If there are two or more entries with the same pos value, the
6211               last entry is used.
6212             * If `pos` is not inside the box formed by `p1` and `p2`, it is
6213               ignored.
6214             * If `probability_list` equals `nil`, no probabilities are applied.
6215     * Apply the specified probability to the specified horizontal slices
6216       according to the `slice_prob_list`.
6217         * `slice_prob_list` is an array of tables containing two fields, `ypos`
6218           and `prob`.
6219             * `ypos` indicates the y position of the slice with a probability
6220               applied, the lowest slice being `ypos = 0`.
6221             * If slice probability list equals `nil`, no slice probabilities
6222               are applied.
6223     * Saves schematic in the Minetest Schematic format to filename.
6224
6225 * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
6226     * Place the schematic specified by schematic (see [Schematic specifier]) at
6227       `pos`.
6228     * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
6229     * If the `rotation` parameter is omitted, the schematic is not rotated.
6230     * `replacements` = `{["old_name"] = "convert_to", ...}`
6231     * `force_placement` is a boolean indicating whether nodes other than `air`
6232       and `ignore` are replaced by the schematic.
6233     * Returns nil if the schematic could not be loaded.
6234     * **Warning**: Once you have loaded a schematic from a file, it will be
6235       cached. Future calls will always use the cached version and the
6236       replacement list defined for it, regardless of whether the file or the
6237       replacement list parameter have changed. The only way to load the file
6238       anew is to restart the server.
6239     * `flags` is a flag field with the available flags:
6240         * place_center_x
6241         * place_center_y
6242         * place_center_z
6243
6244 * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
6245     * This function is analogous to minetest.place_schematic, but places a
6246       schematic onto the specified VoxelManip object `vmanip` instead of the
6247       map.
6248     * Returns false if any part of the schematic was cut-off due to the
6249       VoxelManip not containing the full area required, and true if the whole
6250       schematic was able to fit.
6251     * Returns nil if the schematic could not be loaded.
6252     * After execution, any external copies of the VoxelManip contents are
6253       invalidated.
6254     * `flags` is a flag field with the available flags:
6255         * place_center_x
6256         * place_center_y
6257         * place_center_z
6258
6259 * `minetest.serialize_schematic(schematic, format, options)`
6260     * Return the serialized schematic specified by schematic
6261       (see [Schematic specifier])
6262     * in the `format` of either "mts" or "lua".
6263     * "mts" - a string containing the binary MTS data used in the MTS file
6264       format.
6265     * "lua" - a string containing Lua code representing the schematic in table
6266       format.
6267     * `options` is a table containing the following optional parameters:
6268         * If `lua_use_comments` is true and `format` is "lua", the Lua code
6269           generated will have (X, Z) position comments for every X row
6270           generated in the schematic data for easier reading.
6271         * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
6272           the Lua code generated will use that number of spaces as indentation
6273           instead of a tab character.
6274
6275 * `minetest.read_schematic(schematic, options)`
6276     * Returns a Lua table representing the schematic (see: [Schematic specifier])
6277     * `schematic` is the schematic to read (see: [Schematic specifier])
6278     * `options` is a table containing the following optional parameters:
6279         * `write_yslice_prob`: string value:
6280             * `none`: no `write_yslice_prob` table is inserted,
6281             * `low`: only probabilities that are not 254 or 255 are written in
6282               the `write_ylisce_prob` table,
6283             * `all`: write all probabilities to the `write_yslice_prob` table.
6284             * The default for this option is `all`.
6285             * Any invalid value will be interpreted as `all`.
6286
6287 HTTP Requests
6288 -------------
6289
6290 * `minetest.request_http_api()`:
6291     * returns `HTTPApiTable` containing http functions if the calling mod has
6292       been granted access by being listed in the `secure.http_mods` or
6293       `secure.trusted_mods` setting, otherwise returns `nil`.
6294     * The returned table contains the functions `fetch`, `fetch_async` and
6295       `fetch_async_get` described below.
6296     * Only works at init time and must be called from the mod's main scope
6297       (not from a function).
6298     * Function only exists if minetest server was built with cURL support.
6299     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
6300       A LOCAL VARIABLE!**
6301 * `HTTPApiTable.fetch(HTTPRequest req, callback)`
6302     * Performs given request asynchronously and calls callback upon completion
6303     * callback: `function(HTTPRequestResult res)`
6304     * Use this HTTP function if you are unsure, the others are for advanced use
6305 * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
6306     * Performs given request asynchronously and returns handle for
6307       `HTTPApiTable.fetch_async_get`
6308 * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
6309     * Return response data for given asynchronous HTTP request
6310
6311 Storage API
6312 -----------
6313
6314 * `minetest.get_mod_storage()`:
6315     * returns reference to mod private `StorageRef`
6316     * must be called during mod load time
6317
6318 Misc.
6319 -----
6320
6321 * `minetest.get_connected_players()`: returns list of `ObjectRefs`
6322 * `minetest.is_player(obj)`: boolean, whether `obj` is a player
6323 * `minetest.player_exists(name)`: boolean, whether player exists
6324   (regardless of online status)
6325 * `minetest.hud_replace_builtin(name, hud_definition)`
6326     * Replaces definition of a builtin hud element
6327     * `name`: `"breath"` or `"health"`
6328     * `hud_definition`: definition to replace builtin definition
6329 * `minetest.parse_relative_number(arg, relative_to)`: returns number or nil
6330     * Helper function for chat commands.
6331     * For parsing an optionally relative number of a chat command
6332       parameter, using the chat command tilde notation.
6333     * `arg`: String snippet containing the number; possible values:
6334         * `"<number>"`: return as number
6335         * `"~<number>"`: return `relative_to + <number>`
6336         * `"~"`: return `relative_to`
6337         * Anything else will return `nil`
6338     * `relative_to`: Number to which the `arg` number might be relative to
6339     * Examples:
6340         * `minetest.parse_relative_number("5", 10)` returns 5
6341         * `minetest.parse_relative_number("~5", 10)` returns 15
6342         * `minetest.parse_relative_number("~", 10)` returns 10
6343 * `minetest.send_join_message(player_name)`
6344     * This function can be overridden by mods to change the join message.
6345 * `minetest.send_leave_message(player_name, timed_out)`
6346     * This function can be overridden by mods to change the leave message.
6347 * `minetest.hash_node_position(pos)`: returns a 48-bit integer
6348     * `pos`: table {x=number, y=number, z=number},
6349     * Gives a unique hash number for a node position (16+16+16=48bit)
6350 * `minetest.get_position_from_hash(hash)`: returns a position
6351     * Inverse transform of `minetest.hash_node_position`
6352 * `minetest.get_item_group(name, group)`: returns a rating
6353     * Get rating of a group of an item. (`0` means: not in group)
6354 * `minetest.get_node_group(name, group)`: returns a rating
6355     * Deprecated: An alias for the former.
6356 * `minetest.raillike_group(name)`: returns a rating
6357     * Returns rating of the connect_to_raillike group corresponding to name
6358     * If name is not yet the name of a connect_to_raillike group, a new group
6359       id is created, with that name.
6360 * `minetest.get_content_id(name)`: returns an integer
6361     * Gets the internal content ID of `name`
6362 * `minetest.get_name_from_content_id(content_id)`: returns a string
6363     * Gets the name of the content with that content ID
6364 * `minetest.parse_json(string[, nullvalue])`: returns something
6365     * Convert a string containing JSON data into the Lua equivalent
6366     * `nullvalue`: returned in place of the JSON null; defaults to `nil`
6367     * On success returns a table, a string, a number, a boolean or `nullvalue`
6368     * On failure outputs an error message and returns `nil`
6369     * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
6370 * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
6371   message.
6372     * Convert a Lua table into a JSON string
6373     * styled: Outputs in a human-readable format if this is set, defaults to
6374       false.
6375     * Unserializable things like functions and userdata will cause an error.
6376     * **Warning**: JSON is more strict than the Lua table format.
6377         1. You can only use strings and positive integers of at least one as
6378            keys.
6379         2. You can not mix string and integer keys.
6380            This is due to the fact that JSON has two distinct array and object
6381            values.
6382     * Example: `write_json({10, {a = false}})`,
6383       returns `'[10, {"a": false}]'`
6384 * `minetest.serialize(table)`: returns a string
6385     * Convert a table containing tables, strings, numbers, booleans and `nil`s
6386       into string form readable by `minetest.deserialize`
6387     * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
6388 * `minetest.deserialize(string[, safe])`: returns a table
6389     * Convert a string returned by `minetest.serialize` into a table
6390     * `string` is loaded in an empty sandbox environment.
6391     * Will load functions if safe is false or omitted. Although these functions
6392       cannot directly access the global environment, they could bypass this
6393       restriction with maliciously crafted Lua bytecode if mod security is
6394       disabled.
6395     * This function should not be used on untrusted data, regardless of the
6396      value of `safe`. It is fine to serialize then deserialize user-provided
6397      data, but directly providing user input to deserialize is always unsafe.
6398     * Example: `deserialize('return { ["foo"] = "bar" }')`,
6399       returns `{foo="bar"}`
6400     * Example: `deserialize('print("foo")')`, returns `nil`
6401       (function call fails), returns
6402       `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
6403 * `minetest.compress(data, method, ...)`: returns `compressed_data`
6404     * Compress a string of data.
6405     * `method` is a string identifying the compression method to be used.
6406     * Supported compression methods:
6407         * Deflate (zlib): `"deflate"`
6408         * Zstandard: `"zstd"`
6409     * `...` indicates method-specific arguments. Currently defined arguments
6410       are:
6411         * Deflate: `level` - Compression level, `0`-`9` or `nil`.
6412         * Zstandard: `level` - Compression level. Integer or `nil`. Default `3`.
6413         Note any supported Zstandard compression level could be used here,
6414         but these are subject to change between Zstandard versions.
6415 * `minetest.decompress(compressed_data, method, ...)`: returns data
6416     * Decompress a string of data using the algorithm specified by `method`.
6417     * See documentation on `minetest.compress()` for supported compression
6418       methods.
6419     * `...` indicates method-specific arguments. Currently, no methods use this
6420 * `minetest.rgba(red, green, blue[, alpha])`: returns a string
6421     * Each argument is an 8 Bit unsigned integer
6422     * Returns the ColorString from rgb or rgba values
6423     * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
6424 * `minetest.encode_base64(string)`: returns string encoded in base64
6425     * Encodes a string in base64.
6426 * `minetest.decode_base64(string)`: returns string or nil on failure
6427     * Padding characters are only supported starting at version 5.4.0, where
6428       5.5.0 and newer perform proper checks.
6429     * Decodes a string encoded in base64.
6430 * `minetest.is_protected(pos, name)`: returns boolean
6431     * Returning `true` restricts the player `name` from modifying (i.e. digging,
6432        placing) the node at position `pos`.
6433     * `name` will be `""` for non-players or unknown players.
6434     * This function should be overridden by protection mods. It is highly
6435       recommended to grant access to players with the `protection_bypass` privilege.
6436     * Cache and call the old version of this function if the position is
6437       not protected by the mod. This will allow using multiple protection mods.
6438     * Example:
6439
6440           local old_is_protected = minetest.is_protected
6441           function minetest.is_protected(pos, name)
6442               if mymod:position_protected_from(pos, name) then
6443                   return true
6444               end
6445               return old_is_protected(pos, name)
6446           end
6447 * `minetest.record_protection_violation(pos, name)`
6448     * This function calls functions registered with
6449       `minetest.register_on_protection_violation`.
6450 * `minetest.is_creative_enabled(name)`: returns boolean
6451     * Returning `true` means that Creative Mode is enabled for player `name`.
6452     * `name` will be `""` for non-players or if the player is unknown.
6453     * This function should be overridden by Creative Mode-related mods to
6454       implement a per-player Creative Mode.
6455     * By default, this function returns `true` if the setting
6456       `creative_mode` is `true` and `false` otherwise.
6457 * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
6458     * Returns the position of the first node that `player_name` may not modify
6459       in the specified cuboid between `pos1` and `pos2`.
6460     * Returns `false` if no protections were found.
6461     * Applies `is_protected()` to a 3D lattice of points in the defined volume.
6462       The points are spaced evenly throughout the volume and have a spacing
6463       similar to, but no larger than, `interval`.
6464     * All corners and edges of the defined volume are checked.
6465     * `interval` defaults to 4.
6466     * `interval` should be carefully chosen and maximized to avoid an excessive
6467       number of points being checked.
6468     * Like `minetest.is_protected`, this function may be extended or
6469       overwritten by mods to provide a faster implementation to check the
6470       cuboid for intersections.
6471 * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
6472   orient_flags, prevent_after_place])`
6473     * Attempt to predict the desired orientation of the facedir-capable node
6474       defined by `itemstack`, and place it accordingly (on-wall, on the floor,
6475       or hanging from the ceiling).
6476     * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
6477       stacks are handled normally.
6478     * `orient_flags`: Optional table containing extra tweaks to the placement code:
6479         * `invert_wall`:   if `true`, place wall-orientation on the ground and
6480           ground-orientation on the wall.
6481         * `force_wall`:    if `true`, always place the node in wall orientation.
6482         * `force_ceiling`: if `true`, always place on the ceiling.
6483         * `force_floor`:   if `true`, always place the node on the floor.
6484         * `force_facedir`: if `true`, forcefully reset the facedir to north
6485           when placing on the floor or ceiling.
6486         * The first four options are mutually-exclusive; the last in the list
6487           takes precedence over the first.
6488     * `prevent_after_place` is directly passed to `minetest.item_place_node`
6489     * Returns the new itemstack after placement
6490 * `minetest.rotate_node(itemstack, placer, pointed_thing)`
6491     * calls `rotate_and_place()` with `infinitestacks` set according to the state
6492       of the creative mode setting, checks for "sneak" to set the `invert_wall`
6493       parameter and `prevent_after_place` set to `true`.
6494
6495 * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
6496   tool_capabilities, dir, distance, damage)`
6497     * Returns the amount of knockback applied on the punched player.
6498     * Arguments are equivalent to `register_on_punchplayer`, except the following:
6499         * `distance`: distance between puncher and punched player
6500     * This function can be overridden by mods that wish to modify this behavior.
6501     * You may want to cache and call the old function to allow multiple mods to
6502       change knockback behavior.
6503
6504 * `minetest.forceload_block(pos[, transient])`
6505     * forceloads the position `pos`.
6506     * returns `true` if area could be forceloaded
6507     * If `transient` is `false` or absent, the forceload will be persistent
6508       (saved between server runs). If `true`, the forceload will be transient
6509       (not saved between server runs).
6510
6511 * `minetest.forceload_free_block(pos[, transient])`
6512     * stops forceloading the position `pos`
6513     * If `transient` is `false` or absent, frees a persistent forceload.
6514       If `true`, frees a transient forceload.
6515
6516 * `minetest.compare_block_status(pos, condition)`
6517     * Checks whether the mapblock at position `pos` is in the wanted condition.
6518     * `condition` may be one of the following values:
6519         * `"unknown"`: not in memory
6520         * `"emerging"`: in the queue for loading from disk or generating
6521         * `"loaded"`: in memory but inactive (no ABMs are executed)
6522         * `"active"`: in memory and active
6523         * Other values are reserved for future functionality extensions
6524     * Return value, the comparison status:
6525         * `false`: Mapblock does not fulfill the wanted condition
6526         * `true`: Mapblock meets the requirement
6527         * `nil`: Unsupported `condition` value
6528
6529 * `minetest.request_insecure_environment()`: returns an environment containing
6530   insecure functions if the calling mod has been listed as trusted in the
6531   `secure.trusted_mods` setting or security is disabled, otherwise returns
6532   `nil`.
6533     * Only works at init time and must be called from the mod's main scope
6534       (ie: the init.lua of the mod, not from another Lua file or within a function).
6535     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
6536       IT IN A LOCAL VARIABLE!**
6537
6538 * `minetest.global_exists(name)`
6539     * Checks if a global variable has been set, without triggering a warning.
6540
6541 Global objects
6542 --------------
6543
6544 * `minetest.env`: `EnvRef` of the server environment and world.
6545     * Any function in the minetest namespace can be called using the syntax
6546       `minetest.env:somefunction(somearguments)`
6547       instead of `minetest.somefunction(somearguments)`
6548     * Deprecated, but support is not to be dropped soon
6549
6550 Global tables
6551 -------------
6552
6553 ### Registered definition tables
6554
6555 * `minetest.registered_items`
6556     * Map of registered items, indexed by name
6557 * `minetest.registered_nodes`
6558     * Map of registered node definitions, indexed by name
6559 * `minetest.registered_craftitems`
6560     * Map of registered craft item definitions, indexed by name
6561 * `minetest.registered_tools`
6562     * Map of registered tool definitions, indexed by name
6563 * `minetest.registered_entities`
6564     * Map of registered entity prototypes, indexed by name
6565     * Values in this table may be modified directly.
6566       Note: changes to initial properties will only affect entities spawned afterwards,
6567       as they are only read when spawning.
6568 * `minetest.object_refs`
6569     * Map of object references, indexed by active object id
6570 * `minetest.luaentities`
6571     * Map of Lua entities, indexed by active object id
6572 * `minetest.registered_abms`
6573     * List of ABM definitions
6574 * `minetest.registered_lbms`
6575     * List of LBM definitions
6576 * `minetest.registered_aliases`
6577     * Map of registered aliases, indexed by name
6578 * `minetest.registered_ores`
6579     * Map of registered ore definitions, indexed by the `name` field.
6580     * If `name` is nil, the key is the object handle returned by
6581       `minetest.register_ore`.
6582 * `minetest.registered_biomes`
6583     * Map of registered biome definitions, indexed by the `name` field.
6584     * If `name` is nil, the key is the object handle returned by
6585       `minetest.register_biome`.
6586 * `minetest.registered_decorations`
6587     * Map of registered decoration definitions, indexed by the `name` field.
6588     * If `name` is nil, the key is the object handle returned by
6589       `minetest.register_decoration`.
6590 * `minetest.registered_schematics`
6591     * Map of registered schematic definitions, indexed by the `name` field.
6592     * If `name` is nil, the key is the object handle returned by
6593       `minetest.register_schematic`.
6594 * `minetest.registered_chatcommands`
6595     * Map of registered chat command definitions, indexed by name
6596 * `minetest.registered_privileges`
6597     * Map of registered privilege definitions, indexed by name
6598     * Registered privileges can be modified directly in this table.
6599
6600 ### Registered callback tables
6601
6602 All callbacks registered with [Global callback registration functions] are added
6603 to corresponding `minetest.registered_*` tables.
6604
6605
6606
6607
6608 Class reference
6609 ===============
6610
6611 Sorted alphabetically.
6612
6613 `AreaStore`
6614 -----------
6615
6616 AreaStore is a data structure to calculate intersections of 3D cuboid volumes
6617 and points. The `data` field (string) may be used to store and retrieve any
6618 mod-relevant information to the specified area.
6619
6620 Despite its name, mods must take care of persisting AreaStore data. They may
6621 use the provided load and write functions for this.
6622
6623
6624 ### Methods
6625
6626 * `AreaStore(type_name)`
6627     * Returns a new AreaStore instance
6628     * `type_name`: optional, forces the internally used API.
6629         * Possible values: `"LibSpatial"` (default).
6630         * When other values are specified, or SpatialIndex is not available,
6631           the custom Minetest functions are used.
6632 * `get_area(id, include_corners, include_data)`
6633     * Returns the area information about the specified ID.
6634     * Returned values are either of these:
6635
6636             nil  -- Area not found
6637             true -- Without `include_corners` and `include_data`
6638             {
6639                 min = pos, max = pos -- `include_corners == true`
6640                 data = string        -- `include_data == true`
6641             }
6642
6643 * `get_areas_for_pos(pos, include_corners, include_data)`
6644     * Returns all areas as table, indexed by the area ID.
6645     * Table values: see `get_area`.
6646 * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
6647     * Returns all areas that contain all nodes inside the area specified by`
6648       `corner1 and `corner2` (inclusive).
6649     * `accept_overlap`: if `true`, areas are returned that have nodes in
6650       common (intersect) with the specified area.
6651     * Returns the same values as `get_areas_for_pos`.
6652 * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
6653     * Returns the new area's ID, or nil if the insertion failed.
6654     * The (inclusive) positions `corner1` and `corner2` describe the area.
6655     * `data` is a string stored with the area.
6656     * `id` (optional): will be used as the internal area ID if it is a unique
6657       number between 0 and 2^32-2.
6658 * `reserve(count)`
6659     * Requires SpatialIndex, no-op function otherwise.
6660     * Reserves resources for `count` many contained areas to improve
6661       efficiency when working with many area entries. Additional areas can still
6662       be inserted afterwards at the usual complexity.
6663 * `remove_area(id)`: removes the area with the given id from the store, returns
6664   success.
6665 * `set_cache_params(params)`: sets params for the included prefiltering cache.
6666   Calling invalidates the cache, so that its elements have to be newly
6667   generated.
6668     * `params` is a table with the following fields:
6669
6670           enabled = boolean,   -- Whether to enable, default true
6671           block_radius = int,  -- The radius (in nodes) of the areas the cache
6672                                -- generates prefiltered lists for, minimum 16,
6673                                -- default 64
6674           limit = int,         -- The cache size, minimum 20, default 1000
6675 * `to_string()`: Experimental. Returns area store serialized as a (binary)
6676   string.
6677 * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
6678   a file.
6679 * `from_string(str)`: Experimental. Deserializes string and loads it into the
6680   AreaStore.
6681   Returns success and, optionally, an error message.
6682 * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
6683   from a file.
6684
6685 `InvRef`
6686 --------
6687
6688 An `InvRef` is a reference to an inventory.
6689
6690 ### Methods
6691
6692 * `is_empty(listname)`: return `true` if list is empty
6693 * `get_size(listname)`: get size of a list
6694 * `set_size(listname, size)`: set size of a list
6695     * returns `false` on error (e.g. invalid `listname` or `size`)
6696 * `get_width(listname)`: get width of a list
6697 * `set_width(listname, width)`: set width of list; currently used for crafting
6698 * `get_stack(listname, i)`: get a copy of stack index `i` in list
6699 * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
6700 * `get_list(listname)`: return full list (list of `ItemStack`s)
6701 * `set_list(listname, list)`: set full list (size will not change)
6702 * `get_lists()`: returns table that maps listnames to inventory lists
6703 * `set_lists(lists)`: sets inventory lists (size will not change)
6704 * `add_item(listname, stack)`: add item somewhere in list, returns leftover
6705   `ItemStack`.
6706 * `room_for_item(listname, stack):` returns `true` if the stack of items
6707   can be fully added to the list
6708 * `contains_item(listname, stack, [match_meta])`: returns `true` if
6709   the stack of items can be fully taken from the list.
6710   If `match_meta` is false, only the items' names are compared
6711   (default: `false`).
6712 * `remove_item(listname, stack)`: take as many items as specified from the
6713   list, returns the items that were actually removed (as an `ItemStack`)
6714   -- note that any item metadata is ignored, so attempting to remove a specific
6715   unique item this way will likely remove the wrong one -- to do that use
6716   `set_stack` with an empty `ItemStack`.
6717 * `get_location()`: returns a location compatible to
6718   `minetest.get_inventory(location)`.
6719     * returns `{type="undefined"}` in case location is not known
6720
6721 ### Callbacks
6722
6723 Detached & nodemeta inventories provide the following callbacks for move actions:
6724
6725 #### Before
6726
6727 The `allow_*` callbacks return how many items can be moved.
6728
6729 * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
6730 * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
6731 * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
6732
6733 #### After
6734
6735 The `on_*` callbacks are called after the items have been placed in the inventories.
6736
6737 * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
6738 * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
6739 * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
6740
6741 #### Swapping
6742
6743 When a player tries to put an item to a place where another item is, the items are *swapped*.
6744 This means that all callbacks will be called twice (once for each action).
6745
6746 `ItemStack`
6747 -----------
6748
6749 An `ItemStack` is a stack of items.
6750
6751 It can be created via `ItemStack(x)`, where x is an `ItemStack`,
6752 an itemstring, a table or `nil`.
6753
6754 ### Methods
6755
6756 * `is_empty()`: returns `true` if stack is empty.
6757 * `get_name()`: returns item name (e.g. `"default:stone"`).
6758 * `set_name(item_name)`: returns a boolean indicating whether the item was
6759   cleared.
6760 * `get_count()`: Returns number of items on the stack.
6761 * `set_count(count)`: returns a boolean indicating whether the item was cleared
6762     * `count`: number, unsigned 16 bit integer
6763 * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
6764 * `set_wear(wear)`: returns boolean indicating whether item was cleared
6765     * `wear`: number, unsigned 16 bit integer
6766 * `get_meta()`: returns ItemStackMetaRef. See section for more details
6767 * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
6768   stack).
6769 * `set_metadata(metadata)`: (DEPRECATED) Returns true.
6770 * `get_description()`: returns the description shown in inventory list tooltips.
6771     * The engine uses this when showing item descriptions in tooltips.
6772     * Fields for finding the description, in order:
6773         * `description` in item metadata (See [Item Metadata].)
6774         * `description` in item definition
6775         * item name
6776 * `get_short_description()`: returns the short description or nil.
6777     * Unlike the description, this does not include new lines.
6778     * Fields for finding the short description, in order:
6779         * `short_description` in item metadata (See [Item Metadata].)
6780         * `short_description` in item definition
6781         * first line of the description (From item meta or def, see `get_description()`.)
6782         * Returns nil if none of the above are set
6783 * `clear()`: removes all items from the stack, making it empty.
6784 * `replace(item)`: replace the contents of this stack.
6785     * `item` can also be an itemstring or table.
6786 * `to_string()`: returns the stack in itemstring form.
6787 * `to_table()`: returns the stack in Lua table form.
6788 * `get_stack_max()`: returns the maximum size of the stack (depends on the
6789   item).
6790 * `get_free_space()`: returns `get_stack_max() - get_count()`.
6791 * `is_known()`: returns `true` if the item name refers to a defined item type.
6792 * `get_definition()`: returns the item definition table.
6793 * `get_tool_capabilities()`: returns the digging properties of the item,
6794   or those of the hand if none are defined for this item type
6795 * `add_wear(amount)`
6796     * Increases wear by `amount` if the item is a tool, otherwise does nothing
6797     * Valid `amount` range is [0,65536]
6798     * `amount`: number, integer
6799 * `add_wear_by_uses(max_uses)`
6800     * Increases wear in such a way that, if only this function is called,
6801       the item breaks after `max_uses` times
6802     * Valid `max_uses` range is [0,65536]
6803     * Does nothing if item is not a tool or if `max_uses` is 0
6804 * `add_item(item)`: returns leftover `ItemStack`
6805     * Put some item or stack onto this stack
6806 * `item_fits(item)`: returns `true` if item or stack can be fully added to
6807   this one.
6808 * `take_item(n)`: returns taken `ItemStack`
6809     * Take (and remove) up to `n` items from this stack
6810     * `n`: number, default: `1`
6811 * `peek_item(n)`: returns taken `ItemStack`
6812     * Copy (don't remove) up to `n` items from this stack
6813     * `n`: number, default: `1`
6814 * `equals(other)`:
6815     * returns `true` if this stack is identical to `other`.
6816     * Note: `stack1:to_string() == stack2:to_string()` is not reliable,
6817       as stack metadata can be serialized in arbitrary order.
6818     * Note: if `other` is an itemstring or table representation of an
6819       ItemStack, this will always return false, even if it is
6820       "equivalent".
6821
6822 ### Operators
6823
6824 * `stack1 == stack2`:
6825     * Returns whether `stack1` and `stack2` are identical.
6826     * Note: `stack1:to_string() == stack2:to_string()` is not reliable,
6827       as stack metadata can be serialized in arbitrary order.
6828     * Note: if `stack2` is an itemstring or table representation of an
6829       ItemStack, this will always return false, even if it is
6830       "equivalent".
6831
6832 `ItemStackMetaRef`
6833 ------------------
6834
6835 ItemStack metadata: reference extra data and functionality stored in a stack.
6836 Can be obtained via `item:get_meta()`.
6837
6838 ### Methods
6839
6840 * All methods in MetaDataRef
6841 * `set_tool_capabilities([tool_capabilities])`
6842     * Overrides the item's tool capabilities
6843     * A nil value will clear the override data and restore the original
6844       behavior.
6845
6846 `MetaDataRef`
6847 -------------
6848
6849 Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
6850 and [`PlayerMetaRef`].
6851
6852 ### Methods
6853
6854 * `contains(key)`: Returns true if key present, otherwise false.
6855     * Returns `nil` when the MetaData is inexistent.
6856 * `get(key)`: Returns `nil` if key not present, else the stored string.
6857 * `set_string(key, value)`: Value of `""` will delete the key.
6858 * `get_string(key)`: Returns `""` if key not present.
6859 * `set_int(key, value)`
6860 * `get_int(key)`: Returns `0` if key not present.
6861 * `set_float(key, value)`
6862 * `get_float(key)`: Returns `0` if key not present.
6863 * `to_table()`: returns `nil` or a table with keys:
6864     * `fields`: key-value storage
6865     * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
6866 * `from_table(nil or {})`
6867     * Any non-table value will clear the metadata
6868     * See [Node Metadata] for an example
6869     * returns `true` on success
6870 * `equals(other)`
6871     * returns `true` if this metadata has the same key-value pairs as `other`
6872
6873 `ModChannel`
6874 ------------
6875
6876 An interface to use mod channels on client and server
6877
6878 ### Methods
6879
6880 * `leave()`: leave the mod channel.
6881     * Server leaves channel `channel_name`.
6882     * No more incoming or outgoing messages can be sent to this channel from
6883       server mods.
6884     * This invalidate all future object usage.
6885     * Ensure you set mod_channel to nil after that to free Lua resources.
6886 * `is_writeable()`: returns true if channel is writeable and mod can send over
6887   it.
6888 * `send_all(message)`: Send `message` though the mod channel.
6889     * If mod channel is not writeable or invalid, message will be dropped.
6890     * Message size is limited to 65535 characters by protocol.
6891
6892 `NodeMetaRef`
6893 -------------
6894
6895 Node metadata: reference extra data and functionality stored in a node.
6896 Can be obtained via `minetest.get_meta(pos)`.
6897
6898 ### Methods
6899
6900 * All methods in MetaDataRef
6901 * `get_inventory()`: returns `InvRef`
6902 * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
6903   This will prevent them from being sent to the client. Note that the "private"
6904   status will only be remembered if an associated key-value pair exists,
6905   meaning it's best to call this when initializing all other meta (e.g.
6906   `on_construct`).
6907
6908 `NodeTimerRef`
6909 --------------
6910
6911 Node Timers: a high resolution persistent per-node timer.
6912 Can be gotten via `minetest.get_node_timer(pos)`.
6913
6914 ### Methods
6915
6916 * `set(timeout,elapsed)`
6917     * set a timer's state
6918     * `timeout` is in seconds, and supports fractional values (0.1 etc)
6919     * `elapsed` is in seconds, and supports fractional values (0.1 etc)
6920     * will trigger the node's `on_timer` function after `(timeout - elapsed)`
6921       seconds.
6922 * `start(timeout)`
6923     * start a timer
6924     * equivalent to `set(timeout,0)`
6925 * `stop()`
6926     * stops the timer
6927 * `get_timeout()`: returns current timeout in seconds
6928     * if `timeout` equals `0`, timer is inactive
6929 * `get_elapsed()`: returns current elapsed time in seconds
6930     * the node's `on_timer` function will be called after `(timeout - elapsed)`
6931       seconds.
6932 * `is_started()`: returns boolean state of timer
6933     * returns `true` if timer is started, otherwise `false`
6934
6935 `ObjectRef`
6936 -----------
6937
6938 Moving things in the game are generally these.
6939 This is basically a reference to a C++ `ServerActiveObject`.
6940
6941 ### Advice on handling `ObjectRefs`
6942
6943 When you receive an `ObjectRef` as a callback argument or from another API
6944 function, it is possible to store the reference somewhere and keep it around.
6945 It will keep functioning until the object is unloaded or removed.
6946
6947 However, doing this is **NOT** recommended as there is (intentionally) no method
6948 to test if a previously acquired `ObjectRef` is still valid.
6949 Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
6950 Lua back to the engine.
6951 Doing so is much less error-prone and you will never need to wonder if the
6952 object you are working with still exists.
6953
6954 ### Attachments
6955
6956 It is possible to attach objects to other objects (`set_attach` method).
6957
6958 When an object is attached, it is positioned relative to the parent's position
6959 and rotation. `get_pos` and `get_rotation` will always return the parent's
6960 values and changes via their setter counterparts are ignored.
6961
6962 To change position or rotation call `set_attach` again with the new values.
6963
6964 **Note**: Just like model dimensions, the relative position in `set_attach`
6965 must be multiplied by 10 compared to world positions.
6966
6967 It is also possible to attach to a bone of the parent object. In that case the
6968 child will follow movement and rotation of that bone.
6969
6970 ### Methods
6971
6972 * `get_pos()`: returns `{x=num, y=num, z=num}`
6973 * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
6974 * `get_velocity()`: returns the velocity, a vector.
6975 * `add_velocity(vel)`
6976     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
6977     * In comparison to using get_velocity, adding the velocity and then using
6978       set_velocity, add_velocity is supposed to avoid synchronization problems.
6979       Additionally, players also do not support set_velocity.
6980     * If a player:
6981         * Does not apply during free_move.
6982         * Note that since the player speed is normalized at each move step,
6983           increasing e.g. Y velocity beyond what would usually be achieved
6984           (see: physics overrides) will cause existing X/Z velocity to be reduced.
6985         * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
6986           pressing the jump key (assuming default settings)
6987 * `move_to(pos, continuous=false)`
6988     * Does an interpolated move for Lua entities for visually smooth transitions.
6989     * If `continuous` is true, the Lua entity will not be moved to the current
6990       position before starting the interpolated move.
6991     * For players this does the same as `set_pos`,`continuous` is ignored.
6992 * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
6993     * `puncher` = another `ObjectRef`,
6994     * `time_from_last_punch` = time since last punch action of the puncher
6995     * `direction`: can be `nil`
6996 * `right_click(clicker)`; `clicker` is another `ObjectRef`
6997 * `get_hp()`: returns number of health points
6998 * `set_hp(hp, reason)`: set number of health points
6999     * See reason in register_on_player_hpchange
7000     * Is limited to the range of 0 ... 65535 (2^16 - 1)
7001     * For players: HP are also limited by `hp_max` specified in object properties
7002 * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
7003 * `get_wield_list()`: returns the name of the inventory list the wielded item
7004    is in.
7005 * `get_wield_index()`: returns the index of the wielded item
7006 * `get_wielded_item()`: returns an `ItemStack`
7007 * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
7008   successful.
7009 * `set_armor_groups({group1=rating, group2=rating, ...})`
7010 * `get_armor_groups()`: returns a table with the armor group ratings
7011 * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
7012     * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
7013     * `frame_speed`: number, default: `15.0`
7014     * `frame_blend`: number, default: `0.0`
7015     * `frame_loop`: boolean, default: `true`
7016 * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
7017   `frame_loop`.
7018 * `set_animation_frame_speed(frame_speed)`
7019     * `frame_speed`: number, default: `15.0`
7020 * `set_attach(parent[, bone, position, rotation, forced_visible])`
7021     * `parent`: `ObjectRef` to attach to
7022     * `bone`: default `""` (the root bone)
7023     * `position`: relative position, default `{x=0, y=0, z=0}`
7024     * `rotation`: relative rotation in degrees, default `{x=0, y=0, z=0}`
7025     * `forced_visible`: Boolean to control whether the attached entity
7026        should appear in first person, default `false`.
7027     * Please also read the [Attachments] section above.
7028     * This command may fail silently (do nothing) when it would result
7029       in circular attachments.
7030 * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
7031     or nil if it isn't attached.
7032 * `get_children()`: returns a list of ObjectRefs that are attached to the
7033     object.
7034 * `set_detach()`
7035 * `set_bone_position([bone, position, rotation])`
7036     * `bone`: string. Default is `""`, the root bone
7037     * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
7038     * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
7039 * `get_bone_position(bone)`: returns position and rotation of the bone
7040 * `set_properties(object property table)`
7041 * `get_properties()`: returns object property table
7042 * `is_player()`: returns true for players, false otherwise
7043 * `get_nametag_attributes()`
7044     * returns a table with the attributes of the nametag of an object
7045     * {
7046         text = "",
7047         color = {a=0..255, r=0..255, g=0..255, b=0..255},
7048         bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
7049       }
7050 * `set_nametag_attributes(attributes)`
7051     * sets the attributes of the nametag of an object
7052     * `attributes`:
7053       {
7054         text = "My Nametag",
7055         color = ColorSpec,
7056         -- ^ Text color
7057         bgcolor = ColorSpec or false,
7058         -- ^ Sets background color of nametag
7059         -- `false` will cause the background to be set automatically based on user settings
7060         -- Default: false
7061       }
7062
7063 #### Lua entity only (no-op for other objects)
7064
7065 * `remove()`: remove object
7066     * The object is removed after returning from Lua. However the `ObjectRef`
7067       itself instantly becomes unusable with all further method calls having
7068       no effect and returning `nil`.
7069 * `set_velocity(vel)`
7070     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
7071 * `set_acceleration(acc)`
7072     * `acc` is a vector
7073 * `get_acceleration()`: returns the acceleration, a vector
7074 * `set_rotation(rot)`
7075     * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
7076       and Z is roll (bank).
7077 * `get_rotation()`: returns the rotation, a vector (radians)
7078 * `set_yaw(yaw)`: sets the yaw in radians (heading).
7079 * `get_yaw()`: returns number in radians
7080 * `set_texture_mod(mod)`
7081     * Set a texture modifier to the base texture, for sprites and meshes.
7082     * When calling `set_texture_mod` again, the previous one is discarded.
7083     * `mod` the texture modifier. See [Texture modifiers].
7084 * `get_texture_mod()` returns current texture modifier
7085 * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
7086     * Specifies and starts a sprite animation
7087     * Animations iterate along the frame `y` position.
7088     * `start_frame`: {x=column number, y=row number}, the coordinate of the
7089       first frame, default: `{x=0, y=0}`
7090     * `num_frames`: Total frames in the texture, default: `1`
7091     * `framelength`: Time per animated frame in seconds, default: `0.2`
7092     * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
7093       position according to the view direction. default: `false`.
7094         * First column:  subject facing the camera
7095         * Second column: subject looking to the left
7096         * Third column:  subject backing the camera
7097         * Fourth column: subject looking to the right
7098         * Fifth column:  subject viewed from above
7099         * Sixth column:  subject viewed from below
7100 * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
7101 * `get_luaentity()`
7102
7103 #### Player only (no-op for other objects)
7104
7105 * `get_player_name()`: returns `""` if is not a player
7106 * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
7107   table {x, y, z} representing the player's instantaneous velocity in nodes/s
7108 * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
7109 * `get_look_dir()`: get camera direction as a unit vector
7110 * `get_look_vertical()`: pitch in radians
7111     * Angle ranges between -pi/2 and pi/2, which are straight up and down
7112       respectively.
7113 * `get_look_horizontal()`: yaw in radians
7114     * Angle is counter-clockwise from the +z direction.
7115 * `set_look_vertical(radians)`: sets look pitch
7116     * radians: Angle from looking forward, where positive is downwards.
7117 * `set_look_horizontal(radians)`: sets look yaw
7118     * radians: Angle from the +z direction, where positive is counter-clockwise.
7119 * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
7120   `get_look_vertical`.
7121     * Angle ranges between -pi/2 and pi/2, which are straight down and up
7122       respectively.
7123 * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
7124   `get_look_horizontal`.
7125     * Angle is counter-clockwise from the +x direction.
7126 * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
7127   `set_look_vertical`.
7128 * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
7129   `set_look_horizontal`.
7130 * `get_breath()`: returns player's breath
7131 * `set_breath(value)`: sets player's breath
7132     * values:
7133         * `0`: player is drowning
7134         * max: bubbles bar is not shown
7135         * See [Object properties] for more information
7136     * Is limited to range 0 ... 65535 (2^16 - 1)
7137 * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
7138     * `fov`: FOV value.
7139     * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
7140       Defaults to `false`.
7141     * `transition_time`: If defined, enables smooth FOV transition.
7142       Interpreted as the time (in seconds) to reach target FOV.
7143       If set to 0, FOV change is instantaneous. Defaults to 0.
7144     * Set `fov` to 0 to clear FOV override.
7145 * `get_fov()`: Returns the following:
7146     * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
7147     * Boolean indicating whether the FOV value is a multiplier.
7148     * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
7149 * `set_attribute(attribute, value)`:  DEPRECATED, use get_meta() instead
7150     * Sets an extra attribute with value on player.
7151     * `value` must be a string, or a number which will be converted to a
7152       string.
7153     * If `value` is `nil`, remove attribute from player.
7154 * `get_attribute(attribute)`:  DEPRECATED, use get_meta() instead
7155     * Returns value (a string) for extra attribute.
7156     * Returns `nil` if no attribute found.
7157 * `get_meta()`: Returns a PlayerMetaRef.
7158 * `set_inventory_formspec(formspec)`
7159     * Redefine player's inventory form
7160     * Should usually be called in `on_joinplayer`
7161     * If `formspec` is `""`, the player's inventory is disabled.
7162 * `get_inventory_formspec()`: returns a formspec string
7163 * `set_formspec_prepend(formspec)`:
7164     * the formspec string will be added to every formspec shown to the user,
7165       except for those with a no_prepend[] tag.
7166     * This should be used to set style elements such as background[] and
7167       bgcolor[], any non-style elements (eg: label) may result in weird behavior.
7168     * Only affects formspecs shown after this is called.
7169 * `get_formspec_prepend(formspec)`: returns a formspec string.
7170 * `get_player_control()`: returns table with player pressed keys
7171     * The table consists of fields with the following boolean values
7172       representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
7173       `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
7174     * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
7175       and exist only to preserve backwards compatibility.
7176     * Returns an empty table `{}` if the object is not a player.
7177 * `get_player_control_bits()`: returns integer with bit packed player pressed
7178   keys.
7179     * Bits:
7180         * 0 - up
7181         * 1 - down
7182         * 2 - left
7183         * 3 - right
7184         * 4 - jump
7185         * 5 - aux1
7186         * 6 - sneak
7187         * 7 - dig
7188         * 8 - place
7189         * 9 - zoom
7190     * Returns `0` (no bits set) if the object is not a player.
7191 * `set_physics_override(override_table)`
7192     * `override_table` is a table with the following fields:
7193         * `speed`: multiplier to default walking speed value (default: `1`)
7194         * `jump`: multiplier to default jump value (default: `1`)
7195         * `gravity`: multiplier to default gravity value (default: `1`)
7196         * `sneak`: whether player can sneak (default: `true`)
7197         * `sneak_glitch`: whether player can use the new move code replications
7198           of the old sneak side-effects: sneak ladders and 2 node sneak jump
7199           (default: `false`)
7200         * `new_move`: use new move/sneak code. When `false` the exact old code
7201           is used for the specific old sneak behavior (default: `true`)
7202 * `get_physics_override()`: returns the table given to `set_physics_override`
7203 * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
7204    number on success
7205 * `hud_remove(id)`: remove the HUD element of the specified id
7206 * `hud_change(id, stat, value)`: change a value of a previously added HUD
7207   element.
7208     * `stat` supports the same keys as in the hud definition table except for
7209       `"hud_elem_type"`.
7210 * `hud_get(id)`: gets the HUD element definition structure of the specified ID
7211 * `hud_set_flags(flags)`: sets specified HUD flags of player.
7212     * `flags`: A table with the following fields set to boolean values
7213         * `hotbar`
7214         * `healthbar`
7215         * `crosshair`
7216         * `wielditem`
7217         * `breathbar`
7218         * `minimap`: Modifies the client's permission to view the minimap.
7219           The client may locally elect to not view the minimap.
7220         * `minimap_radar`: is only usable when `minimap` is true
7221         * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
7222           This includes map seed, player position, look direction, the pointed node and block bounds.
7223           Does not affect players with the `debug` privilege.
7224     * If a flag equals `nil`, the flag is not modified
7225 * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
7226     * See `hud_set_flags` for a list of flags that can be toggled.
7227 * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
7228     * `count`: number of items, must be between `1` and `32`
7229 * `hud_get_hotbar_itemcount`: returns number of visible items
7230 * `hud_set_hotbar_image(texturename)`
7231     * sets background image for hotbar
7232 * `hud_get_hotbar_image`: returns texturename
7233 * `hud_set_hotbar_selected_image(texturename)`
7234     * sets image for selected item of hotbar
7235 * `hud_get_hotbar_selected_image`: returns texturename
7236 * `set_minimap_modes({mode, mode, ...}, selected_mode)`
7237     * Overrides the available minimap modes (and toggle order), and changes the
7238     selected mode.
7239     * `mode` is a table consisting of up to four fields:
7240         * `type`: Available type:
7241             * `off`: Minimap off
7242             * `surface`: Minimap in surface mode
7243             * `radar`: Minimap in radar mode
7244             * `texture`: Texture to be displayed instead of terrain map
7245               (texture is centered around 0,0 and can be scaled).
7246               Texture size is limited to 512 x 512 pixel.
7247         * `label`: Optional label to display on minimap mode toggle
7248           The translation must be handled within the mod.
7249         * `size`: Sidelength or diameter, in number of nodes, of the terrain
7250           displayed in minimap
7251         * `texture`: Only for texture type, name of the texture to display
7252         * `scale`: Only for texture type, scale of the texture map in nodes per
7253           pixel (for example a `scale` of 2 means each pixel represents a 2x2
7254           nodes square)
7255     * `selected_mode` is the mode index to be selected after modes have been changed
7256     (0 is the first mode).
7257 * `set_sky(sky_parameters)`
7258     * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
7259       whether `set_sky` accepts this format. Check the legacy format otherwise.
7260     * Passing no arguments resets the sky to its default values.
7261     * `sky_parameters` is a table with the following optional fields:
7262         * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
7263           (default: `#ffffff`)
7264         * `type`: Available types:
7265             * `"regular"`: Uses 0 textures, `base_color` ignored
7266             * `"skybox"`: Uses 6 textures, `base_color` used as fog.
7267             * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
7268             (default: `"regular"`)
7269         * `textures`: A table containing up to six textures in the following
7270             order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
7271         * `clouds`: Boolean for whether clouds appear. (default: `true`)
7272         * `sky_color`: A table used in `"regular"` type only, containing the
7273           following values (alpha is ignored):
7274             * `day_sky`: ColorSpec, for the top half of the sky during the day.
7275               (default: `#61b5f5`)
7276             * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
7277               (default: `#90d3f6`)
7278             * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
7279               (default: `#b4bafa`)
7280               The resulting sky color will be a darkened version of the ColorSpec.
7281               Warning: The darkening of the ColorSpec is subject to change.
7282             * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
7283               (default: `#bac1f0`)
7284               The resulting sky color will be a darkened version of the ColorSpec.
7285               Warning: The darkening of the ColorSpec is subject to change.
7286             * `night_sky`: ColorSpec, for the top half of the sky during the night.
7287               (default: `#006bff`)
7288               The resulting sky color will be a dark version of the ColorSpec.
7289               Warning: The darkening of the ColorSpec is subject to change.
7290             * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
7291               (default: `#4090ff`)
7292               The resulting sky color will be a dark version of the ColorSpec.
7293               Warning: The darkening of the ColorSpec is subject to change.
7294             * `indoors`: ColorSpec, for when you're either indoors or underground.
7295               (default: `#646464`)
7296             * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
7297               at sunrise and sunset. (default: `#f47d1d`)
7298             * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
7299               at sunrise and sunset. (default: `#7f99cc`)
7300             * `fog_tint_type`: string, changes which mode the directional fog
7301                 abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
7302                 `"default"` uses the classic Minetest sun and moon tinting.
7303                 Will use tonemaps, if set to `"default"`. (default: `"default"`)
7304 * `set_sky(base_color, type, {texture names}, clouds)`
7305     * Deprecated. Use `set_sky(sky_parameters)`
7306     * `base_color`: ColorSpec, defaults to white
7307     * `type`: Available types:
7308         * `"regular"`: Uses 0 textures, `bgcolor` ignored
7309         * `"skybox"`: Uses 6 textures, `bgcolor` used
7310         * `"plain"`: Uses 0 textures, `bgcolor` used
7311     * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
7312       `"plain"` custom skyboxes (default: `true`)
7313 * `get_sky(as_table)`:
7314     * `as_table`: boolean that determines whether the deprecated version of this
7315     function is being used.
7316         * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
7317         * Deprecated: `false` or `nil` returns base_color, type, table of textures,
7318         clouds.
7319 * `get_sky_color()`:
7320     * Deprecated: Use `get_sky(as_table)` instead.
7321     * returns a table with the `sky_color` parameters as in `set_sky`.
7322 * `set_sun(sun_parameters)`:
7323     * Passing no arguments resets the sun to its default values.
7324     * `sun_parameters` is a table with the following optional fields:
7325         * `visible`: Boolean for whether the sun is visible.
7326             (default: `true`)
7327         * `texture`: A regular texture for the sun. Setting to `""`
7328             will re-enable the mesh sun. (default: "sun.png", if it exists)
7329             The texture appears non-rotated at sunrise and rotated 180 degrees
7330             (upside down) at sunset.
7331         * `tonemap`: A 512x1 texture containing the tonemap for the sun
7332             (default: `"sun_tonemap.png"`)
7333         * `sunrise`: A regular texture for the sunrise texture.
7334             (default: `"sunrisebg.png"`)
7335         * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
7336             (default: `true`)
7337         * `scale`: Float controlling the overall size of the sun. (default: `1`)
7338             Note: For legacy reasons, the sun is bigger than the moon by a factor
7339             of about `1.57` for equal `scale` values.
7340 * `get_sun()`: returns a table with the current sun parameters as in
7341     `set_sun`.
7342 * `set_moon(moon_parameters)`:
7343     * Passing no arguments resets the moon to its default values.
7344     * `moon_parameters` is a table with the following optional fields:
7345         * `visible`: Boolean for whether the moon is visible.
7346             (default: `true`)
7347         * `texture`: A regular texture for the moon. Setting to `""`
7348             will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
7349             The texture appears non-rotated at sunrise / moonset and rotated 180
7350             degrees (upside down) at sunset / moonrise.
7351             Note: Relative to the sun, the moon texture is hence rotated by 180°.
7352             You can use the `^[transformR180` texture modifier to achieve the same orientation.
7353         * `tonemap`: A 512x1 texture containing the tonemap for the moon
7354             (default: `"moon_tonemap.png"`)
7355         * `scale`: Float controlling the overall size of the moon (default: `1`)
7356             Note: For legacy reasons, the sun is bigger than the moon by a factor
7357             of about `1.57` for equal `scale` values.
7358 * `get_moon()`: returns a table with the current moon parameters as in
7359     `set_moon`.
7360 * `set_stars(star_parameters)`:
7361     * Passing no arguments resets stars to their default values.
7362     * `star_parameters` is a table with the following optional fields:
7363         * `visible`: Boolean for whether the stars are visible.
7364             (default: `true`)
7365         * `day_opacity`: Float for maximum opacity of stars at day.
7366             No effect if `visible` is false.
7367             (default: 0.0; maximum: 1.0; minimum: 0.0)
7368         * `count`: Integer number to set the number of stars in
7369             the skybox. Only applies to `"skybox"` and `"regular"` sky types.
7370             (default: `1000`)
7371         * `star_color`: ColorSpec, sets the colors of the stars,
7372             alpha channel is used to set overall star brightness.
7373             (default: `#ebebff69`)
7374         * `scale`: Float controlling the overall size of the stars (default: `1`)
7375 * `get_stars()`: returns a table with the current stars parameters as in
7376     `set_stars`.
7377 * `set_clouds(cloud_parameters)`: set cloud parameters
7378     * Passing no arguments resets clouds to their default values.
7379     * `cloud_parameters` is a table with the following optional fields:
7380         * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
7381         * `color`: basic cloud color with alpha channel, ColorSpec
7382           (default `#fff0f0e5`).
7383         * `ambient`: cloud color lower bound, use for a "glow at night" effect.
7384           ColorSpec (alpha ignored, default `#000000`)
7385         * `height`: cloud height, i.e. y of cloud base (default per conf,
7386           usually `120`)
7387         * `thickness`: cloud thickness in nodes (default `16`)
7388         * `speed`: 2D cloud speed + direction in nodes per second
7389           (default `{x=0, z=-2}`).
7390 * `get_clouds()`: returns a table with the current cloud parameters as in
7391   `set_clouds`.
7392 * `override_day_night_ratio(ratio or nil)`
7393     * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
7394       amount.
7395     * `nil`: Disables override, defaulting to sunlight based on day-night cycle
7396 * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
7397 * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
7398   set animation for player model in third person view.
7399     * Every animation equals to a `{x=starting frame, y=ending frame}` table.
7400     * `frame_speed` sets the animations frame speed. Default is 30.
7401 * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
7402   `frame_speed`.
7403 * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
7404   camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
7405     * in first person view
7406     * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
7407 * `get_eye_offset()`: returns first and third person offsets.
7408 * `send_mapblock(blockpos)`:
7409     * Sends an already loaded mapblock to the player.
7410     * Returns `false` if nothing was sent (note that this can also mean that
7411       the client already has the block)
7412     * Resource intensive - use sparsely
7413 * `set_lighting(light_definition)`: sets lighting for the player
7414     * `light_definition` is a table with the following optional fields:
7415       * `shadows` is a table that controls ambient shadows
7416         * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
7417 * `get_lighting()`: returns the current state of lighting for the player.
7418     * Result is a table with the same fields as `light_definition` in `set_lighting`.
7419 * `respawn()`: Respawns the player using the same mechanism as the death screen,
7420   including calling on_respawnplayer callbacks.
7421
7422 `PcgRandom`
7423 -----------
7424
7425 A 32-bit pseudorandom number generator.
7426 Uses PCG32, an algorithm of the permuted congruential generator family,
7427 offering very strong randomness.
7428
7429 It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
7430
7431 ### Methods
7432
7433 * `next()`: return next integer random number [`-2147483648`...`2147483647`]
7434 * `next(min, max)`: return next integer random number [`min`...`max`]
7435 * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
7436   random number [`min`...`max`].
7437     * This is only a rough approximation of a normal distribution with:
7438     * `mean = (max - min) / 2`, and
7439     * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
7440     * Increasing `num_trials` improves accuracy of the approximation
7441
7442 `PerlinNoise`
7443 -------------
7444
7445 A perlin noise generator.
7446 It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
7447 For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
7448 plus the world seed, to create world-specific noise.
7449
7450 `PerlinNoise(noiseparams)`
7451 `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
7452
7453 `minetest.get_perlin(noiseparams)`
7454 `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
7455
7456 ### Methods
7457
7458 * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
7459 * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
7460
7461 `PerlinNoiseMap`
7462 ----------------
7463
7464 A fast, bulk perlin noise generator.
7465
7466 It can be created via `PerlinNoiseMap(noiseparams, size)` or
7467 `minetest.get_perlin_map(noiseparams, size)`.
7468 For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
7469 plus the world seed, to create world-specific noise.
7470
7471 Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
7472 for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
7473 `nil` is returned).
7474
7475 For each of the functions with an optional `buffer` parameter: If `buffer` is
7476 not nil, this table will be used to store the result instead of creating a new
7477 table.
7478
7479 ### Methods
7480
7481 * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
7482   with values starting at `pos={x=,y=}`
7483 * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
7484   3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
7485 * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
7486   array of 2D noise with values starting at `pos={x=,y=}`
7487 * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
7488 * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
7489   is stored internally.
7490 * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
7491   is stored internally.
7492 * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
7493   returns a slice of the most recently computed noise results. The result slice
7494   begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
7495   E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
7496   offset y = 20:
7497   `noisevals = noise:get_map_slice({y=20}, {y=2})`
7498   It is important to note that `slice_offset` offset coordinates begin at 1,
7499   and are relative to the starting position of the most recently calculated
7500   noise.
7501   To grab a single vertical column of noise starting at map coordinates
7502   x = 1023, y=1000, z = 1000:
7503   `noise:calc_3d_map({x=1000, y=1000, z=1000})`
7504   `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
7505
7506 `PlayerMetaRef`
7507 ---------------
7508
7509 Player metadata.
7510 Uses the same method of storage as the deprecated player attribute API, so
7511 data there will also be in player meta.
7512 Can be obtained using `player:get_meta()`.
7513
7514 ### Methods
7515
7516 * All methods in MetaDataRef
7517
7518 `PseudoRandom`
7519 --------------
7520
7521 A 16-bit pseudorandom number generator.
7522 Uses a well-known LCG algorithm introduced by K&R.
7523
7524 It can be created via `PseudoRandom(seed)`.
7525
7526 ### Methods
7527
7528 * `next()`: return next integer random number [`0`...`32767`]
7529 * `next(min, max)`: return next integer random number [`min`...`max`]
7530     * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
7531       due to the simple implementation making bad distribution otherwise.
7532
7533 `Raycast`
7534 ---------
7535
7536 A raycast on the map. It works with selection boxes.
7537 Can be used as an iterator in a for loop as:
7538
7539     local ray = Raycast(...)
7540     for pointed_thing in ray do
7541         ...
7542     end
7543
7544 The map is loaded as the ray advances. If the map is modified after the
7545 `Raycast` is created, the changes may or may not have an effect on the object.
7546
7547 It can be created via `Raycast(pos1, pos2, objects, liquids)` or
7548 `minetest.raycast(pos1, pos2, objects, liquids)` where:
7549
7550 * `pos1`: start of the ray
7551 * `pos2`: end of the ray
7552 * `objects`: if false, only nodes will be returned. Default is true.
7553 * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
7554              returned. Default is false.
7555
7556 ### Methods
7557
7558 * `next()`: returns a `pointed_thing` with exact pointing location
7559     * Returns the next thing pointed by the ray or nil.
7560
7561 `SecureRandom`
7562 --------------
7563
7564 Interface for the operating system's crypto-secure PRNG.
7565
7566 It can be created via `SecureRandom()`.  The constructor returns nil if a
7567 secure random device cannot be found on the system.
7568
7569 ### Methods
7570
7571 * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
7572   random bytes, as a string.
7573
7574 `Settings`
7575 ----------
7576
7577 An interface to read config files in the format of `minetest.conf`.
7578
7579 It can be created via `Settings(filename)`.
7580
7581 ### Methods
7582
7583 * `get(key)`: returns a value
7584 * `get_bool(key, [default])`: returns a boolean
7585     * `default` is the value returned if `key` is not found.
7586     * Returns `nil` if `key` is not found and `default` not specified.
7587 * `get_np_group(key)`: returns a NoiseParams table
7588 * `get_flags(key)`:
7589     * Returns `{flag = true/false, ...}` according to the set flags.
7590     * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
7591       flags like `mgv5_spflags`.
7592 * `set(key, value)`
7593     * Setting names can't contain whitespace or any of `="{}#`.
7594     * Setting values can't contain the sequence `\n"""`.
7595     * Setting names starting with "secure." can't be set on the main settings
7596       object (`minetest.settings`).
7597 * `set_bool(key, value)`
7598     * See documentation for set() above.
7599 * `set_np_group(key, value)`
7600     * `value` is a NoiseParams table.
7601     * Also, see documentation for set() above.
7602 * `remove(key)`: returns a boolean (`true` for success)
7603 * `get_names()`: returns `{key1,...}`
7604 * `write()`: returns a boolean (`true` for success)
7605     * Writes changes to file.
7606 * `to_table()`: returns `{[key1]=value1,...}`
7607
7608 ### Format
7609
7610 The settings have the format `key = value`. Example:
7611
7612     foo = example text
7613     bar = """
7614     Multiline
7615     value
7616     """
7617
7618
7619 `StorageRef`
7620 ------------
7621
7622 Mod metadata: per mod metadata, saved automatically.
7623 Can be obtained via `minetest.get_mod_storage()` during load time.
7624
7625 WARNING: This storage backend is incapable of saving raw binary data due
7626 to restrictions of JSON.
7627
7628 ### Methods
7629
7630 * All methods in MetaDataRef
7631
7632
7633
7634
7635 Definition tables
7636 =================
7637
7638 Object properties
7639 -----------------
7640
7641 Used by `ObjectRef` methods. Part of an Entity definition.
7642 These properties are not persistent, but are applied automatically to the
7643 corresponding Lua entity using the given registration fields.
7644 Player properties need to be saved manually.
7645
7646     {
7647         hp_max = 10,
7648         -- Defines the maximum and default HP of the entity
7649         -- For Lua entities the maximum is not enforced.
7650         -- For players this defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
7651
7652         breath_max = 0,
7653         -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
7654
7655         zoom_fov = 0.0,
7656         -- For players only. Zoom FOV in degrees.
7657         -- Note that zoom loads and/or generates world beyond the server's
7658         -- maximum send and generate distances, so acts like a telescope.
7659         -- Smaller zoom_fov values increase the distance loaded/generated.
7660         -- Defaults to 15 in creative mode, 0 in survival mode.
7661         -- zoom_fov = 0 disables zooming for the player.
7662
7663         eye_height = 1.625,
7664         -- For players only. Camera height above feet position in nodes.
7665
7666         physical = false,
7667         -- Collide with `walkable` nodes.
7668
7669         collide_with_objects = true,
7670         -- Collide with other objects if physical = true
7671
7672         collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
7673         selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
7674         -- Selection box uses collision box dimensions when not set.
7675         -- For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
7676         -- object position.
7677
7678         pointable = true,
7679         -- Whether the object can be pointed at
7680
7681         visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
7682         -- "cube" is a node-sized cube.
7683         -- "sprite" is a flat texture always facing the player.
7684         -- "upright_sprite" is a vertical flat texture.
7685         -- "mesh" uses the defined mesh model.
7686         -- "wielditem" is used for dropped items.
7687         --   (see builtin/game/item_entity.lua).
7688         --   For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
7689         --   If the item has a 'wield_image' the object will be an extrusion of
7690         --   that, otherwise:
7691         --   If 'itemname' is a cubic node or nodebox the object will appear
7692         --   identical to 'itemname'.
7693         --   If 'itemname' is a plantlike node the object will be an extrusion
7694         --   of its texture.
7695         --   Otherwise for non-node items, the object will be an extrusion of
7696         --   'inventory_image'.
7697         --   If 'itemname' contains a ColorString or palette index (e.g. from
7698         --   `minetest.itemstring_with_palette()`), the entity will inherit the color.
7699         -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
7700
7701         visual_size = {x = 1, y = 1, z = 1},
7702         -- Multipliers for the visual size. If `z` is not specified, `x` will be used
7703         -- to scale the entity along both horizontal axes.
7704
7705         mesh = "model.obj",
7706         -- File name of mesh when using "mesh" visual
7707
7708         textures = {},
7709         -- Number of required textures depends on visual.
7710         -- "cube" uses 6 textures just like a node, but all 6 must be defined.
7711         -- "sprite" uses 1 texture.
7712         -- "upright_sprite" uses 2 textures: {front, back}.
7713         -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
7714         -- "mesh" requires one texture for each mesh buffer/material (in order)
7715
7716         colors = {},
7717         -- Number of required colors depends on visual
7718
7719         use_texture_alpha = false,
7720         -- Use texture's alpha channel.
7721         -- Excludes "upright_sprite" and "wielditem".
7722         -- Note: currently causes visual issues when viewed through other
7723         -- semi-transparent materials such as water.
7724
7725         spritediv = {x = 1, y = 1},
7726         -- Used with spritesheet textures for animation and/or frame selection
7727         -- according to position relative to player.
7728         -- Defines the number of columns and rows in the spritesheet:
7729         -- {columns, rows}.
7730
7731         initial_sprite_basepos = {x = 0, y = 0},
7732         -- Used with spritesheet textures.
7733         -- Defines the {column, row} position of the initially used frame in the
7734         -- spritesheet.
7735
7736         is_visible = true,
7737         -- If false, object is invisible and can't be pointed.
7738
7739         makes_footstep_sound = false,
7740         -- If true, is able to make footstep sounds of nodes
7741         -- (see node sound definition for details).
7742
7743         automatic_rotate = 0,
7744         -- Set constant rotation in radians per second, positive or negative.
7745         -- Object rotates along the local Y-axis, and works with set_rotation.
7746         -- Set to 0 to disable constant rotation.
7747
7748         stepheight = 0,
7749         -- If positive number, object will climb upwards when it moves
7750         -- horizontally against a `walkable` node, if the height difference
7751         -- is within `stepheight`.
7752
7753         automatic_face_movement_dir = 0.0,
7754         -- Automatically set yaw to movement direction, offset in degrees.
7755         -- 'false' to disable.
7756
7757         automatic_face_movement_max_rotation_per_sec = -1,
7758         -- Limit automatic rotation to this value in degrees per second.
7759         -- No limit if value <= 0.
7760
7761         backface_culling = true,
7762         -- Set to false to disable backface_culling for model
7763
7764         glow = 0,
7765         -- Add this much extra lighting when calculating texture color.
7766         -- Value < 0 disables light's effect on texture color.
7767         -- For faking self-lighting, UI style entities, or programmatic coloring
7768         -- in mods.
7769
7770         nametag = "",
7771         -- The name to display on the head of the object. By default empty.
7772         -- If the object is a player, a nil or empty nametag is replaced by the player's name.
7773         -- For all other objects, a nil or empty string removes the nametag.
7774         -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
7775
7776         nametag_color = <ColorSpec>,
7777         -- Sets text color of nametag
7778
7779         nametag_bgcolor = <ColorSpec>,
7780         -- Sets background color of nametag
7781         -- `false` will cause the background to be set automatically based on user settings.
7782         -- Default: false
7783
7784         infotext = "",
7785         -- Same as infotext for nodes. Empty by default
7786
7787         static_save = true,
7788         -- If false, never save this object statically. It will simply be
7789         -- deleted when the block gets unloaded.
7790         -- The get_staticdata() callback is never called then.
7791         -- Defaults to 'true'.
7792
7793         damage_texture_modifier = "^[brighten",
7794         -- Texture modifier to be applied for a short duration when object is hit
7795
7796         shaded = true,
7797         -- Setting this to 'false' disables diffuse lighting of entity
7798
7799         show_on_minimap = false,
7800         -- Defaults to true for players, false for other entities.
7801         -- If set to true the entity will show as a marker on the minimap.
7802     }
7803
7804 Entity definition
7805 -----------------
7806
7807 Used by `minetest.register_entity`.
7808
7809     {
7810         initial_properties = {
7811             visual = "mesh",
7812             mesh = "boats_boat.obj",
7813             ...,
7814         },
7815         -- A table of object properties, see the `Object properties` section.
7816         -- The properties in this table are applied to the object
7817         -- once when it is spawned.
7818
7819         -- Refer to the "Registered entities" section for explanations
7820         on_activate = function(self, staticdata, dtime_s),
7821         on_deactivate = function(self, removal),
7822         on_step = function(self, dtime, moveresult),
7823         on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage),
7824         on_death = function(self, killer),
7825         on_rightclick = function(self, clicker),
7826         on_attach_child = function(self, child),
7827         on_detach_child = function(self, child),
7828         on_detach = function(self, parent),
7829         get_staticdata = function(self),
7830
7831         _custom_field = whatever,
7832         -- You can define arbitrary member variables here (see Item definition
7833         -- for more info) by using a '_' prefix
7834     }
7835
7836
7837 ABM (ActiveBlockModifier) definition
7838 ------------------------------------
7839
7840 Used by `minetest.register_abm`.
7841
7842     {
7843         label = "Lava cooling",
7844         -- Descriptive label for profiling purposes (optional).
7845         -- Definitions with identical labels will be listed as one.
7846
7847         nodenames = {"default:lava_source"},
7848         -- Apply `action` function to these nodes.
7849         -- `group:groupname` can also be used here.
7850
7851         neighbors = {"default:water_source", "default:water_flowing"},
7852         -- Only apply `action` to nodes that have one of, or any
7853         -- combination of, these neighbors.
7854         -- If left out or empty, any neighbor will do.
7855         -- `group:groupname` can also be used here.
7856
7857         interval = 1.0,
7858         -- Operation interval in seconds
7859
7860         chance = 1,
7861         -- Chance of triggering `action` per-node per-interval is 1.0 / this
7862         -- value
7863
7864         min_y = -32768,
7865         max_y = 32767,
7866         -- min and max height levels where ABM will be processed (inclusive)
7867         -- can be used to reduce CPU usage
7868
7869         catch_up = true,
7870         -- If true, catch-up behavior is enabled: The `chance` value is
7871         -- temporarily reduced when returning to an area to simulate time lost
7872         -- by the area being unattended. Note that the `chance` value can often
7873         -- be reduced to 1.
7874
7875         action = function(pos, node, active_object_count, active_object_count_wider),
7876         -- Function triggered for each qualifying node.
7877         -- `active_object_count` is number of active objects in the node's
7878         -- mapblock.
7879         -- `active_object_count_wider` is number of active objects in the node's
7880         -- mapblock plus all 26 neighboring mapblocks. If any neighboring
7881         -- mapblocks are unloaded an estimate is calculated for them based on
7882         -- loaded mapblocks.
7883     }
7884
7885 LBM (LoadingBlockModifier) definition
7886 -------------------------------------
7887
7888 Used by `minetest.register_lbm`.
7889
7890 A loading block modifier (LBM) is used to define a function that is called for
7891 specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
7892 gets activated (not loaded!)
7893
7894     {
7895         label = "Upgrade legacy doors",
7896         -- Descriptive label for profiling purposes (optional).
7897         -- Definitions with identical labels will be listed as one.
7898
7899         name = "modname:replace_legacy_door",
7900         -- Identifier of the LBM, should follow the modname:<whatever> convention
7901
7902         nodenames = {"default:lava_source"},
7903         -- List of node names to trigger the LBM on.
7904         -- Names of non-registered nodes and groups (as group:groupname)
7905         -- will work as well.
7906
7907         run_at_every_load = false,
7908         -- Whether to run the LBM's action every time a block gets activated,
7909         -- and not only the first time the block gets activated after the LBM
7910         -- was introduced.
7911
7912         action = function(pos, node),
7913         -- Function triggered for each qualifying node.
7914     }
7915
7916 Tile definition
7917 ---------------
7918
7919 * `"image.png"`
7920 * `{name="image.png", animation={Tile Animation definition}}`
7921 * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
7922     * backface culling enabled by default for most nodes
7923     * align style determines whether the texture will be rotated with the node
7924       or kept aligned with its surroundings. "user" means that client
7925       setting will be used, similar to `glasslike_framed_optional`.
7926       Note: supported by solid nodes and nodeboxes only.
7927     * scale is used to make texture span several (exactly `scale`) nodes,
7928       instead of just one, in each direction. Works for world-aligned
7929       textures only.
7930       Note that as the effect is applied on per-mapblock basis, `16` should
7931       be equally divisible by `scale` or you may get wrong results.
7932 * `{name="image.png", color=ColorSpec}`
7933     * the texture's color will be multiplied with this color.
7934     * the tile's color overrides the owning node's color in all cases.
7935 * deprecated, yet still supported field names:
7936     * `image` (name)
7937
7938 Tile animation definition
7939 -------------------------
7940
7941     {
7942         type = "vertical_frames",
7943
7944         aspect_w = 16,
7945         -- Width of a frame in pixels
7946
7947         aspect_h = 16,
7948         -- Height of a frame in pixels
7949
7950         length = 3.0,
7951         -- Full loop length
7952     }
7953
7954     {
7955         type = "sheet_2d",
7956
7957         frames_w = 5,
7958         -- Width in number of frames
7959
7960         frames_h = 3,
7961         -- Height in number of frames
7962
7963         frame_length = 0.5,
7964         -- Length of a single frame
7965     }
7966
7967 Item definition
7968 ---------------
7969
7970 Used by `minetest.register_node`, `minetest.register_craftitem`, and
7971 `minetest.register_tool`.
7972
7973     {
7974         description = "",
7975         -- Can contain new lines. "\n" has to be used as new line character.
7976         -- See also: `get_description` in [`ItemStack`]
7977
7978         short_description = "",
7979         -- Must not contain new lines.
7980         -- Defaults to nil.
7981         -- Use an [`ItemStack`] to get the short description, e.g.:
7982         --   ItemStack(itemname):get_short_description()
7983
7984         groups = {},
7985         -- key = name, value = rating; rating = <number>.
7986         -- If rating not applicable, use 1.
7987         -- e.g. {wool = 1, fluffy = 3}
7988         --      {soil = 2, outerspace = 1, crumbly = 1}
7989         --      {bendy = 2, snappy = 1},
7990         --      {hard = 1, metal = 1, spikes = 1}
7991
7992         inventory_image = "",
7993         -- Texture shown in the inventory GUI
7994         -- Defaults to a 3D rendering of the node if left empty.
7995
7996         inventory_overlay = "",
7997         -- An overlay texture which is not affected by colorization
7998
7999         wield_image = "",
8000         -- Texture shown when item is held in hand
8001         -- Defaults to a 3D rendering of the node if left empty.
8002
8003         wield_overlay = "",
8004         -- Like inventory_overlay but only used in the same situation as wield_image
8005
8006         wield_scale = {x = 1, y = 1, z = 1},
8007         -- Scale for the item when held in hand
8008
8009         palette = "",
8010         -- An image file containing the palette of a node.
8011         -- You can set the currently used color as the "palette_index" field of
8012         -- the item stack metadata.
8013         -- The palette is always stretched to fit indices between 0 and 255, to
8014         -- ensure compatibility with "colorfacedir" (and similar) nodes.
8015
8016         color = "#ffffffff",
8017         -- Color the item is colorized with. The palette overrides this.
8018
8019         stack_max = 99,
8020         -- Maximum amount of items that can be in a single stack.
8021         -- The default can be changed by the setting `default_stack_max`
8022
8023         range = 4.0,
8024         -- Range of node and object pointing that is possible with this item held
8025
8026         liquids_pointable = false,
8027         -- If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
8028         -- even those for which `pointable = false`
8029
8030         light_source = 0,
8031         -- When used for nodes: Defines amount of light emitted by node.
8032         -- Otherwise: Defines texture glow when viewed as a dropped item
8033         -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
8034         -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
8035         -- behavior.
8036
8037         -- See "Tool Capabilities" section for an example including explanation
8038         tool_capabilities = {
8039             full_punch_interval = 1.0,
8040             max_drop_level = 0,
8041             groupcaps = {
8042                 -- For example:
8043                 choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
8044             },
8045             damage_groups = {groupname = damage},
8046             -- Damage values must be between -32768 and 32767 (2^15)
8047
8048             punch_attack_uses = nil,
8049             -- Amount of uses this tool has for attacking players and entities
8050             -- by punching them (0 = infinite uses).
8051             -- For compatibility, this is automatically set from the first
8052             -- suitable groupcap using the formula "uses * 3^(maxlevel - 1)".
8053             -- It is recommend to set this explicitly instead of relying on the
8054             -- fallback behavior.
8055         },
8056
8057         node_placement_prediction = nil,
8058         -- If nil and item is node, prediction is made automatically.
8059         -- If nil and item is not a node, no prediction is made.
8060         -- If "" and item is anything, no prediction is made.
8061         -- Otherwise should be name of node which the client immediately places
8062         -- on ground when the player places the item. Server will always update
8063         -- with actual result shortly.
8064
8065         node_dig_prediction = "air",
8066         -- if "", no prediction is made.
8067         -- if "air", node is removed.
8068         -- Otherwise should be name of node which the client immediately places
8069         -- upon digging. Server will always update with actual result shortly.
8070
8071         sound = {
8072             -- Definition of item sounds to be played at various events.
8073             -- All fields in this table are optional.
8074
8075             breaks = <SimpleSoundSpec>,
8076             -- When tool breaks due to wear. Ignored for non-tools
8077
8078             eat = <SimpleSoundSpec>,
8079             -- When item is eaten with `minetest.do_item_eat`
8080
8081             punch_use = <SimpleSoundSpec>,
8082             -- When item is used with the 'punch/mine' key pointing at a node or entity
8083
8084             punch_use_air = <SimpleSoundSpec>,
8085             -- When item is used with the 'punch/mine' key pointing at nothing (air)
8086         },
8087
8088         on_place = function(itemstack, placer, pointed_thing),
8089         -- When the 'place' key was pressed with the item in hand
8090         -- and a node was pointed at.
8091         -- Shall place item and return the leftover itemstack
8092         -- or nil to not modify the inventory.
8093         -- The placer may be any ObjectRef or nil.
8094         -- default: minetest.item_place
8095
8096         on_secondary_use = function(itemstack, user, pointed_thing),
8097         -- Same as on_place but called when not pointing at a node.
8098         -- Function must return either nil if inventory shall not be modified,
8099         -- or an itemstack to replace the original itemstack.
8100         -- The user may be any ObjectRef or nil.
8101         -- default: nil
8102
8103         on_drop = function(itemstack, dropper, pos),
8104         -- Shall drop item and return the leftover itemstack.
8105         -- The dropper may be any ObjectRef or nil.
8106         -- default: minetest.item_drop
8107
8108         on_pickup = function(itemstack, picker, pointed_thing, time_from_last_punch, ...),
8109         -- Called when a dropped item is punched by a player.
8110         -- Shall pick-up the item and return the leftover itemstack or nil to not
8111         -- modify the dropped item.
8112         -- Parameters:
8113         -- * `itemstack`: The `ItemStack` to be picked up.
8114         -- * `picker`: Any `ObjectRef` or `nil`.
8115         -- * `pointed_thing` (optional): The dropped item (a `"__builtin:item"`
8116         --   luaentity) as `type="object"` `pointed_thing`.
8117         -- * `time_from_last_punch, ...` (optional): Other parameters from
8118         --   `luaentity:on_punch`.
8119         -- default: `minetest.item_pickup`
8120
8121         on_use = function(itemstack, user, pointed_thing),
8122         -- default: nil
8123         -- When user pressed the 'punch/mine' key with the item in hand.
8124         -- Function must return either nil if inventory shall not be modified,
8125         -- or an itemstack to replace the original itemstack.
8126         -- e.g. itemstack:take_item(); return itemstack
8127         -- Otherwise, the function is free to do what it wants.
8128         -- The user may be any ObjectRef or nil.
8129         -- The default functions handle regular use cases.
8130
8131         after_use = function(itemstack, user, node, digparams),
8132         -- default: nil
8133         -- If defined, should return an itemstack and will be called instead of
8134         -- wearing out the item (if tool). If returns nil, does nothing.
8135         -- If after_use doesn't exist, it is the same as:
8136         --   function(itemstack, user, node, digparams)
8137         --     itemstack:add_wear(digparams.wear)
8138         --     return itemstack
8139         --   end
8140         -- The user may be any ObjectRef or nil.
8141
8142         _custom_field = whatever,
8143         -- Add your own custom fields. By convention, all custom field names
8144         -- should start with `_` to avoid naming collisions with future engine
8145         -- usage.
8146     }
8147
8148 Node definition
8149 ---------------
8150
8151 Used by `minetest.register_node`.
8152
8153     {
8154         -- <all fields allowed in item definitions>
8155
8156         drawtype = "normal",  -- See "Node drawtypes"
8157
8158         visual_scale = 1.0,
8159         -- Supported for drawtypes "plantlike", "signlike", "torchlike",
8160         -- "firelike", "mesh", "nodebox", "allfaces".
8161         -- For plantlike and firelike, the image will start at the bottom of the
8162         -- node. For torchlike, the image will start at the surface to which the
8163         -- node "attaches". For the other drawtypes the image will be centered
8164         -- on the node.
8165
8166         tiles = {tile definition 1, def2, def3, def4, def5, def6},
8167         -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
8168         -- List can be shortened to needed length.
8169
8170         overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
8171         -- Same as `tiles`, but these textures are drawn on top of the base
8172         -- tiles. You can use this to colorize only specific parts of your
8173         -- texture. If the texture name is an empty string, that overlay is not
8174         -- drawn. Since such tiles are drawn twice, it is not recommended to use
8175         -- overlays on very common nodes.
8176
8177         special_tiles = {tile definition 1, Tile definition 2},
8178         -- Special textures of node; used rarely.
8179         -- List can be shortened to needed length.
8180
8181         color = ColorSpec,
8182         -- The node's original color will be multiplied with this color.
8183         -- If the node has a palette, then this setting only has an effect in
8184         -- the inventory and on the wield item.
8185
8186         use_texture_alpha = ...,
8187         -- Specifies how the texture's alpha channel will be used for rendering.
8188         -- possible values:
8189         -- * "opaque": Node is rendered opaque regardless of alpha channel
8190         -- * "clip": A given pixel is either fully see-through or opaque
8191         --           depending on the alpha channel being below/above 50% in value
8192         -- * "blend": The alpha channel specifies how transparent a given pixel
8193         --            of the rendered node is
8194         -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
8195         -- "clip" otherwise.
8196         -- If set to a boolean value (deprecated): true either sets it to blend
8197         -- or clip, false sets it to clip or opaque mode depending on the drawtype.
8198
8199         palette = "",
8200         -- The node's `param2` is used to select a pixel from the image.
8201         -- Pixels are arranged from left to right and from top to bottom.
8202         -- The node's color will be multiplied with the selected pixel's color.
8203         -- Tiles can override this behavior.
8204         -- Only when `paramtype2` supports palettes.
8205
8206         post_effect_color = "#00000000",
8207         -- Screen tint if player is inside node, see "ColorSpec"
8208
8209         paramtype = "none",  -- See "Nodes"
8210
8211         paramtype2 = "none",  -- See "Nodes"
8212
8213         place_param2 = 0,
8214         -- Value for param2 that is set when player places node
8215
8216         is_ground_content = true,
8217         -- If false, the cave generator and dungeon generator will not carve
8218         -- through this node.
8219         -- Specifically, this stops mod-added nodes being removed by caves and
8220         -- dungeons when those generate in a neighbor mapchunk and extend out
8221         -- beyond the edge of that mapchunk.
8222
8223         sunlight_propagates = false,
8224         -- If true, sunlight will go infinitely through this node
8225
8226         walkable = true,  -- If true, objects collide with node
8227
8228         pointable = true,  -- If true, can be pointed at
8229
8230         diggable = true,  -- If false, can never be dug
8231
8232         climbable = false,  -- If true, can be climbed on like a ladder
8233
8234         move_resistance = 0,
8235         -- Slows down movement of players through this node (max. 7).
8236         -- If this is nil, it will be equal to liquid_viscosity.
8237         -- Note: If liquid movement physics apply to the node
8238         -- (see `liquid_move_physics`), the movement speed will also be
8239         -- affected by the `movement_liquid_*` settings.
8240
8241         buildable_to = false,  -- If true, placed nodes can replace this node
8242
8243         floodable = false,
8244         -- If true, liquids flow into and replace this node.
8245         -- Warning: making a liquid node 'floodable' will cause problems.
8246
8247         liquidtype = "none",  -- specifies liquid flowing physics
8248         -- * "none":    no liquid flowing physics
8249         -- * "source":  spawns flowing liquid nodes at all 4 sides and below;
8250         --              recommended drawtype: "liquid".
8251         -- * "flowing": spawned from source, spawns more flowing liquid nodes
8252         --              around it until `liquid_range` is reached;
8253         --              will drain out without a source;
8254         --              recommended drawtype: "flowingliquid".
8255         -- If it's "source" or "flowing", then the
8256         -- `liquid_alternative_*` fields _must_ be specified
8257
8258         liquid_alternative_flowing = "",
8259         liquid_alternative_source = "",
8260         -- These fields may contain node names that represent the
8261         -- flowing version (`liquid_alternative_flowing`) and
8262         -- source version (`liquid_alternative_source`) of a liquid.
8263         --
8264         -- Specifically, these fields are required if any of these is true:
8265         -- * `liquidtype ~= "none" or
8266         -- * `drawtype == "liquid" or
8267         -- * `drawtype == "flowingliquid"
8268         --
8269         -- Liquids consist of up to two nodes: source and flowing.
8270         --
8271         -- There are two ways to define a liquid:
8272         -- 1) Source node and flowing node. This requires both fields to be
8273         --    specified for both nodes.
8274         -- 2) Standalone source node (cannot flow). `liquid_alternative_source`
8275         --    must be specified and `liquid_range` must be set to 0.
8276         --
8277         -- Example:
8278         --     liquid_alternative_flowing = "example:water_flowing",
8279         --     liquid_alternative_source = "example:water_source",
8280
8281         liquid_viscosity = 0,
8282         -- Controls speed at which the liquid spreads/flows (max. 7).
8283         -- 0 is fastest, 7 is slowest.
8284         -- By default, this also slows down movement of players inside the node
8285         -- (can be overridden using `move_resistance`)
8286
8287         liquid_renewable = true,
8288         -- If true, a new liquid source can be created by placing two or more
8289         -- sources nearby
8290
8291         liquid_move_physics = nil, -- specifies movement physics if inside node
8292         -- * false: No liquid movement physics apply.
8293         -- * true: Enables liquid movement physics. Enables things like
8294         --   ability to "swim" up/down, sinking slowly if not moving,
8295         --   smoother speed change when falling into, etc. The `movement_liquid_*`
8296         --   settings apply.
8297         -- * nil: Will be treated as true if `liquidtype ~= "none"`
8298         --   and as false otherwise.
8299
8300         leveled = 0,
8301         -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
8302         -- Allows defining the nodebox height without using param2.
8303         -- The nodebox height is 'leveled' / 64 nodes.
8304         -- The maximum value of 'leveled' is `leveled_max`.
8305
8306         leveled_max = 127,
8307         -- Maximum value for `leveled` (0-127), enforced in
8308         -- `minetest.set_node_level` and `minetest.add_node_level`.
8309         -- Values above 124 might causes collision detection issues.
8310
8311         liquid_range = 8,
8312         -- Maximum distance that flowing liquid nodes can spread around
8313         -- source on flat land;
8314         -- maximum = 8; set to 0 to disable liquid flow
8315
8316         drowning = 0,
8317         -- Player will take this amount of damage if no bubbles are left
8318
8319         damage_per_second = 0,
8320         -- If player is inside node, this damage is caused
8321
8322         node_box = {type = "regular"},  -- See "Node boxes"
8323
8324         connects_to = {},
8325         -- Used for nodebox nodes with the type == "connected".
8326         -- Specifies to what neighboring nodes connections will be drawn.
8327         -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
8328
8329         connect_sides = {},
8330         -- Tells connected nodebox nodes to connect only to these sides of this
8331         -- node. possible: "top", "bottom", "front", "left", "back", "right"
8332
8333         mesh = "",
8334         -- File name of mesh when using "mesh" drawtype
8335
8336         selection_box = {
8337             -- see [Node boxes] for possibilities
8338         },
8339         -- Custom selection box definition. Multiple boxes can be defined.
8340         -- If "nodebox" drawtype is used and selection_box is nil, then node_box
8341         -- definition is used for the selection box.
8342
8343         collision_box = {
8344             -- see [Node boxes] for possibilities
8345         },
8346         -- Custom collision box definition. Multiple boxes can be defined.
8347         -- If "nodebox" drawtype is used and collision_box is nil, then node_box
8348         -- definition is used for the collision box.
8349
8350         -- Support maps made in and before January 2012
8351         legacy_facedir_simple = false,
8352         legacy_wallmounted = false,
8353
8354         waving = 0,
8355         -- Valid for drawtypes:
8356         -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
8357         -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
8358         -- 2 - wave node like leaves (whole node moves side-to-side)
8359         -- 3 - wave node like liquids (whole node moves up and down)
8360         -- Not all models will properly wave.
8361         -- plantlike drawtype can only wave like plants.
8362         -- allfaces_optional drawtype can only wave like leaves.
8363         -- liquid, flowingliquid drawtypes can only wave like liquids.
8364
8365         sounds = {
8366             -- Definition of node sounds to be played at various events.
8367             -- All fields in this table are optional.
8368
8369             footstep = <SimpleSoundSpec>,
8370             -- If walkable, played when object walks on it. If node is
8371             -- climbable or a liquid, played when object moves through it
8372
8373             dig = <SimpleSoundSpec> or "__group",
8374             -- While digging node.
8375             -- If `"__group"`, then the sound will be
8376             -- `default_dig_<groupname>`, where `<groupname>` is the
8377             -- name of the item's digging group with the fastest digging time.
8378             -- In case of a tie, one of the sounds will be played (but we
8379             -- cannot predict which one)
8380             -- Default value: `"__group"`
8381
8382             dug = <SimpleSoundSpec>,
8383             -- Node was dug
8384
8385             place = <SimpleSoundSpec>,
8386             -- Node was placed. Also played after falling
8387
8388             place_failed = <SimpleSoundSpec>,
8389             -- When node placement failed.
8390             -- Note: This happens if the _built-in_ node placement failed.
8391             -- This sound will still be played if the node is placed in the
8392             -- `on_place` callback manually.
8393
8394             fall = <SimpleSoundSpec>,
8395             -- When node starts to fall or is detached
8396         },
8397
8398         drop = "",
8399         -- Name of dropped item when dug.
8400         -- Default dropped item is the node itself.
8401
8402         -- Using a table allows multiple items, drop chances and item filtering:
8403         drop = {
8404             max_items = 1,
8405             -- Maximum number of item lists to drop.
8406             -- The entries in 'items' are processed in order. For each:
8407             -- Item filtering is applied, chance of drop is applied, if both are
8408             -- successful the entire item list is dropped.
8409             -- Entry processing continues until the number of dropped item lists
8410             -- equals 'max_items'.
8411             -- Therefore, entries should progress from low to high drop chance.
8412             items = {
8413                 -- Examples:
8414                 {
8415                     -- 1 in 1000 chance of dropping a diamond.
8416                     -- Default rarity is '1'.
8417                     rarity = 1000,
8418                     items = {"default:diamond"},
8419                 },
8420                 {
8421                     -- Only drop if using an item whose name is identical to one
8422                     -- of these.
8423                     tools = {"default:shovel_mese", "default:shovel_diamond"},
8424                     rarity = 5,
8425                     items = {"default:dirt"},
8426                     -- Whether all items in the dropped item list inherit the
8427                     -- hardware coloring palette color from the dug node.
8428                     -- Default is 'false'.
8429                     inherit_color = true,
8430                 },
8431                 {
8432                     -- Only drop if using an item whose name contains
8433                     -- "default:shovel_" (this item filtering by string matching
8434                     -- is deprecated, use tool_groups instead).
8435                     tools = {"~default:shovel_"},
8436                     rarity = 2,
8437                     -- The item list dropped.
8438                     items = {"default:sand", "default:desert_sand"},
8439                 },
8440                 {
8441                     -- Only drop if using an item in the "magicwand" group, or
8442                     -- an item that is in both the "pickaxe" and the "lucky"
8443                     -- groups.
8444                     tool_groups = {
8445                         "magicwand",
8446                         {"pickaxe", "lucky"}
8447                     },
8448                     items = {"default:coal_lump"},
8449                 },
8450             },
8451         },
8452
8453         on_construct = function(pos),
8454         -- Node constructor; called after adding node.
8455         -- Can set up metadata and stuff like that.
8456         -- Not called for bulk node placement (i.e. schematics and VoxelManip).
8457         -- default: nil
8458
8459         on_destruct = function(pos),
8460         -- Node destructor; called before removing node.
8461         -- Not called for bulk node placement.
8462         -- default: nil
8463
8464         after_destruct = function(pos, oldnode),
8465         -- Node destructor; called after removing node.
8466         -- Not called for bulk node placement.
8467         -- default: nil
8468
8469         on_flood = function(pos, oldnode, newnode),
8470         -- Called when a liquid (newnode) is about to flood oldnode, if it has
8471         -- `floodable = true` in the nodedef. Not called for bulk node placement
8472         -- (i.e. schematics and VoxelManip) or air nodes. If return true the
8473         -- node is not flooded, but on_flood callback will most likely be called
8474         -- over and over again every liquid update interval.
8475         -- Default: nil
8476         -- Warning: making a liquid node 'floodable' will cause problems.
8477
8478         preserve_metadata = function(pos, oldnode, oldmeta, drops),
8479         -- Called when oldnode is about be converted to an item, but before the
8480         -- node is deleted from the world or the drops are added. This is
8481         -- generally the result of either the node being dug or an attached node
8482         -- becoming detached.
8483         -- oldmeta are the metadata fields (table) of the node before deletion.
8484         -- drops is a table of ItemStacks, so any metadata to be preserved can
8485         -- be added directly to one or more of the dropped items. See
8486         -- "ItemStackMetaRef".
8487         -- default: nil
8488
8489         after_place_node = function(pos, placer, itemstack, pointed_thing),
8490         -- Called after constructing node when node was placed using
8491         -- minetest.item_place_node / minetest.place_node.
8492         -- If return true no item is taken from itemstack.
8493         -- `placer` may be any valid ObjectRef or nil.
8494         -- default: nil
8495
8496         after_dig_node = function(pos, oldnode, oldmetadata, digger),
8497         -- oldmetadata is in table format.
8498         -- Called after destructing node when node was dug using
8499         -- minetest.node_dig / minetest.dig_node.
8500         -- default: nil
8501
8502         can_dig = function(pos, [player]),
8503         -- Returns true if node can be dug, or false if not.
8504         -- default: nil
8505
8506         on_punch = function(pos, node, puncher, pointed_thing),
8507         -- default: minetest.node_punch
8508         -- Called when puncher (an ObjectRef) punches the node at pos.
8509         -- By default calls minetest.register_on_punchnode callbacks.
8510
8511         on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
8512         -- default: nil
8513         -- Called when clicker (an ObjectRef) used the 'place/build' key
8514         -- (not necessarily an actual rightclick)
8515         -- while pointing at the node at pos with 'node' being the node table.
8516         -- itemstack will hold clicker's wielded item.
8517         -- Shall return the leftover itemstack.
8518         -- Note: pointed_thing can be nil, if a mod calls this function.
8519         -- This function does not get triggered by clients <=0.4.16 if the
8520         -- "formspec" node metadata field is set.
8521
8522         on_dig = function(pos, node, digger),
8523         -- default: minetest.node_dig
8524         -- By default checks privileges, wears out item (if tool) and removes node.
8525         -- return true if the node was dug successfully, false otherwise.
8526         -- Deprecated: returning nil is the same as returning true.
8527
8528         on_timer = function(pos, elapsed),
8529         -- default: nil
8530         -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
8531         -- elapsed is the total time passed since the timer was started.
8532         -- return true to run the timer for another cycle with the same timeout
8533         -- value.
8534
8535         on_receive_fields = function(pos, formname, fields, sender),
8536         -- fields = {name1 = value1, name2 = value2, ...}
8537         -- Called when an UI form (e.g. sign text input) returns data.
8538         -- See minetest.register_on_player_receive_fields for more info.
8539         -- default: nil
8540
8541         allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8542         -- Called when a player wants to move items inside the inventory.
8543         -- Return value: number of items allowed to move.
8544
8545         allow_metadata_inventory_put = function(pos, listname, index, stack, player),
8546         -- Called when a player wants to put something into the inventory.
8547         -- Return value: number of items allowed to put.
8548         -- Return value -1: Allow and don't modify item count in inventory.
8549
8550         allow_metadata_inventory_take = function(pos, listname, index, stack, player),
8551         -- Called when a player wants to take something out of the inventory.
8552         -- Return value: number of items allowed to take.
8553         -- Return value -1: Allow and don't modify item count in inventory.
8554
8555         on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8556         on_metadata_inventory_put = function(pos, listname, index, stack, player),
8557         on_metadata_inventory_take = function(pos, listname, index, stack, player),
8558         -- Called after the actual action has happened, according to what was
8559         -- allowed.
8560         -- No return value.
8561
8562         on_blast = function(pos, intensity),
8563         -- intensity: 1.0 = mid range of regular TNT.
8564         -- If defined, called when an explosion touches the node, instead of
8565         -- removing the node.
8566
8567         mod_origin = "modname",
8568         -- stores which mod actually registered a node
8569         -- If the source could not be determined it contains "??"
8570         -- Useful for getting which mod truly registered something
8571         -- example: if a node is registered as ":othermodname:nodename",
8572         -- nodename will show "othermodname", but mod_origin will say "modname"
8573     }
8574
8575 Crafting recipes
8576 ----------------
8577
8578 Crafting converts one or more inputs to one output itemstack of arbitrary
8579 count (except for fuels, which don't have an output). The conversion reduces
8580 each input ItemStack by 1.
8581
8582 Craft recipes are registered by `minetest.register_craft` and use a
8583 table format. The accepted parameters are listed below.
8584
8585 Recipe input items can either be specified by item name (item count = 1)
8586 or by group (see "Groups in crafting recipes" for details).
8587
8588 The following sections describe the types and syntaxes of recipes.
8589
8590 ### Shaped
8591
8592 This is the default recipe type (when no `type` is specified).
8593
8594 A shaped recipe takes one or multiple items as input and has
8595 a single item stack as output. The input items must be specified
8596 in a 2-dimensional matrix (see parameters below) to specify the
8597 exact arrangement (the "shape") in which the player must place them
8598 in the crafting grid.
8599
8600 For example, for a 3x3 recipe, the `recipes` table must have
8601 3 rows and 3 columns.
8602
8603 In order to craft the recipe, the players' crafting grid must
8604 have equal or larger dimensions (both width and height).
8605
8606 Parameters:
8607
8608 * `type = "shaped"`: (optional) specifies recipe type as shaped
8609 * `output`: Itemstring of output itemstack (item counts >= 1 are allowed)
8610 * `recipe`: A 2-dimensional matrix of items, with a width *w* and height *h*.
8611     * *w* and *h* are chosen by you, they don't have to be equal but must be at least 1
8612     * The matrix is specified as a table containing tables containing itemnames
8613     * The inner tables are the rows. There must be *h* tables, specified from the top to the bottom row
8614     * Values inside of the inner table are the columns.
8615       Each inner table must contain a list of *w* items, specified from left to right
8616     * Empty slots *must* be filled with the empty string
8617 * `replacements`: (optional) Allows you to replace input items with some other items
8618       when something is crafted
8619     * Provided as a list of item pairs of the form `{ old_item, new_item }` where
8620       `old_item` is the input item to replace (same syntax as for a regular input
8621       slot; groups are allowed) and `new_item` is an itemstring for the item stack
8622       it will become
8623     * When the output is crafted, Minetest iterates through the list
8624       of input items if the crafting grid. For each input item stack, it checks if
8625       it matches with an `old_item` in the item pair list.
8626         * If it matches, the item will be replaced. Also, this item pair
8627           will *not* be applied again for the remaining items
8628         * If it does not match, the item is consumed (reduced by 1) normally
8629     * The `new_item` will appear in one of 3 places:
8630         * Crafting grid, if the input stack size was exactly 1
8631         * Player inventory, if input stack size was larger
8632         * Drops as item entity, if it fits neither in craft grid or inventory
8633
8634 #### Examples
8635
8636 A typical shaped recipe:
8637
8638     -- Stone pickaxe
8639     {
8640         output = "example:stone_pickaxe",
8641         -- A 3x3 recipe which needs 3 stone in the 1st row,
8642         -- and 1 stick in the horizontal middle in each of the 2nd and 3nd row.
8643         -- The 4 remaining slots have to be empty.
8644         recipe = {
8645             {"example:stone", "example:stone", "example:stone"}, -- row 1
8646             {"",              "example:stick", ""             }, -- row 2
8647             {"",              "example:stick", ""             }, -- row 3
8648         --   ^ column 1       ^ column 2       ^ column 3
8649         },
8650         -- There is no replacements table, so every input item
8651         -- will be consumed.
8652     }
8653
8654 Simple replacement example:
8655
8656     -- Wet sponge
8657     {
8658         output = "example:wet_sponge",
8659         -- 1x2 recipe with a water bucket above a dry sponge
8660         recipe = {
8661             {"example:water_bucket"},
8662             {"example:dry_sponge"},
8663         },
8664         -- When the wet sponge is crafted, the water bucket
8665         -- in the input slot is replaced with an empty
8666         -- bucket
8667         replacements = {
8668             {"example:water_bucket", "example:empty_bucket"},
8669         },
8670     }
8671
8672 Complex replacement example 1:
8673
8674     -- Very wet sponge
8675     {
8676         output = "example:very_wet_sponge",
8677         -- 3x3 recipe with a wet sponge in the center
8678         -- and 4 water buckets around it
8679         recipe = {
8680             {"","example:water_bucket",""},
8681             {"example:water_bucket","example:wet_sponge","example:water_bucket"},
8682             {"","example:water_bucket",""},
8683         },
8684         -- When the wet sponge is crafted, all water buckets
8685         -- in the input slot become empty
8686         replacements = {
8687             -- Without these repetitions, only the first
8688             -- water bucket would be replaced.
8689             {"example:water_bucket", "example:empty_bucket"},
8690             {"example:water_bucket", "example:empty_bucket"},
8691             {"example:water_bucket", "example:empty_bucket"},
8692             {"example:water_bucket", "example:empty_bucket"},
8693         },
8694     }
8695
8696 Complex replacement example 2:
8697
8698     -- Magic book:
8699     -- 3 magic orbs + 1 book crafts a magic book,
8700     -- and the orbs will be replaced with 3 different runes.
8701     {
8702         output = "example:magic_book",
8703         -- 3x2 recipe
8704         recipe = {
8705             -- 3 items in the group `magic_orb` on top of a book in the middle
8706             {"group:magic_orb", "group:magic_orb", "group:magic_orb"},
8707             {"", "example:book", ""},
8708         },
8709         -- When the book is crafted, the 3 magic orbs will be turned into
8710         -- 3 runes: ice rune, earth rune and fire rune (from left to right)
8711         replacements = {
8712             {"group:magic_orb", "example:ice_rune"},
8713             {"group:magic_orb", "example:earth_rune"},
8714             {"group:magic_orb", "example:fire_rune"},
8715         },
8716     }
8717
8718 ### Shapeless
8719
8720 Takes a list of input items (at least 1). The order or arrangement
8721 of input items does not matter.
8722
8723 In order to craft the recipe, the players' crafting grid must have matching or
8724 larger *count* of slots. The grid dimensions do not matter.
8725
8726 Parameters:
8727
8728 * `type = "shapeless"`: Mandatory
8729 * `output`: Same as for shaped recipe
8730 * `recipe`: List of item names
8731 * `replacements`: Same as for shaped recipe
8732
8733 #### Example
8734
8735     {
8736         -- Craft a mushroom stew from a bowl, a brown mushroom and a red mushroom
8737         -- (no matter where in the input grid the items are placed)
8738         type = "shapeless",
8739         output = "example:mushroom_stew",
8740         recipe = {
8741             "example:bowl",
8742             "example:mushroom_brown",
8743             "example:mushroom_red",
8744         },
8745     }
8746
8747 ### Tool repair
8748
8749 Syntax:
8750
8751     {
8752         type = "toolrepair",
8753         additional_wear = -0.02, -- multiplier of 65536
8754     }
8755
8756 Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
8757 group. If this recipe is used, repairing is possible with any crafting grid
8758 with at least 2 slots.
8759 The player can put 2 equal tools in the craft grid to get one "repaired" tool
8760 back.
8761 The wear of the output is determined by the wear of both tools, plus a
8762 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
8763 you want `additional_wear` to be negative.
8764
8765 The formula used to calculate the resulting wear is:
8766
8767     65536 * (1 - ( (1 - tool_1_wear) + (1 - tool_2_wear) + additional_wear))
8768
8769 The result is rounded and can't be lower than 0. If the result is 65536 or higher,
8770 no crafting is possible.
8771
8772 ### Cooking
8773
8774 A cooking recipe has a single input item, a single output item stack
8775 and a cooking time. It represents cooking/baking/smelting/etc. items in
8776 an oven, furnace, or something similar; the exact meaning is up for games
8777 to decide, if they choose to use cooking at all.
8778
8779 The engine does not implement anything specific to cooking recipes, but
8780 the recipes can be retrieved later using `minetest.get_craft_result` to
8781 have a consistent interface across different games/mods.
8782
8783 Parameters:
8784
8785 * `type = "cooking"`: Mandatory
8786 * `output`: Same as for shaped recipe
8787 * `recipe`: An itemname of the single input item
8788 * `cooktime`: (optional) Time it takes to cook this item, in seconds.
8789               A floating-point number. (default: 3.0)
8790 * `replacements`: Same meaning as for shaped recipes, but the mods
8791                   that utilize cooking recipes (e.g. for adding a furnace
8792                   node) need to implement replacements on their own
8793
8794 Note: Games and mods are free to re-interpret the cooktime in special
8795 cases, e.g. for a super furnace that cooks items twice as fast.
8796
8797 #### Example
8798
8799 Cooking sand to glass in 3 seconds:
8800
8801     {
8802         type = "cooking",
8803         output = "example:glass",
8804         recipe = "example:sand",
8805         cooktime = 3.0,
8806     }
8807
8808 ### Fuel
8809
8810 A fuel recipe is an item associated with a "burning time" and an optional
8811 item replacement. There is no output. This is usually used as fuel for
8812 furnaces, ovens, stoves, etc.
8813
8814 Like with cooking recipes, the engine does not do anything specific with
8815 fuel recipes and it's up to games and mods to use them by retrieving
8816 them via `minetest.get_craft_result`.
8817
8818 Parameters:
8819
8820 * `type = "fuel"`: Mandatory
8821 * `recipe`: Itemname of the item to be used as fuel
8822 * `burntime`: (optional) Burning time this item provides, in seconds.
8823               A floating-point number. (default: 1.0)
8824 * `replacements`: Same meaning as for shaped recipes, but the mods
8825                   that utilize fuels need to implement replacements
8826                   on their own
8827
8828 Note: Games and mods are free to re-interpret the burntime in special
8829 cases, e.g. for an efficient furnace in which fuels burn twice as
8830 long.
8831
8832 #### Examples
8833
8834 Coal lump with a burntime of 20 seconds. Will be consumed when used.
8835
8836     {
8837         type = "fuel",
8838         recipe = "example:coal_lump",
8839         burntime = 20.0,
8840     }
8841
8842 Lava bucket with a burn time of 60 seconds. Will become an empty bucket
8843 if used:
8844
8845     {
8846         type = "fuel",
8847         recipe = "example:lava_bucket",
8848         burntime = 60.0,
8849         replacements = {{"example:lava_bucket", "example:empty_bucket"}},
8850     }
8851
8852 Ore definition
8853 --------------
8854
8855 Used by `minetest.register_ore`.
8856
8857 See [Ores] section above for essential information.
8858
8859     {
8860         ore_type = "",
8861         -- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
8862
8863         ore = "",
8864         -- Ore node to place
8865
8866         ore_param2 = 0,
8867         -- Param2 to set for ore (e.g. facedir rotation)
8868
8869         wherein = "",
8870         -- Node to place ore in. Multiple are possible by passing a list.
8871
8872         clust_scarcity = 8 * 8 * 8,
8873         -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
8874         -- If the desired average distance between ores is 'd', set this to
8875         -- d * d * d.
8876
8877         clust_num_ores = 8,
8878         -- Number of ores in a cluster
8879
8880         clust_size = 3,
8881         -- Size of the bounding box of the cluster.
8882         -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
8883         -- nodes are coal ore.
8884
8885         y_min = -31000,
8886         y_max = 31000,
8887         -- Lower and upper limits for ore (inclusive)
8888
8889         flags = "",
8890         -- Attributes for the ore generation, see 'Ore attributes' section above
8891
8892         noise_threshold = 0,
8893         -- If noise is above this threshold, ore is placed. Not needed for a
8894         -- uniform distribution.
8895
8896         noise_params = {
8897             offset = 0,
8898             scale = 1,
8899             spread = {x = 100, y = 100, z = 100},
8900             seed = 23,
8901             octaves = 3,
8902             persistence = 0.7
8903         },
8904         -- NoiseParams structure describing one of the perlin noises used for
8905         -- ore distribution.
8906         -- Needed by "sheet", "puff", "blob" and "vein" ores.
8907         -- Omit from "scatter" ore for a uniform ore distribution.
8908         -- Omit from "stratum" ore for a simple horizontal strata from y_min to
8909         -- y_max.
8910
8911         biomes = {"desert", "rainforest"},
8912         -- List of biomes in which this ore occurs.
8913         -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
8914         -- being used does not support biomes.
8915         -- Can be a list of (or a single) biome names, IDs, or definitions.
8916
8917         -- Type-specific parameters
8918
8919         -- "sheet"
8920         column_height_min = 1,
8921         column_height_max = 16,
8922         column_midpoint_factor = 0.5,
8923
8924         -- "puff"
8925         np_puff_top = {
8926             offset = 4,
8927             scale = 2,
8928             spread = {x = 100, y = 100, z = 100},
8929             seed = 47,
8930             octaves = 3,
8931             persistence = 0.7
8932         },
8933         np_puff_bottom = {
8934             offset = 4,
8935             scale = 2,
8936             spread = {x = 100, y = 100, z = 100},
8937             seed = 11,
8938             octaves = 3,
8939             persistence = 0.7
8940         },
8941
8942         -- "vein"
8943         random_factor = 1.0,
8944
8945         -- "stratum"
8946         np_stratum_thickness = {
8947             offset = 8,
8948             scale = 4,
8949             spread = {x = 100, y = 100, z = 100},
8950             seed = 17,
8951             octaves = 3,
8952             persistence = 0.7
8953         },
8954         stratum_thickness = 8, -- only used if no noise defined
8955     }
8956
8957 Biome definition
8958 ----------------
8959
8960 Used by `minetest.register_biome`.
8961
8962 The maximum number of biomes that can be used is 65535. However, using an
8963 excessive number of biomes will slow down map generation. Depending on desired
8964 performance and computing power the practical limit is much lower.
8965
8966     {
8967         name = "tundra",
8968
8969         node_dust = "default:snow",
8970         -- Node dropped onto upper surface after all else is generated
8971
8972         node_top = "default:dirt_with_snow",
8973         depth_top = 1,
8974         -- Node forming surface layer of biome and thickness of this layer
8975
8976         node_filler = "default:permafrost",
8977         depth_filler = 3,
8978         -- Node forming lower layer of biome and thickness of this layer
8979
8980         node_stone = "default:bluestone",
8981         -- Node that replaces all stone nodes between roughly y_min and y_max.
8982
8983         node_water_top = "default:ice",
8984         depth_water_top = 10,
8985         -- Node forming a surface layer in seawater with the defined thickness
8986
8987         node_water = "",
8988         -- Node that replaces all seawater nodes not in the surface layer
8989
8990         node_river_water = "default:ice",
8991         -- Node that replaces river water in mapgens that use
8992         -- default:river_water
8993
8994         node_riverbed = "default:gravel",
8995         depth_riverbed = 2,
8996         -- Node placed under river water and thickness of this layer
8997
8998         node_cave_liquid = "default:lava_source",
8999         node_cave_liquid = {"default:water_source", "default:lava_source"},
9000         -- Nodes placed inside 50% of the medium size caves.
9001         -- Multiple nodes can be specified, each cave will use a randomly
9002         -- chosen node from the list.
9003         -- If this field is left out or 'nil', cave liquids fall back to
9004         -- classic behavior of lava and water distributed using 3D noise.
9005         -- For no cave liquid, specify "air".
9006
9007         node_dungeon = "default:cobble",
9008         -- Node used for primary dungeon structure.
9009         -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
9010         -- alias, if that is also absent, dungeon nodes fall back to the biome
9011         -- 'node_stone'.
9012         -- If present, the following two nodes are also used.
9013
9014         node_dungeon_alt = "default:mossycobble",
9015         -- Node used for randomly-distributed alternative structure nodes.
9016         -- If alternative structure nodes are not wanted leave this absent.
9017
9018         node_dungeon_stair = "stairs:stair_cobble",
9019         -- Node used for dungeon stairs.
9020         -- If absent, stairs fall back to 'node_dungeon'.
9021
9022         y_max = 31000,
9023         y_min = 1,
9024         -- Upper and lower limits for biome.
9025         -- Alternatively you can use xyz limits as shown below.
9026
9027         max_pos = {x = 31000, y = 128, z = 31000},
9028         min_pos = {x = -31000, y = 9, z = -31000},
9029         -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
9030         -- Biome is limited to a cuboid defined by these positions.
9031         -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
9032         -- 31000 in 'max_pos'.
9033
9034         vertical_blend = 8,
9035         -- Vertical distance in nodes above 'y_max' over which the biome will
9036         -- blend with the biome above.
9037         -- Set to 0 for no vertical blend. Defaults to 0.
9038
9039         heat_point = 0,
9040         humidity_point = 50,
9041         -- Characteristic temperature and humidity for the biome.
9042         -- These values create 'biome points' on a voronoi diagram with heat and
9043         -- humidity as axes. The resulting voronoi cells determine the
9044         -- distribution of the biomes.
9045         -- Heat and humidity have average values of 50, vary mostly between
9046         -- 0 and 100 but can exceed these values.
9047     }
9048
9049 Decoration definition
9050 ---------------------
9051
9052 See [Decoration types]. Used by `minetest.register_decoration`.
9053
9054     {
9055         deco_type = "simple",
9056         -- Type. "simple" or "schematic" supported
9057
9058         place_on = "default:dirt_with_grass",
9059         -- Node (or list of nodes) that the decoration can be placed on
9060
9061         sidelen = 8,
9062         -- Size of the square (X / Z) divisions of the mapchunk being generated.
9063         -- Determines the resolution of noise variation if used.
9064         -- If the chunk size is not evenly divisible by sidelen, sidelen is made
9065         -- equal to the chunk size.
9066
9067         fill_ratio = 0.02,
9068         -- The value determines 'decorations per surface node'.
9069         -- Used only if noise_params is not specified.
9070         -- If >= 10.0 complete coverage is enabled and decoration placement uses
9071         -- a different and much faster method.
9072
9073         noise_params = {
9074             offset = 0,
9075             scale = 0.45,
9076             spread = {x = 100, y = 100, z = 100},
9077             seed = 354,
9078             octaves = 3,
9079             persistence = 0.7,
9080             lacunarity = 2.0,
9081             flags = "absvalue"
9082         },
9083         -- NoiseParams structure describing the perlin noise used for decoration
9084         -- distribution.
9085         -- A noise value is calculated for each square division and determines
9086         -- 'decorations per surface node' within each division.
9087         -- If the noise value >= 10.0 complete coverage is enabled and
9088         -- decoration placement uses a different and much faster method.
9089
9090         biomes = {"Oceanside", "Hills", "Plains"},
9091         -- List of biomes in which this decoration occurs. Occurs in all biomes
9092         -- if this is omitted, and ignored if the Mapgen being used does not
9093         -- support biomes.
9094         -- Can be a list of (or a single) biome names, IDs, or definitions.
9095
9096         y_min = -31000,
9097         y_max = 31000,
9098         -- Lower and upper limits for decoration (inclusive).
9099         -- These parameters refer to the Y co-ordinate of the 'place_on' node.
9100
9101         spawn_by = "default:water",
9102         -- Node (or list of nodes) that the decoration only spawns next to.
9103         -- Checks the 8 neighboring nodes on the same Y, and also the ones
9104         -- at Y+1, excluding both center nodes.
9105
9106         num_spawn_by = 1,
9107         -- Number of spawn_by nodes that must be surrounding the decoration
9108         -- position to occur.
9109         -- If absent or -1, decorations occur next to any nodes.
9110
9111         flags = "liquid_surface, force_placement, all_floors, all_ceilings",
9112         -- Flags for all decoration types.
9113         -- "liquid_surface": Instead of placement on the highest solid surface
9114         --   in a mapchunk column, placement is on the highest liquid surface.
9115         --   Placement is disabled if solid nodes are found above the liquid
9116         --   surface.
9117         -- "force_placement": Nodes other than "air" and "ignore" are replaced
9118         --   by the decoration.
9119         -- "all_floors", "all_ceilings": Instead of placement on the highest
9120         --   surface in a mapchunk the decoration is placed on all floor and/or
9121         --   ceiling surfaces, for example in caves and dungeons.
9122         --   Ceiling decorations act as an inversion of floor decorations so the
9123         --   effect of 'place_offset_y' is inverted.
9124         --   Y-slice probabilities do not function correctly for ceiling
9125         --   schematic decorations as the behavior is unchanged.
9126         --   If a single decoration registration has both flags the floor and
9127         --   ceiling decorations will be aligned vertically.
9128
9129         ----- Simple-type parameters
9130
9131         decoration = "default:grass",
9132         -- The node name used as the decoration.
9133         -- If instead a list of strings, a randomly selected node from the list
9134         -- is placed as the decoration.
9135
9136         height = 1,
9137         -- Decoration height in nodes.
9138         -- If height_max is not 0, this is the lower limit of a randomly
9139         -- selected height.
9140
9141         height_max = 0,
9142         -- Upper limit of the randomly selected height.
9143         -- If absent, the parameter 'height' is used as a constant.
9144
9145         param2 = 0,
9146         -- Param2 value of decoration nodes.
9147         -- If param2_max is not 0, this is the lower limit of a randomly
9148         -- selected param2.
9149
9150         param2_max = 0,
9151         -- Upper limit of the randomly selected param2.
9152         -- If absent, the parameter 'param2' is used as a constant.
9153
9154         place_offset_y = 0,
9155         -- Y offset of the decoration base node relative to the standard base
9156         -- node position.
9157         -- Can be positive or negative. Default is 0.
9158         -- Effect is inverted for "all_ceilings" decorations.
9159         -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
9160         -- to the 'place_on' node.
9161
9162         ----- Schematic-type parameters
9163
9164         schematic = "foobar.mts",
9165         -- If schematic is a string, it is the filepath relative to the current
9166         -- working directory of the specified Minetest schematic file.
9167         -- Could also be the ID of a previously registered schematic.
9168
9169         schematic = {
9170             size = {x = 4, y = 6, z = 4},
9171             data = {
9172                 {name = "default:cobble", param1 = 255, param2 = 0},
9173                 {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
9174                 {name = "air", param1 = 255, param2 = 0},
9175                  ...
9176             },
9177             yslice_prob = {
9178                 {ypos = 2, prob = 128},
9179                 {ypos = 5, prob = 64},
9180                  ...
9181             },
9182         },
9183         -- Alternative schematic specification by supplying a table. The fields
9184         -- size and data are mandatory whereas yslice_prob is optional.
9185         -- See 'Schematic specifier' for details.
9186
9187         replacements = {["oldname"] = "convert_to", ...},
9188         -- Map of node names to replace in the schematic after reading it.
9189
9190         flags = "place_center_x, place_center_y, place_center_z",
9191         -- Flags for schematic decorations. See 'Schematic attributes'.
9192
9193         rotation = "90",
9194         -- Rotation can be "0", "90", "180", "270", or "random"
9195
9196         place_offset_y = 0,
9197         -- If the flag 'place_center_y' is set this parameter is ignored.
9198         -- Y offset of the schematic base node layer relative to the 'place_on'
9199         -- node.
9200         -- Can be positive or negative. Default is 0.
9201         -- Effect is inverted for "all_ceilings" decorations.
9202         -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
9203         -- to the 'place_on' node.
9204     }
9205
9206 Chat command definition
9207 -----------------------
9208
9209 Used by `minetest.register_chatcommand`.
9210
9211     {
9212         params = "<name> <privilege>",  -- Short parameter description
9213
9214         description = "Remove privilege from player",  -- Full description
9215
9216         privs = {privs=true},  -- Require the "privs" privilege to run
9217
9218         func = function(name, param),
9219         -- Called when command is run. Returns boolean success and text output.
9220         -- Special case: The help message is shown to the player if `func`
9221         -- returns false without a text output.
9222     }
9223
9224 Note that in params, use of symbols is as follows:
9225
9226 * `<>` signifies a placeholder to be replaced when the command is used. For
9227   example, when a player name is needed: `<name>`
9228 * `[]` signifies param is optional and not required when the command is used.
9229   For example, if you require param1 but param2 is optional:
9230   `<param1> [<param2>]`
9231 * `|` signifies exclusive or. The command requires one param from the options
9232   provided. For example: `<param1> | <param2>`
9233 * `()` signifies grouping. For example, when param1 and param2 are both
9234   required, or only param3 is required: `(<param1> <param2>) | <param3>`
9235
9236 Privilege definition
9237 --------------------
9238
9239 Used by `minetest.register_privilege`.
9240
9241     {
9242         description = "",
9243         -- Privilege description
9244
9245         give_to_singleplayer = true,
9246         -- Whether to grant the privilege to singleplayer.
9247
9248         give_to_admin = true,
9249         -- Whether to grant the privilege to the server admin.
9250         -- Uses value of 'give_to_singleplayer' by default.
9251
9252         on_grant = function(name, granter_name),
9253         -- Called when given to player 'name' by 'granter_name'.
9254         -- 'granter_name' will be nil if the priv was granted by a mod.
9255
9256         on_revoke = function(name, revoker_name),
9257         -- Called when taken from player 'name' by 'revoker_name'.
9258         -- 'revoker_name' will be nil if the priv was revoked by a mod.
9259
9260         -- Note that the above two callbacks will be called twice if a player is
9261         -- responsible, once with the player name, and then with a nil player
9262         -- name.
9263         -- Return true in the above callbacks to stop register_on_priv_grant or
9264         -- revoke being called.
9265     }
9266
9267 Detached inventory callbacks
9268 ----------------------------
9269
9270 Used by `minetest.create_detached_inventory`.
9271
9272     {
9273         allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
9274         -- Called when a player wants to move items inside the inventory.
9275         -- Return value: number of items allowed to move.
9276
9277         allow_put = function(inv, listname, index, stack, player),
9278         -- Called when a player wants to put something into the inventory.
9279         -- Return value: number of items allowed to put.
9280         -- Return value -1: Allow and don't modify item count in inventory.
9281
9282         allow_take = function(inv, listname, index, stack, player),
9283         -- Called when a player wants to take something out of the inventory.
9284         -- Return value: number of items allowed to take.
9285         -- Return value -1: Allow and don't modify item count in inventory.
9286
9287         on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
9288         on_put = function(inv, listname, index, stack, player),
9289         on_take = function(inv, listname, index, stack, player),
9290         -- Called after the actual action has happened, according to what was
9291         -- allowed.
9292         -- No return value.
9293     }
9294
9295 HUD Definition
9296 --------------
9297
9298 Since most values have multiple different functions, please see the
9299 documentation in [HUD] section.
9300
9301 Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
9302
9303     {
9304         hud_elem_type = "image",
9305         -- Type of element, can be "image", "text", "statbar", "inventory",
9306         -- "waypoint", "image_waypoint", "compass" or "minimap"
9307
9308         position = {x=0.5, y=0.5},
9309         -- Top left corner position of element
9310
9311         name = "<name>",
9312
9313         scale = {x = 1, y = 1},
9314
9315         text = "<text>",
9316
9317         text2 = "<text>",
9318
9319         number = 0,
9320
9321         item = 0,
9322
9323         direction = 0,
9324         -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
9325
9326         alignment = {x=0, y=0},
9327
9328         offset = {x=0, y=0},
9329
9330         world_pos = {x=0, y=0, z=0},
9331
9332         size = {x=0, y=0},
9333
9334         z_index = 0,
9335         -- Z index: lower z-index HUDs are displayed behind higher z-index HUDs
9336
9337         style = 0,
9338     }
9339
9340 Particle definition
9341 -------------------
9342
9343 Used by `minetest.add_particle`.
9344
9345     {
9346         pos = {x=0, y=0, z=0},
9347         velocity = {x=0, y=0, z=0},
9348         acceleration = {x=0, y=0, z=0},
9349         -- Spawn particle at pos with velocity and acceleration
9350
9351         expirationtime = 1,
9352         -- Disappears after expirationtime seconds
9353
9354         size = 1,
9355         -- Scales the visual size of the particle texture.
9356         -- If `node` is set, size can be set to 0 to spawn a randomly-sized
9357         -- particle (just like actual node dig particles).
9358
9359         collisiondetection = false,
9360         -- If true collides with `walkable` nodes and, depending on the
9361         -- `object_collision` field, objects too.
9362
9363         collision_removal = false,
9364         -- If true particle is removed when it collides.
9365         -- Requires collisiondetection = true to have any effect.
9366
9367         object_collision = false,
9368         -- If true particle collides with objects that are defined as
9369         -- `physical = true,` and `collide_with_objects = true,`.
9370         -- Requires collisiondetection = true to have any effect.
9371
9372         vertical = false,
9373         -- If true faces player using y axis only
9374
9375         texture = "image.png",
9376         -- The texture of the particle
9377         -- v5.6.0 and later: also supports the table format described in the
9378         -- following section
9379
9380         playername = "singleplayer",
9381         -- Optional, if specified spawns particle only on the player's client
9382
9383         animation = {Tile Animation definition},
9384         -- Optional, specifies how to animate the particle texture
9385
9386         glow = 0
9387         -- Optional, specify particle self-luminescence in darkness.
9388         -- Values 0-14.
9389
9390         node = {name = "ignore", param2 = 0},
9391         -- Optional, if specified the particle will have the same appearance as
9392         -- node dig particles for the given node.
9393         -- `texture` and `animation` will be ignored if this is set.
9394
9395         node_tile = 0,
9396         -- Optional, only valid in combination with `node`
9397         -- If set to a valid number 1-6, specifies the tile from which the
9398         -- particle texture is picked.
9399         -- Otherwise, the default behavior is used. (currently: any random tile)
9400
9401         drag = {x=0, y=0, z=0},
9402         -- v5.6.0 and later: Optional drag value, consult the following section
9403
9404         bounce = {min = ..., max = ..., bias = 0},
9405         -- v5.6.0 and later: Optional bounce range, consult the following section
9406     }
9407
9408
9409 `ParticleSpawner` definition
9410 ----------------------------
9411
9412 Used by `minetest.add_particlespawner`.
9413
9414 Before v5.6.0, particlespawners used a different syntax and had a more limited set
9415 of features. Definition fields that are the same in both legacy and modern versions
9416 are shown in the next listing, and the fields that are used by legacy versions are
9417 shown separated by a comment; the modern fields are too complex to compactly
9418 describe in this manner and are documented after the listing.
9419
9420 The older syntax can be used in combination with the newer syntax (e.g. having
9421 `minpos`, `maxpos`, and `pos` all set) to support older servers. On newer servers,
9422 the new syntax will override the older syntax; on older servers, the newer syntax
9423 will be ignored.
9424
9425     {
9426         -- Common fields (same name and meaning in both new and legacy syntax)
9427
9428         amount = 1,
9429         -- Number of particles spawned over the time period `time`.
9430
9431         time = 1,
9432         -- Lifespan of spawner in seconds.
9433         -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
9434         -- a per-second basis.
9435
9436         collisiondetection = false,
9437         -- If true collide with `walkable` nodes and, depending on the
9438         -- `object_collision` field, objects too.
9439
9440         collision_removal = false,
9441         -- If true particles are removed when they collide.
9442         -- Requires collisiondetection = true to have any effect.
9443
9444         object_collision = false,
9445         -- If true particles collide with objects that are defined as
9446         -- `physical = true,` and `collide_with_objects = true,`.
9447         -- Requires collisiondetection = true to have any effect.
9448
9449         attached = ObjectRef,
9450         -- If defined, particle positions, velocities and accelerations are
9451         -- relative to this object's position and yaw
9452
9453         vertical = false,
9454         -- If true face player using y axis only
9455
9456         texture = "image.png",
9457         -- The texture of the particle
9458
9459         playername = "singleplayer",
9460         -- Optional, if specified spawns particles only on the player's client
9461
9462         animation = {Tile Animation definition},
9463         -- Optional, specifies how to animate the particles' texture
9464         -- v5.6.0 and later: set length to -1 to synchronize the length
9465         -- of the animation with the expiration time of individual particles.
9466         -- (-2 causes the animation to be played twice, and so on)
9467
9468         glow = 0,
9469         -- Optional, specify particle self-luminescence in darkness.
9470         -- Values 0-14.
9471
9472         node = {name = "ignore", param2 = 0},
9473         -- Optional, if specified the particles will have the same appearance as
9474         -- node dig particles for the given node.
9475         -- `texture` and `animation` will be ignored if this is set.
9476
9477         node_tile = 0,
9478         -- Optional, only valid in combination with `node`
9479         -- If set to a valid number 1-6, specifies the tile from which the
9480         -- particle texture is picked.
9481         -- Otherwise, the default behavior is used. (currently: any random tile)
9482
9483         -- Legacy definition fields
9484
9485         minpos = {x=0, y=0, z=0},
9486         maxpos = {x=0, y=0, z=0},
9487         minvel = {x=0, y=0, z=0},
9488         maxvel = {x=0, y=0, z=0},
9489         minacc = {x=0, y=0, z=0},
9490         maxacc = {x=0, y=0, z=0},
9491         minexptime = 1,
9492         maxexptime = 1,
9493         minsize = 1,
9494         maxsize = 1,
9495         -- The particles' properties are random values between the min and max
9496         -- values.
9497         -- applies to: pos, velocity, acceleration, expirationtime, size
9498         -- If `node` is set, min and maxsize can be set to 0 to spawn
9499         -- randomly-sized particles (just like actual node dig particles).
9500     }
9501
9502 ### Modern definition fields
9503
9504 After v5.6.0, spawner properties can be defined in several different ways depending
9505 on the level of control you need. `pos` for instance can be set as a single vector,
9506 in which case all particles will appear at that exact point throughout the lifetime
9507 of the spawner. Alternately, it can be specified as a min-max pair, specifying a
9508 cubic range the particles can appear randomly within. Finally, some properties can
9509 be animated by suffixing their key with `_tween` (e.g. `pos_tween`) and supplying
9510 a tween table.
9511
9512 The following definitions are all equivalent, listed in order of precedence from
9513 lowest (the legacy syntax) to highest (tween tables). If multiple forms of a
9514 property definition are present, the highest-precedence form will be selected
9515 and all lower-precedence fields will be ignored, allowing for graceful
9516 degradation in older clients).
9517
9518     {
9519       -- old syntax
9520       maxpos = {x = 0, y = 0, z = 0},
9521       minpos = {x = 0, y = 0, z = 0},
9522
9523       -- absolute value
9524       pos = 0,
9525       -- all components of every particle's position vector will be set to this
9526       -- value
9527
9528       -- vec3
9529       pos = vector.new(0,0,0),
9530       -- all particles will appear at this exact position throughout the lifetime
9531       -- of the particlespawner
9532
9533       -- vec3 range
9534       pos = {
9535             -- the particle will appear at a position that is picked at random from
9536             -- within a cubic range
9537
9538             min = vector.new(0,0,0),
9539             -- `min` is the minimum value this property will be set to in particles
9540             -- spawned by the generator
9541
9542             max = vector.new(0,0,0),
9543             -- `max` is the minimum value this property will be set to in particles
9544             -- spawned by the generator
9545
9546             bias = 0,
9547             -- when `bias` is 0, all random values are exactly as likely as any
9548             -- other. when it is positive, the higher it is, the more likely values
9549             -- will appear towards the minimum end of the allowed spectrum. when
9550             -- it is negative, the lower it is, the more likely values will appear
9551             -- towards the maximum end of the allowed spectrum. the curve is
9552             -- exponential and there is no particular maximum or minimum value
9553         },
9554
9555         -- tween table
9556         pos_tween = {...},
9557         -- a tween table should consist of a list of frames in the same form as the
9558         -- untweened pos property above, which the engine will interpolate between,
9559         -- and optionally a number of properties that control how the interpolation
9560         -- takes place. currently **only two frames**, the first and the last, are
9561         -- used, but extra frames are accepted for the sake of forward compatibility.
9562         -- any of the above definition styles can be used here as well in any combination
9563         -- supported by the property type
9564
9565         pos_tween = {
9566             style = "fwd",
9567             -- linear animation from first to last frame (default)
9568             style = "rev",
9569             -- linear animation from last to first frame
9570             style = "pulse",
9571             -- linear animation from first to last then back to first again
9572             style = "flicker",
9573             -- like "pulse", but slightly randomized to add a bit of stutter
9574
9575             reps = 1,
9576             -- number of times the animation is played over the particle's lifespan
9577
9578             start = 0.0,
9579             -- point in the spawner's lifespan at which the animation begins. 0 is
9580             -- the very beginning, 1 is the very end
9581
9582             -- frames can be defined in a number of different ways, depending on the
9583             -- underlying type of the property. for now, all but the first and last
9584             -- frame are ignored
9585
9586             -- frames
9587
9588                 -- floats
9589                 0, 0,
9590
9591                 -- vec3s
9592                 vector.new(0,0,0),
9593                 vector.new(0,0,0),
9594
9595                 -- vec3 ranges
9596                 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9597                 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9598
9599                 -- mixed
9600                 0, { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9601         },
9602     }
9603
9604 All of the properties that can be defined in this way are listed in the next
9605 section, along with the datatypes they accept.
9606
9607 #### List of particlespawner properties
9608 All of the properties in this list can be animated with `*_tween` tables
9609 unless otherwise specified. For example, `jitter` can be tweened by setting
9610 a `jitter_tween` table instead of (or in addition to) a `jitter` table/value.
9611 Types used are defined in the previous section.
9612
9613 * vec3 range `pos`: the position at which particles can appear
9614 * vec3 range `vel`: the initial velocity of the particle
9615 * vec3 range `acc`: the direction and speed with which the particle
9616   accelerates
9617 * vec3 range `jitter`: offsets the velocity of each particle by a random
9618   amount within the specified range each frame. used to create Brownian motion.
9619 * vec3 range `drag`: the amount by which absolute particle velocity along
9620   each axis is decreased per second.  a value of 1.0 means that the particle
9621   will be slowed to a stop over the space of a second; a value of -1.0 means
9622   that the particle speed will be doubled every second. to avoid interfering
9623   with gravity provided by `acc`, a drag vector like `vector.new(1,0,1)` can
9624   be used instead of a uniform value.
9625 * float range `bounce`: how bouncy the particles are when `collisiondetection`
9626   is turned on. values less than or equal to `0` turn off particle bounce;
9627   `1` makes the particles bounce without losing any velocity, and `2` makes
9628   them double their velocity with every bounce.  `bounce` is not bounded but
9629   values much larger than `1.0` probably aren't very useful.
9630 * float range `exptime`: the number of seconds after which the particle
9631   disappears.
9632 * table `attract`: sets the birth orientation of particles relative to various
9633   shapes defined in world coordinate space. this is an alternative means of
9634   setting the velocity which allows particles to emerge from or enter into
9635   some entity or node on the map, rather than simply being assigned random
9636   velocity values within a range. the velocity calculated by this method will
9637   be **added** to that specified by `vel` if `vel` is also set, so in most
9638   cases **`vel` should be set to 0**. `attract` has the fields:
9639   * string `kind`: selects the kind of shape towards which the particles will
9640     be oriented. it must have one of the following values:
9641     * `"none"`: no attractor is set and the `attractor` table is ignored
9642     * `"point"`: the particles are attracted to a specific point in space.
9643       use this also if you want a sphere-like effect, in combination with
9644       the `radius` property.
9645     * `"line"`: the particles are attracted to an (infinite) line passing
9646       through the points `origin` and `angle`. use this for e.g. beacon
9647       effects, energy beam effects, etc.
9648     * `"plane"`: the particles are attracted to an (infinite) plane on whose
9649       surface `origin` designates a point in world coordinate space. use this
9650       for e.g. particles entering or emerging from a portal.
9651   * float range `strength`: the speed with which particles will move towards
9652     `attractor`. If negative, the particles will instead move away from that
9653     point.
9654   * vec3 `origin`: the origin point of the shape towards which particles will
9655     initially be oriented. functions as an offset if `origin_attached` is also
9656     set.
9657   * vec3 `direction`: sets the direction in which the attractor shape faces. for
9658     lines, this sets the angle of the line; e.g. a vector of (0,1,0) will
9659     create a vertical line that passes through `origin`. for planes, `direction`
9660     is the surface normal of an infinite plane on whose surface `origin` is
9661     a point. functions as an offset if `direction_attached` is also set.
9662   * entity `origin_attached`: allows the origin to be specified as an offset
9663     from the position of an entity rather than a coordinate in world space.
9664   * entity `direction_attached`: allows the direction to be specified as an offset
9665     from the position of an entity rather than a coordinate in world space.
9666   * bool `die_on_contact`: if true, the particles' lifetimes are adjusted so
9667     that they will die as they cross the attractor threshold. this behavior
9668     is the default but is undesirable for some kinds of animations; set it to
9669     false to allow particles to live out their natural lives.
9670 * vec3 range `radius`: if set, particles will be arranged in a sphere around
9671   `pos`. A constant can be used to create a spherical shell of particles, a
9672   vector to create an ovoid shell, and a range to create a volume; e.g.
9673   `{min = 0.5, max = 1, bias = 1}` will allow particles to appear between 0.5
9674   and 1 nodes away from `pos` but will cluster them towards the center of the
9675   sphere. Usually if `radius` is used, `pos` should be a single point, but it
9676   can still be a range if you really know what you're doing (e.g. to create a
9677   "roundcube" emitter volume).
9678
9679 ### Textures
9680
9681 In versions before v5.6.0, particlespawner textures could only be specified as a single
9682 texture string. After v5.6.0, textures can now be specified as a table as well. This
9683 table contains options that allow simple animations to be applied to the texture.
9684
9685     texture = {
9686         name = "mymod_particle_texture.png",
9687         -- the texture specification string
9688
9689         alpha = 1.0,
9690         -- controls how visible the particle is; at 1.0 the particle is fully
9691         -- visible, at 0, it is completely invisible.
9692
9693         alpha_tween = {1, 0},
9694         -- can be used instead of `alpha` to animate the alpha value over the
9695         -- particle's lifetime. these tween tables work identically to the tween
9696         -- tables used in particlespawner properties, except that time references
9697         -- are understood with respect to the particle's lifetime, not the
9698         -- spawner's. {1,0} fades the particle out over its lifetime.
9699
9700         scale = 1,
9701         scale = {x = 1, y = 1},
9702         -- scales the texture onscreen
9703
9704         scale_tween = {
9705             {x = 1, y = 1},
9706             {x = 0, y = 1},
9707         },
9708         -- animates the scale over the particle's lifetime. works like the
9709         -- alpha_tween table, but can accept two-dimensional vectors as well as
9710         -- integer values. the example value would cause the particle to shrink
9711         -- in one dimension over the course of its life until it disappears
9712
9713         blend = "alpha",
9714         -- (default) blends transparent pixels with those they are drawn atop
9715         -- according to the alpha channel of the source texture. useful for
9716         -- e.g. material objects like rocks, dirt, smoke, or node chunks
9717         blend = "add",
9718         -- adds the value of pixels to those underneath them, modulo the sources
9719         -- alpha channel. useful for e.g. bright light effects like sparks or fire
9720         blend = "screen",
9721         -- like "add" but less bright. useful for subtler light effects. note that
9722         -- this is NOT formally equivalent to the "screen" effect used in image
9723         -- editors and compositors, as it does not respect the alpha channel of
9724         -- of the image being blended
9725         blend = "sub",
9726         -- the inverse of "add"; the value of the source pixel is subtracted from
9727         -- the pixel underneath it. a white pixel will turn whatever is underneath
9728         -- it black; a black pixel will be "transparent". useful for creating
9729         -- darkening effects
9730
9731         animation = {Tile Animation definition},
9732         -- overrides the particlespawner's global animation property for a single
9733         -- specific texture
9734     }
9735
9736 Instead of setting a single texture definition, it is also possible to set a
9737 `texpool` property. A `texpool` consists of a list of possible particle textures.
9738 Every time a particle is spawned, the engine will pick a texture at random from
9739 the `texpool` and assign it as that particle's texture. You can also specify a
9740 `texture` in addition to a `texpool`; the `texture` value will be ignored on newer
9741 clients but will be sent to older (pre-v5.6.0) clients that do not implement
9742 texpools.
9743
9744     texpool = {
9745         "mymod_particle_texture.png";
9746         { name = "mymod_spark.png", fade = "out" },
9747         {
9748           name = "mymod_dust.png",
9749           alpha = 0.3,
9750           scale = 1.5,
9751           animation = {
9752                 type = "vertical_frames",
9753                 aspect_w = 16, aspect_h = 16,
9754
9755                 length = 3,
9756                 -- the animation lasts for 3s and then repeats
9757                 length = -3,
9758                 -- repeat the animation three times over the particle's lifetime
9759                 -- (post-v5.6.0 clients only)
9760           },
9761         },
9762   }
9763
9764 #### List of animatable texture properties
9765
9766 While animated particlespawner values vary over the course of the particlespawner's
9767 lifetime, animated texture properties vary over the lifespans of the individual
9768 particles spawned with that texture. So a particle with the texture property
9769
9770     alpha_tween = {
9771         0.0, 1.0,
9772         style = "pulse",
9773         reps = 4,
9774     }
9775
9776 would be invisible at its spawning, pulse visible four times throughout its
9777 lifespan, and then vanish again before expiring.
9778
9779 * float `alpha` (0.0 - 1.0): controls the visibility of the texture
9780 * vec2 `scale`: controls the size of the displayed billboard onscreen. Its units
9781   are multiples of the parent particle's assigned size (see the `size` property above)
9782
9783 `HTTPRequest` definition
9784 ------------------------
9785
9786 Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
9787
9788     {
9789         url = "http://example.org",
9790
9791         timeout = 10,
9792         -- Timeout for request to be completed in seconds. Default depends on engine settings.
9793
9794         method = "GET", "POST", "PUT" or "DELETE"
9795         -- The http method to use. Defaults to "GET".
9796
9797         data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
9798         -- Data for the POST, PUT or DELETE request.
9799         -- Accepts both a string and a table. If a table is specified, encodes
9800         -- table as x-www-form-urlencoded key-value pairs.
9801
9802         user_agent = "ExampleUserAgent",
9803         -- Optional, if specified replaces the default minetest user agent with
9804         -- given string
9805
9806         extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
9807         -- Optional, if specified adds additional headers to the HTTP request.
9808         -- You must make sure that the header strings follow HTTP specification
9809         -- ("Key: Value").
9810
9811         multipart = boolean
9812         -- Optional, if true performs a multipart HTTP request.
9813         -- Default is false.
9814         -- Post only, data must be array
9815
9816         post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
9817         -- Deprecated, use `data` instead. Forces `method = "POST"`.
9818     }
9819
9820 `HTTPRequestResult` definition
9821 ------------------------------
9822
9823 Passed to `HTTPApiTable.fetch` callback. Returned by
9824 `HTTPApiTable.fetch_async_get`.
9825
9826     {
9827         completed = true,
9828         -- If true, the request has finished (either succeeded, failed or timed
9829         -- out)
9830
9831         succeeded = true,
9832         -- If true, the request was successful
9833
9834         timeout = false,
9835         -- If true, the request timed out
9836
9837         code = 200,
9838         -- HTTP status code
9839
9840         data = "response"
9841     }
9842
9843 Authentication handler definition
9844 ---------------------------------
9845
9846 Used by `minetest.register_authentication_handler`.
9847
9848     {
9849         get_auth = function(name),
9850         -- Get authentication data for existing player `name` (`nil` if player
9851         -- doesn't exist).
9852         -- Returns following structure:
9853         -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
9854
9855         create_auth = function(name, password),
9856         -- Create new auth data for player `name`.
9857         -- Note that `password` is not plain-text but an arbitrary
9858         -- representation decided by the engine.
9859
9860         delete_auth = function(name),
9861         -- Delete auth data of player `name`.
9862         -- Returns boolean indicating success (false if player is nonexistent).
9863
9864         set_password = function(name, password),
9865         -- Set password of player `name` to `password`.
9866         -- Auth data should be created if not present.
9867
9868         set_privileges = function(name, privileges),
9869         -- Set privileges of player `name`.
9870         -- `privileges` is in table form, auth data should be created if not
9871         -- present.
9872
9873         reload = function(),
9874         -- Reload authentication data from the storage location.
9875         -- Returns boolean indicating success.
9876
9877         record_login = function(name),
9878         -- Called when player joins, used for keeping track of last_login
9879
9880         iterate = function(),
9881         -- Returns an iterator (use with `for` loops) for all player names
9882         -- currently in the auth database
9883     }
9884
9885 Bit Library
9886 -----------
9887
9888 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
9889
9890 See http://bitop.luajit.org/ for advanced information.