]> git.lizzy.rs Git - minetest.git/blob - doc/lua_api.txt
More corrections to lua_api.txt (#12505)
[minetest.git] / doc / lua_api.txt
1 Minetest Lua Modding API Reference
2 ==================================
3
4 * More information at <http://www.minetest.net/>
5 * Developer Wiki: <http://dev.minetest.net/>
6 * (Unofficial) Minetest Modding Book by rubenwardy: <https://rubenwardy.com/minetest_modding_book/>
7
8 Introduction
9 ------------
10
11 Content and functionality can be added to Minetest using Lua scripting
12 in run-time loaded mods.
13
14 A mod is a self-contained bunch of scripts, textures and other related
15 things, which is loaded by and interfaces with Minetest.
16
17 Mods are contained and ran solely on the server side. Definitions and media
18 files are automatically transferred to the client.
19
20 If you see a deficiency in the API, feel free to attempt to add the
21 functionality in the engine and API, and to document it here.
22
23 Programming in Lua
24 ------------------
25
26 If you have any difficulty in understanding this, please read
27 [Programming in Lua](http://www.lua.org/pil/).
28
29 Startup
30 -------
31
32 Mods are loaded during server startup from the mod load paths by running
33 the `init.lua` scripts in a shared environment.
34
35 Paths
36 -----
37
38 Minetest keeps and looks for files mostly in two paths. `path_share` or `path_user`.
39
40 `path_share` contains possibly read-only content for the engine (incl. games and mods).
41 `path_user` contains mods or games installed by the user but also the users
42 worlds or settings.
43
44 With a local build (`RUN_IN_PLACE=1`) `path_share` and `path_user` both point to
45 the build directory. For system-wide builds on Linux the share path is usually at
46 `/usr/share/minetest` while the user path resides in `.minetest` in the home directory.
47 Paths on other operating systems will differ.
48
49 Games
50 =====
51
52 Games are looked up from:
53
54 * `$path_share/games/<gameid>/`
55 * `$path_user/games/<gameid>/`
56
57 Where `<gameid>` is unique to each game.
58
59 The game directory can contain the following files:
60
61 * `game.conf`, with the following keys:
62     * `title`: Required, a human-readable title to address the game, e.g. `title = Minetest Game`.
63     * `name`: (Deprecated) same as title.
64     * `description`: Short description to be shown in the content tab
65     * `allowed_mapgens = <comma-separated mapgens>`
66       e.g. `allowed_mapgens = v5,v6,flat`
67       Mapgens not in this list are removed from the list of mapgens for the
68       game.
69       If not specified, all mapgens are allowed.
70     * `disallowed_mapgens = <comma-separated mapgens>`
71       e.g. `disallowed_mapgens = v5,v6,flat`
72       These mapgens are removed from the list of mapgens for the game.
73       When both `allowed_mapgens` and `disallowed_mapgens` are
74       specified, `allowed_mapgens` is applied before
75       `disallowed_mapgens`.
76     * `disallowed_mapgen_settings= <comma-separated mapgen settings>`
77       e.g. `disallowed_mapgen_settings = mgv5_spflags`
78       These mapgen settings are hidden for this game in the world creation
79       dialog and game start menu. Add `seed` to hide the seed input field.
80     * `disabled_settings = <comma-separated settings>`
81       e.g. `disabled_settings = enable_damage, creative_mode`
82       These settings are hidden for this game in the "Start game" tab
83       and will be initialized as `false` when the game is started.
84       Prepend a setting name with an exclamation mark to initialize it to `true`
85       (this does not work for `enable_server`).
86       Only these settings are supported:
87           `enable_damage`, `creative_mode`, `enable_server`.
88     * `author`: The author of the game. It only appears when downloaded from
89                 ContentDB.
90     * `release`: Ignore this: Should only ever be set by ContentDB, as it is
91                  an internal ID used to track versions.
92 * `minetest.conf`:
93   Used to set default settings when running this game.
94 * `settingtypes.txt`:
95   In the same format as the one in builtin.
96   This settingtypes.txt will be parsed by the menu and the settings will be
97   displayed in the "Games" category in the advanced settings tab.
98 * If the game contains a folder called `textures` the server will load it as a
99   texturepack, overriding mod textures.
100   Any server texturepack will override mod textures and the game texturepack.
101
102 Menu images
103 -----------
104
105 Games can provide custom main menu images. They are put inside a `menu`
106 directory inside the game directory.
107
108 The images are named `$identifier.png`, where `$identifier` is one of
109 `overlay`, `background`, `footer`, `header`.
110 If you want to specify multiple images for one identifier, add additional
111 images named like `$identifier.$n.png`, with an ascending number $n starting
112 with 1, and a random image will be chosen from the provided ones.
113
114 Menu music
115 -----------
116
117 Games can provide custom main menu music. They are put inside a `menu`
118 directory inside the game directory.
119
120 The music files are named `theme.ogg`.
121 If you want to specify multiple music files for one game, add additional
122 images named like `theme.$n.ogg`, with an ascending number $n starting
123 with 1 (max 10), and a random music file will be chosen from the provided ones.
124
125 Mods
126 ====
127
128 Mod load path
129 -------------
130
131 Paths are relative to the directories listed in the [Paths] section above.
132
133 * `games/<gameid>/mods/`
134 * `mods/`
135 * `worlds/<worldname>/worldmods/`
136
137 World-specific games
138 --------------------
139
140 It is possible to include a game in a world; in this case, no mods or
141 games are loaded or checked from anywhere else.
142
143 This is useful for e.g. adventure worlds and happens if the `<worldname>/game/`
144 directory exists.
145
146 Mods should then be placed in `<worldname>/game/mods/`.
147
148 Modpacks
149 --------
150
151 Mods can be put in a subdirectory, if the parent directory, which otherwise
152 should be a mod, contains a file named `modpack.conf`.
153 The file is a key-value store of modpack details.
154
155 * `name`: The modpack name. Allows Minetest to determine the modpack name even
156           if the folder is wrongly named.
157 * `description`: Description of mod to be shown in the Mods tab of the main
158                  menu.
159 * `author`: The author of the modpack. It only appears when downloaded from
160             ContentDB.
161 * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
162              internal ID used to track versions.
163 * `title`: A human-readable title to address the modpack.
164
165 Note: to support 0.4.x, please also create an empty modpack.txt file.
166
167 Mod directory structure
168 -----------------------
169
170     mods
171     ├── modname
172     │   ├── mod.conf
173     │   ├── screenshot.png
174     │   ├── settingtypes.txt
175     │   ├── init.lua
176     │   ├── models
177     │   ├── textures
178     │   │   ├── modname_stuff.png
179     │   │   ├── modname_stuff_normal.png
180     │   │   ├── modname_something_else.png
181     │   │   ├── subfolder_foo
182     │   │   │   ├── modname_more_stuff.png
183     │   │   │   └── another_subfolder
184     │   │   └── bar_subfolder
185     │   ├── sounds
186     │   ├── media
187     │   ├── locale
188     │   └── <custom data>
189     └── another
190
191 ### modname
192
193 The location of this directory can be fetched by using
194 `minetest.get_modpath(modname)`.
195
196 ### mod.conf
197
198 A `Settings` file that provides meta information about the mod.
199
200 * `name`: The mod name. Allows Minetest to determine the mod name even if the
201           folder is wrongly named.
202 * `description`: Description of mod to be shown in the Mods tab of the main
203                  menu.
204 * `depends`: A comma separated list of dependencies. These are mods that must be
205              loaded before this mod.
206 * `optional_depends`: A comma separated list of optional dependencies.
207                       Like a dependency, but no error if the mod doesn't exist.
208 * `author`: The author of the mod. It only appears when downloaded from
209             ContentDB.
210 * `release`: Ignore this: Should only ever be set by ContentDB, as it is an
211              internal ID used to track versions.
212 * `title`: A human-readable title to address the mod.
213
214 ### `screenshot.png`
215
216 A screenshot shown in the mod manager within the main menu. It should
217 have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
218
219 ### `depends.txt`
220
221 **Deprecated:** you should use mod.conf instead.
222
223 This file is used if there are no dependencies in mod.conf.
224
225 List of mods that have to be loaded before loading this mod.
226
227 A single line contains a single modname.
228
229 Optional dependencies can be defined by appending a question mark
230 to a single modname. This means that if the specified mod
231 is missing, it does not prevent this mod from being loaded.
232
233 ### `description.txt`
234
235 **Deprecated:** you should use mod.conf instead.
236
237 This file is used if there is no description in mod.conf.
238
239 A file containing a description to be shown in the Mods tab of the main menu.
240
241 ### `settingtypes.txt`
242
243 The format is documented in `builtin/settingtypes.txt`.
244 It is parsed by the main menu settings dialogue to list mod-specific
245 settings in the "Mods" category.
246
247 ### `init.lua`
248
249 The main Lua script. Running this script should register everything it
250 wants to register. Subsequent execution depends on minetest calling the
251 registered callbacks.
252
253 `minetest.settings` can be used to read custom or existing settings at load
254 time, if necessary. (See [`Settings`])
255
256 ### `textures`, `sounds`, `media`, `models`, `locale`
257
258 Media files (textures, sounds, whatever) that will be transferred to the
259 client and will be available for use by the mod and translation files for
260 the clients (see [Translations]).
261
262 It is suggested to use the folders for the purpose they are thought for,
263 eg. put textures into `textures`, translation files into `locale`,
264 models for entities or meshnodes into `models` et cetera.
265
266 These folders and subfolders can contain subfolders.
267 Subfolders with names starting with `_` or `.` are ignored.
268 If a subfolder contains a media file with the same name as a media file
269 in one of its parents, the parent's file is used.
270
271 Although it is discouraged, a mod can overwrite a media file of any mod that it
272 depends on by supplying a file with an equal name.
273
274 Naming conventions
275 ------------------
276
277 Registered names should generally be in this format:
278
279     modname:<whatever>
280
281 `<whatever>` can have these characters:
282
283     a-zA-Z0-9_
284
285 This is to prevent conflicting names from corrupting maps and is
286 enforced by the mod loader.
287
288 Registered names can be overridden by prefixing the name with `:`. This can
289 be used for overriding the registrations of some other mod.
290
291 The `:` prefix can also be used for maintaining backwards compatibility.
292
293 ### Example
294
295 In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
296 So the name should be `experimental:tnt`.
297
298 Any mod can redefine `experimental:tnt` by using the name
299
300     :experimental:tnt
301
302 when registering it. For this to work correctly, that mod must have
303 `experimental` as a dependency.
304
305
306
307
308 Aliases
309 =======
310
311 Aliases of itemnames can be added by using
312 `minetest.register_alias(alias, original_name)` or
313 `minetest.register_alias_force(alias, original_name)`.
314
315 This adds an alias `alias` for the item called `original_name`.
316 From now on, you can use `alias` to refer to the item `original_name`.
317
318 The only difference between `minetest.register_alias` and
319 `minetest.register_alias_force` is that if an item named `alias` already exists,
320 `minetest.register_alias` will do nothing while
321 `minetest.register_alias_force` will unregister it.
322
323 This can be used for maintaining backwards compatibility.
324
325 This can also set quick access names for things, e.g. if
326 you have an item called `epiclylongmodname:stuff`, you could do
327
328     minetest.register_alias("stuff", "epiclylongmodname:stuff")
329
330 and be able to use `/giveme stuff`.
331
332 Mapgen aliases
333 --------------
334
335 In a game, a certain number of these must be set to tell core mapgens which
336 of the game's nodes are to be used for core mapgen generation. For example:
337
338     minetest.register_alias("mapgen_stone", "default:stone")
339
340 ### Aliases for non-V6 mapgens
341
342 #### Essential aliases
343
344 * `mapgen_stone`
345 * `mapgen_water_source`
346 * `mapgen_river_water_source`
347
348 `mapgen_river_water_source` is required for mapgens with sloping rivers where
349 it is necessary to have a river liquid node with a short `liquid_range` and
350 `liquid_renewable = false` to avoid flooding.
351
352 #### Optional aliases
353
354 * `mapgen_lava_source`
355
356 Fallback lava node used if cave liquids are not defined in biome definitions.
357 Deprecated, define cave liquids in biome definitions instead.
358
359 * `mapgen_cobble`
360
361 Fallback node used if dungeon nodes are not defined in biome definitions.
362 Deprecated, define dungeon nodes in biome definitions instead.
363
364 ### Aliases for Mapgen V6
365
366 #### Essential
367
368 * `mapgen_stone`
369 * `mapgen_water_source`
370 * `mapgen_lava_source`
371 * `mapgen_dirt`
372 * `mapgen_dirt_with_grass`
373 * `mapgen_sand`
374
375 * `mapgen_tree`
376 * `mapgen_leaves`
377 * `mapgen_apple`
378
379 * `mapgen_cobble`
380
381 #### Optional
382
383 * `mapgen_gravel` (falls back to stone)
384 * `mapgen_desert_stone` (falls back to stone)
385 * `mapgen_desert_sand` (falls back to sand)
386 * `mapgen_dirt_with_snow` (falls back to dirt_with_grass)
387 * `mapgen_snowblock` (falls back to dirt_with_grass)
388 * `mapgen_snow` (not placed if missing)
389 * `mapgen_ice` (falls back to water_source)
390
391 * `mapgen_jungletree` (falls back to tree)
392 * `mapgen_jungleleaves` (falls back to leaves)
393 * `mapgen_junglegrass` (not placed if missing)
394 * `mapgen_pine_tree` (falls back to tree)
395 * `mapgen_pine_needles` (falls back to leaves)
396
397 * `mapgen_stair_cobble` (falls back to cobble)
398 * `mapgen_mossycobble` (falls back to cobble)
399 * `mapgen_stair_desert_stone` (falls backto desert_stone)
400
401 ### Setting the node used in Mapgen Singlenode
402
403 By default the world is filled with air nodes. To set a different node use e.g.:
404
405     minetest.register_alias("mapgen_singlenode", "default:stone")
406
407
408
409
410 Textures
411 ========
412
413 Mods should generally prefix their textures with `modname_`, e.g. given
414 the mod name `foomod`, a texture could be called:
415
416     foomod_foothing.png
417
418 Textures are referred to by their complete name, or alternatively by
419 stripping out the file extension:
420
421 * e.g. `foomod_foothing.png`
422 * e.g. `foomod_foothing`
423
424 Supported texture formats are PNG (`.png`), JPEG (`.jpg`), Bitmap (`.bmp`)
425 and Targa (`.tga`).
426 Since better alternatives exist, the latter two may be removed in the future.
427
428 Texture modifiers
429 -----------------
430
431 There are various texture modifiers that can be used
432 to let the client generate textures on-the-fly.
433 The modifiers are applied directly in sRGB colorspace,
434 i.e. without gamma-correction.
435
436 ### Texture overlaying
437
438 Textures can be overlaid by putting a `^` between them.
439
440 Example:
441
442     default_dirt.png^default_grass_side.png
443
444 `default_grass_side.png` is overlaid over `default_dirt.png`.
445 The texture with the lower resolution will be automatically upscaled to
446 the higher resolution texture.
447
448 ### Texture grouping
449
450 Textures can be grouped together by enclosing them in `(` and `)`.
451
452 Example: `cobble.png^(thing1.png^thing2.png)`
453
454 A texture for `thing1.png^thing2.png` is created and the resulting
455 texture is overlaid on top of `cobble.png`.
456
457 ### Escaping
458
459 Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
460 passing complex texture names as arguments. Escaping is done with backslash and
461 is required for `^` and `:`.
462
463 Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
464
465 The lower 50 percent of `color.png^[mask:trans.png` are overlaid
466 on top of `cobble.png`.
467
468 ### Advanced texture modifiers
469
470 #### Crack
471
472 * `[crack:<n>:<p>`
473 * `[cracko:<n>:<p>`
474 * `[crack:<t>:<n>:<p>`
475 * `[cracko:<t>:<n>:<p>`
476
477 Parameters:
478
479 * `<t>`: tile count (in each direction)
480 * `<n>`: animation frame count
481 * `<p>`: current animation frame
482
483 Draw a step of the crack animation on the texture.
484 `crack` draws it normally, while `cracko` lays it over, keeping transparent
485 pixels intact.
486
487 Example:
488
489     default_cobble.png^[crack:10:1
490
491 #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
492
493 * `<w>`: width
494 * `<h>`: height
495 * `<x>`: x position
496 * `<y>`: y position
497 * `<file>`: texture to combine
498
499 Creates a texture of size `<w>` times `<h>` and blits the listed files to their
500 specified coordinates.
501
502 Example:
503
504     [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
505
506 #### `[resize:<w>x<h>`
507
508 Resizes the texture to the given dimensions.
509
510 Example:
511
512     default_sandstone.png^[resize:16x16
513
514 #### `[opacity:<r>`
515
516 Makes the base image transparent according to the given ratio.
517
518 `r` must be between 0 (transparent) and 255 (opaque).
519
520 Example:
521
522     default_sandstone.png^[opacity:127
523
524 #### `[invert:<mode>`
525
526 Inverts the given channels of the base image.
527 Mode may contain the characters "r", "g", "b", "a".
528 Only the channels that are mentioned in the mode string will be inverted.
529
530 Example:
531
532     default_apple.png^[invert:rgb
533
534 #### `[brighten`
535
536 Brightens the texture.
537
538 Example:
539
540     tnt_tnt_side.png^[brighten
541
542 #### `[noalpha`
543
544 Makes the texture completely opaque.
545
546 Example:
547
548     default_leaves.png^[noalpha
549
550 #### `[makealpha:<r>,<g>,<b>`
551
552 Convert one color to transparency.
553
554 Example:
555
556     default_cobble.png^[makealpha:128,128,128
557
558 #### `[transform<t>`
559
560 * `<t>`: transformation(s) to apply
561
562 Rotates and/or flips the image.
563
564 `<t>` can be a number (between 0 and 7) or a transform name.
565 Rotations are counter-clockwise.
566
567     0  I      identity
568     1  R90    rotate by 90 degrees
569     2  R180   rotate by 180 degrees
570     3  R270   rotate by 270 degrees
571     4  FX     flip X
572     5  FXR90  flip X then rotate by 90 degrees
573     6  FY     flip Y
574     7  FYR90  flip Y then rotate by 90 degrees
575
576 Example:
577
578     default_stone.png^[transformFXR90
579
580 #### `[inventorycube{<top>{<left>{<right>`
581
582 Escaping does not apply here and `^` is replaced by `&` in texture names
583 instead.
584
585 Create an inventory cube texture using the side textures.
586
587 Example:
588
589     [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
590
591 Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
592 `dirt.png^grass_side.png` textures
593
594 #### `[lowpart:<percent>:<file>`
595
596 Blit the lower `<percent>`% part of `<file>` on the texture.
597
598 Example:
599
600     base.png^[lowpart:25:overlay.png
601
602 #### `[verticalframe:<t>:<n>`
603
604 * `<t>`: animation frame count
605 * `<n>`: current animation frame
606
607 Crops the texture to a frame of a vertical animation.
608
609 Example:
610
611     default_torch_animated.png^[verticalframe:16:8
612
613 #### `[mask:<file>`
614
615 Apply a mask to the base image.
616
617 The mask is applied using binary AND.
618
619 #### `[sheet:<w>x<h>:<x>,<y>`
620
621 Retrieves a tile at position x,y from the base image
622 which it assumes to be a tilesheet with dimensions w,h.
623
624 #### `[colorize:<color>:<ratio>`
625
626 Colorize the textures with the given color.
627 `<color>` is specified as a `ColorString`.
628 `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`".  If
629 it is an int, then it specifies how far to interpolate between the
630 colors where 0 is only the texture color and 255 is only `<color>`. If
631 omitted, the alpha of `<color>` will be used as the ratio.  If it is
632 the word "`alpha`", then each texture pixel will contain the RGB of
633 `<color>` and the alpha of `<color>` multiplied by the alpha of the
634 texture pixel.
635
636 #### `[multiply:<color>`
637
638 Multiplies texture colors with the given color.
639 `<color>` is specified as a `ColorString`.
640 Result is more like what you'd expect if you put a color on top of another
641 color, meaning white surfaces get a lot of your new color while black parts
642 don't change very much.
643
644 #### `[png:<base64>`
645
646 Embed a base64 encoded PNG image in the texture string.
647 You can produce a valid string for this by calling
648 `minetest.encode_base64(minetest.encode_png(tex))`,
649 refer to the documentation of these functions for details.
650 You can use this to send disposable images such as captchas
651 to individual clients, or render things that would be too
652 expensive to compose with `[combine:`.
653
654 IMPORTANT: Avoid sending large images this way.
655 This is not a replacement for asset files, do not use it to do anything
656 that you could instead achieve by just using a file.
657 In particular consider `minetest.dynamic_add_media` and test whether
658 using other texture modifiers could result in a shorter string than
659 embedding a whole image, this may vary by use case.
660
661 Hardware coloring
662 -----------------
663
664 The goal of hardware coloring is to simplify the creation of
665 colorful nodes. If your textures use the same pattern, and they only
666 differ in their color (like colored wool blocks), you can use hardware
667 coloring instead of creating and managing many texture files.
668 All of these methods use color multiplication (so a white-black texture
669 with red coloring will result in red-black color).
670
671 ### Static coloring
672
673 This method is useful if you wish to create nodes/items with
674 the same texture, in different colors, each in a new node/item definition.
675
676 #### Global color
677
678 When you register an item or node, set its `color` field (which accepts a
679 `ColorSpec`) to the desired color.
680
681 An `ItemStack`'s static color can be overwritten by the `color` metadata
682 field. If you set that field to a `ColorString`, that color will be used.
683
684 #### Tile color
685
686 Each tile may have an individual static color, which overwrites every
687 other coloring method. To disable the coloring of a face,
688 set its color to white (because multiplying with white does nothing).
689 You can set the `color` property of the tiles in the node's definition
690 if the tile is in table format.
691
692 ### Palettes
693
694 For nodes and items which can have many colors, a palette is more
695 suitable. A palette is a texture, which can contain up to 256 pixels.
696 Each pixel is one possible color for the node/item.
697 You can register one node/item, which can have up to 256 colors.
698
699 #### Palette indexing
700
701 When using palettes, you always provide a pixel index for the given
702 node or `ItemStack`. The palette is read from left to right and from
703 top to bottom. If the palette has less than 256 pixels, then it is
704 stretched to contain exactly 256 pixels (after arranging the pixels
705 to one line). The indexing starts from 0.
706
707 Examples:
708
709 * 16x16 palette, index = 0: the top left corner
710 * 16x16 palette, index = 4: the fifth pixel in the first row
711 * 16x16 palette, index = 16: the pixel below the top left corner
712 * 16x16 palette, index = 255: the bottom right corner
713 * 2 (width) x 4 (height) palette, index = 31: the top left corner.
714   The palette has 8 pixels, so each pixel is stretched to 32 pixels,
715   to ensure the total 256 pixels.
716 * 2x4 palette, index = 32: the top right corner
717 * 2x4 palette, index = 63: the top right corner
718 * 2x4 palette, index = 64: the pixel below the top left corner
719
720 #### Using palettes with items
721
722 When registering an item, set the item definition's `palette` field to
723 a texture. You can also use texture modifiers.
724
725 The `ItemStack`'s color depends on the `palette_index` field of the
726 stack's metadata. `palette_index` is an integer, which specifies the
727 index of the pixel to use.
728
729 #### Linking palettes with nodes
730
731 When registering a node, set the item definition's `palette` field to
732 a texture. You can also use texture modifiers.
733 The node's color depends on its `param2`, so you also must set an
734 appropriate `paramtype2`:
735
736 * `paramtype2 = "color"` for nodes which use their full `param2` for
737   palette indexing. These nodes can have 256 different colors.
738   The palette should contain 256 pixels.
739 * `paramtype2 = "colorwallmounted"` for nodes which use the first
740   five bits (most significant) of `param2` for palette indexing.
741   The remaining three bits are describing rotation, as in `wallmounted`
742   paramtype2. Division by 8 yields the palette index (without stretching the
743   palette). These nodes can have 32 different colors, and the palette
744   should contain 32 pixels.
745   Examples:
746     * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
747       pixel will be picked from the palette.
748     * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
749       pixel will be picked from the palette.
750 * `paramtype2 = "colorfacedir"` for nodes which use the first
751   three bits of `param2` for palette indexing. The remaining
752   five bits are describing rotation, as in `facedir` paramtype2.
753   Division by 32 yields the palette index (without stretching the
754   palette). These nodes can have 8 different colors, and the
755   palette should contain 8 pixels.
756   Examples:
757     * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
758       first (= 0 + 1) pixel will be picked from the palette.
759     * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
760       second (= 1 + 1) pixel will be picked from the palette.
761
762 To colorize a node on the map, set its `param2` value (according
763 to the node's paramtype2).
764
765 ### Conversion between nodes in the inventory and on the map
766
767 Static coloring is the same for both cases, there is no need
768 for conversion.
769
770 If the `ItemStack`'s metadata contains the `color` field, it will be
771 lost on placement, because nodes on the map can only use palettes.
772
773 If the `ItemStack`'s metadata contains the `palette_index` field, it is
774 automatically transferred between node and item forms by the engine,
775 when a player digs or places a colored node.
776 You can disable this feature by setting the `drop` field of the node
777 to itself (without metadata).
778 To transfer the color to a special drop, you need a drop table.
779
780 Example:
781
782     minetest.register_node("mod:stone", {
783         description = "Stone",
784         tiles = {"default_stone.png"},
785         paramtype2 = "color",
786         palette = "palette.png",
787         drop = {
788             items = {
789                 -- assume that mod:cobblestone also has the same palette
790                 {items = {"mod:cobblestone"}, inherit_color = true },
791             }
792         }
793     })
794
795 ### Colored items in craft recipes
796
797 Craft recipes only support item strings, but fortunately item strings
798 can also contain metadata. Example craft recipe registration:
799
800     minetest.register_craft({
801         output = minetest.itemstring_with_palette("wool:block", 3),
802         type = "shapeless",
803         recipe = {
804             "wool:block",
805             "dye:red",
806         },
807     })
808
809 To set the `color` field, you can use `minetest.itemstring_with_color`.
810
811 Metadata field filtering in the `recipe` field are not supported yet,
812 so the craft output is independent of the color of the ingredients.
813
814 Soft texture overlay
815 --------------------
816
817 Sometimes hardware coloring is not enough, because it affects the
818 whole tile. Soft texture overlays were added to Minetest to allow
819 the dynamic coloring of only specific parts of the node's texture.
820 For example a grass block may have colored grass, while keeping the
821 dirt brown.
822
823 These overlays are 'soft', because unlike texture modifiers, the layers
824 are not merged in the memory, but they are simply drawn on top of each
825 other. This allows different hardware coloring, but also means that
826 tiles with overlays are drawn slower. Using too much overlays might
827 cause FPS loss.
828
829 For inventory and wield images you can specify overlays which
830 hardware coloring does not modify. You have to set `inventory_overlay`
831 and `wield_overlay` fields to an image name.
832
833 To define a node overlay, simply set the `overlay_tiles` field of the node
834 definition. These tiles are defined in the same way as plain tiles:
835 they can have a texture name, color etc.
836 To skip one face, set that overlay tile to an empty string.
837
838 Example (colored grass block):
839
840     minetest.register_node("default:dirt_with_grass", {
841         description = "Dirt with Grass",
842         -- Regular tiles, as usual
843         -- The dirt tile disables palette coloring
844         tiles = {{name = "default_grass.png"},
845             {name = "default_dirt.png", color = "white"}},
846         -- Overlay tiles: define them in the same style
847         -- The top and bottom tile does not have overlay
848         overlay_tiles = {"", "",
849             {name = "default_grass_side.png"}},
850         -- Global color, used in inventory
851         color = "green",
852         -- Palette in the world
853         paramtype2 = "color",
854         palette = "default_foilage.png",
855     })
856
857
858
859
860 Sounds
861 ======
862
863 Only Ogg Vorbis files are supported.
864
865 For positional playing of sounds, only single-channel (mono) files are
866 supported. Otherwise OpenAL will play them non-positionally.
867
868 Mods should generally prefix their sounds with `modname_`, e.g. given
869 the mod name "`foomod`", a sound could be called:
870
871     foomod_foosound.ogg
872
873 Sounds are referred to by their name with a dot, a single digit and the
874 file extension stripped out. When a sound is played, the actual sound file
875 is chosen randomly from the matching sounds.
876
877 When playing the sound `foomod_foosound`, the sound is chosen randomly
878 from the available ones of the following files:
879
880 * `foomod_foosound.ogg`
881 * `foomod_foosound.0.ogg`
882 * `foomod_foosound.1.ogg`
883 * (...)
884 * `foomod_foosound.9.ogg`
885
886 Examples of sound parameter tables:
887
888     -- Play locationless on all clients
889     {
890         gain = 1.0,   -- default
891         fade = 0.0,   -- default, change to a value > 0 to fade the sound in
892         pitch = 1.0,  -- default
893     }
894     -- Play locationless to one player
895     {
896         to_player = name,
897         gain = 1.0,   -- default
898         fade = 0.0,   -- default, change to a value > 0 to fade the sound in
899         pitch = 1.0,  -- default
900     }
901     -- Play locationless to one player, looped
902     {
903         to_player = name,
904         gain = 1.0,  -- default
905         loop = true,
906     }
907     -- Play at a location
908     {
909         pos = {x = 1, y = 2, z = 3},
910         gain = 1.0,  -- default
911         max_hear_distance = 32,  -- default, uses an euclidean metric
912     }
913     -- Play connected to an object, looped
914     {
915         object = <an ObjectRef>,
916         gain = 1.0,  -- default
917         max_hear_distance = 32,  -- default, uses an euclidean metric
918         loop = true,
919     }
920     -- Play at a location, heard by anyone *but* the given player
921     {
922         pos = {x = 32, y = 0, z = 100},
923         max_hear_distance = 40,
924         exclude_player = name,
925     }
926
927 Looped sounds must either be connected to an object or played locationless to
928 one player using `to_player = name`.
929
930 A positional sound will only be heard by players that are within
931 `max_hear_distance` of the sound position, at the start of the sound.
932
933 `exclude_player = name` can be applied to locationless, positional and object-
934 bound sounds to exclude a single player from hearing them.
935
936 `SimpleSoundSpec`
937 -----------------
938
939 Specifies a sound name, gain (=volume) and pitch.
940 This is either a string or a table.
941
942 In string form, you just specify the sound name or
943 the empty string for no sound.
944
945 Table form has the following fields:
946
947 * `name`: Sound name
948 * `gain`: Volume (`1.0` = 100%)
949 * `pitch`: Pitch (`1.0` = 100%)
950
951 `gain` and `pitch` are optional and default to `1.0`.
952
953 Examples:
954
955 * `""`: No sound
956 * `{}`: No sound
957 * `"default_place_node"`: Play e.g. `default_place_node.ogg`
958 * `{name = "default_place_node"}`: Same as above
959 * `{name = "default_place_node", gain = 0.5}`: 50% volume
960 * `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
961
962 Special sound files
963 -------------------
964
965 These sound files are played back by the engine if provided.
966
967  * `player_damage`: Played when the local player takes damage (gain = 0.5)
968  * `player_falling_damage`: Played when the local player takes
969    damage by falling (gain = 0.5)
970  * `player_jump`: Played when the local player jumps
971  * `default_dig_<groupname>`: Default node digging sound
972    (see node sound definition for details)
973
974 Registered definitions
975 ======================
976
977 Anything added using certain [Registration functions] gets added to one or more
978 of the global [Registered definition tables].
979
980 Note that in some cases you will stumble upon things that are not contained
981 in these tables (e.g. when a mod has been removed). Always check for
982 existence before trying to access the fields.
983
984 Example:
985
986 All nodes register with `minetest.register_node` get added to the table
987 `minetest.registered_nodes`.
988
989 If you want to check the drawtype of a node, you could do it like this:
990
991     local def = minetest.registered_nodes[nodename]
992     local drawtype = def and def.drawtype
993
994
995
996
997 Nodes
998 =====
999
1000 Nodes are the bulk data of the world: cubes and other things that take the
1001 space of a cube. Huge amounts of them are handled efficiently, but they
1002 are quite static.
1003
1004 The definition of a node is stored and can be accessed by using
1005
1006     minetest.registered_nodes[node.name]
1007
1008 See [Registered definitions].
1009
1010 Nodes are passed by value between Lua and the engine.
1011 They are represented by a table:
1012
1013     {name="name", param1=num, param2=num}
1014
1015 `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
1016 them for certain automated functions. If you don't use these functions, you can
1017 use them to store arbitrary values.
1018
1019 Node paramtypes
1020 ---------------
1021
1022 The functions of `param1` and `param2` are determined by certain fields in the
1023 node definition.
1024
1025 The function of `param1` is determined by `paramtype` in node definition.
1026 `param1` is reserved for the engine when `paramtype != "none"`.
1027
1028 * `paramtype = "light"`
1029     * The value stores light with and without sun in its lower and upper 4 bits
1030       respectively.
1031     * Required by a light source node to enable spreading its light.
1032     * Required by the following drawtypes as they determine their visual
1033       brightness from their internal light value:
1034         * torchlike
1035         * signlike
1036         * firelike
1037         * fencelike
1038         * raillike
1039         * nodebox
1040         * mesh
1041         * plantlike
1042         * plantlike_rooted
1043 * `paramtype = "none"`
1044     * `param1` will not be used by the engine and can be used to store
1045       an arbitrary value
1046
1047 The function of `param2` is determined by `paramtype2` in node definition.
1048 `param2` is reserved for the engine when `paramtype2 != "none"`.
1049
1050 * `paramtype2 = "flowingliquid"`
1051     * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"`
1052     * The liquid level and a flag of the liquid are stored in `param2`
1053     * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node;
1054       see `minetest.get_node_level`, `minetest.set_node_level` and `minetest.add_node_level`
1055       to access/manipulate the content of this field
1056     * Bit 3: If set, liquid is flowing downwards (no graphical effect)
1057 * `paramtype2 = "wallmounted"`
1058     * Supported drawtypes: "torchlike", "signlike", "plantlike",
1059       "plantlike_rooted", "normal", "nodebox", "mesh"
1060     * The rotation of the node is stored in `param2`
1061     * You can make this value by using `minetest.dir_to_wallmounted()`
1062     * Values range 0 - 5
1063     * The value denotes at which direction the node is "mounted":
1064       0 = y+,   1 = y-,   2 = x+,   3 = x-,   4 = z+,   5 = z-
1065 * `paramtype2 = "facedir"`
1066     * Supported drawtypes: "normal", "nodebox", "mesh"
1067     * The rotation of the node is stored in `param2`. Furnaces and chests are
1068       rotated this way. Can be made by using `minetest.dir_to_facedir()`.
1069     * Values range 0 - 23
1070     * facedir / 4 = axis direction:
1071       0 = y+,   1 = z+,   2 = z-,   3 = x+,   4 = x-,   5 = y-
1072     * facedir modulo 4 = rotation around that axis
1073 * `paramtype2 = "leveled"`
1074     * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
1075         * Leveled nodebox:
1076             * The level of the top face of the nodebox is stored in `param2`.
1077             * The other faces are defined by 'fixed = {}' like 'type = "fixed"'
1078               nodeboxes.
1079             * The nodebox height is (`param2` / 64) nodes.
1080             * The maximum accepted value of `param2` is 127.
1081         * Rooted plantlike:
1082             * The height of the 'plantlike' section is stored in `param2`.
1083             * The height is (`param2` / 16) nodes.
1084 * `paramtype2 = "degrotate"`
1085     * Valid for `plantlike` and `mesh` drawtypes. The rotation of the node is
1086       stored in `param2`.
1087     * Values range 0–239. The value stored in `param2` is multiplied by 1.5 to
1088       get the actual rotation in degrees of the node.
1089 * `paramtype2 = "meshoptions"`
1090     * Only valid for "plantlike" drawtype. `param2` encodes the shape and
1091       optional modifiers of the "plant". `param2` is a bitfield.
1092     * Bits 0 to 2 select the shape.
1093       Use only one of the values below:
1094         * 0 = a "x" shaped plant (ordinary plant)
1095         * 1 = a "+" shaped plant (just rotated 45 degrees)
1096         * 2 = a "*" shaped plant with 3 faces instead of 2
1097         * 3 = a "#" shaped plant with 4 faces instead of 2
1098         * 4 = a "#" shaped plant with 4 faces that lean outwards
1099         * 5-7 are unused and reserved for future meshes.
1100     * Bits 3 to 7 are used to enable any number of optional modifiers.
1101       Just add the corresponding value(s) below to `param2`:
1102         * 8  - Makes the plant slightly vary placement horizontally
1103         * 16 - Makes the plant mesh 1.4x larger
1104         * 32 - Moves each face randomly a small bit down (1/8 max)
1105         * values 64 and 128 (bits 6-7) are reserved for future use.
1106     * Example: `param2 = 0` selects a normal "x" shaped plant
1107     * Example: `param2 = 17` selects a "+" shaped plant, 1.4x larger (1+16)
1108 * `paramtype2 = "color"`
1109     * `param2` tells which color is picked from the palette.
1110       The palette should have 256 pixels.
1111 * `paramtype2 = "colorfacedir"`
1112     * Same as `facedir`, but with colors.
1113     * The first three bits of `param2` tells which color is picked from the
1114       palette. The palette should have 8 pixels.
1115 * `paramtype2 = "colorwallmounted"`
1116     * Same as `wallmounted`, but with colors.
1117     * The first five bits of `param2` tells which color is picked from the
1118       palette. The palette should have 32 pixels.
1119 * `paramtype2 = "glasslikeliquidlevel"`
1120     * Only valid for "glasslike_framed" or "glasslike_framed_optional"
1121       drawtypes. "glasslike_framed_optional" nodes are only affected if the
1122       "Connected Glass" setting is enabled.
1123     * Bits 0-5 define 64 levels of internal liquid, 0 being empty and 63 being
1124       full.
1125     * Bits 6 and 7 modify the appearance of the frame and node faces. One or
1126       both of these values may be added to `param2`:
1127         * 64  - Makes the node not connect with neighbors above or below it.
1128         * 128 - Makes the node not connect with neighbors to its sides.
1129     * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}`
1130 * `paramtype2 = "colordegrotate"`
1131     * Same as `degrotate`, but with colors.
1132     * The first (most-significant) three bits of `param2` tells which color
1133       is picked from the palette. The palette should have 8 pixels.
1134     * Remaining 5 bits store rotation in range 0–23 (i.e. in 15° steps)
1135 * `paramtype2 = "none"`
1136     * `param2` will not be used by the engine and can be used to store
1137       an arbitrary value
1138
1139 Nodes can also contain extra data. See [Node Metadata].
1140
1141 Node drawtypes
1142 --------------
1143
1144 There are a bunch of different looking node types.
1145
1146 Look for examples in `games/devtest` or `games/minetest_game`.
1147
1148 * `normal`
1149     * A node-sized cube.
1150 * `airlike`
1151     * Invisible, uses no texture.
1152 * `liquid`
1153     * The cubic source node for a liquid.
1154     * Faces bordering to the same node are never rendered.
1155     * Connects to node specified in `liquid_alternative_flowing`.
1156     * Use `backface_culling = false` for the tiles you want to make
1157       visible when inside the node.
1158 * `flowingliquid`
1159     * The flowing version of a liquid, appears with various heights and slopes.
1160     * Faces bordering to the same node are never rendered.
1161     * Connects to node specified in `liquid_alternative_source`.
1162     * Node textures are defined with `special_tiles` where the first tile
1163       is for the top and bottom faces and the second tile is for the side
1164       faces.
1165     * `tiles` is used for the item/inventory/wield image rendering.
1166     * Use `backface_culling = false` for the special tiles you want to make
1167       visible when inside the node
1168 * `glasslike`
1169     * Often used for partially-transparent nodes.
1170     * Only external sides of textures are visible.
1171 * `glasslike_framed`
1172     * All face-connected nodes are drawn as one volume within a surrounding
1173       frame.
1174     * The frame appearance is generated from the edges of the first texture
1175       specified in `tiles`. The width of the edges used are 1/16th of texture
1176       size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
1177     * The glass 'shine' (or other desired detail) on each node face is supplied
1178       by the second texture specified in `tiles`.
1179 * `glasslike_framed_optional`
1180     * This switches between the above 2 drawtypes according to the menu setting
1181       'Connected Glass'.
1182 * `allfaces`
1183     * Often used for partially-transparent nodes.
1184     * External and internal sides of textures are visible.
1185 * `allfaces_optional`
1186     * Often used for leaves nodes.
1187     * This switches between `normal`, `glasslike` and `allfaces` according to
1188       the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
1189     * With 'Simple Leaves' selected, the texture specified in `special_tiles`
1190       is used instead, if present. This allows a visually thicker texture to be
1191       used to compensate for how `glasslike` reduces visual thickness.
1192 * `torchlike`
1193     * A single vertical texture.
1194     * If `paramtype2="[color]wallmounted"`:
1195         * If placed on top of a node, uses the first texture specified in `tiles`.
1196         * If placed against the underside of a node, uses the second texture
1197           specified in `tiles`.
1198         * If placed on the side of a node, uses the third texture specified in
1199           `tiles` and is perpendicular to that node.
1200     * If `paramtype2="none"`:
1201         * Will be rendered as if placed on top of a node (see
1202           above) and only the first texture is used.
1203 * `signlike`
1204     * A single texture parallel to, and mounted against, the top, underside or
1205       side of a node.
1206     * If `paramtype2="[color]wallmounted"`, it rotates according to `param2`
1207     * If `paramtype2="none"`, it will always be on the floor.
1208 * `plantlike`
1209     * Two vertical and diagonal textures at right-angles to each other.
1210     * See `paramtype2 = "meshoptions"` above for other options.
1211 * `firelike`
1212     * When above a flat surface, appears as 6 textures, the central 2 as
1213       `plantlike` plus 4 more surrounding those.
1214     * If not above a surface the central 2 do not appear, but the texture
1215       appears against the faces of surrounding nodes if they are present.
1216 * `fencelike`
1217     * A 3D model suitable for a wooden fence.
1218     * One placed node appears as a single vertical post.
1219     * Adjacently-placed nodes cause horizontal bars to appear between them.
1220 * `raillike`
1221     * Often used for tracks for mining carts.
1222     * Requires 4 textures to be specified in `tiles`, in order: Straight,
1223       curved, t-junction, crossing.
1224     * Each placed node automatically switches to a suitable rotated texture
1225       determined by the adjacent `raillike` nodes, in order to create a
1226       continuous track network.
1227     * Becomes a sloping node if placed against stepped nodes.
1228 * `nodebox`
1229     * Often used for stairs and slabs.
1230     * Allows defining nodes consisting of an arbitrary number of boxes.
1231     * See [Node boxes] below for more information.
1232 * `mesh`
1233     * Uses models for nodes.
1234     * Tiles should hold model materials textures.
1235     * Only static meshes are implemented.
1236     * For supported model formats see Irrlicht engine documentation.
1237 * `plantlike_rooted`
1238     * Enables underwater `plantlike` without air bubbles around the nodes.
1239     * Consists of a base cube at the co-ordinates of the node plus a
1240       `plantlike` extension above
1241     * If `paramtype2="leveled", the `plantlike` extension has a height
1242       of `param2 / 16` nodes, otherwise it's the height of 1 node
1243     * If `paramtype2="wallmounted"`, the `plantlike` extension
1244       will be at one of the corresponding 6 sides of the base cube.
1245       Also, the base cube rotates like a `normal` cube would
1246     * The `plantlike` extension visually passes through any nodes above the
1247       base cube without affecting them.
1248     * The base cube texture tiles are defined as normal, the `plantlike`
1249       extension uses the defined special tile, for example:
1250       `special_tiles = {{name = "default_papyrus.png"}},`
1251
1252 `*_optional` drawtypes need less rendering time if deactivated
1253 (always client-side).
1254
1255 Node boxes
1256 ----------
1257
1258 Node selection boxes are defined using "node boxes".
1259
1260 A nodebox is defined as any of:
1261
1262     {
1263         -- A normal cube; the default in most things
1264         type = "regular"
1265     }
1266     {
1267         -- A fixed box (or boxes) (facedir param2 is used, if applicable)
1268         type = "fixed",
1269         fixed = box OR {box1, box2, ...}
1270     }
1271     {
1272         -- A variable height box (or boxes) with the top face position defined
1273         -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
1274         -- by param2.
1275         -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
1276         type = "leveled",
1277         fixed = box OR {box1, box2, ...}
1278     }
1279     {
1280         -- A box like the selection box for torches
1281         -- (wallmounted param2 is used, if applicable)
1282         type = "wallmounted",
1283         wall_top = box,
1284         wall_bottom = box,
1285         wall_side = box
1286     }
1287     {
1288         -- A node that has optional boxes depending on neighbouring nodes'
1289         -- presence and type. See also `connects_to`.
1290         type = "connected",
1291         fixed = box OR {box1, box2, ...}
1292         connect_top = box OR {box1, box2, ...}
1293         connect_bottom = box OR {box1, box2, ...}
1294         connect_front = box OR {box1, box2, ...}
1295         connect_left = box OR {box1, box2, ...}
1296         connect_back = box OR {box1, box2, ...}
1297         connect_right = box OR {box1, box2, ...}
1298         -- The following `disconnected_*` boxes are the opposites of the
1299         -- `connect_*` ones above, i.e. when a node has no suitable neighbour
1300         -- on the respective side, the corresponding disconnected box is drawn.
1301         disconnected_top = box OR {box1, box2, ...}
1302         disconnected_bottom = box OR {box1, box2, ...}
1303         disconnected_front = box OR {box1, box2, ...}
1304         disconnected_left = box OR {box1, box2, ...}
1305         disconnected_back = box OR {box1, box2, ...}
1306         disconnected_right = box OR {box1, box2, ...}
1307         disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour
1308         disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
1309                                                       -- neighbours to the sides
1310     }
1311
1312 A `box` is defined as:
1313
1314     {x1, y1, z1, x2, y2, z2}
1315
1316 A box of a regular node would look like:
1317
1318     {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
1319
1320 To avoid collision issues, keep each value within the range of +/- 1.45.
1321 This also applies to leveled nodeboxes, where the final height shall not
1322 exceed this soft limit.
1323
1324
1325
1326 Map terminology and coordinates
1327 ===============================
1328
1329 Nodes, mapblocks, mapchunks
1330 ---------------------------
1331
1332 A 'node' is the fundamental cubic unit of a world and appears to a player as
1333 roughly 1x1x1 meters in size.
1334
1335 A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
1336 fundamental region of a world that is stored in the world database, sent to
1337 clients and handled by many parts of the engine.
1338 'mapblock' is preferred terminology to 'block' to help avoid confusion with
1339 'node', however 'block' often appears in the API.
1340
1341 A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
1342 (80x80x80 nodes) and is the volume of world generated in one operation by
1343 the map generator.
1344 The size in mapblocks has been chosen to optimise map generation.
1345
1346 Coordinates
1347 -----------
1348
1349 ### Orientation of axes
1350
1351 For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
1352
1353 ### Node coordinates
1354
1355 Almost all positions used in the API use node coordinates.
1356
1357 ### Mapblock coordinates
1358
1359 Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
1360 specify a particular mapblock.
1361 For example blockpos (0,0,0) specifies the mapblock that extends from
1362 node position (0,0,0) to node position (15,15,15).
1363
1364 #### Converting node position to the containing blockpos
1365
1366 To calculate the blockpos of the mapblock that contains the node at 'nodepos',
1367 for each axis:
1368
1369 * blockpos = math.floor(nodepos / 16)
1370
1371 #### Converting blockpos to min/max node positions
1372
1373 To calculate the min/max node positions contained in the mapblock at 'blockpos',
1374 for each axis:
1375
1376 * Minimum:
1377   nodepos = blockpos * 16
1378 * Maximum:
1379   nodepos = blockpos * 16 + 15
1380
1381
1382
1383
1384 HUD
1385 ===
1386
1387 HUD element types
1388 -----------------
1389
1390 The position field is used for all element types.
1391 To account for differing resolutions, the position coordinates are the
1392 percentage of the screen, ranging in value from `0` to `1`.
1393
1394 The `name` field is not yet used, but should contain a description of what the
1395 HUD element represents.
1396
1397 The `direction` field is the direction in which something is drawn.
1398 `0` draws from left to right, `1` draws from right to left, `2` draws from
1399 top to bottom, and `3` draws from bottom to top.
1400
1401 The `alignment` field specifies how the item will be aligned. It is a table
1402 where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
1403 moved to the left/up, and `1` is to the right/down. Fractional values can be
1404 used.
1405
1406 The `offset` field specifies a pixel offset from the position. Contrary to
1407 position, the offset is not scaled to screen size. This allows for some
1408 precisely positioned items in the HUD.
1409
1410 **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
1411 factor!
1412
1413 The `z_index` field specifies the order of HUD elements from back to front.
1414 Lower z-index elements are displayed behind higher z-index elements. Elements
1415 with same z-index are displayed in an arbitrary order. Default 0.
1416 Supports negative values. By convention, the following values are recommended:
1417
1418 *  -400: Graphical effects, such as vignette
1419 *  -300: Name tags, waypoints
1420 *  -200: Wieldhand
1421 *  -100: Things that block the player's view, e.g. masks
1422 *     0: Default. For standard in-game HUD elements like crosshair, hotbar,
1423          minimap, builtin statbars, etc.
1424 *   100: Temporary text messages or notification icons
1425 *  1000: Full-screen effects such as full-black screen or credits.
1426          This includes effects that cover the entire screen
1427
1428 If your HUD element doesn't fit into any category, pick a number
1429 between the suggested values
1430
1431 Below are the specific uses for fields in each type; fields not listed for that
1432 type are ignored.
1433
1434 ### `image`
1435
1436 Displays an image on the HUD.
1437
1438 * `scale`: The scale of the image, with 1 being the original texture size.
1439   Only the X coordinate scale is used (positive values).
1440   Negative values represent that percentage of the screen it
1441   should take; e.g. `x=-100` means 100% (width).
1442 * `text`: The name of the texture that is displayed.
1443 * `alignment`: The alignment of the image.
1444 * `offset`: offset in pixels from position.
1445
1446 ### `text`
1447
1448 Displays text on the HUD.
1449
1450 * `scale`: Defines the bounding rectangle of the text.
1451   A value such as `{x=100, y=100}` should work.
1452 * `text`: The text to be displayed in the HUD element.
1453 * `number`: An integer containing the RGB value of the color used to draw the
1454   text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
1455 * `alignment`: The alignment of the text.
1456 * `offset`: offset in pixels from position.
1457 * `size`: size of the text.
1458   The player-set font size is multiplied by size.x (y value isn't used).
1459 * `style`: determines font style
1460   Bitfield with 1 = bold, 2 = italic, 4 = monospace
1461
1462 ### `statbar`
1463
1464 Displays a horizontal bar made up of half-images with an optional background.
1465
1466 * `text`: The name of the texture to use.
1467 * `text2`: Optional texture name to enable a background / "off state"
1468   texture (useful to visualize the maximal value). Both textures
1469   must have the same size.
1470 * `number`: The number of half-textures that are displayed.
1471   If odd, will end with a vertically center-split texture.
1472 * `item`: Same as `number` but for the "off state" texture
1473 * `direction`: To which direction the images will extend to
1474 * `offset`: offset in pixels from position.
1475 * `size`: If used, will force full-image size to this value (override texture
1476   pack image size)
1477
1478 ### `inventory`
1479
1480 * `text`: The name of the inventory list to be displayed.
1481 * `number`: Number of items in the inventory to be displayed.
1482 * `item`: Position of item that is selected.
1483 * `direction`: Direction the list will be displayed in
1484 * `offset`: offset in pixels from position.
1485
1486 ### `waypoint`
1487
1488 Displays distance to selected world position.
1489
1490 * `name`: The name of the waypoint.
1491 * `text`: Distance suffix. Can be blank.
1492 * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
1493   If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
1494   When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
1495   `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
1496   `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
1497   `precision = n` will show multiples of `1/n`
1498 * `number:` An integer containing the RGB value of the color used to draw the
1499   text.
1500 * `world_pos`: World position of the waypoint.
1501 * `offset`: offset in pixels from position.
1502 * `alignment`: The alignment of the waypoint.
1503
1504 ### `image_waypoint`
1505
1506 Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
1507
1508 * `scale`: The scale of the image, with 1 being the original texture size.
1509   Only the X coordinate scale is used (positive values).
1510   Negative values represent that percentage of the screen it
1511   should take; e.g. `x=-100` means 100% (width).
1512 * `text`: The name of the texture that is displayed.
1513 * `alignment`: The alignment of the image.
1514 * `world_pos`: World position of the waypoint.
1515 * `offset`: offset in pixels from position.
1516
1517 ### `compass`
1518
1519 Displays an image oriented or translated according to current heading direction.
1520
1521 * `size`: The size of this element. Negative values represent percentage
1522   of the screen; e.g. `x=-100` means 100% (width).
1523 * `scale`: Scale of the translated image (used only for dir = 2 or dir = 3).
1524 * `text`: The name of the texture to use.
1525 * `alignment`: The alignment of the image.
1526 * `offset`: Offset in pixels from position.
1527 * `direction`: How the image is rotated/translated:
1528   * 0 - Rotate as heading direction
1529   * 1 - Rotate in reverse direction
1530   * 2 - Translate as landscape direction
1531   * 3 - Translate in reverse direction
1532
1533 If translation is chosen, texture is repeated horizontally to fill the whole element.
1534
1535 ### `minimap`
1536
1537 Displays a minimap on the HUD.
1538
1539 * `size`: Size of the minimap to display. Minimap should be a square to avoid
1540   distortion.
1541 * `alignment`: The alignment of the minimap.
1542 * `offset`: offset in pixels from position.
1543
1544 Representations of simple things
1545 ================================
1546
1547 Vector (ie. a position)
1548 -----------------------
1549
1550     vector.new(x, y, z)
1551
1552 See [Spatial Vectors] for details.
1553
1554 `pointed_thing`
1555 ---------------
1556
1557 * `{type="nothing"}`
1558 * `{type="node", under=pos, above=pos}`
1559     * Indicates a pointed node selection box.
1560     * `under` refers to the node position behind the pointed face.
1561     * `above` refers to the node position in front of the pointed face.
1562 * `{type="object", ref=ObjectRef}`
1563
1564 Exact pointing location (currently only `Raycast` supports these fields):
1565
1566 * `pointed_thing.intersection_point`: The absolute world coordinates of the
1567   point on the selection box which is pointed at. May be in the selection box
1568   if the pointer is in the box too.
1569 * `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
1570   from 1).
1571 * `pointed_thing.intersection_normal`: Unit vector, points outwards of the
1572   selected selection box. This specifies which face is pointed at.
1573   Is a null vector `vector.zero()` when the pointer is inside the selection box.
1574
1575
1576
1577
1578 Flag Specifier Format
1579 =====================
1580
1581 Flags using the standardized flag specifier format can be specified in either
1582 of two ways, by string or table.
1583
1584 The string format is a comma-delimited set of flag names; whitespace and
1585 unrecognized flag fields are ignored. Specifying a flag in the string sets the
1586 flag, and specifying a flag prefixed by the string `"no"` explicitly
1587 clears the flag from whatever the default may be.
1588
1589 In addition to the standard string flag format, the schematic flags field can
1590 also be a table of flag names to boolean values representing whether or not the
1591 flag is set. Additionally, if a field with the flag name prefixed with `"no"`
1592 is present, mapped to a boolean of any value, the specified flag is unset.
1593
1594 E.g. A flag field of value
1595
1596     {place_center_x = true, place_center_y=false, place_center_z=true}
1597
1598 is equivalent to
1599
1600     {place_center_x = true, noplace_center_y=true, place_center_z=true}
1601
1602 which is equivalent to
1603
1604     "place_center_x, noplace_center_y, place_center_z"
1605
1606 or even
1607
1608     "place_center_x, place_center_z"
1609
1610 since, by default, no schematic attributes are set.
1611
1612
1613
1614
1615 Items
1616 =====
1617
1618 Items are things that can be held by players, dropped in the map and
1619 stored in inventories.
1620 Items come in the form of item stacks, which are collections of equal
1621 items that occupy a single inventory slot.
1622
1623 Item types
1624 ----------
1625
1626 There are three kinds of items: nodes, tools and craftitems.
1627
1628 * Node: Placeable item form of a node in the world's voxel grid
1629 * Tool: Has a changable wear property but cannot be stacked
1630 * Craftitem: Has no special properties
1631
1632 Every registered node (the voxel in the world) has a corresponding
1633 item form (the thing in your inventory) that comes along with it.
1634 This item form can be placed which will create a node in the
1635 world (by default).
1636 Both the 'actual' node and its item form share the same identifier.
1637 For all practical purposes, you can treat the node and its item form
1638 interchangeably. We usually just say 'node' to the item form of
1639 the node as well.
1640
1641 Note the definition of tools is purely technical. The only really
1642 unique thing about tools is their wear, and that's basically it.
1643 Beyond that, you can't make any gameplay-relevant assumptions
1644 about tools or non-tools. It is perfectly valid to register something
1645 that acts as tool in a gameplay sense as a craftitem, and vice-versa.
1646
1647 Craftitems can be used for items that neither need to be a node
1648 nor a tool.
1649
1650 Amount and wear
1651 ---------------
1652
1653 All item stacks have an amount between 0 and 65535. It is 1 by
1654 default. Tool item stacks can not have an amount greater than 1.
1655
1656 Tools use a wear (damage) value ranging from 0 to 65535. The
1657 value 0 is the default and is used for unworn tools. The values
1658 1 to 65535 are used for worn tools, where a higher value stands for
1659 a higher wear. Non-tools technically also have a wear property,
1660 but it is always 0. There is also a special 'toolrepair' crafting
1661 recipe that is only available to tools.
1662
1663 Item formats
1664 ------------
1665
1666 Items and item stacks can exist in three formats: Serializes, table format
1667 and `ItemStack`.
1668
1669 When an item must be passed to a function, it can usually be in any of
1670 these formats.
1671
1672 ### Serialized
1673
1674 This is called "stackstring" or "itemstring". It is a simple string with
1675 1-4 components:
1676
1677 1. Full item identifier ("item name")
1678 2. Optional amount
1679 3. Optional wear value
1680 4. Optional item metadata
1681
1682 Syntax:
1683
1684     <identifier> [<amount>[ <wear>[ <metadata>]]]
1685
1686 Examples:
1687
1688 * `"default:apple"`: 1 apple
1689 * `"default:dirt 5"`: 5 dirt
1690 * `"default:pick_stone"`: a new stone pickaxe
1691 * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out
1692 * `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`:
1693   * a wooden pickaxe from the `default` mod,
1694   * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool),
1695   * with the `description` field set to `"My worn out pick"` in its metadata
1696 * `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`:
1697   * analogeous to the above example
1698   * note how the wear is set to `0` as dirt is not a tool
1699
1700 You should ideally use the `ItemStack` format to build complex item strings
1701 (especially if they use item metadata)
1702 without relying on the serialization format. Example:
1703
1704     local stack = ItemStack("default:pick_wood")
1705     stack:set_wear(21323)
1706     stack:get_meta():set_string("description", "My worn out pick")
1707     local itemstring = stack:to_string()
1708
1709 Additionally the methods `minetest.itemstring_with_palette(item, palette_index)`
1710 and `minetest.itemstring_with_color(item, colorstring)` may be used to create
1711 item strings encoding color information in their metadata.
1712
1713 ### Table format
1714
1715 Examples:
1716
1717 5 dirt nodes:
1718
1719     {name="default:dirt", count=5, wear=0, metadata=""}
1720
1721 A wooden pick about 1/3 worn out:
1722
1723     {name="default:pick_wood", count=1, wear=21323, metadata=""}
1724
1725 An apple:
1726
1727     {name="default:apple", count=1, wear=0, metadata=""}
1728
1729 ### `ItemStack`
1730
1731 A native C++ format with many helper methods. Useful for converting
1732 between formats. See the [Class reference] section for details.
1733
1734
1735
1736
1737 Groups
1738 ======
1739
1740 In a number of places, there is a group table. Groups define the
1741 properties of a thing (item, node, armor of entity, tool capabilities)
1742 in such a way that the engine and other mods can can interact with
1743 the thing without actually knowing what the thing is.
1744
1745 Usage
1746 -----
1747
1748 Groups are stored in a table, having the group names with keys and the
1749 group ratings as values. Group ratings are integer values within the
1750 range [-32767, 32767]. For example:
1751
1752     -- Default dirt
1753     groups = {crumbly=3, soil=1}
1754
1755     -- A more special dirt-kind of thing
1756     groups = {crumbly=2, soil=1, level=2, outerspace=1}
1757
1758 Groups always have a rating associated with them. If there is no
1759 useful meaning for a rating for an enabled group, it shall be `1`.
1760
1761 When not defined, the rating of a group defaults to `0`. Thus when you
1762 read groups, you must interpret `nil` and `0` as the same value, `0`.
1763
1764 You can read the rating of a group for an item or a node by using
1765
1766     minetest.get_item_group(itemname, groupname)
1767
1768 Groups of items
1769 ---------------
1770
1771 Groups of items can define what kind of an item it is (e.g. wool).
1772
1773 Groups of nodes
1774 ---------------
1775
1776 In addition to the general item things, groups are used to define whether
1777 a node is destroyable and how long it takes to destroy by a tool.
1778
1779 Groups of entities
1780 ------------------
1781
1782 For entities, groups are, as of now, used only for calculating damage.
1783 The rating is the percentage of damage caused by items with this damage group.
1784 See [Entity damage mechanism].
1785
1786     object.get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
1787     object.set_armor_groups({fleshy=30, cracky=80})
1788
1789 Groups of tool capabilities
1790 ---------------------------
1791
1792 Groups in tool capabilities define which groups of nodes and entities they
1793 are effective towards.
1794
1795 Groups in crafting recipes
1796 --------------------------
1797
1798 An example: Make meat soup from any meat, any water and any bowl:
1799
1800     {
1801         output = "food:meat_soup_raw",
1802         recipe = {
1803             {"group:meat"},
1804             {"group:water"},
1805             {"group:bowl"},
1806         },
1807     }
1808
1809 Another example: Make red wool from white wool and red dye:
1810
1811     {
1812         type = "shapeless",
1813         output = "wool:red",
1814         recipe = {"wool:white", "group:dye,basecolor_red"},
1815     }
1816
1817 Special groups
1818 --------------
1819
1820 The asterisk `(*)` after a group name describes that there is no engine
1821 functionality bound to it, and implementation is left up as a suggestion
1822 to games.
1823
1824 ### Node and item groups
1825
1826 * `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
1827   that the item should be hidden in item lists.
1828
1829
1830 ### Node-only groups
1831
1832 * `attached_node`: if the node under it is not a walkable block the node will be
1833   dropped as an item. If the node is wallmounted the wallmounted direction is
1834   checked.
1835 * `bouncy`: value is bounce speed in percent
1836 * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1837   connect to each other
1838 * `dig_immediate`: Player can always pick up node without reducing tool wear
1839     * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
1840     * `3`: the node always gets the digging time 0 seconds (torch)
1841 * `disable_jump`: Player (and possibly other things) cannot jump from node
1842   or if their feet are in the node. Note: not supported for `new_move = false`
1843 * `fall_damage_add_percent`: modifies the fall damage suffered when hitting
1844   the top of this node. There's also an armor group with the same name.
1845   The final player damage is determined by the following formula:
1846     damage =
1847       collision speed
1848       * ((node_fall_damage_add_percent   + 100) / 100) -- node group
1849       * ((player_fall_damage_add_percent + 100) / 100) -- player armor group
1850       - (14)                                           -- constant tolerance
1851   Negative damage values are discarded as no damage.
1852 * `falling_node`: if there is no walkable block under the node it will fall
1853 * `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
1854 * `level`: Can be used to give an additional sense of progression in the game.
1855      * A larger level will cause e.g. a weapon of a lower level make much less
1856        damage, and get worn out much faster, or not be able to get drops
1857        from destroyed nodes.
1858      * `0` is something that is directly accessible at the start of gameplay
1859      * There is no upper limit
1860      * See also: `leveldiff` in [Tool Capabilities]
1861 * `slippery`: Players and items will slide on the node.
1862   Slipperiness rises steadily with `slippery` value, starting at 1.
1863
1864
1865 ### Tool-only groups
1866
1867 * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
1868   `"toolrepair"` crafting recipe
1869
1870
1871 ### `ObjectRef` armor groups
1872
1873 * `immortal`: Skips all damage and breath handling for an object. This group
1874   will also hide the integrated HUD status bars for players. It is
1875   automatically set to all players when damage is disabled on the server and
1876   cannot be reset (subject to change).
1877 * `fall_damage_add_percent`: Modifies the fall damage suffered by players
1878   when they hit the ground. It is analog to the node group with the same
1879   name. See the node group above for the exact calculation.
1880 * `punch_operable`: For entities; disables the regular damage mechanism for
1881   players punching it by hand or a non-tool item, so that it can do something
1882   else than take damage.
1883
1884
1885
1886 Known damage and digging time defining groups
1887 ---------------------------------------------
1888
1889 * `crumbly`: dirt, sand
1890 * `cracky`: tough but crackable stuff like stone.
1891 * `snappy`: something that can be cut using things like scissors, shears,
1892   bolt cutters and the like, e.g. leaves, small plants, wire, sheets of metal
1893 * `choppy`: something that can be cut using force; e.g. trees, wooden planks
1894 * `fleshy`: Living things like animals and the player. This could imply
1895   some blood effects when hitting.
1896 * `explody`: Especially prone to explosions
1897 * `oddly_breakable_by_hand`:
1898    Can be added to nodes that shouldn't logically be breakable by the
1899    hand but are. Somewhat similar to `dig_immediate`, but times are more
1900    like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
1901    digging speed of an item if it can dig at a faster speed than this
1902    suggests for the hand.
1903
1904 Examples of custom groups
1905 -------------------------
1906
1907 Item groups are often used for defining, well, _groups of items_.
1908
1909 * `meat`: any meat-kind of a thing (rating might define the size or healing
1910   ability or be irrelevant -- it is not defined as of yet)
1911 * `eatable`: anything that can be eaten. Rating might define HP gain in half
1912   hearts.
1913 * `flammable`: can be set on fire. Rating might define the intensity of the
1914   fire, affecting e.g. the speed of the spreading of an open fire.
1915 * `wool`: any wool (any origin, any color)
1916 * `metal`: any metal
1917 * `weapon`: any weapon
1918 * `heavy`: anything considerably heavy
1919
1920 Digging time calculation specifics
1921 ----------------------------------
1922
1923 Groups such as `crumbly`, `cracky` and `snappy` are used for this
1924 purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
1925 faster digging time.
1926
1927 The `level` group is used to limit the toughness of nodes an item capable
1928 of digging can dig and to scale the digging times / damage to a greater extent.
1929
1930 **Please do understand this**, otherwise you cannot use the system to it's
1931 full potential.
1932
1933 Items define their properties by a list of parameters for groups. They
1934 cannot dig other groups; thus it is important to use a standard bunch of
1935 groups to enable interaction with items.
1936
1937
1938
1939
1940 Tool Capabilities
1941 =================
1942
1943 'Tool capabilities' is a property of items that defines two things:
1944
1945 1) Which nodes it can dig and how fast
1946 2) Which objects it can hurt by punching and by how much
1947
1948 Tool capabilities are available for all items, not just tools.
1949 But only tools can receive wear from digging and punching.
1950
1951 Missing or incomplete tool capabilities will default to the
1952 player's hand.
1953
1954 Tool capabilities definition
1955 ----------------------------
1956
1957 Tool capabilities define:
1958
1959 * Full punch interval
1960 * Maximum drop level
1961 * For an arbitrary list of node groups:
1962     * Uses (until the tool breaks)
1963     * Maximum level (usually `0`, `1`, `2` or `3`)
1964     * Digging times
1965 * Damage groups
1966 * Punch attack uses (until the tool breaks)
1967
1968 ### Full punch interval `full_punch_interval`
1969
1970 When used as a weapon, the item will do full damage if this time is spent
1971 between punches. If e.g. half the time is spent, the item will do half
1972 damage.
1973
1974 ### Maximum drop level `max_drop_level`
1975
1976 Suggests the maximum level of node, when dug with the item, that will drop
1977 its useful item. (e.g. iron ore to drop a lump of iron).
1978
1979 This value is not used in the engine; it is the responsibility of the game/mod
1980 code to implement this.
1981
1982 ### Uses `uses` (tools only)
1983
1984 Determines how many uses the tool has when it is used for digging a node,
1985 of this group, of the maximum level. The maximum supported number of
1986 uses is 65535. The special number 0 is used for infinite uses.
1987 For lower leveled nodes, the use count is multiplied by `3^leveldiff`.
1988 `leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the
1989 node's `level` group. The node cannot be dug if `leveldiff` is less than zero.
1990
1991 * `uses=10, leveldiff=0`: actual uses: 10
1992 * `uses=10, leveldiff=1`: actual uses: 30
1993 * `uses=10, leveldiff=2`: actual uses: 90
1994
1995 For non-tools, this has no effect.
1996
1997 ### Maximum level `maxlevel`
1998
1999 Tells what is the maximum level of a node of this group that the item will
2000 be able to dig.
2001
2002 ### Digging times `times`
2003
2004 List of digging times for different ratings of the group, for nodes of the
2005 maximum level.
2006
2007 For example, as a Lua table, `times={[2]=2.00, [3]=0.70}`. This would
2008 result in the item to be able to dig nodes that have a rating of `2` or `3`
2009 for this group, and unable to dig the rating `1`, which is the toughest.
2010 Unless there is a matching group that enables digging otherwise.
2011
2012 If the result digging time is 0, a delay of 0.15 seconds is added between
2013 digging nodes; If the player releases LMB after digging, this delay is set to 0,
2014 i.e. players can more quickly click the nodes away instead of holding LMB.
2015
2016 ### Damage groups
2017
2018 List of damage for groups of entities. See [Entity damage mechanism].
2019
2020 ### Punch attack uses (tools only)
2021
2022 Determines how many uses (before breaking) the tool has when dealing damage
2023 to an object, when the full punch interval (see above) was always
2024 waited out fully.
2025
2026 Wear received by the tool is proportional to the time spent, scaled by
2027 the full punch interval.
2028
2029 For non-tools, this has no effect.
2030
2031 Example definition of the capabilities of an item
2032 -------------------------------------------------
2033
2034     tool_capabilities = {
2035         groupcaps={
2036             crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
2037         },
2038     }
2039
2040 This makes the item capable of digging nodes that fulfil both of these:
2041
2042 * Have the `crumbly` group
2043 * Have a `level` group less or equal to `2`
2044
2045 Table of resulting digging times:
2046
2047     crumbly        0     1     2     3     4  <- level
2048          ->  0     -     -     -     -     -
2049              1  0.80  1.60  1.60     -     -
2050              2  0.60  1.20  1.20     -     -
2051              3  0.40  0.80  0.80     -     -
2052
2053     level diff:    2     1     0    -1    -2
2054
2055 Table of resulting tool uses:
2056
2057     ->  0     -     -     -     -     -
2058         1   180    60    20     -     -
2059         2   180    60    20     -     -
2060         3   180    60    20     -     -
2061
2062 **Notes**:
2063
2064 * At `crumbly==0`, the node is not diggable.
2065 * At `crumbly==3`, the level difference digging time divider kicks in and makes
2066   easy nodes to be quickly breakable.
2067 * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
2068
2069
2070
2071
2072 Entity damage mechanism
2073 =======================
2074
2075 Damage calculation:
2076
2077     damage = 0
2078     foreach group in cap.damage_groups:
2079         damage += cap.damage_groups[group]
2080             * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0)
2081             * (object.armor_groups[group] / 100.0)
2082             -- Where object.armor_groups[group] is 0 for inexistent values
2083     return damage
2084
2085 Client predicts damage based on damage groups. Because of this, it is able to
2086 give an immediate response when an entity is damaged or dies; the response is
2087 pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
2088 TODO).
2089 Currently a smoke puff will appear when an entity dies.
2090
2091 The group `immortal` completely disables normal damage.
2092
2093 Entities can define a special armor group, which is `punch_operable`. This
2094 group disables the regular damage mechanism for players punching it by hand or
2095 a non-tool item, so that it can do something else than take damage.
2096
2097 On the Lua side, every punch calls:
2098
2099     entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction,
2100                     damage)
2101
2102 This should never be called directly, because damage is usually not handled by
2103 the entity itself.
2104
2105 * `puncher` is the object performing the punch. Can be `nil`. Should never be
2106   accessed unless absolutely required, to encourage interoperability.
2107 * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
2108 * `tool_capabilities` can be `nil`.
2109 * `direction` is a unit vector, pointing from the source of the punch to
2110    the punched object.
2111 * `damage` damage that will be done to entity
2112 Return value of this function will determine if damage is done by this function
2113 (retval true) or shall be done by engine (retval false)
2114
2115 To punch an entity/object in Lua, call:
2116
2117   object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
2118
2119 * Return value is tool wear.
2120 * Parameters are equal to the above callback.
2121 * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
2122   will be automatically filled in based on the location of `puncher`.
2123
2124
2125
2126
2127 Metadata
2128 ========
2129
2130 Node Metadata
2131 -------------
2132
2133 The instance of a node in the world normally only contains the three values
2134 mentioned in [Nodes]. However, it is possible to insert extra data into a node.
2135 It is called "node metadata"; See `NodeMetaRef`.
2136
2137 Node metadata contains two things:
2138
2139 * A key-value store
2140 * An inventory
2141
2142 Some of the values in the key-value store are handled specially:
2143
2144 * `formspec`: Defines an inventory menu that is opened with the
2145               'place/use' key. Only works if no `on_rightclick` was
2146               defined for the node. See also [Formspec].
2147 * `infotext`: Text shown on the screen when the node is pointed at.
2148               Line-breaks will be applied automatically.
2149               If the infotext is very long, it will be truncated.
2150
2151 Example:
2152
2153     local meta = minetest.get_meta(pos)
2154     meta:set_string("formspec",
2155             "size[8,9]"..
2156             "list[context;main;0,0;8,4;]"..
2157             "list[current_player;main;0,5;8,4;]")
2158     meta:set_string("infotext", "Chest");
2159     local inv = meta:get_inventory()
2160     inv:set_size("main", 8*4)
2161     print(dump(meta:to_table()))
2162     meta:from_table({
2163         inventory = {
2164             main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
2165                     [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
2166                     [10] = "", [11] = "", [12] = "", [13] = "",
2167                     [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
2168                     [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
2169                     [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
2170                     [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
2171                     [32] = ""}
2172         },
2173         fields = {
2174             formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
2175             infotext = "Chest"
2176         }
2177     })
2178
2179 Item Metadata
2180 -------------
2181
2182 Item stacks can store metadata too. See [`ItemStackMetaRef`].
2183
2184 Item metadata only contains a key-value store.
2185
2186 Some of the values in the key-value store are handled specially:
2187
2188 * `description`: Set the item stack's description.
2189   See also: `get_description` in [`ItemStack`]
2190 * `short_description`: Set the item stack's short description.
2191   See also: `get_short_description` in [`ItemStack`]
2192 * `color`: A `ColorString`, which sets the stack's color.
2193 * `palette_index`: If the item has a palette, this is used to get the
2194   current color from the palette.
2195 * `count_meta`: Replace the displayed count with any string.
2196 * `count_alignment`: Set the alignment of the displayed count value. This is an
2197   int value. The lowest 2 bits specify the alignment in x-direction, the 3rd and
2198   4th bit specify the alignment in y-direction:
2199   0 = default, 1 = left / up, 2 = middle, 3 = right / down
2200   The default currently is the same as right/down.
2201   Example: 6 = 2 + 1*4 = middle,up
2202
2203 Example:
2204
2205     local meta = stack:get_meta()
2206     meta:set_string("key", "value")
2207     print(dump(meta:to_table()))
2208
2209 Example manipulations of "description" and expected output behaviors:
2210
2211     print(ItemStack("default:pick_steel"):get_description()) --> Steel Pickaxe
2212     print(ItemStack("foobar"):get_description()) --> Unknown Item
2213
2214     local stack = ItemStack("default:stone")
2215     stack:get_meta():set_string("description", "Custom description\nAnother line")
2216     print(stack:get_description()) --> Custom description\nAnother line
2217     print(stack:get_short_description()) --> Custom description
2218
2219     stack:get_meta():set_string("short_description", "Short")
2220     print(stack:get_description()) --> Custom description\nAnother line
2221     print(stack:get_short_description()) --> Short
2222
2223     print(ItemStack("mod:item_with_no_desc"):get_description()) --> mod:item_with_no_desc
2224
2225
2226
2227 Formspec
2228 ========
2229
2230 Formspec defines a menu. This supports inventories and some of the
2231 typical widgets like buttons, checkboxes, text input fields, etc.
2232 It is a string, with a somewhat strange format.
2233
2234 A formspec is made out of formspec elements, which includes widgets
2235 like buttons but also can be used to set stuff like background color.
2236
2237 Many formspec elements have a `name`, which is a unique identifier which
2238 is used when the server receives user input. You must not use the name
2239 "quit" for formspec elements.
2240
2241 Spaces and newlines can be inserted between the blocks, as is used in the
2242 examples.
2243
2244 Position and size units are inventory slots unless the new coordinate system
2245 is enabled. `X` and `Y` position the formspec element relative to the top left
2246 of the menu or container. `W` and `H` are its width and height values.
2247
2248 If the new system is enabled, all elements have unified coordinates for all
2249 elements with no padding or spacing in between. This is highly recommended
2250 for new forms. See `real_coordinates[<bool>]` and `Migrating to Real
2251 Coordinates`.
2252
2253 Inventories with a `player:<name>` inventory location are only sent to the
2254 player named `<name>`.
2255
2256 When displaying text which can contain formspec code, e.g. text set by a player,
2257 use `minetest.formspec_escape`.
2258 For colored text you can use `minetest.colorize`.
2259
2260 Since formspec version 3, elements drawn in the order they are defined. All
2261 background elements are drawn before all other elements.
2262
2263 **WARNING**: do _not_ use a element name starting with `key_`; those names are
2264 reserved to pass key press events to formspec!
2265
2266 **WARNING**: Minetest allows you to add elements to every single formspec instance
2267 using `player:set_formspec_prepend()`, which may be the reason backgrounds are
2268 appearing when you don't expect them to, or why things are styled differently
2269 to normal. See [`no_prepend[]`] and [Styling Formspecs].
2270
2271 Examples
2272 --------
2273
2274 ### Chest
2275
2276     size[8,9]
2277     list[context;main;0,0;8,4;]
2278     list[current_player;main;0,5;8,4;]
2279
2280 ### Furnace
2281
2282     size[8,9]
2283     list[context;fuel;2,3;1,1;]
2284     list[context;src;2,1;1,1;]
2285     list[context;dst;5,1;2,2;]
2286     list[current_player;main;0,5;8,4;]
2287
2288 ### Minecraft-like player inventory
2289
2290     size[8,7.5]
2291     image[1,0.6;1,2;player.png]
2292     list[current_player;main;0,3.5;8,4;]
2293     list[current_player;craft;3,0;3,3;]
2294     list[current_player;craftpreview;7,1;1,1;]
2295
2296 Version History
2297 ---------------
2298
2299 * Formspec version 1 (pre-5.1.0):
2300   * (too much)
2301 * Formspec version 2 (5.1.0):
2302   * Forced real coordinates
2303   * background9[]: 9-slice scaling parameters
2304 * Formspec version 3 (5.2.0):
2305   * Formspec elements are drawn in the order of definition
2306   * bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
2307   * box[] and image[] elements enable clipping by default
2308   * new element: scroll_container[]
2309 * Formspec version 4 (5.4.0):
2310   * Allow dropdown indexing events
2311 * Formspec version 5 (5.5.0):
2312   * Added padding[] element
2313 * Formspec version 6 (5.6.0):
2314   * Add nine-slice images, animated_images, and fgimg_middle
2315
2316 Elements
2317 --------
2318
2319 ### `formspec_version[<version>]`
2320
2321 * Set the formspec version to a certain number. If not specified,
2322   version 1 is assumed.
2323 * Must be specified before `size` element.
2324 * Clients older than this version can neither show newer elements nor display
2325   elements with new arguments correctly.
2326 * Available since feature `formspec_version_element`.
2327 * See also: [Version History]
2328
2329 ### `size[<W>,<H>,<fixed_size>]`
2330
2331 * Define the size of the menu in inventory slots
2332 * `fixed_size`: `true`/`false` (optional)
2333 * deprecated: `invsize[<W>,<H>;]`
2334
2335 ### `position[<X>,<Y>]`
2336
2337 * Must be used after `size` element.
2338 * Defines the position on the game window of the formspec's `anchor` point.
2339 * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
2340   for example:
2341     * [0.0, 0.0] sets the position to the top left corner of the game window.
2342     * [1.0, 1.0] sets the position to the bottom right of the game window.
2343 * Defaults to the center of the game window [0.5, 0.5].
2344
2345 ### `anchor[<X>,<Y>]`
2346
2347 * Must be used after both `size` and `position` (if present) elements.
2348 * Defines the location of the anchor point within the formspec.
2349 * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
2350   for example:
2351     * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
2352     * [1.0, 0.0] sets the anchor to the top right of the formspec.
2353 * Defaults to the center of the formspec [0.5, 0.5].
2354
2355 * `position` and `anchor` elements need suitable values to avoid a formspec
2356   extending off the game window due to particular game window sizes.
2357
2358 ### `padding[<X>,<Y>]`
2359
2360 * Must be used after the `size`, `position`, and `anchor` elements (if present).
2361 * Defines how much space is padded around the formspec if the formspec tries to
2362   increase past the size of the screen and coordinates have to be shrunk.
2363 * For X and Y, 0.0 represents no padding (the formspec can touch the edge of the
2364   screen), and 0.5 represents half the screen (which forces the coordinate size
2365   to 0). If negative, the formspec can extend off the edge of the screen.
2366 * Defaults to [0.05, 0.05].
2367
2368 ### `no_prepend[]`
2369
2370 * Must be used after the `size`, `position`, `anchor`, and `padding` elements
2371   (if present).
2372 * Disables player:set_formspec_prepend() from applying to this formspec.
2373
2374 ### `real_coordinates[<bool>]`
2375
2376 * INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
2377 * When set to true, all following formspec elements will use the new coordinate system.
2378 * If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
2379   (if present), the form size will use the new coordinate system.
2380 * **Note**: Formspec prepends are not affected by the coordinates in the main form.
2381   They must enable it explicitly.
2382 * For information on converting forms to the new coordinate system, see `Migrating
2383   to Real Coordinates`.
2384
2385 ### `container[<X>,<Y>]`
2386
2387 * Start of a container block, moves all physical elements in the container by
2388   (X, Y).
2389 * Must have matching `container_end`
2390 * Containers can be nested, in which case the offsets are added
2391   (child containers are relative to parent containers)
2392
2393 ### `container_end[]`
2394
2395 * End of a container, following elements are no longer relative to this
2396   container.
2397
2398 ### `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
2399
2400 * Start of a scroll_container block. All contained elements will ...
2401   * take the scroll_container coordinate as position origin,
2402   * be additionally moved by the current value of the scrollbar with the name
2403     `scrollbar name` times `scroll factor` along the orientation `orientation` and
2404   * be clipped to the rectangle defined by `X`, `Y`, `W` and `H`.
2405 * `orientation`: possible values are `vertical` and `horizontal`.
2406 * `scroll factor`: optional, defaults to `0.1`.
2407 * Nesting is possible.
2408 * Some elements might work a little different if they are in a scroll_container.
2409 * Note: If you want the scroll_container to actually work, you also need to add a
2410   scrollbar element with the specified name. Furthermore, it is highly recommended
2411   to use a scrollbaroptions element on this scrollbar.
2412
2413 ### `scroll_container_end[]`
2414
2415 * End of a scroll_container, following elements are no longer bound to this
2416   container.
2417
2418 ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
2419
2420 * Show an inventory list if it has been sent to the client.
2421 * If the inventory list changes (eg. it didn't exist before, it's resized, or its items
2422   are moved) while the formspec is open, the formspec element may (but is not guaranteed
2423   to) adapt to the new inventory list.
2424 * Item slots are drawn in a grid from left to right, then up to down, ordered
2425   according to the slot index.
2426 * `W` and `H` are in inventory slots, not in coordinates.
2427 * `starting item index` (Optional): The index of the first (upper-left) item to draw.
2428   Indices start at `0`. Default is `0`.
2429 * The number of shown slots is the minimum of `W*H` and the inventory list's size minus
2430   `starting item index`.
2431 * **Note**: With the new coordinate system, the spacing between inventory
2432   slots is one-fourth the size of an inventory slot by default. Also see
2433   [Styling Formspecs] for changing the size of slots and spacing.
2434
2435 ### `listring[<inventory location>;<list name>]`
2436
2437 * Appends to an internal ring of inventory lists.
2438 * Shift-clicking on items in one element of the ring
2439   will send them to the next inventory list inside the ring
2440 * The first occurrence of an element inside the ring will
2441   determine the inventory where items will be sent to
2442
2443 ### `listring[]`
2444
2445 * Shorthand for doing `listring[<inventory location>;<list name>]`
2446   for the last two inventory lists added by list[...]
2447
2448 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
2449
2450 * Sets background color of slots as `ColorString`
2451 * Sets background color of slots on mouse hovering
2452
2453 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
2454
2455 * Sets background color of slots as `ColorString`
2456 * Sets background color of slots on mouse hovering
2457 * Sets color of slots border
2458
2459 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
2460
2461 * Sets background color of slots as `ColorString`
2462 * Sets background color of slots on mouse hovering
2463 * Sets color of slots border
2464 * Sets default background color of tooltips
2465 * Sets default font color of tooltips
2466
2467 ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2468
2469 * Adds tooltip for an element
2470 * `bgcolor` tooltip background color as `ColorString` (optional)
2471 * `fontcolor` tooltip font color as `ColorString` (optional)
2472
2473 ### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
2474
2475 * Adds tooltip for an area. Other tooltips will take priority when present.
2476 * `bgcolor` tooltip background color as `ColorString` (optional)
2477 * `fontcolor` tooltip font color as `ColorString` (optional)
2478
2479 ### `image[<X>,<Y>;<W>,<H>;<texture name>;<middle>]`
2480
2481 * Show an image.
2482 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2483     * Requires formspec version >= 6.
2484     * See `background9[]` documentation for more information.
2485
2486 ### `animated_image[<X>,<Y>;<W>,<H>;<name>;<texture name>;<frame count>;<frame duration>;<frame start>;<middle>]`
2487
2488 * Show an animated image. The image is drawn like a "vertical_frames" tile
2489   animation (See [Tile animation definition]), but uses a frame count/duration for simplicity
2490 * `name`: Element name to send when an event occurs. The event value is the index of the current frame.
2491 * `texture name`: The image to use.
2492 * `frame count`: The number of frames animating the image.
2493 * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance.
2494 * `frame start` (optional): The index of the frame to start on. Default `1`.
2495 * `middle` (optional): Makes the image render in 9-sliced mode and defines the middle rect.
2496     * Requires formspec version >= 6.
2497     * See `background9[]` documentation for more information.
2498
2499 ### `model[<X>,<Y>;<W>,<H>;<name>;<mesh>;<textures>;<rotation X,Y>;<continuous>;<mouse control>;<frame loop range>;<animation speed>]`
2500
2501 * Show a mesh model.
2502 * `name`: Element name that can be used for styling
2503 * `mesh`: The mesh model to use.
2504 * `textures`: The mesh textures to use according to the mesh materials.
2505    Texture names must be separated by commas.
2506 * `rotation {X,Y}` (Optional): Initial rotation of the camera.
2507   The axes are euler angles in degrees.
2508 * `continuous` (Optional): Whether the rotation is continuous. Default `false`.
2509 * `mouse control` (Optional): Whether the model can be controlled with the mouse. Default `true`.
2510 * `frame loop range` (Optional): Range of the animation frames.
2511     * Defaults to the full range of all available frames.
2512     * Syntax: `<begin>,<end>`
2513 * `animation speed` (Optional): Sets the animation speed. Default 0 FPS.
2514
2515 ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
2516
2517 * Show an inventory image of registered item/node
2518
2519 ### `bgcolor[<bgcolor>;<fullscreen>;<fbgcolor>]`
2520
2521 * Sets background color of formspec.
2522 * `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color
2523   of the non-fullscreen and the fullscreen background.
2524 * `fullscreen` (optional) can be one of the following:
2525   * `false`: Only the non-fullscreen background color is drawn. (default)
2526   * `true`: Only the fullscreen background color is drawn.
2527   * `both`: The non-fullscreen and the fullscreen background color are drawn.
2528   * `neither`: No background color is drawn.
2529 * Note: Leave a parameter empty to not modify the value.
2530 * Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that
2531   are not bools are only available since formspec version 3.
2532
2533 ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
2534
2535 * Example for formspec 8x4 in 16x resolution: image shall be sized
2536   8 times 16px  times  4 times 16px.
2537
2538 ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
2539
2540 * Example for formspec 8x4 in 16x resolution:
2541   image shall be sized 8 times 16px  times  4 times 16px
2542 * If `auto_clip` is `true`, the background is clipped to the formspec size
2543   (`x` and `y` are used as offset values, `w` and `h` are ignored)
2544
2545 ### `background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>]`
2546
2547 * 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
2548 * Middle is a rect which defines the middle of the 9-slice.
2549     * `x` - The middle will be x pixels from all sides.
2550     * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
2551     * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
2552         will be added to the width and height of the texture, allowing it to be used as the
2553         distance from the far end.
2554     * All numbers in middle are integers.
2555 * If `auto_clip` is `true`, the background is clipped to the formspec size
2556   (`x` and `y` are used as offset values, `w` and `h` are ignored)
2557 * Available since formspec version 2
2558
2559 ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
2560
2561 * Textual password style field; will be sent to server when a button is clicked
2562 * When enter is pressed in field, fields.key_enter_field will be sent with the
2563   name of this field.
2564 * With the old coordinate system, fields are a set height, but will be vertically
2565   centred on `H`. With the new coordinate system, `H` will modify the height.
2566 * `name` is the name of the field as returned in fields to `on_receive_fields`
2567 * `label`, if not blank, will be text printed on the top left above the field
2568 * See `field_close_on_enter` to stop enter closing the formspec
2569
2570 ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2571
2572 * Textual field; will be sent to server when a button is clicked
2573 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2574   the name of this field.
2575 * With the old coordinate system, fields are a set height, but will be vertically
2576   centred on `H`. With the new coordinate system, `H` will modify the height.
2577 * `name` is the name of the field as returned in fields to `on_receive_fields`
2578 * `label`, if not blank, will be text printed on the top left above the field
2579 * `default` is the default value of the field
2580     * `default` may contain variable references such as `${text}` which
2581       will fill the value from the metadata value `text`
2582     * **Note**: no extra text or more than a single variable is supported ATM.
2583 * See `field_close_on_enter` to stop enter closing the formspec
2584
2585 ### `field[<name>;<label>;<default>]`
2586
2587 * As above, but without position/size units
2588 * When enter is pressed in field, `fields.key_enter_field` will be sent with
2589   the name of this field.
2590 * Special field for creating simple forms, such as sign text input
2591 * Must be used without a `size[]` element
2592 * A "Proceed" button will be added automatically
2593 * See `field_close_on_enter` to stop enter closing the formspec
2594
2595 ### `field_close_on_enter[<name>;<close_on_enter>]`
2596
2597 * <name> is the name of the field
2598 * if <close_on_enter> is false, pressing enter in the field will submit the
2599   form but not close it.
2600 * defaults to true when not specified (ie: no tag for a field)
2601
2602 ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
2603
2604 * Same as fields above, but with multi-line input
2605 * If the text overflows, a vertical scrollbar is added.
2606 * If the name is empty, the textarea is read-only and
2607   the background is not shown, which corresponds to a multi-line label.
2608
2609 ### `label[<X>,<Y>;<label>]`
2610
2611 * The label formspec element displays the text set in `label`
2612   at the specified position.
2613 * **Note**: If the new coordinate system is enabled, labels are
2614   positioned from the center of the text, not the top.
2615 * The text is displayed directly without automatic line breaking,
2616   so label should not be used for big text chunks.  Newlines can be
2617   used to make labels multiline.
2618 * **Note**: With the new coordinate system, newlines are spaced with
2619   half a coordinate.  With the old system, newlines are spaced 2/5 of
2620   an inventory slot.
2621
2622 ### `hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]`
2623 * Displays a static formatted text with hyperlinks.
2624 * **Note**: This element is currently unstable and subject to change.
2625 * `x`, `y`, `w` and `h` work as per field
2626 * `name` is the name of the field as returned in fields to `on_receive_fields` in case of action in text.
2627 * `text` is the formatted text using `Markup Language` described below.
2628
2629 ### `vertlabel[<X>,<Y>;<label>]`
2630 * Textual label drawn vertically
2631 * `label` is the text on the label
2632 * **Note**: If the new coordinate system is enabled, vertlabels are
2633   positioned from the center of the text, not the left.
2634
2635 ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
2636
2637 * Clickable button. When clicked, fields will be sent.
2638 * With the old coordinate system, buttons are a set height, but will be vertically
2639   centred on `H`. With the new coordinate system, `H` will modify the height.
2640 * `label` is the text on the button
2641
2642 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2643
2644 * `texture name` is the filename of an image
2645 * **Note**: Height is supported on both the old and new coordinate systems
2646   for image_buttons.
2647
2648 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
2649
2650 * `texture name` is the filename of an image
2651 * `noclip=true` means the image button doesn't need to be within specified
2652   formsize.
2653 * `drawborder`: draw button border or not
2654 * `pressed texture name` is the filename of an image on pressed state
2655
2656 ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
2657
2658 * `item name` is the registered name of an item/node
2659 * The item description will be used as the tooltip. This can be overridden with
2660   a tooltip element.
2661
2662 ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
2663
2664 * When clicked, fields will be sent and the form will quit.
2665 * Same as `button` in all other respects.
2666
2667 ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2668
2669 * When clicked, fields will be sent and the form will quit.
2670 * Same as `image_button` in all other respects.
2671
2672 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
2673
2674 * Scrollable item list showing arbitrary text elements
2675 * `name` fieldname sent to server on doubleclick value is current selected
2676   element.
2677 * `listelements` can be prepended by #color in hexadecimal format RRGGBB
2678   (only).
2679     * if you want a listelement to start with "#" write "##".
2680
2681 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
2682
2683 * Scrollable itemlist showing arbitrary text elements
2684 * `name` fieldname sent to server on doubleclick value is current selected
2685   element.
2686 * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
2687     * if you want a listelement to start with "#" write "##"
2688 * Index to be selected within textlist
2689 * `true`/`false`: draw transparent background
2690 * See also `minetest.explode_textlist_event`
2691   (main menu: `core.explode_textlist_event`).
2692
2693 ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2694
2695 * Show a tab**header** at specific position (ignores formsize)
2696 * `X` and `Y`: position of the tabheader
2697 * *Note*: Width and height are automatically chosen with this syntax
2698 * `name` fieldname data is transferred to Lua
2699 * `caption 1`...: name shown on top of tab
2700 * `current_tab`: index of selected tab 1...
2701 * `transparent` (optional): if true, tabs are semi-transparent
2702 * `draw_border` (optional): if true, draw a thin line at tab base
2703
2704 ### `tabheader[<X>,<Y>;<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2705
2706 * Show a tab**header** at specific position (ignores formsize)
2707 * **Important note**: This syntax for tabheaders can only be used with the
2708   new coordinate system.
2709 * `X` and `Y`: position of the tabheader
2710 * `H`: height of the tabheader. Width is automatically determined with this syntax.
2711 * `name` fieldname data is transferred to Lua
2712 * `caption 1`...: name shown on top of tab
2713 * `current_tab`: index of selected tab 1...
2714 * `transparent` (optional): show transparent
2715 * `draw_border` (optional): draw border
2716
2717 ### `tabheader[<X>,<Y>;<W>,<H>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2718
2719 * Show a tab**header** at specific position (ignores formsize)
2720 * **Important note**: This syntax for tabheaders can only be used with the
2721   new coordinate system.
2722 * `X` and `Y`: position of the tabheader
2723 * `W` and `H`: width and height of the tabheader
2724 * `name` fieldname data is transferred to Lua
2725 * `caption 1`...: name shown on top of tab
2726 * `current_tab`: index of selected tab 1...
2727 * `transparent` (optional): show transparent
2728 * `draw_border` (optional): draw border
2729
2730 ### `box[<X>,<Y>;<W>,<H>;<color>]`
2731
2732 * Simple colored box
2733 * `color` is color specified as a `ColorString`.
2734   If the alpha component is left blank, the box will be semitransparent.
2735   If the color is not specified, the box will use the options specified by
2736   its style. If the color is specified, all styling options will be ignored.
2737
2738 ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2739
2740 * Show a dropdown field
2741 * **Important note**: There are two different operation modes:
2742     1. handle directly on change (only changed dropdown is submitted)
2743     2. read the value on pressing a button (all dropdown values are available)
2744 * `X` and `Y`: position of the dropdown
2745 * `W`: width of the dropdown. Height is automatically chosen with this syntax.
2746 * Fieldname data is transferred to Lua
2747 * Items to be shown in dropdown
2748 * Index of currently selected dropdown item
2749 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2750   event field value for selected items.
2751     * `true`: Selected item index
2752     * `false` (default): Selected item value
2753
2754 ### `dropdown[<X>,<Y>;<W>,<H>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>;<index event>]`
2755
2756 * Show a dropdown field
2757 * **Important note**: This syntax for dropdowns can only be used with the
2758   new coordinate system.
2759 * **Important note**: There are two different operation modes:
2760     1. handle directly on change (only changed dropdown is submitted)
2761     2. read the value on pressing a button (all dropdown values are available)
2762 * `X` and `Y`: position of the dropdown
2763 * `W` and `H`: width and height of the dropdown
2764 * Fieldname data is transferred to Lua
2765 * Items to be shown in dropdown
2766 * Index of currently selected dropdown item
2767 * `index event` (optional, allowed parameter since formspec version 4): Specifies the
2768   event field value for selected items.
2769     * `true`: Selected item index
2770     * `false` (default): Selected item value
2771
2772 ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
2773
2774 * Show a checkbox
2775 * `name` fieldname data is transferred to Lua
2776 * `label` to be shown left of checkbox
2777 * `selected` (optional): `true`/`false`
2778 * **Note**: If the new coordinate system is enabled, checkboxes are
2779   positioned from the center of the checkbox, not the top.
2780
2781 ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
2782
2783 * Show a scrollbar using options defined by the previous `scrollbaroptions[]`
2784 * There are two ways to use it:
2785     1. handle the changed event (only changed scrollbar is available)
2786     2. read the value on pressing a button (all scrollbars are available)
2787 * `orientation`: `vertical`/`horizontal`. Default horizontal.
2788 * Fieldname data is transferred to Lua
2789 * Value of this trackbar is set to (`0`-`1000`) by default
2790 * See also `minetest.explode_scrollbar_event`
2791   (main menu: `core.explode_scrollbar_event`).
2792
2793 ### `scrollbaroptions[opt1;opt2;...]`
2794 * Sets options for all following `scrollbar[]` elements
2795 * `min=<int>`
2796     * Sets scrollbar minimum value, defaults to `0`.
2797 * `max=<int>`
2798     * Sets scrollbar maximum value, defaults to `1000`.
2799       If the max is equal to the min, the scrollbar will be disabled.
2800 * `smallstep=<int>`
2801     * Sets scrollbar step value when the arrows are clicked or the mouse wheel is
2802       scrolled.
2803     * If this is set to a negative number, the value will be reset to `10`.
2804 * `largestep=<int>`
2805     * Sets scrollbar step value used by page up and page down.
2806     * If this is set to a negative number, the value will be reset to `100`.
2807 * `thumbsize=<int>`
2808     * Sets size of the thumb on the scrollbar. Size is calculated in the number of
2809       units the thumb spans out of the range of the scrollbar values.
2810     * Example: If a scrollbar has a `min` of 1 and a `max` of 100, a thumbsize of 10
2811       would span a tenth of the scrollbar space.
2812     * If this is set to zero or less, the value will be reset to `1`.
2813 * `arrows=<show/hide/default>`
2814     * Whether to show the arrow buttons on the scrollbar. `default` hides the arrows
2815       when the scrollbar gets too small, but shows them otherwise.
2816
2817 ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
2818
2819 * Show scrollable table using options defined by the previous `tableoptions[]`
2820 * Displays cells as defined by the previous `tablecolumns[]`
2821 * `name`: fieldname sent to server on row select or doubleclick
2822 * `cell 1`...`cell n`: cell contents given in row-major order
2823 * `selected idx`: index of row to be selected within table (first row = `1`)
2824 * See also `minetest.explode_table_event`
2825   (main menu: `core.explode_table_event`).
2826
2827 ### `tableoptions[<opt 1>;<opt 2>;...]`
2828
2829 * Sets options for `table[]`
2830 * `color=#RRGGBB`
2831     * default text color (`ColorString`), defaults to `#FFFFFF`
2832 * `background=#RRGGBB`
2833     * table background color (`ColorString`), defaults to `#000000`
2834 * `border=<true/false>`
2835     * should the table be drawn with a border? (default: `true`)
2836 * `highlight=#RRGGBB`
2837     * highlight background color (`ColorString`), defaults to `#466432`
2838 * `highlight_text=#RRGGBB`
2839     * highlight text color (`ColorString`), defaults to `#FFFFFF`
2840 * `opendepth=<value>`
2841     * all subtrees up to `depth < value` are open (default value = `0`)
2842     * only useful when there is a column of type "tree"
2843
2844 ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
2845
2846 * Sets columns for `table[]`
2847 * Types: `text`, `image`, `color`, `indent`, `tree`
2848     * `text`:   show cell contents as text
2849     * `image`:  cell contents are an image index, use column options to define
2850                 images.
2851     * `color`:  cell contents are a ColorString and define color of following
2852                 cell.
2853     * `indent`: cell contents are a number and define indentation of following
2854                 cell.
2855     * `tree`:   same as indent, but user can open and close subtrees
2856                 (treeview-like).
2857 * Column options:
2858     * `align=<value>`
2859         * for `text` and `image`: content alignment within cells.
2860           Available values: `left` (default), `center`, `right`, `inline`
2861     * `width=<value>`
2862         * for `text` and `image`: minimum width in em (default: `0`)
2863         * for `indent` and `tree`: indent width in em (default: `1.5`)
2864     * `padding=<value>`: padding left of the column, in em (default `0.5`).
2865       Exception: defaults to 0 for indent columns
2866     * `tooltip=<value>`: tooltip text (default: empty)
2867     * `image` column options:
2868         * `0=<value>` sets image for image index 0
2869         * `1=<value>` sets image for image index 1
2870         * `2=<value>` sets image for image index 2
2871         * and so on; defined indices need not be contiguous empty or
2872           non-numeric cells are treated as `0`.
2873     * `color` column options:
2874         * `span=<value>`: number of following columns to affect
2875           (default: infinite).
2876
2877 ### `style[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2878
2879 * Set the style for the element(s) matching `selector` by name.
2880 * `selector` can be one of:
2881     * `<name>` - An element name. Includes `*`, which represents every element.
2882     * `<name>:<state>` - An element name, a colon, and one or more states.
2883 * `state` is a list of states separated by the `+` character.
2884     * If a state is provided, the style will only take effect when the element is in that state.
2885     * All provided states must be active for the style to apply.
2886 * Note: this **must** be before the element is defined.
2887 * See [Styling Formspecs].
2888
2889
2890 ### `style_type[<selector 1>,<selector 2>,...;<prop1>;<prop2>;...]`
2891
2892 * Set the style for the element(s) matching `selector` by type.
2893 * `selector` can be one of:
2894     * `<type>` - An element type. Includes `*`, which represents every element.
2895     * `<type>:<state>` - An element type, a colon, and one or more states.
2896 * `state` is a list of states separated by the `+` character.
2897     * If a state is provided, the style will only take effect when the element is in that state.
2898     * All provided states must be active for the style to apply.
2899 * See [Styling Formspecs].
2900
2901 ### `set_focus[<name>;<force>]`
2902
2903 * Sets the focus to the element with the same `name` parameter.
2904 * **Note**: This element must be placed before the element it focuses.
2905 * `force` (optional, default `false`): By default, focus is not applied for
2906   re-sent formspecs with the same name so that player-set focus is kept.
2907   `true` sets the focus to the specified element for every sent formspec.
2908 * The following elements have the ability to be focused:
2909     * checkbox
2910     * button
2911     * button_exit
2912     * image_button
2913     * image_button_exit
2914     * item_image_button
2915     * table
2916     * textlist
2917     * dropdown
2918     * field
2919     * pwdfield
2920     * textarea
2921     * scrollbar
2922
2923 Migrating to Real Coordinates
2924 -----------------------------
2925
2926 In the old system, positions included padding and spacing. Padding is a gap between
2927 the formspec window edges and content, and spacing is the gaps between items. For
2928 example, two `1x1` elements at `0,0` and `1,1` would have a spacing of `5/4` between them,
2929 and a padding of `3/8` from the formspec edge. It may be easiest to recreate old layouts
2930 in the new coordinate system from scratch.
2931
2932 To recreate an old layout with padding, you'll need to pass the positions and sizes
2933 through the following formula to re-introduce padding:
2934
2935 ```
2936 pos = (oldpos + 1)*spacing + padding
2937 where
2938     padding = 3/8
2939     spacing = 5/4
2940 ```
2941
2942 You'll need to change the `size[]` tag like this:
2943
2944 ```
2945 size = (oldsize-1)*spacing + padding*2 + 1
2946 ```
2947
2948 A few elements had random offsets in the old system. Here is a table which shows these
2949 offsets when migrating:
2950
2951 | Element |  Position  |  Size   | Notes
2952 |---------|------------|---------|-------
2953 | box     | +0.3, +0.1 | 0, -0.4 |
2954 | button  |            |         | Buttons now support height, so set h = 2 * 15/13 * 0.35, and reposition if h ~= 15/13 * 0.35 before
2955 | list    |            |         | Spacing is now 0.25 for both directions, meaning lists will be taller in height
2956 | label   | 0, +0.3    |         | The first line of text is now positioned centered exactly at the position specified
2957
2958 Styling Formspecs
2959 -----------------
2960
2961 Formspec elements can be themed using the style elements:
2962
2963     style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
2964     style[<name 1>:<state>,<name 2>:<state>,...;<prop1>;<prop2>;...]
2965     style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
2966     style_type[<type 1>:<state>,<type 2>:<state>,...;<prop1>;<prop2>;...]
2967
2968 Where a prop is:
2969
2970     property_name=property_value
2971
2972 For example:
2973
2974     style_type[button;bgcolor=#006699]
2975     style[world_delete;bgcolor=red;textcolor=yellow]
2976     button[4,3.95;2.6,1;world_delete;Delete]
2977
2978 A name/type can optionally be a comma separated list of names/types, like so:
2979
2980     world_delete,world_create,world_configure
2981     button,image_button
2982
2983 A `*` type can be used to select every element in the formspec.
2984
2985 Any name/type in the list can also be accompanied by a `+`-separated list of states, like so:
2986
2987     world_delete:hovered+pressed
2988     button:pressed
2989
2990 States allow you to apply styles in response to changes in the element, instead of applying at all times.
2991
2992 Setting a property to nothing will reset it to the default value. For example:
2993
2994     style_type[button;bgimg=button.png;bgimg_pressed=button_pressed.png;border=false]
2995     style[btn_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]
2996
2997
2998 ### Supported Element Types
2999
3000 Some types may inherit styles from parent types.
3001
3002 * animated_image, inherits from image
3003 * box
3004 * button
3005 * button_exit, inherits from button
3006 * checkbox
3007 * dropdown
3008 * field
3009 * image
3010 * image_button
3011 * item_image_button
3012 * label
3013 * list
3014 * model
3015 * pwdfield, inherits from field
3016 * scrollbar
3017 * tabheader
3018 * table
3019 * textarea
3020 * textlist
3021 * vertlabel, inherits from label
3022
3023
3024 ### Valid Properties
3025
3026 * animated_image
3027     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3028 * box
3029     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3030         * Defaults to false in formspec_version version 3 or higher
3031     * **Note**: `colors`, `bordercolors`, and `borderwidths` accept multiple input types:
3032         * Single value (e.g. `#FF0`): All corners/borders.
3033         * Two values (e.g. `red,#FFAAFF`): top-left and bottom-right,top-right and bottom-left/
3034           top and bottom,left and right.
3035         * Four values (e.g. `blue,#A0F,green,#FFFA`): top-left/top and rotates clockwise.
3036         * These work similarly to CSS borders.
3037     * colors - `ColorString`. Sets the color(s) of the box corners. Default `black`.
3038     * bordercolors - `ColorString`. Sets the color(s) of the borders. Default `black`.
3039     * borderwidths - Integer. Sets the width(s) of the borders in pixels. If the width is
3040       negative, the border will extend inside the box, whereas positive extends outside
3041       the box. A width of zero results in no border; this is default.
3042 * button, button_exit, image_button, item_image_button
3043     * alpha - boolean, whether to draw alpha in bgimg. Default true.
3044     * bgcolor - color, sets button tint.
3045     * bgcolor_hovered - color when hovered. Defaults to a lighter bgcolor when not provided.
3046         * This is deprecated, use states instead.
3047     * bgcolor_pressed - color when pressed. Defaults to a darker bgcolor when not provided.
3048         * This is deprecated, use states instead.
3049     * bgimg - standard background image. Defaults to none.
3050     * bgimg_hovered - background image when hovered. Defaults to bgimg when not provided.
3051         * This is deprecated, use states instead.
3052     * bgimg_middle - Makes the bgimg textures render in 9-sliced mode and defines the middle rect.
3053                      See background9[] documentation for more details. This property also pads the
3054                      button's content when set.
3055     * bgimg_pressed - background image when pressed. Defaults to bgimg when not provided.
3056         * This is deprecated, use states instead.
3057     * font - Sets font type. This is a comma separated list of options. Valid options:
3058       * Main font type options. These cannot be combined with each other:
3059         * `normal`: Default font
3060         * `mono`: Monospaced font
3061       * Font modification options. If used without a main font type, `normal` is used:
3062         * `bold`: Makes font bold.
3063         * `italic`: Makes font italic.
3064       Default `normal`.
3065     * font_size - Sets font size. Default is user-set. Can have multiple values:
3066       * `<number>`: Sets absolute font size to `number`.
3067       * `+<number>`/`-<number>`: Offsets default font size by `number` points.
3068       * `*<number>`: Multiplies default font size by `number`, similar to CSS `em`.
3069     * border - boolean, draw border. Set to false to hide the bevelled button pane. Default true.
3070     * content_offset - 2d vector, shifts the position of the button's content without resizing it.
3071     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3072     * padding - rect, adds space between the edges of the button and the content. This value is
3073                 relative to bgimg_middle.
3074     * sound - a sound to be played when triggered.
3075     * textcolor - color, default white.
3076 * checkbox
3077     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3078     * sound - a sound to be played when triggered.
3079 * dropdown
3080     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3081     * sound - a sound to be played when the entry is changed.
3082 * field, pwdfield, textarea
3083     * border - set to false to hide the textbox background and border. Default true.
3084     * font - Sets font type. See button `font` property for more information.
3085     * font_size - Sets font size. See button `font_size` property for more information.
3086     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3087     * textcolor - color. Default white.
3088 * model
3089     * bgcolor - color, sets background color.
3090     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3091         * Default to false in formspec_version version 3 or higher
3092 * image
3093     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3094         * Default to false in formspec_version version 3 or higher
3095 * item_image
3096     * noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
3097 * label, vertlabel
3098     * font - Sets font type. See button `font` property for more information.
3099     * font_size - Sets font size. See button `font_size` property for more information.
3100     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3101 * list
3102     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3103     * size - 2d vector, sets the size of inventory slots in coordinates.
3104     * spacing - 2d vector, sets the space between inventory slots in coordinates.
3105 * image_button (additional properties)
3106     * fgimg - standard image. Defaults to none.
3107     * fgimg_hovered - image when hovered. Defaults to fgimg when not provided.
3108         * This is deprecated, use states instead.
3109     * fgimg_pressed - image when pressed. Defaults to fgimg when not provided.
3110         * This is deprecated, use states instead.
3111     * fgimg_middle - Makes the fgimg textures render in 9-sliced mode and defines the middle rect.
3112                      See background9[] documentation for more details.
3113     * NOTE: The parameters of any given image_button will take precedence over fgimg/fgimg_pressed
3114     * sound - a sound to be played when triggered.
3115 * scrollbar
3116     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3117 * tabheader
3118     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3119     * sound - a sound to be played when a different tab is selected.
3120     * textcolor - color. Default white.
3121 * table, textlist
3122     * font - Sets font type. See button `font` property for more information.
3123     * font_size - Sets font size. See button `font_size` property for more information.
3124     * noclip - boolean, set to true to allow the element to exceed formspec bounds.
3125
3126 ### Valid States
3127
3128 * *all elements*
3129     * default - Equivalent to providing no states
3130 * button, button_exit, image_button, item_image_button
3131     * hovered - Active when the mouse is hovering over the element
3132     * pressed - Active when the button is pressed
3133
3134 Markup Language
3135 ---------------
3136
3137 Markup language used in `hypertext[]` elements uses tags that look like HTML tags.
3138 The markup language is currently unstable and subject to change. Use with caution.
3139 Some tags can enclose text, they open with `<tagname>` and close with `</tagname>`.
3140 Tags can have attributes, in that case, attributes are in the opening tag in
3141 form of a key/value separated with equal signs. Attribute values should not be quoted.
3142
3143 If you want to insert a literal greater-than sign or a backslash into the text,
3144 you must escape it by preceding it with a backslash.
3145
3146 These are the technically basic tags but see below for usual tags. Base tags are:
3147
3148 `<style color=... font=... size=...>...</style>`
3149
3150 Changes the style of the text.
3151
3152 * `color`: Text color. Given color is a `colorspec`.
3153 * `size`: Text size.
3154 * `font`: Text font (`mono` or `normal`).
3155
3156 `<global background=... margin=... valign=... color=... hovercolor=... size=... font=... halign=... >`
3157
3158 Sets global style.
3159
3160 Global only styles:
3161 * `background`: Text background, a `colorspec` or `none`.
3162 * `margin`: Page margins in pixel.
3163 * `valign`: Text vertical alignment (`top`, `middle`, `bottom`).
3164
3165 Inheriting styles (affects child elements):
3166 * `color`: Default text color. Given color is a `colorspec`.
3167 * `hovercolor`: Color of <action> tags when mouse is over.
3168 * `size`: Default text size.
3169 * `font`: Default text font (`mono` or `normal`).
3170 * `halign`: Default text horizontal alignment (`left`, `right`, `center`, `justify`).
3171
3172 This tag needs to be placed only once as it changes the global settings of the
3173 text. Anyway, if several tags are placed, each changed will be made in the order
3174 tags appear.
3175
3176 `<tag name=... color=... hovercolor=... font=... size=...>`
3177
3178 Defines or redefines tag style. This can be used to define new tags.
3179 * `name`: Name of the tag to define or change.
3180 * `color`: Text color. Given color is a `colorspec`.
3181 * `hovercolor`: Text color when element hovered (only for `action` tags). Given color is a `colorspec`.
3182 * `size`: Text size.
3183 * `font`: Text font (`mono` or `normal`).
3184
3185 Following tags are the usual tags for text layout. They are defined by default.
3186 Other tags can be added using `<tag ...>` tag.
3187
3188 `<normal>...</normal>`: Normal size text
3189
3190 `<big>...</big>`: Big text
3191
3192 `<bigger>...</bigger>`: Bigger text
3193
3194 `<center>...</center>`: Centered text
3195
3196 `<left>...</left>`: Left-aligned text
3197
3198 `<right>...</right>`: Right-aligned text
3199
3200 `<justify>...</justify>`: Justified text
3201
3202 `<mono>...</mono>`: Monospaced font
3203
3204 `<b>...</b>`, `<i>...</i>`, `<u>...</u>`: Bold, italic, underline styles.
3205
3206 `<action name=...>...</action>`
3207
3208 Make that text a clickable text triggering an action.
3209
3210 * `name`: Name of the action (mandatory).
3211
3212 When clicked, the formspec is send to the server. The value of the text field
3213 sent to `on_player_receive_fields` will be "action:" concatenated to the action
3214 name.
3215
3216 `<img name=... float=... width=... height=...>`
3217
3218 Draws an image which is present in the client media cache.
3219
3220 * `name`: Name of the texture (mandatory).
3221 * `float`: If present, makes the image floating (`left` or `right`).
3222 * `width`: Force image width instead of taking texture width.
3223 * `height`: Force image height instead of taking texture height.
3224
3225 If only width or height given, texture aspect is kept.
3226
3227 `<item name=... float=... width=... height=... rotate=...>`
3228
3229 Draws an item image.
3230
3231 * `name`: Item string of the item to draw (mandatory).
3232 * `float`: If present, makes the image floating (`left` or `right`).
3233 * `width`: Item image width.
3234 * `height`: Item image height.
3235 * `rotate`: Rotate item image if set to `yes` or `X,Y,Z`. X, Y and Z being
3236 rotation speeds in percent of standard speed (-1000 to 1000). Works only if
3237 `inventory_items_animations` is set to true.
3238 * `angle`: Angle in which the item image is shown. Value has `X,Y,Z` form.
3239 X, Y and Z being angles around each three axes. Works only if
3240 `inventory_items_animations` is set to true.
3241
3242 Inventory
3243 =========
3244
3245 Inventory locations
3246 -------------------
3247
3248 * `"context"`: Selected node metadata (deprecated: `"current_name"`)
3249 * `"current_player"`: Player to whom the menu is shown
3250 * `"player:<name>"`: Any player
3251 * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
3252 * `"detached:<name>"`: A detached inventory
3253
3254 Player Inventory lists
3255 ----------------------
3256
3257 * `main`: list containing the default inventory
3258 * `craft`: list containing the craft input
3259 * `craftpreview`: list containing the craft prediction
3260 * `craftresult`: list containing the crafted output
3261 * `hand`: list containing an override for the empty hand
3262     * Is not created automatically, use `InvRef:set_size`
3263     * Is only used to enhance the empty hand's tool capabilities
3264
3265 Colors
3266 ======
3267
3268 `ColorString`
3269 -------------
3270
3271 `#RGB` defines a color in hexadecimal format.
3272
3273 `#RGBA` defines a color in hexadecimal format and alpha channel.
3274
3275 `#RRGGBB` defines a color in hexadecimal format.
3276
3277 `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
3278
3279 Named colors are also supported and are equivalent to
3280 [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color).
3281 To specify the value of the alpha channel, append `#A` or `#AA` to the end of
3282 the color name (e.g. `colorname#08`).
3283
3284 `ColorSpec`
3285 -----------
3286
3287 A ColorSpec specifies a 32-bit color. It can be written in any of the following
3288 forms:
3289
3290 * table form: Each element ranging from 0..255 (a, if absent, defaults to 255):
3291     * `colorspec = {a=255, r=0, g=255, b=0}`
3292 * numerical form: The raw integer value of an ARGB8 quad:
3293     * `colorspec = 0xFF00FF00`
3294 * string form: A ColorString (defined above):
3295     * `colorspec = "green"`
3296
3297
3298
3299
3300 Escape sequences
3301 ================
3302
3303 Most text can contain escape sequences, that can for example color the text.
3304 There are a few exceptions: tab headers, dropdowns and vertical labels can't.
3305 The following functions provide escape sequences:
3306
3307 * `minetest.get_color_escape_sequence(color)`:
3308     * `color` is a ColorString
3309     * The escape sequence sets the text color to `color`
3310 * `minetest.colorize(color, message)`:
3311     * Equivalent to:
3312       `minetest.get_color_escape_sequence(color) ..
3313       message ..
3314       minetest.get_color_escape_sequence("#ffffff")`
3315 * `minetest.get_background_escape_sequence(color)`
3316     * `color` is a ColorString
3317     * The escape sequence sets the background of the whole text element to
3318       `color`. Only defined for item descriptions and tooltips.
3319 * `minetest.strip_foreground_colors(str)`
3320     * Removes foreground colors added by `get_color_escape_sequence`.
3321 * `minetest.strip_background_colors(str)`
3322     * Removes background colors added by `get_background_escape_sequence`.
3323 * `minetest.strip_colors(str)`
3324     * Removes all color escape sequences.
3325
3326
3327
3328
3329 Spatial Vectors
3330 ===============
3331
3332 Minetest stores 3-dimensional spatial vectors in Lua as tables of 3 coordinates,
3333 and has a class to represent them (`vector.*`), which this chapter is about.
3334 For details on what a spatial vectors is, please refer to Wikipedia:
3335 https://en.wikipedia.org/wiki/Euclidean_vector.
3336
3337 Spatial vectors are used for various things, including, but not limited to:
3338
3339 * any 3D spatial vector (x/y/z-directions)
3340 * Euler angles (pitch/yaw/roll in radians) (Spatial vectors have no real semantic
3341   meaning here. Therefore, most vector operations make no sense in this use case.)
3342
3343 Note that they are *not* used for:
3344
3345 * n-dimensional vectors where n is not 3 (ie. n=2)
3346 * arrays of the form `{num, num, num}`
3347
3348 The API documentation may refer to spatial vectors, as produced by `vector.new`,
3349 by any of the following notations:
3350
3351 * `(x, y, z)` (Used rarely, and only if it's clear that it's a vector.)
3352 * `vector.new(x, y, z)`
3353 * `{x=num, y=num, z=num}` (Even here you are still supposed to use `vector.new`.)
3354
3355 Compatibility notes
3356 -------------------
3357
3358 Vectors used to be defined as tables of the form `{x = num, y = num, z = num}`.
3359 Since Minetest 5.5.0, vectors additionally have a metatable to enable easier use.
3360 Note: Those old-style vectors can still be found in old mod code. Hence, mod and
3361 engine APIs still need to be able to cope with them in many places.
3362
3363 Manually constructed tables are deprecated and highly discouraged. This interface
3364 should be used to ensure seamless compatibility between mods and the Minetest API.
3365 This is especially important to callback function parameters and functions overwritten
3366 by mods.
3367 Also, though not likely, the internal implementation of a vector might change in
3368 the future.
3369 In your own code, or if you define your own API, you can, of course, still use
3370 other representations of vectors.
3371
3372 Vectors provided by API functions will provide an instance of this class if not
3373 stated otherwise. Mods should adapt this for convenience reasons.
3374
3375 Special properties of the class
3376 -------------------------------
3377
3378 Vectors can be indexed with numbers and allow method and operator syntax.
3379
3380 All these forms of addressing a vector `v` are valid:
3381 `v[1]`, `v[3]`, `v.x`, `v[1] = 42`, `v.y = 13`
3382 Note: Prefer letter over number indexing for performance and compatibility reasons.
3383
3384 Where `v` is a vector and `foo` stands for any function name, `v:foo(...)` does
3385 the same as `vector.foo(v, ...)`, apart from deprecated functionality.
3386
3387 `tostring` is defined for vectors, see `vector.to_string`.
3388
3389 The metatable that is used for vectors can be accessed via `vector.metatable`.
3390 Do not modify it!
3391
3392 All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables.
3393 Returned vectors always have a metatable set.
3394
3395 Common functions and methods
3396 ----------------------------
3397
3398 For the following functions (and subchapters),
3399 `v`, `v1`, `v2` are vectors,
3400 `p1`, `p2` are position vectors,
3401 `s` is a scalar (a number),
3402 vectors are written like this: `(x, y, z)`:
3403
3404 * `vector.new([a[, b, c]])`:
3405     * Returns a new vector `(a, b, c)`.
3406     * Deprecated: `vector.new()` does the same as `vector.zero()` and
3407       `vector.new(v)` does the same as `vector.copy(v)`
3408 * `vector.zero()`:
3409     * Returns a new vector `(0, 0, 0)`.
3410 * `vector.copy(v)`:
3411     * Returns a copy of the vector `v`.
3412 * `vector.from_string(s[, init])`:
3413     * Returns `v, np`, where `v` is a vector read from the given string `s` and
3414       `np` is the next position in the string after the vector.
3415     * Returns `nil` on failure.
3416     * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
3417            spaces, leaving away commas and adding an additional comma to the end
3418            is allowed.
3419     * `init`: If given starts looking for the vector at this string index.
3420 * `vector.to_string(v)`:
3421     * Returns a string of the form `"(x, y, z)"`.
3422     *  `tostring(v)` does the same.
3423 * `vector.direction(p1, p2)`:
3424     * Returns a vector of length 1 with direction `p1` to `p2`.
3425     * If `p1` and `p2` are identical, returns `(0, 0, 0)`.
3426 * `vector.distance(p1, p2)`:
3427     * Returns zero or a positive number, the distance between `p1` and `p2`.
3428 * `vector.length(v)`:
3429     * Returns zero or a positive number, the length of vector `v`.
3430 * `vector.normalize(v)`:
3431     * Returns a vector of length 1 with direction of vector `v`.
3432     * If `v` has zero length, returns `(0, 0, 0)`.
3433 * `vector.floor(v)`:
3434     * Returns a vector, each dimension rounded down.
3435 * `vector.round(v)`:
3436     * Returns a vector, each dimension rounded to nearest integer.
3437     * At a multiple of 0.5, rounds away from zero.
3438 * `vector.apply(v, func)`:
3439     * Returns a vector where the function `func` has been applied to each
3440       component.
3441 * `vector.combine(v, w, func)`:
3442         * Returns a vector where the function `func` has combined both components of `v` and `w`
3443           for each component
3444 * `vector.equals(v1, v2)`:
3445     * Returns a boolean, `true` if the vectors are identical.
3446 * `vector.sort(v1, v2)`:
3447     * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
3448 * `vector.angle(v1, v2)`:
3449     * Returns the angle between `v1` and `v2` in radians.
3450 * `vector.dot(v1, v2)`:
3451     * Returns the dot product of `v1` and `v2`.
3452 * `vector.cross(v1, v2)`:
3453     * Returns the cross product of `v1` and `v2`.
3454 * `vector.offset(v, x, y, z)`:
3455     * Returns the sum of the vectors `v` and `(x, y, z)`.
3456 * `vector.check(v)`:
3457     * Returns a boolean value indicating whether `v` is a real vector, eg. created
3458       by a `vector.*` function.
3459     * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`.
3460
3461 For the following functions `x` can be either a vector or a number:
3462
3463 * `vector.add(v, x)`:
3464     * Returns a vector.
3465     * If `x` is a vector: Returns the sum of `v` and `x`.
3466     * If `x` is a number: Adds `x` to each component of `v`.
3467 * `vector.subtract(v, x)`:
3468     * Returns a vector.
3469     * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
3470     * If `x` is a number: Subtracts `x` from each component of `v`.
3471 * `vector.multiply(v, s)`:
3472     * Returns a scaled vector.
3473     * Deprecated: If `s` is a vector: Returns the Schur product.
3474 * `vector.divide(v, s)`:
3475     * Returns a scaled vector.
3476     * Deprecated: If `s` is a vector: Returns the Schur quotient.
3477
3478 Operators
3479 ---------
3480
3481 Operators can be used if all of the involved vectors have metatables:
3482 * `v1 == v2`:
3483     * Returns whether `v1` and `v2` are identical.
3484 * `-v`:
3485     * Returns the additive inverse of v.
3486 * `v1 + v2`:
3487     * Returns the sum of both vectors.
3488     * Note: `+` can not be used together with scalars.
3489 * `v1 - v2`:
3490     * Returns the difference of `v1` subtracted by `v2`.
3491     * Note: `-` can not be used together with scalars.
3492 * `v * s` or `s * v`:
3493     * Returns `v` scaled by `s`.
3494 * `v / s`:
3495     * Returns `v` scaled by `1 / s`.
3496
3497 Rotation-related functions
3498 --------------------------
3499
3500 For the following functions `a` is an angle in radians and `r` is a rotation
3501 vector (`{x = <pitch>, y = <yaw>, z = <roll>}`) where pitch, yaw and roll are
3502 angles in radians.
3503
3504 * `vector.rotate(v, r)`:
3505     * Applies the rotation `r` to `v` and returns the result.
3506     * `vector.rotate(vector.new(0, 0, 1), r)` and
3507       `vector.rotate(vector.new(0, 1, 0), r)` return vectors pointing
3508       forward and up relative to an entity's rotation `r`.
3509 * `vector.rotate_around_axis(v1, v2, a)`:
3510     * Returns `v1` rotated around axis `v2` by `a` radians according to
3511       the right hand rule.
3512 * `vector.dir_to_rotation(direction[, up])`:
3513     * Returns a rotation vector for `direction` pointing forward using `up`
3514       as the up vector.
3515     * If `up` is omitted, the roll of the returned vector defaults to zero.
3516     * Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
3517
3518 Further helpers
3519 ---------------
3520
3521 There are more helper functions involving vectors, but they are listed elsewhere
3522 because they only work on specific sorts of vectors or involve things that are not
3523 vectors.
3524
3525 For example:
3526
3527 * `minetest.hash_node_position` (Only works on node positions.)
3528 * `minetest.dir_to_wallmounted` (Involves wallmounted param2 values.)
3529
3530
3531
3532
3533 Helper functions
3534 ================
3535
3536 * `dump2(obj, name, dumped)`: returns a string which makes `obj`
3537   human-readable, handles reference loops.
3538     * `obj`: arbitrary variable
3539     * `name`: string, default: `"_"`
3540     * `dumped`: table, default: `{}`
3541 * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
3542     * `obj`: arbitrary variable
3543     * `dumped`: table, default: `{}`
3544 * `math.hypot(x, y)`
3545     * Get the hypotenuse of a triangle with legs x and y.
3546       Useful for distance calculation.
3547 * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
3548     * Get the sign of a number.
3549     * tolerance: number, default: `0.0`
3550     * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
3551       `0` is returned.
3552 * `math.factorial(x)`: returns the factorial of `x`
3553 * `math.round(x)`: Returns `x` rounded to the nearest integer.
3554     * At a multiple of 0.5, rounds away from zero.
3555 * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
3556     * `separator`: string, default: `","`
3557     * `include_empty`: boolean, default: `false`
3558     * `max_splits`: number, if it's negative, splits aren't limited,
3559       default: `-1`
3560     * `sep_is_pattern`: boolean, it specifies whether separator is a plain
3561       string or a pattern (regex), default: `false`
3562     * e.g. `"a,b":split","` returns `{"a","b"}`
3563 * `string:trim()`: returns the string without whitespace pre- and suffixes
3564     * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
3565 * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
3566     * Adds newlines to the string to keep it within the specified character
3567       limit
3568     * Note that the returned lines may be longer than the limit since it only
3569       splits at word borders.
3570     * `limit`: number, maximal amount of characters in one line
3571     * `as_table`: boolean, if set to true, a table of lines instead of a string
3572       is returned, default: `false`
3573 * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
3574     * `pos`: table {x=X, y=Y, z=Z}
3575     * Converts the position `pos` to a human-readable, printable string
3576     * `decimal_places`: number, if specified, the x, y and z values of
3577       the position are rounded to the given decimal place.
3578 * `minetest.string_to_pos(string)`: returns a position or `nil`
3579     * Same but in reverse.
3580     * If the string can't be parsed to a position, nothing is returned.
3581 * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)", relative_to)`:
3582     * returns two positions
3583     * Converts a string representing an area box into two positions
3584     * X1, Y1, ... Z2 are coordinates
3585     * `relative_to`: Optional. If set to a position, each coordinate
3586       can use the tilde notation for relative positions
3587     * Tilde notation: "~": Relative coordinate
3588                       "~<number>": Relative coordinate plus <number>
3589     * Example: `minetest.string_to_area("(1,2,3) (~5,~-5,~)", {x=10,y=10,z=10})`
3590       returns `{x=1,y=2,z=3}, {x=15,y=5,z=10}`
3591 * `minetest.formspec_escape(string)`: returns a string
3592     * escapes the characters "[", "]", "\", "," and ";", which can not be used
3593       in formspecs.
3594 * `minetest.is_yes(arg)`
3595     * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
3596 * `minetest.is_nan(arg)`
3597     * returns true when the passed number represents NaN.
3598 * `minetest.get_us_time()`
3599     * returns time with microsecond precision. May not return wall time.
3600 * `table.copy(table)`: returns a table
3601     * returns a deep copy of `table`
3602 * `table.indexof(list, val)`: returns the smallest numerical index containing
3603       the value `val` in the table `list`. Non-numerical indices are ignored.
3604       If `val` could not be found, `-1` is returned. `list` must not have
3605       negative indices.
3606 * `table.insert_all(table, other_table)`:
3607     * Appends all values in `other_table` to `table` - uses `#table + 1` to
3608       find new indices.
3609 * `table.key_value_swap(t)`: returns a table with keys and values swapped
3610     * If multiple keys in `t` map to the same value, it is unspecified which
3611       value maps to that key.
3612 * `table.shuffle(table, [from], [to], [random_func])`:
3613     * Shuffles elements `from` to `to` in `table` in place
3614     * `from` defaults to `1`
3615     * `to` defaults to `#table`
3616     * `random_func` defaults to `math.random`. This function receives two
3617       integers as arguments and should return a random integer inclusively
3618       between them.
3619 * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
3620   position.
3621     * returns the exact position on the surface of a pointed node
3622 * `minetest.get_tool_wear_after_use(uses [, initial_wear])`
3623     * Simulates a tool being used once and returns the added wear,
3624       such that, if only this function is used to calculate wear,
3625       the tool will break exactly after `uses` times of uses
3626     * `uses`: Number of times the tool can be used
3627     * `initial_wear`: The initial wear the tool starts with (default: 0)
3628 * `minetest.get_dig_params(groups, tool_capabilities [, wear])`:
3629     Simulates an item that digs a node.
3630     Returns a table with the following fields:
3631     * `diggable`: `true` if node can be dug, `false` otherwise.
3632     * `time`: Time it would take to dig the node.
3633     * `wear`: How much wear would be added to the tool (ignored for non-tools).
3634     `time` and `wear` are meaningless if node's not diggable
3635     Parameters:
3636     * `groups`: Table of the node groups of the node that would be dug
3637     * `tool_capabilities`: Tool capabilities table of the item
3638     * `wear`: Amount of wear the tool starts with (default: 0)
3639 * `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch [, wear]])`:
3640     Simulates an item that punches an object.
3641     Returns a table with the following fields:
3642     * `hp`: How much damage the punch would cause (between -65535 and 65535).
3643     * `wear`: How much wear would be added to the tool (ignored for non-tools).
3644     Parameters:
3645     * `groups`: Damage groups of the object
3646     * `tool_capabilities`: Tool capabilities table of the item
3647     * `time_from_last_punch`: time in seconds since last punch action
3648     * `wear`: Amount of wear the item starts with (default: 0)
3649
3650
3651
3652
3653 Translations
3654 ============
3655
3656 Texts can be translated client-side with the help of `minetest.translate` and
3657 translation files.
3658
3659 Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
3660 to generate and update translation files automatically from the Lua source.
3661
3662 Translating a string
3663 --------------------
3664
3665 Two functions are provided to translate strings: `minetest.translate` and
3666 `minetest.get_translator`.
3667
3668 * `minetest.get_translator(textdomain)` is a simple wrapper around
3669   `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
3670   equivalent to `minetest.translate(textdomain, str, ...)`.
3671   It is intended to be used in the following way, so that it avoids verbose
3672   repetitions of `minetest.translate`:
3673
3674       local S = minetest.get_translator(textdomain)
3675       S(str, ...)
3676
3677   As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
3678
3679 * `minetest.translate(textdomain, str, ...)` translates the string `str` with
3680   the given `textdomain` for disambiguation. The textdomain must match the
3681   textdomain specified in the translation file in order to get the string
3682   translated. This can be used so that a string is translated differently in
3683   different contexts.
3684   It is advised to use the name of the mod as textdomain whenever possible, to
3685   avoid clashes with other mods.
3686   This function must be given a number of arguments equal to the number of
3687   arguments the translated string expects.
3688   Arguments are literal strings -- they will not be translated, so if you want
3689   them to be, they need to come as outputs of `minetest.translate` as well.
3690
3691   For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
3692   by the translation of "Red". We can do the following:
3693
3694       local S = minetest.get_translator()
3695       S("@1 Wool", S("Red"))
3696
3697   This will be displayed as "Red Wool" on old clients and on clients that do
3698   not have localization enabled. However, if we have for instance a translation
3699   file named `wool.fr.tr` containing the following:
3700
3701       @1 Wool=Laine @1
3702       Red=Rouge
3703
3704   this will be displayed as "Laine Rouge" on clients with a French locale.
3705
3706 Operations on translated strings
3707 --------------------------------
3708
3709 The output of `minetest.translate` is a string, with escape sequences adding
3710 additional information to that string so that it can be translated on the
3711 different clients. In particular, you can't expect operations like string.length
3712 to work on them like you would expect them to, or string.gsub to work in the
3713 expected manner. However, string concatenation will still work as expected
3714 (note that you should only use this for things like formspecs; do not translate
3715 sentences by breaking them into parts; arguments should be used instead), and
3716 operations such as `minetest.colorize` which are also concatenation.
3717
3718 Translation file format
3719 -----------------------
3720
3721 A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
3722 it corresponds to. It must be put into the `locale` subdirectory of the mod.
3723 The file should be a text file, with the following format:
3724
3725 * Lines beginning with `# textdomain:` (the space is significant) can be used
3726   to specify the text domain of all following translations in the file.
3727 * All other empty lines or lines beginning with `#` are ignored.
3728 * Other lines should be in the format `original=translated`. Both `original`
3729   and `translated` can contain escape sequences beginning with `@` to insert
3730   arguments, literal `@`, `=` or newline (See [Escapes] below).
3731   There must be no extraneous whitespace around the `=` or at the beginning or
3732   the end of the line.
3733
3734 Escapes
3735 -------
3736
3737 Strings that need to be translated can contain several escapes, preceded by `@`.
3738
3739 * `@@` acts as a literal `@`.
3740 * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
3741   string that will be inlined when translated. Due to how translations are
3742   implemented, the original translation string **must** have its arguments in
3743   increasing order, without gaps or repetitions, starting from 1.
3744 * `@=` acts as a literal `=`. It is not required in strings given to
3745   `minetest.translate`, but is in translation files to avoid being confused
3746   with the `=` separating the original from the translation.
3747 * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
3748   As with `@=`, this escape is not required in strings given to
3749   `minetest.translate`, but is in translation files.
3750 * `@n` acts as a literal newline as well.
3751
3752 Server side translations
3753 ------------------------
3754
3755 On some specific cases, server translation could be useful. For example, filter
3756 a list on labels and send results to client. A method is supplied to achieve
3757 that:
3758
3759 `minetest.get_translated_string(lang_code, string)`: Translates `string` using
3760 translations for `lang_code` language. It gives the same result as if the string
3761 was translated by the client.
3762
3763 The `lang_code` to use for a given player can be retrieved from
3764 the table returned by `minetest.get_player_information(name)`.
3765
3766 IMPORTANT: This functionality should only be used for sorting, filtering or similar purposes.
3767 You do not need to use this to get translated strings to show up on the client.
3768
3769 Perlin noise
3770 ============
3771
3772 Perlin noise creates a continuously-varying value depending on the input values.
3773 Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
3774 The result is used during map generation to create the terrain shape, vary heat
3775 and humidity to distribute biomes, vary the density of decorations or vary the
3776 structure of ores.
3777
3778 Structure of perlin noise
3779 -------------------------
3780
3781 An 'octave' is a simple noise generator that outputs a value between -1 and 1.
3782 The smooth wavy noise it generates has a single characteristic scale, almost
3783 like a 'wavelength', so on its own does not create fine detail.
3784 Due to this perlin noise combines several octaves to create variation on
3785 multiple scales. Each additional octave has a smaller 'wavelength' than the
3786 previous.
3787
3788 This combination results in noise varying very roughly between -2.0 and 2.0 and
3789 with an average value of 0.0, so `scale` and `offset` are then used to multiply
3790 and offset the noise variation.
3791
3792 The final perlin noise variation is created as follows:
3793
3794 noise = offset + scale * (octave1 +
3795                           octave2 * persistence +
3796                           octave3 * persistence ^ 2 +
3797                           octave4 * persistence ^ 3 +
3798                           ...)
3799
3800 Noise Parameters
3801 ----------------
3802
3803 Noise Parameters are commonly called `NoiseParams`.
3804
3805 ### `offset`
3806
3807 After the multiplication by `scale` this is added to the result and is the final
3808 step in creating the noise value.
3809 Can be positive or negative.
3810
3811 ### `scale`
3812
3813 Once all octaves have been combined, the result is multiplied by this.
3814 Can be positive or negative.
3815
3816 ### `spread`
3817
3818 For octave1, this is roughly the change of input value needed for a very large
3819 variation in the noise value generated by octave1. It is almost like a
3820 'wavelength' for the wavy noise variation.
3821 Each additional octave has a 'wavelength' that is smaller than the previous
3822 octave, to create finer detail. `spread` will therefore roughly be the typical
3823 size of the largest structures in the final noise variation.
3824
3825 `spread` is a vector with values for x, y, z to allow the noise variation to be
3826 stretched or compressed in the desired axes.
3827 Values are positive numbers.
3828
3829 ### `seed`
3830
3831 This is a whole number that determines the entire pattern of the noise
3832 variation. Altering it enables different noise patterns to be created.
3833 With other parameters equal, different seeds produce different noise patterns
3834 and identical seeds produce identical noise patterns.
3835
3836 For this parameter you can randomly choose any whole number. Usually it is
3837 preferable for this to be different from other seeds, but sometimes it is useful
3838 to be able to create identical noise patterns.
3839
3840 In some noise APIs the world seed is added to the seed specified in noise
3841 parameters. This is done to make the resulting noise pattern vary in different
3842 worlds, and be 'world-specific'.
3843
3844 ### `octaves`
3845
3846 The number of simple noise generators that are combined.
3847 A whole number, 1 or more.
3848 Each additional octave adds finer detail to the noise but also increases the
3849 noise calculation load.
3850 3 is a typical minimum for a high quality, complex and natural-looking noise
3851 variation. 1 octave has a slight 'gridlike' appearance.
3852
3853 Choose the number of octaves according to the `spread` and `lacunarity`, and the
3854 size of the finest detail you require. For example:
3855 if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
3856 nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
3857 512, 256, 128, 64, 32, 16 nodes.
3858 Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
3859
3860 ### `persistence`
3861
3862 Each additional octave has an amplitude that is the amplitude of the previous
3863 octave multiplied by `persistence`, to reduce the amplitude of finer details,
3864 as is often helpful and natural to do so.
3865 Since this controls the balance of fine detail to large-scale detail
3866 `persistence` can be thought of as the 'roughness' of the noise.
3867
3868 A positive or negative non-zero number, often between 0.3 and 1.0.
3869 A common medium value is 0.5, such that each octave has half the amplitude of
3870 the previous octave.
3871 This may need to be tuned when altering `lacunarity`; when doing so consider
3872 that a common medium value is 1 / lacunarity.
3873
3874 ### `lacunarity`
3875
3876 Each additional octave has a 'wavelength' that is the 'wavelength' of the
3877 previous octave multiplied by 1 / lacunarity, to create finer detail.
3878 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
3879
3880 A positive number no smaller than 1.0.
3881 Values below 2.0 create higher quality noise at the expense of requiring more
3882 octaves to cover a paticular range of 'wavelengths'.
3883
3884 ### `flags`
3885
3886 Leave this field unset for no special handling.
3887 Currently supported are `defaults`, `eased` and `absvalue`:
3888
3889 #### `defaults`
3890
3891 Specify this if you would like to keep auto-selection of eased/not-eased while
3892 specifying some other flags.
3893
3894 #### `eased`
3895
3896 Maps noise gradient values onto a quintic S-curve before performing
3897 interpolation. This results in smooth, rolling noise.
3898 Disable this (`noeased`) for sharp-looking noise with a slightly gridded
3899 appearence.
3900 If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
3901 not eased.
3902 Easing a 3D noise significantly increases the noise calculation load, so use
3903 with restraint.
3904
3905 #### `absvalue`
3906
3907 The absolute value of each octave's noise variation is used when combining the
3908 octaves. The final perlin noise variation is created as follows:
3909
3910 noise = offset + scale * (abs(octave1) +
3911                           abs(octave2) * persistence +
3912                           abs(octave3) * persistence ^ 2 +
3913                           abs(octave4) * persistence ^ 3 +
3914                           ...)
3915
3916 ### Format example
3917
3918 For 2D or 3D perlin noise or perlin noise maps:
3919
3920     np_terrain = {
3921         offset = 0,
3922         scale = 1,
3923         spread = {x = 500, y = 500, z = 500},
3924         seed = 571347,
3925         octaves = 5,
3926         persistence = 0.63,
3927         lacunarity = 2.0,
3928         flags = "defaults, absvalue",
3929     }
3930
3931 For 2D noise the Z component of `spread` is still defined but is ignored.
3932 A single noise parameter table can be used for 2D or 3D noise.
3933
3934
3935
3936
3937 Ores
3938 ====
3939
3940 Ore types
3941 ---------
3942
3943 These tell in what manner the ore is generated.
3944
3945 All default ores are of the uniformly-distributed scatter type.
3946
3947 ### `scatter`
3948
3949 Randomly chooses a location and generates a cluster of ore.
3950
3951 If `noise_params` is specified, the ore will be placed if the 3D perlin noise
3952 at that point is greater than the `noise_threshold`, giving the ability to
3953 create a non-equal distribution of ore.
3954
3955 ### `sheet`
3956
3957 Creates a sheet of ore in a blob shape according to the 2D perlin noise
3958 described by `noise_params` and `noise_threshold`. This is essentially an
3959 improved version of the so-called "stratus" ore seen in some unofficial mods.
3960
3961 This sheet consists of vertical columns of uniform randomly distributed height,
3962 varying between the inclusive range `column_height_min` and `column_height_max`.
3963 If `column_height_min` is not specified, this parameter defaults to 1.
3964 If `column_height_max` is not specified, this parameter defaults to `clust_size`
3965 for reverse compatibility. New code should prefer `column_height_max`.
3966
3967 The `column_midpoint_factor` parameter controls the position of the column at
3968 which ore emanates from.
3969 If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
3970 equally starting from each direction.
3971 `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
3972 this parameter is not specified, the default is 0.5.
3973
3974 The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
3975 ore type.
3976
3977 ### `puff`
3978
3979 Creates a sheet of ore in a cloud-like puff shape.
3980
3981 As with the `sheet` ore type, the size and shape of puffs are described by
3982 `noise_params` and `noise_threshold` and are placed at random vertical
3983 positions within the currently generated chunk.
3984
3985 The vertical top and bottom displacement of each puff are determined by the
3986 noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
3987
3988 ### `blob`
3989
3990 Creates a deformed sphere of ore according to 3d perlin noise described by
3991 `noise_params`. The maximum size of the blob is `clust_size`, and
3992 `clust_scarcity` has the same meaning as with the `scatter` type.
3993
3994 ### `vein`
3995
3996 Creates veins of ore varying in density by according to the intersection of two
3997 instances of 3d perlin noise with different seeds, both described by
3998 `noise_params`.
3999
4000 `random_factor` varies the influence random chance has on placement of an ore
4001 inside the vein, which is `1` by default. Note that modifying this parameter
4002 may require adjusting `noise_threshold`.
4003
4004 The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
4005 by this ore type.
4006
4007 This ore type is difficult to control since it is sensitive to small changes.
4008 The following is a decent set of parameters to work from:
4009
4010     noise_params = {
4011         offset  = 0,
4012         scale   = 3,
4013         spread  = {x=200, y=200, z=200},
4014         seed    = 5390,
4015         octaves = 4,
4016         persistence = 0.5,
4017         lacunarity = 2.0,
4018         flags = "eased",
4019     },
4020     noise_threshold = 1.6
4021
4022 **WARNING**: Use this ore type *very* sparingly since it is ~200x more
4023 computationally expensive than any other ore.
4024
4025 ### `stratum`
4026
4027 Creates a single undulating ore stratum that is continuous across mapchunk
4028 borders and horizontally spans the world.
4029
4030 The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
4031 the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
4032 defines the stratum's vertical thickness (in units of nodes). Due to being
4033 continuous across mapchunk borders the stratum's vertical thickness is
4034 unlimited.
4035
4036 If the noise parameter `noise_params` is omitted the ore will occur from y_min
4037 to y_max in a simple horizontal stratum.
4038
4039 A parameter `stratum_thickness` can be provided instead of the noise parameter
4040 `np_stratum_thickness`, to create a constant thickness.
4041
4042 Leaving out one or both noise parameters makes the ore generation less
4043 intensive, useful when adding multiple strata.
4044
4045 `y_min` and `y_max` define the limits of the ore generation and for performance
4046 reasons should be set as close together as possible but without clipping the
4047 stratum's Y variation.
4048
4049 Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
4050 solid-ore stratum would require a `clust_scarcity` of 1.
4051
4052 The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
4053 `random_factor` are ignored by this ore type.
4054
4055 Ore attributes
4056 --------------
4057
4058 See section [Flag Specifier Format].
4059
4060 Currently supported flags:
4061 `puff_cliffs`, `puff_additive_composition`.
4062
4063 ### `puff_cliffs`
4064
4065 If set, puff ore generation will not taper down large differences in
4066 displacement when approaching the edge of a puff. This flag has no effect for
4067 ore types other than `puff`.
4068
4069 ### `puff_additive_composition`
4070
4071 By default, when noise described by `np_puff_top` or `np_puff_bottom` results
4072 in a negative displacement, the sub-column at that point is not generated. With
4073 this attribute set, puff ore generation will instead generate the absolute
4074 difference in noise displacement values. This flag has no effect for ore types
4075 other than `puff`.
4076
4077
4078
4079
4080 Decoration types
4081 ================
4082
4083 The varying types of decorations that can be placed.
4084
4085 `simple`
4086 --------
4087
4088 Creates a 1 times `H` times 1 column of a specified node (or a random node from
4089 a list, if a decoration list is specified). Can specify a certain node it must
4090 spawn next to, such as water or lava, for example. Can also generate a
4091 decoration of random height between a specified lower and upper bound.
4092 This type of decoration is intended for placement of grass, flowers, cacti,
4093 papyri, waterlilies and so on.
4094
4095 `schematic`
4096 -----------
4097
4098 Copies a box of `MapNodes` from a specified schematic file (or raw description).
4099 Can specify a probability of a node randomly appearing when placed.
4100 This decoration type is intended to be used for multi-node sized discrete
4101 structures, such as trees, cave spikes, rocks, and so on.
4102
4103
4104
4105
4106 Schematics
4107 ==========
4108
4109 Schematic specifier
4110 --------------------
4111
4112 A schematic specifier identifies a schematic by either a filename to a
4113 Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
4114 in the form of a table.  This table specifies the following fields:
4115
4116 * The `size` field is a 3D vector containing the dimensions of the provided
4117   schematic. (required field)
4118 * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
4119   sets the probability of a particular horizontal slice of the schematic being
4120   placed. (optional field)
4121   `ypos` = 0 for the lowest horizontal slice of a schematic.
4122   The default of `prob` is 255.
4123 * The `data` field is a flat table of MapNode tables making up the schematic,
4124   in the order of `[z [y [x]]]`. (required field)
4125   Each MapNode table contains:
4126     * `name`: the name of the map node to place (required)
4127     * `prob` (alias `param1`): the probability of this node being placed
4128       (default: 255)
4129     * `param2`: the raw param2 value of the node being placed onto the map
4130       (default: 0)
4131     * `force_place`: boolean representing if the node should forcibly overwrite
4132       any previous contents (default: false)
4133
4134 About probability values:
4135
4136 * A probability value of `0` or `1` means that node will never appear
4137   (0% chance).
4138 * A probability value of `254` or `255` means the node will always appear
4139   (100% chance).
4140 * If the probability value `p` is greater than `1`, then there is a
4141   `(p / 256 * 100)` percent chance that node will appear when the schematic is
4142   placed on the map.
4143
4144 Schematic attributes
4145 --------------------
4146
4147 See section [Flag Specifier Format].
4148
4149 Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
4150                            `force_placement`.
4151
4152 * `place_center_x`: Placement of this decoration is centered along the X axis.
4153 * `place_center_y`: Placement of this decoration is centered along the Y axis.
4154 * `place_center_z`: Placement of this decoration is centered along the Z axis.
4155 * `force_placement`: Schematic nodes other than "ignore" will replace existing
4156   nodes.
4157
4158
4159
4160
4161 Lua Voxel Manipulator
4162 =====================
4163
4164 About VoxelManip
4165 ----------------
4166
4167 VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
4168 facility. The purpose of this object is for fast, low-level, bulk access to
4169 reading and writing Map content. As such, setting map nodes through VoxelManip
4170 will lack many of the higher level features and concepts you may be used to
4171 with other methods of setting nodes. For example, nodes will not have their
4172 construction and destruction callbacks run, and no rollback information is
4173 logged.
4174
4175 It is important to note that VoxelManip is designed for speed, and *not* ease
4176 of use or flexibility. If your mod requires a map manipulation facility that
4177 will handle 100% of all edge cases, or the use of high level node placement
4178 features, perhaps `minetest.set_node()` is better suited for the job.
4179
4180 In addition, VoxelManip might not be faster, or could even be slower, for your
4181 specific use case. VoxelManip is most effective when setting large areas of map
4182 at once - for example, if only setting a 3x3x3 node area, a
4183 `minetest.set_node()` loop may be more optimal. Always profile code using both
4184 methods of map manipulation to determine which is most appropriate for your
4185 usage.
4186
4187 A recent simple test of setting cubic areas showed that `minetest.set_node()`
4188 is faster than a VoxelManip for a 3x3x3 node cube or smaller.
4189
4190 Using VoxelManip
4191 ----------------
4192
4193 A VoxelManip object can be created any time using either:
4194 `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
4195
4196 If the optional position parameters are present for either of these routines,
4197 the specified region will be pre-loaded into the VoxelManip object on creation.
4198 Otherwise, the area of map you wish to manipulate must first be loaded into the
4199 VoxelManip object using `VoxelManip:read_from_map()`.
4200
4201 Note that `VoxelManip:read_from_map()` returns two position vectors. The region
4202 formed by these positions indicate the minimum and maximum (respectively)
4203 positions of the area actually loaded in the VoxelManip, which may be larger
4204 than the area requested. For convenience, the loaded area coordinates can also
4205 be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
4206
4207 Now that the VoxelManip object is populated with map data, your mod can fetch a
4208 copy of this data using either of two methods. `VoxelManip:get_node_at()`,
4209 which retrieves an individual node in a MapNode formatted table at the position
4210 requested is the simplest method to use, but also the slowest.
4211
4212 Nodes in a VoxelManip object may also be read in bulk to a flat array table
4213 using:
4214
4215 * `VoxelManip:get_data()` for node content (in Content ID form, see section
4216   [Content IDs]),
4217 * `VoxelManip:get_light_data()` for node light levels, and
4218 * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
4219
4220 See section [Flat array format] for more details.
4221
4222 It is very important to understand that the tables returned by any of the above
4223 three functions represent a snapshot of the VoxelManip's internal state at the
4224 time of the call. This copy of the data will not magically update itself if
4225 another function modifies the internal VoxelManip state.
4226 Any functions that modify a VoxelManip's contents work on the VoxelManip's
4227 internal state unless otherwise explicitly stated.
4228
4229 Once the bulk data has been edited to your liking, the internal VoxelManip
4230 state can be set using:
4231
4232 * `VoxelManip:set_data()` for node content (in Content ID form, see section
4233   [Content IDs]),
4234 * `VoxelManip:set_light_data()` for node light levels, and
4235 * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
4236
4237 The parameter to each of the above three functions can use any table at all in
4238 the same flat array format as produced by `get_data()` etc. and is not required
4239 to be a table retrieved from `get_data()`.
4240
4241 Once the internal VoxelManip state has been modified to your liking, the
4242 changes can be committed back to the map by calling `VoxelManip:write_to_map()`
4243
4244 ### Flat array format
4245
4246 Let
4247     `Nx = p2.X - p1.X + 1`,
4248     `Ny = p2.Y - p1.Y + 1`, and
4249     `Nz = p2.Z - p1.Z + 1`.
4250
4251 Then, for a loaded region of p1..p2, this array ranges from `1` up to and
4252 including the value of the expression `Nx * Ny * Nz`.
4253
4254 Positions offset from p1 are present in the array with the format of:
4255
4256     [
4257         (0, 0, 0),   (1, 0, 0),   (2, 0, 0),   ... (Nx, 0, 0),
4258         (0, 1, 0),   (1, 1, 0),   (2, 1, 0),   ... (Nx, 1, 0),
4259         ...
4260         (0, Ny, 0),  (1, Ny, 0),  (2, Ny, 0),  ... (Nx, Ny, 0),
4261         (0, 0, 1),   (1, 0, 1),   (2, 0, 1),   ... (Nx, 0, 1),
4262         ...
4263         (0, Ny, 2),  (1, Ny, 2),  (2, Ny, 2),  ... (Nx, Ny, 2),
4264         ...
4265         (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
4266     ]
4267
4268 and the array index for a position p contained completely in p1..p2 is:
4269
4270 `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
4271
4272 Note that this is the same "flat 3D array" format as
4273 `PerlinNoiseMap:get3dMap_flat()`.
4274 VoxelArea objects (see section [`VoxelArea`]) can be used to simplify calculation
4275 of the index for a single point in a flat VoxelManip array.
4276
4277 ### Content IDs
4278
4279 A Content ID is a unique integer identifier for a specific node type.
4280 These IDs are used by VoxelManip in place of the node name string for
4281 `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
4282 `minetest.get_content_id()` to look up the Content ID for the specified node
4283 name, and `minetest.get_name_from_content_id()` to look up the node name string
4284 for a given Content ID.
4285 After registration of a node, its Content ID will remain the same throughout
4286 execution of the mod.
4287 Note that the node being queried needs to have already been been registered.
4288
4289 The following builtin node types have their Content IDs defined as constants:
4290
4291 * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
4292 * `minetest.CONTENT_AIR`:     ID for "air" nodes
4293 * `minetest.CONTENT_IGNORE`:  ID for "ignore" nodes
4294
4295 ### Mapgen VoxelManip objects
4296
4297 Inside of `on_generated()` callbacks, it is possible to retrieve the same
4298 VoxelManip object used by the core's Map Generator (commonly abbreviated
4299 Mapgen). Most of the rules previously described still apply but with a few
4300 differences:
4301
4302 * The Mapgen VoxelManip object is retrieved using:
4303   `minetest.get_mapgen_object("voxelmanip")`
4304 * This VoxelManip object already has the region of map just generated loaded
4305   into it; it's not necessary to call `VoxelManip:read_from_map()`.
4306   Note that the region of map it has loaded is NOT THE SAME as the `minp`, `maxp`
4307   parameters of `on_generated()`. Refer to `minetest.get_mapgen_object` docs.
4308 * The `on_generated()` callbacks of some mods may place individual nodes in the
4309   generated area using non-VoxelManip map modification methods. Because the
4310   same Mapgen VoxelManip object is passed through each `on_generated()`
4311   callback, it becomes necessary for the Mapgen VoxelManip object to maintain
4312   consistency with the current map state. For this reason, calling any of
4313   `minetest.add_node()`, `minetest.set_node()` or `minetest.swap_node()`
4314   will also update the Mapgen VoxelManip object's internal state active on the
4315   current thread.
4316 * After modifying the Mapgen VoxelManip object's internal buffer, it may be
4317   necessary to update lighting information using either:
4318   `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
4319
4320 ### Other API functions operating on a VoxelManip
4321
4322 If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
4323 `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
4324 flowing. It is recommended to call this function only after having written all
4325 buffered data back to the VoxelManip object, save for special situations where
4326 the modder desires to only have certain liquid nodes begin flowing.
4327
4328 The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
4329 will generate all registered decorations and ores throughout the full area
4330 inside of the specified VoxelManip object.
4331
4332 `minetest.place_schematic_on_vmanip()` is otherwise identical to
4333 `minetest.place_schematic()`, except instead of placing the specified schematic
4334 directly on the map at the specified position, it will place the schematic
4335 inside the VoxelManip.
4336
4337 ### Notes
4338
4339 * Attempting to read data from a VoxelManip object before map is read will
4340   result in a zero-length array table for `VoxelManip:get_data()`, and an
4341   "ignore" node at any position for `VoxelManip:get_node_at()`.
4342 * If either a region of map has not yet been generated or is out-of-bounds of
4343   the map, that region is filled with "ignore" nodes.
4344 * Other mods, or the core itself, could possibly modify the area of map
4345   currently loaded into a VoxelManip object. With the exception of Mapgen
4346   VoxelManips (see above section), the internal buffers are not updated. For
4347   this reason, it is strongly encouraged to complete the usage of a particular
4348   VoxelManip object in the same callback it had been created.
4349 * If a VoxelManip object will be used often, such as in an `on_generated()`
4350   callback, consider passing a file-scoped table as the optional parameter to
4351   `VoxelManip:get_data()`, which serves as a static buffer the function can use
4352   to write map data to instead of returning a new table each call. This greatly
4353   enhances performance by avoiding unnecessary memory allocations.
4354
4355 Methods
4356 -------
4357
4358 * `read_from_map(p1, p2)`:  Loads a chunk of map into the VoxelManip object
4359   containing the region formed by `p1` and `p2`.
4360     * returns actual emerged `pmin`, actual emerged `pmax`
4361 * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
4362   the map.
4363     * **important**: data must be set using `VoxelManip:set_data()` before
4364       calling this.
4365     * if `light` is true, then lighting is automatically recalculated.
4366       The default value is true.
4367       If `light` is false, no light calculations happen, and you should correct
4368       all modified blocks with `minetest.fix_light()` as soon as possible.
4369       Keep in mind that modifying the map where light is incorrect can cause
4370       more lighting bugs.
4371 * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
4372   the `VoxelManip` at that position
4373 * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
4374   that position.
4375 * `get_data([buffer])`: Retrieves the node content data loaded into the
4376   `VoxelManip` object.
4377     * returns raw node data in the form of an array of node content IDs
4378     * if the param `buffer` is present, this table will be used to store the
4379       result instead.
4380 * `set_data(data)`: Sets the data contents of the `VoxelManip` object
4381 * `update_map()`: Does nothing, kept for compatibility.
4382 * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
4383   a uniform value.
4384     * `light` is a table, `{day=<0...15>, night=<0...15>}`
4385     * To be used only by a `VoxelManip` object from
4386       `minetest.get_mapgen_object`.
4387     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4388       area if left out.
4389 * `get_light_data()`: Gets the light data read into the `VoxelManip` object
4390     * Returns an array (indices 1 to volume) of integers ranging from `0` to
4391       `255`.
4392     * Each value is the bitwise combination of day and night light values
4393       (`0` to `15` each).
4394     * `light = day + (night * 16)`
4395 * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
4396   in the `VoxelManip`.
4397     * expects lighting data in the same format that `get_light_data()` returns
4398 * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
4399   `VoxelManip` object.
4400     * Returns an array (indices 1 to volume) of integers ranging from `0` to
4401       `255`.
4402     * If the param `buffer` is present, this table will be used to store the
4403       result instead.
4404 * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
4405   the `VoxelManip`.
4406 * `calc_lighting([p1, p2], [propagate_shadow])`:  Calculate lighting within the
4407   `VoxelManip`.
4408     * To be used only by a `VoxelManip` object from
4409       `minetest.get_mapgen_object`.
4410     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
4411       area if left out or nil. For almost all uses these should be left out
4412       or nil to use the default.
4413     * `propagate_shadow` is an optional boolean deciding whether shadows in a
4414       generated mapchunk above are propagated down into the mapchunk, defaults
4415       to `true` if left out.
4416 * `update_liquids()`: Update liquid flow
4417 * `was_modified()`: Returns `true` or `false` if the data in the voxel
4418   manipulator had been modified since the last read from map, due to a call to
4419   `minetest.set_data()` on the loaded area elsewhere.
4420 * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
4421
4422 `VoxelArea`
4423 -----------
4424
4425 A helper class for voxel areas.
4426 It can be created via `VoxelArea:new({MinEdge = pmin, MaxEdge = pmax})`.
4427 The coordinates are *inclusive*, like most other things in Minetest.
4428
4429 ### Methods
4430
4431 * `getExtent()`: returns a 3D vector containing the size of the area formed by
4432   `MinEdge` and `MaxEdge`.
4433 * `getVolume()`: returns the volume of the area formed by `MinEdge` and
4434   `MaxEdge`.
4435 * `index(x, y, z)`: returns the index of an absolute position in a flat array
4436   starting at `1`.
4437     * `x`, `y` and `z` must be integers to avoid an incorrect index result.
4438     * The position (x, y, z) is not checked for being inside the area volume,
4439       being outside can cause an incorrect index result.
4440     * Useful for things like `VoxelManip`, raw Schematic specifiers,
4441       `PerlinNoiseMap:get2d`/`3dMap`, and so on.
4442 * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
4443     * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
4444       is not checked for being inside the area volume.
4445 * `position(i)`: returns the absolute position vector corresponding to index
4446   `i`.
4447 * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
4448   `MinEdge` and `MaxEdge`.
4449 * `containsp(p)`: same as above, except takes a vector
4450 * `containsi(i)`: same as above, except takes an index `i`
4451 * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
4452   indices.
4453     * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
4454       `[z [y [x]]]`.
4455 * `iterp(minp, maxp)`: same as above, except takes a vector
4456
4457 ### Y stride and z stride of a flat array
4458
4459 For a particular position in a voxel area, whose flat array index is known,
4460 it is often useful to know the index of a neighboring or nearby position.
4461 The table below shows the changes of index required for 1 node movements along
4462 the axes in a voxel area:
4463
4464     Movement    Change of index
4465     +x          +1
4466     -x          -1
4467     +y          +ystride
4468     -y          -ystride
4469     +z          +zstride
4470     -z          -zstride
4471
4472 If, for example:
4473
4474     local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
4475
4476 The values of `ystride` and `zstride` can be obtained using `area.ystride` and
4477 `area.zstride`.
4478
4479
4480
4481
4482 Mapgen objects
4483 ==============
4484
4485 A mapgen object is a construct used in map generation. Mapgen objects can be
4486 used by an `on_generate` callback to speed up operations by avoiding
4487 unnecessary recalculations, these can be retrieved using the
4488 `minetest.get_mapgen_object()` function. If the requested Mapgen object is
4489 unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
4490 callback, `nil` is returned.
4491
4492 The following Mapgen objects are currently available:
4493
4494 ### `voxelmanip`
4495
4496 This returns three values; the `VoxelManip` object to be used, minimum and
4497 maximum emerged position, in that order. All mapgens support this object.
4498
4499 ### `heightmap`
4500
4501 Returns an array containing the y coordinates of the ground levels of nodes in
4502 the most recently generated chunk by the current mapgen.
4503
4504 ### `biomemap`
4505
4506 Returns an array containing the biome IDs of nodes in the most recently
4507 generated chunk by the current mapgen.
4508
4509 ### `heatmap`
4510
4511 Returns an array containing the temperature values of nodes in the most
4512 recently generated chunk by the current mapgen.
4513
4514 ### `humiditymap`
4515
4516 Returns an array containing the humidity values of nodes in the most recently
4517 generated chunk by the current mapgen.
4518
4519 ### `gennotify`
4520
4521 Returns a table mapping requested generation notification types to arrays of
4522 positions at which the corresponding generated structures are located within
4523 the current chunk. To enable the capture of positions of interest to be recorded
4524 call `minetest.set_gen_notify()` first.
4525
4526 Possible fields of the returned table are:
4527
4528 * `dungeon`: bottom center position of dungeon rooms
4529 * `temple`: as above but for desert temples (mgv6 only)
4530 * `cave_begin`
4531 * `cave_end`
4532 * `large_cave_begin`
4533 * `large_cave_end`
4534 * `decoration#id` (see below)
4535
4536 Decorations have a key in the format of `"decoration#id"`, where `id` is the
4537 numeric unique decoration ID as returned by `minetest.get_decoration_id()`.
4538 For example, `decoration#123`.
4539
4540 The returned positions are the ground surface 'place_on' nodes,
4541 not the decorations themselves. A 'simple' type decoration is often 1
4542 node above the returned position and possibly displaced by 'place_offset_y'.
4543
4544
4545 Registered entities
4546 ===================
4547
4548 Functions receive a "luaentity" table as `self`:
4549
4550 * It has the member `name`, which is the registered name `("mod:thing")`
4551 * It has the member `object`, which is an `ObjectRef` pointing to the object
4552 * The original prototype is visible directly via a metatable
4553
4554 Callbacks:
4555
4556 * `on_activate(self, staticdata, dtime_s)`
4557     * Called when the object is instantiated.
4558     * `dtime_s` is the time passed since the object was unloaded, which can be
4559       used for updating the entity state.
4560 * `on_deactivate(self, removal)`
4561     * Called when the object is about to get removed or unloaded.
4562         * `removal`: boolean indicating whether the object is about to get removed.
4563           Calling `object:remove()` on an active object will call this with `removal=true`.
4564           The mapblock the entity resides in being unloaded will call this with `removal=false`.
4565         * Note that this won't be called if the object hasn't been activated in the first place.
4566           In particular, `minetest.clear_objects({mode = "full"})` won't call this,
4567           whereas `minetest.clear_objects({mode = "quick"})` might call this.
4568 * `on_step(self, dtime, moveresult)`
4569     * Called on every server tick, after movement and collision processing.
4570     * `dtime`: elapsed time since last call
4571     * `moveresult`: table with collision info (only available if physical=true)
4572 * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
4573     * Called when somebody punches the object.
4574     * Note that you probably want to handle most punches using the automatic
4575       armor group system.
4576     * `puncher`: an `ObjectRef` (can be `nil`)
4577     * `time_from_last_punch`: Meant for disallowing spamming of clicks
4578       (can be `nil`).
4579     * `tool_capabilities`: capability table of used item (can be `nil`)
4580     * `dir`: unit vector of direction of punch. Always defined. Points from the
4581       puncher to the punched.
4582     * `damage`: damage that will be done to entity.
4583     * Can return `true` to prevent the default damage mechanism.
4584 * `on_death(self, killer)`
4585     * Called when the object dies.
4586     * `killer`: an `ObjectRef` (can be `nil`)
4587 * `on_rightclick(self, clicker)`
4588     * Called when `clicker` pressed the 'place/use' key while pointing
4589       to the object (not neccessarily an actual rightclick)
4590     * `clicker`: an `ObjectRef` (may or may not be a player)
4591 * `on_attach_child(self, child)`
4592     * `child`: an `ObjectRef` of the child that attaches
4593 * `on_detach_child(self, child)`
4594     * `child`: an `ObjectRef` of the child that detaches
4595 * `on_detach(self, parent)`
4596     * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
4597     * This happens before the parent object is removed from the world
4598 * `get_staticdata(self)`
4599     * Should return a string that will be passed to `on_activate` when the
4600       object is instantiated the next time.
4601
4602 Collision info passed to `on_step` (`moveresult` argument):
4603
4604     {
4605         touching_ground = boolean,
4606         -- Note that touching_ground is only true if the entity was moving and
4607         -- collided with ground.
4608
4609         collides = boolean,
4610         standing_on_object = boolean,
4611
4612         collisions = {
4613             {
4614                 type = string, -- "node" or "object",
4615                 axis = string, -- "x", "y" or "z"
4616                 node_pos = vector, -- if type is "node"
4617                 object = ObjectRef, -- if type is "object"
4618                 old_velocity = vector,
4619                 new_velocity = vector,
4620             },
4621             ...
4622         }
4623         -- `collisions` does not contain data of unloaded mapblock collisions
4624         -- or when the velocity changes are negligibly small
4625     }
4626
4627
4628
4629 L-system trees
4630 ==============
4631
4632 Tree definition
4633 ---------------
4634
4635     treedef={
4636         axiom,         --string  initial tree axiom
4637         rules_a,       --string  rules set A
4638         rules_b,       --string  rules set B
4639         rules_c,       --string  rules set C
4640         rules_d,       --string  rules set D
4641         trunk,         --string  trunk node name
4642         leaves,        --string  leaves node name
4643         leaves2,       --string  secondary leaves node name
4644         leaves2_chance,--num     chance (0-100) to replace leaves with leaves2
4645         angle,         --num     angle in deg
4646         iterations,    --num     max # of iterations, usually 2 -5
4647         random_level,  --num     factor to lower nr of iterations, usually 0 - 3
4648         trunk_type,    --string  single/double/crossed) type of trunk: 1 node,
4649                        --        2x2 nodes or 3x3 in cross shape
4650         thin_branches, --boolean true -> use thin (1 node) branches
4651         fruit,         --string  fruit node name
4652         fruit_chance,  --num     chance (0-100) to replace leaves with fruit node
4653         seed,          --num     random seed, if no seed is provided, the engine
4654                                  will create one.
4655     }
4656
4657 Key for special L-System symbols used in axioms
4658 -----------------------------------------------
4659
4660 * `G`: move forward one unit with the pen up
4661 * `F`: move forward one unit with the pen down drawing trunks and branches
4662 * `f`: move forward one unit with the pen down drawing leaves (100% chance)
4663 * `T`: move forward one unit with the pen down drawing trunks only
4664 * `R`: move forward one unit with the pen down placing fruit
4665 * `A`: replace with rules set A
4666 * `B`: replace with rules set B
4667 * `C`: replace with rules set C
4668 * `D`: replace with rules set D
4669 * `a`: replace with rules set A, chance 90%
4670 * `b`: replace with rules set B, chance 80%
4671 * `c`: replace with rules set C, chance 70%
4672 * `d`: replace with rules set D, chance 60%
4673 * `+`: yaw the turtle right by `angle` parameter
4674 * `-`: yaw the turtle left by `angle` parameter
4675 * `&`: pitch the turtle down by `angle` parameter
4676 * `^`: pitch the turtle up by `angle` parameter
4677 * `/`: roll the turtle to the right by `angle` parameter
4678 * `*`: roll the turtle to the left by `angle` parameter
4679 * `[`: save in stack current state info
4680 * `]`: recover from stack state info
4681
4682 Example
4683 -------
4684
4685 Spawn a small apple tree:
4686
4687     pos = {x=230,y=20,z=4}
4688     apple_tree={
4689         axiom="FFFFFAFFBF",
4690         rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
4691         rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
4692         trunk="default:tree",
4693         leaves="default:leaves",
4694         angle=30,
4695         iterations=2,
4696         random_level=0,
4697         trunk_type="single",
4698         thin_branches=true,
4699         fruit_chance=10,
4700         fruit="default:apple"
4701     }
4702     minetest.spawn_tree(pos,apple_tree)
4703
4704
4705 Privileges
4706 ==========
4707
4708 Privileges provide a means for server administrators to give certain players
4709 access to special abilities in the engine, games or mods.
4710 For example, game moderators may need to travel instantly to any place in the world, 
4711 this ability is implemented in `/teleport` command which requires `teleport` privilege.
4712
4713 Registering privileges
4714 ----------------------
4715
4716 A mod can register a custom privilege using `minetest.register_privilege` function 
4717 to give server administrators fine-grained access control over mod functionality.
4718
4719 For consistency and practical reasons, privileges should strictly increase the abilities of the user.
4720 Do not register custom privileges that e.g. restrict the player from certain in-game actions.
4721
4722 Checking privileges
4723 -------------------
4724
4725 A mod can call `minetest.check_player_privs` to test whether a player has privileges 
4726 to perform an operation.
4727 Also, when registering a chat command with `minetest.register_chatcommand` a mod can
4728 declare privileges that the command requires using the `privs` field of the command
4729 definition.
4730
4731 Managing player privileges
4732 --------------------------
4733
4734 A mod can update player privileges using `minetest.set_player_privs` function.
4735 Players holding the `privs` privilege can see and manage privileges for all
4736 players on the server.
4737
4738 A mod can subscribe to changes in player privileges using `minetest.register_on_priv_grant`
4739 and `minetest.register_on_priv_revoke` functions.
4740
4741 Built-in privileges
4742 -------------------
4743
4744 Minetest includes a set of built-in privileges that control capabilities
4745 provided by the Minetest engine and can be used by mods:
4746
4747   * Basic privileges are normally granted to all players:
4748       * `shout`: can communicate using the in-game chat.
4749       * `interact`: can modify the world by digging, building and interacting
4750         with the nodes, entities and other players. Players without the `interact`
4751         privilege can only travel and observe the world.
4752
4753   * Advanced privileges allow bypassing certain aspects of the gameplay:
4754       * `fast`: can use "fast mode" to move with maximum speed.
4755       * `fly`: can use "fly mode" to move freely above the ground without falling.
4756       * `noclip`: can use "noclip mode" to fly through solid nodes (e.g. walls).
4757       * `teleport`: can use `/teleport` command to move to any point in the world.
4758       * `creative`: can access creative inventory.
4759       * `bring`: can teleport other players to oneself.
4760       * `give`: can use `/give` and `/giveme` commands to give any item
4761         in the game to oneself or others.
4762       * `settime`: can use `/time` command to change current in-game time.
4763       * `debug`: can enable wireframe rendering mode.
4764
4765   * Security-related privileges:
4766       * `privs`: can modify privileges of the players using `/grant[me]` and
4767         `/revoke[me]` commands.
4768       * `basic_privs`: can grant and revoke basic privileges as defined by
4769         the `basic_privs` setting.
4770       * `kick`: can kick other players from the server using `/kick` command.
4771       * `ban`: can ban other players using `/ban` command.
4772       * `password`: can use `/setpassword` and `/clearpassword` commands
4773         to manage players' passwords.
4774       * `protection_bypass`: can bypass node protection. Note that the engine does not act upon this privilege,
4775         it is only an implementation suggestion for games.
4776
4777   * Administrative privileges:
4778       * `server`: can use `/fixlight`, `/deleteblocks` and `/deleteobjects`
4779         commands. Can clear inventory of other players using `/clearinv` command.
4780       * `rollback`: can use `/rollback_check` and `/rollback` commands.
4781
4782 Related settings
4783 ----------------
4784
4785 Minetest includes the following settings to control behavior of privileges:
4786
4787    * `default_privs`: defines privileges granted to new players.
4788    * `basic_privs`: defines privileges that can be granted/revoked by players having
4789     the `basic_privs` privilege. This can be used, for example, to give 
4790     limited moderation powers to selected users.
4791
4792 'minetest' namespace reference
4793 ==============================
4794
4795 Utilities
4796 ---------
4797
4798 * `minetest.get_current_modname()`: returns the currently loading mod's name,
4799   when loading a mod.
4800 * `minetest.get_modpath(modname)`: returns the directory path for a mod,
4801   e.g. `"/home/user/.minetest/usermods/modname"`.
4802     * Returns nil if the mod is not enabled or does not exist (not installed).
4803     * Works regardless of whether the mod has been loaded yet.
4804     * Useful for loading additional `.lua` modules or static data from a mod,
4805   or checking if a mod is enabled.
4806 * `minetest.get_modnames()`: returns a list of enabled mods, sorted alphabetically.
4807     * Does not include disabled mods, even if they are installed.
4808 * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
4809     * Useful for storing custom data
4810 * `minetest.is_singleplayer()`
4811 * `minetest.features`: Table containing API feature flags
4812
4813       {
4814           glasslike_framed = true,  -- 0.4.7
4815           nodebox_as_selectionbox = true,  -- 0.4.7
4816           get_all_craft_recipes_works = true,  -- 0.4.7
4817           -- The transparency channel of textures can optionally be used on
4818           -- nodes (0.4.7)
4819           use_texture_alpha = true,
4820           -- Tree and grass ABMs are no longer done from C++ (0.4.8)
4821           no_legacy_abms = true,
4822           -- Texture grouping is possible using parentheses (0.4.11)
4823           texture_names_parens = true,
4824           -- Unique Area ID for AreaStore:insert_area (0.4.14)
4825           area_store_custom_ids = true,
4826           -- add_entity supports passing initial staticdata to on_activate
4827           -- (0.4.16)
4828           add_entity_with_staticdata = true,
4829           -- Chat messages are no longer predicted (0.4.16)
4830           no_chat_message_prediction = true,
4831           -- The transparency channel of textures can optionally be used on
4832           -- objects (ie: players and lua entities) (5.0.0)
4833           object_use_texture_alpha = true,
4834           -- Object selectionbox is settable independently from collisionbox
4835           -- (5.0.0)
4836           object_independent_selectionbox = true,
4837           -- Specifies whether binary data can be uploaded or downloaded using
4838           -- the HTTP API (5.1.0)
4839           httpfetch_binary_data = true,
4840           -- Whether formspec_version[<version>] may be used (5.1.0)
4841           formspec_version_element = true,
4842           -- Whether AreaStore's IDs are kept on save/load (5.1.0)
4843           area_store_persistent_ids = true,
4844           -- Whether minetest.find_path is functional (5.2.0)
4845           pathfinder_works = true,
4846           -- Whether Collision info is available to an objects' on_step (5.3.0)
4847           object_step_has_moveresult = true,
4848           -- Whether get_velocity() and add_velocity() can be used on players (5.4.0)
4849           direct_velocity_on_players = true,
4850           -- nodedef's use_texture_alpha accepts new string modes (5.4.0)
4851           use_texture_alpha_string_modes = true,
4852           -- degrotate param2 rotates in units of 1.5° instead of 2°
4853           -- thus changing the range of values from 0-179 to 0-240 (5.5.0)
4854           degrotate_240_steps = true,
4855           -- ABM supports min_y and max_y fields in definition (5.5.0)
4856           abm_min_max_y = true,
4857           -- dynamic_add_media supports passing a table with options (5.5.0)
4858           dynamic_add_media_table = true,
4859           -- particlespawners support texpools and animation of properties,
4860           -- particle textures support smooth fade and scale animations, and
4861           -- sprite-sheet particle animations can by synced to the lifetime
4862           -- of individual particles (5.6.0)
4863           particlespawner_tweenable = true,
4864           -- allows get_sky to return a table instead of separate values (5.6.0)
4865           get_sky_as_table = true,
4866       }
4867
4868 * `minetest.has_feature(arg)`: returns `boolean, missing_features`
4869     * `arg`: string or table in format `{foo=true, bar=true}`
4870     * `missing_features`: `{foo=true, bar=true}`
4871 * `minetest.get_player_information(player_name)`: Table containing information
4872   about a player. Example return value:
4873
4874       {
4875           address = "127.0.0.1",     -- IP address of client
4876           ip_version = 4,            -- IPv4 / IPv6
4877           connection_uptime = 200,   -- seconds since client connected
4878           protocol_version = 32,     -- protocol version used by client
4879           formspec_version = 2,      -- supported formspec version
4880           lang_code = "fr"           -- Language code used for translation
4881           -- the following keys can be missing if no stats have been collected yet
4882           min_rtt = 0.01,            -- minimum round trip time
4883           max_rtt = 0.2,             -- maximum round trip time
4884           avg_rtt = 0.02,            -- average round trip time
4885           min_jitter = 0.01,         -- minimum packet time jitter
4886           max_jitter = 0.5,          -- maximum packet time jitter
4887           avg_jitter = 0.03,         -- average packet time jitter
4888           -- the following information is available in a debug build only!!!
4889           -- DO NOT USE IN MODS
4890           --ser_vers = 26,             -- serialization version used by client
4891           --major = 0,                 -- major version number
4892           --minor = 4,                 -- minor version number
4893           --patch = 10,                -- patch version number
4894           --vers_string = "0.4.9-git", -- full version string
4895           --state = "Active"           -- current client state
4896       }
4897
4898 * `minetest.mkdir(path)`: returns success.
4899     * Creates a directory specified by `path`, creating parent directories
4900       if they don't exist.
4901 * `minetest.rmdir(path, recursive)`: returns success.
4902     * Removes a directory specified by `path`.
4903     * If `recursive` is set to `true`, the directory is recursively removed.
4904       Otherwise, the directory will only be removed if it is empty.
4905     * Returns true on success, false on failure.
4906 * `minetest.cpdir(source, destination)`: returns success.
4907     * Copies a directory specified by `path` to `destination`
4908     * Any files in `destination` will be overwritten if they already exist.
4909     * Returns true on success, false on failure.
4910 * `minetest.mvdir(source, destination)`: returns success.
4911     * Moves a directory specified by `path` to `destination`.
4912     * If the `destination` is a non-empty directory, then the move will fail.
4913     * Returns true on success, false on failure.
4914 * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
4915     * is_dir is one of:
4916         * nil: return all entries,
4917         * true: return only subdirectory names, or
4918         * false: return only file names.
4919 * `minetest.safe_file_write(path, content)`: returns boolean indicating success
4920     * Replaces contents of file at path with new contents in a safe (atomic)
4921       way. Use this instead of below code when writing e.g. database files:
4922       `local f = io.open(path, "wb"); f:write(content); f:close()`
4923 * `minetest.get_version()`: returns a table containing components of the
4924    engine version.  Components:
4925     * `project`: Name of the project, eg, "Minetest"
4926     * `string`: Simple version, eg, "1.2.3-dev"
4927     * `hash`: Full git version (only set if available),
4928       eg, "1.2.3-dev-01234567-dirty".
4929   Use this for informational purposes only. The information in the returned
4930   table does not represent the capabilities of the engine, nor is it
4931   reliable or verifiable. Compatible forks will have a different name and
4932   version entirely. To check for the presence of engine features, test
4933   whether the functions exported by the wanted features exist. For example:
4934   `if minetest.check_for_falling then ... end`.
4935 * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
4936     * `data`: string of data to hash
4937     * `raw`: return raw bytes instead of hex digits, default: false
4938 * `minetest.colorspec_to_colorstring(colorspec)`: Converts a ColorSpec to a
4939   ColorString. If the ColorSpec is invalid, returns `nil`.
4940     * `colorspec`: The ColorSpec to convert
4941 * `minetest.colorspec_to_bytes(colorspec)`: Converts a ColorSpec to a raw
4942   string of four bytes in an RGBA layout, returned as a string.
4943   * `colorspec`: The ColorSpec to convert
4944 * `minetest.encode_png(width, height, data, [compression])`: Encode a PNG
4945   image and return it in string form.
4946     * `width`: Width of the image
4947     * `height`: Height of the image
4948     * `data`: Image data, one of:
4949         * array table of ColorSpec, length must be width*height
4950         * string with raw RGBA pixels, length must be width*height*4
4951     * `compression`: Optional zlib compression level, number in range 0 to 9.
4952   The data is one-dimensional, starting in the upper left corner of the image
4953   and laid out in scanlines going from left to right, then top to bottom.
4954   Please note that it's not safe to use string.char to generate raw data,
4955   use `colorspec_to_bytes` to generate raw RGBA values in a predictable way.
4956   The resulting PNG image is always 32-bit. Palettes are not supported at the moment.
4957   You may use this to procedurally generate textures during server init.
4958
4959 Logging
4960 -------
4961
4962 * `minetest.debug(...)`
4963     * Equivalent to `minetest.log(table.concat({...}, "\t"))`
4964 * `minetest.log([level,] text)`
4965     * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
4966       `"info"`, or `"verbose"`.  Default is `"none"`.
4967
4968 Registration functions
4969 ----------------------
4970
4971 Call these functions only at load time!
4972
4973 ### Environment
4974
4975 * `minetest.register_node(name, node definition)`
4976 * `minetest.register_craftitem(name, item definition)`
4977 * `minetest.register_tool(name, item definition)`
4978 * `minetest.override_item(name, redefinition)`
4979     * Overrides fields of an item registered with register_node/tool/craftitem.
4980     * Note: Item must already be defined, (opt)depend on the mod defining it.
4981     * Example: `minetest.override_item("default:mese",
4982       {light_source=minetest.LIGHT_MAX})`
4983 * `minetest.unregister_item(name)`
4984     * Unregisters the item from the engine, and deletes the entry with key
4985       `name` from `minetest.registered_items` and from the associated item table
4986       according to its nature: `minetest.registered_nodes`, etc.
4987 * `minetest.register_entity(name, entity definition)`
4988 * `minetest.register_abm(abm definition)`
4989 * `minetest.register_lbm(lbm definition)`
4990 * `minetest.register_alias(alias, original_name)`
4991     * Also use this to set the 'mapgen aliases' needed in a game for the core
4992       mapgens. See [Mapgen aliases] section above.
4993 * `minetest.register_alias_force(alias, original_name)`
4994 * `minetest.register_ore(ore definition)`
4995     * Returns an integer object handle uniquely identifying the registered
4996       ore on success.
4997     * The order of ore registrations determines the order of ore generation.
4998 * `minetest.register_biome(biome definition)`
4999     * Returns an integer object handle uniquely identifying the registered
5000       biome on success. To get the biome ID, use `minetest.get_biome_id`.
5001 * `minetest.unregister_biome(name)`
5002     * Unregisters the biome from the engine, and deletes the entry with key
5003       `name` from `minetest.registered_biomes`.
5004     * Warning: This alters the biome to biome ID correspondences, so any
5005       decorations or ores using the 'biomes' field must afterwards be cleared
5006       and re-registered.
5007 * `minetest.register_decoration(decoration definition)`
5008     * Returns an integer object handle uniquely identifying the registered
5009       decoration on success. To get the decoration ID, use
5010       `minetest.get_decoration_id`.
5011     * The order of decoration registrations determines the order of decoration
5012       generation.
5013 * `minetest.register_schematic(schematic definition)`
5014     * Returns an integer object handle uniquely identifying the registered
5015       schematic on success.
5016     * If the schematic is loaded from a file, the `name` field is set to the
5017       filename.
5018     * If the function is called when loading the mod, and `name` is a relative
5019       path, then the current mod path will be prepended to the schematic
5020       filename.
5021 * `minetest.clear_registered_biomes()`
5022     * Clears all biomes currently registered.
5023     * Warning: Clearing and re-registering biomes alters the biome to biome ID
5024       correspondences, so any decorations or ores using the 'biomes' field must
5025       afterwards be cleared and re-registered.
5026 * `minetest.clear_registered_decorations()`
5027     * Clears all decorations currently registered.
5028 * `minetest.clear_registered_ores()`
5029     * Clears all ores currently registered.
5030 * `minetest.clear_registered_schematics()`
5031     * Clears all schematics currently registered.
5032
5033 ### Gameplay
5034
5035 * `minetest.register_craft(recipe)`
5036     * Check recipe table syntax for different types below.
5037 * `minetest.clear_craft(recipe)`
5038     * Will erase existing craft based either on output item or on input recipe.
5039     * Specify either output or input only. If you specify both, input will be
5040       ignored. For input use the same recipe table syntax as for
5041       `minetest.register_craft(recipe)`. For output specify only the item,
5042       without a quantity.
5043     * Returns false if no erase candidate could be found, otherwise returns true.
5044     * **Warning**! The type field ("shaped", "cooking" or any other) will be
5045       ignored if the recipe contains output. Erasing is then done independently
5046       from the crafting method.
5047 * `minetest.register_chatcommand(cmd, chatcommand definition)`
5048 * `minetest.override_chatcommand(name, redefinition)`
5049     * Overrides fields of a chatcommand registered with `register_chatcommand`.
5050 * `minetest.unregister_chatcommand(name)`
5051     * Unregisters a chatcommands registered with `register_chatcommand`.
5052 * `minetest.register_privilege(name, definition)`
5053     * `definition` can be a description or a definition table (see [Privilege
5054       definition]).
5055     * If it is a description, the priv will be granted to singleplayer and admin
5056       by default.
5057     * To allow players with `basic_privs` to grant, see the `basic_privs`
5058       minetest.conf setting.
5059 * `minetest.register_authentication_handler(authentication handler definition)`
5060     * Registers an auth handler that overrides the builtin one.
5061     * This function can be called by a single mod once only.
5062
5063 Global callback registration functions
5064 --------------------------------------
5065
5066 Call these functions only at load time!
5067
5068 * `minetest.register_globalstep(function(dtime))`
5069     * Called every server step, usually interval of 0.1s
5070 * `minetest.register_on_mods_loaded(function())`
5071     * Called after mods have finished loading and before the media is cached or the
5072       aliases handled.
5073 * `minetest.register_on_shutdown(function())`
5074     * Called before server shutdown
5075     * **Warning**: If the server terminates abnormally (i.e. crashes), the
5076       registered callbacks **will likely not be run**. Data should be saved at
5077       semi-frequent intervals as well as on server shutdown.
5078 * `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
5079     * Called when a node has been placed
5080     * If return `true` no item is taken from `itemstack`
5081     * `placer` may be any valid ObjectRef or nil.
5082     * **Not recommended**; use `on_construct` or `after_place_node` in node
5083       definition whenever possible.
5084 * `minetest.register_on_dignode(function(pos, oldnode, digger))`
5085     * Called when a node has been dug.
5086     * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
5087       definition whenever possible.
5088 * `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
5089     * Called when a node is punched
5090 * `minetest.register_on_generated(function(minp, maxp, blockseed))`
5091     * Called after generating a piece of world. Modifying nodes inside the area
5092       is a bit faster than usual.
5093 * `minetest.register_on_newplayer(function(ObjectRef))`
5094     * Called when a new player enters the world for the first time
5095 * `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
5096     * Called when a player is punched
5097     * Note: This callback is invoked even if the punched player is dead.
5098     * `player`: ObjectRef - Player that was punched
5099     * `hitter`: ObjectRef - Player that hit
5100     * `time_from_last_punch`: Meant for disallowing spamming of clicks
5101       (can be nil).
5102     * `tool_capabilities`: Capability table of used item (can be nil)
5103     * `dir`: Unit vector of direction of punch. Always defined. Points from
5104       the puncher to the punched.
5105     * `damage`: Number that represents the damage calculated by the engine
5106     * should return `true` to prevent the default damage mechanism
5107 * `minetest.register_on_rightclickplayer(function(player, clicker))`
5108     * Called when the 'place/use' key was used while pointing a player
5109       (not neccessarily an actual rightclick)
5110     * `player`: ObjectRef - Player that is acted upon
5111     * `clicker`: ObjectRef - Object that acted upon `player`, may or may not be a player
5112 * `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
5113     * Called when the player gets damaged or healed
5114     * `player`: ObjectRef of the player
5115     * `hp_change`: the amount of change. Negative when it is damage.
5116     * `reason`: a PlayerHPChangeReason table.
5117         * The `type` field will have one of the following values:
5118             * `set_hp`: A mod or the engine called `set_hp` without
5119                         giving a type - use this for custom damage types.
5120             * `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
5121             * `fall`
5122             * `node_damage`: `damage_per_second` from a neighbouring node.
5123                              `reason.node` will hold the node name or nil.
5124             * `drown`
5125             * `respawn`
5126         * Any of the above types may have additional fields from mods.
5127         * `reason.from` will be `mod` or `engine`.
5128     * `modifier`: when true, the function should return the actual `hp_change`.
5129        Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
5130        Modifiers can return true as a second argument to stop the execution of further functions.
5131        Non-modifiers receive the final HP change calculated by the modifiers.
5132 * `minetest.register_on_dieplayer(function(ObjectRef, reason))`
5133     * Called when a player dies
5134     * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
5135 * `minetest.register_on_respawnplayer(function(ObjectRef))`
5136     * Called when player is to be respawned
5137     * Called _before_ repositioning of player occurs
5138     * return true in func to disable regular player placement
5139 * `minetest.register_on_prejoinplayer(function(name, ip))`
5140     * Called when a client connects to the server, prior to authentication
5141     * If it returns a string, the client is disconnected with that string as
5142       reason.
5143 * `minetest.register_on_joinplayer(function(ObjectRef, last_login))`
5144     * Called when a player joins the game
5145     * `last_login`: The timestamp of the previous login, or nil if player is new
5146 * `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
5147     * Called when a player leaves the game
5148     * `timed_out`: True for timeout, false for other reasons.
5149 * `minetest.register_on_authplayer(function(name, ip, is_success))`
5150     * Called when a client attempts to log into an account.
5151     * `name`: The name of the account being authenticated.
5152     * `ip`: The IP address of the client
5153     * `is_success`: Whether the client was successfully authenticated
5154     * For newly registered accounts, `is_success` will always be true
5155 * `minetest.register_on_auth_fail(function(name, ip))`
5156     * Deprecated: use `minetest.register_on_authplayer(name, ip, is_success)` instead.
5157 * `minetest.register_on_cheat(function(ObjectRef, cheat))`
5158     * Called when a player cheats
5159     * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
5160         * `moved_too_fast`
5161         * `interacted_too_far`
5162         * `interacted_with_self`
5163         * `interacted_while_dead`
5164         * `finished_unknown_dig`
5165         * `dug_unbreakable`
5166         * `dug_too_fast`
5167 * `minetest.register_on_chat_message(function(name, message))`
5168     * Called always when a player says something
5169     * Return `true` to mark the message as handled, which means that it will
5170       not be sent to other players.
5171 * `minetest.register_on_chatcommand(function(name, command, params))`
5172     * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
5173       is checked to see if the command exists, but after the input is parsed.
5174     * Return `true` to mark the command as handled, which means that the default
5175       handlers will be prevented.
5176 * `minetest.register_on_player_receive_fields(function(player, formname, fields))`
5177     * Called when the server received input from `player` in a formspec with
5178       the given `formname`. Specifically, this is called on any of the
5179       following events:
5180           * a button was pressed,
5181           * Enter was pressed while the focus was on a text field
5182           * a checkbox was toggled,
5183           * something was selected in a dropdown list,
5184           * a different tab was selected,
5185           * selection was changed in a textlist or table,
5186           * an entry was double-clicked in a textlist or table,
5187           * a scrollbar was moved, or
5188           * the form was actively closed by the player.
5189     * Fields are sent for formspec elements which define a field. `fields`
5190       is a table containing each formspecs element value (as string), with
5191       the `name` parameter as index for each. The value depends on the
5192       formspec element type:
5193         * `animated_image`: Returns the index of the current frame.
5194         * `button` and variants: If pressed, contains the user-facing button
5195           text as value. If not pressed, is `nil`
5196         * `field`, `textarea` and variants: Text in the field
5197         * `dropdown`: Either the index or value, depending on the `index event`
5198           dropdown argument.
5199         * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
5200         * `checkbox`: `"true"` if checked, `"false"` if unchecked
5201         * `textlist`: See `minetest.explode_textlist_event`
5202         * `table`: See `minetest.explode_table_event`
5203         * `scrollbar`: See `minetest.explode_scrollbar_event`
5204         * Special case: `["quit"]="true"` is sent when the user actively
5205           closed the form by mouse click, keypress or through a button_exit[]
5206           element.
5207         * Special case: `["key_enter"]="true"` is sent when the user pressed
5208           the Enter key and the focus was either nowhere (causing the formspec
5209           to be closed) or on a button. If the focus was on a text field,
5210           additionally, the index `key_enter_field` contains the name of the
5211           text field. See also: `field_close_on_enter`.
5212     * Newest functions are called first
5213     * If function returns `true`, remaining functions are not called
5214 * `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
5215     * Called when `player` crafts something
5216     * `itemstack` is the output
5217     * `old_craft_grid` contains the recipe (Note: the one in the inventory is
5218       cleared).
5219     * `craft_inv` is the inventory with the crafting grid
5220     * Return either an `ItemStack`, to replace the output, or `nil`, to not
5221       modify it.
5222 * `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
5223     * The same as before, except that it is called before the player crafts, to
5224       make craft prediction, and it should not change anything.
5225 * `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
5226     * Determines how much of a stack may be taken, put or moved to a
5227       player inventory.
5228     * `player` (type `ObjectRef`) is the player who modified the inventory
5229       `inventory` (type `InvRef`).
5230     * List of possible `action` (string) values and their
5231       `inventory_info` (table) contents:
5232         * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
5233         * `put`:  `{listname=string, index=number, stack=ItemStack}`
5234         * `take`: Same as `put`
5235     * Return a numeric value to limit the amount of items to be taken, put or
5236       moved. A value of `-1` for `take` will make the source stack infinite.
5237 * `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
5238     * Called after a take, put or move event from/to/in a player inventory
5239     * Function arguments: see `minetest.register_allow_player_inventory_action`
5240     * Does not accept or handle any return value.
5241 * `minetest.register_on_protection_violation(function(pos, name))`
5242     * Called by `builtin` and mods when a player violates protection at a
5243       position (eg, digs a node or punches a protected entity).
5244     * The registered functions can be called using
5245       `minetest.record_protection_violation`.
5246     * The provided function should check that the position is protected by the
5247       mod calling this function before it prints a message, if it does, to
5248       allow for multiple protection mods.
5249 * `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
5250     * Called when an item is eaten, by `minetest.item_eat`
5251     * Return `itemstack` to cancel the default item eat response (i.e.: hp increase).
5252 * `minetest.register_on_priv_grant(function(name, granter, priv))`
5253     * Called when `granter` grants the priv `priv` to `name`.
5254     * Note that the callback will be called twice if it's done by a player,
5255       once with granter being the player name, and again with granter being nil.
5256 * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
5257     * Called when `revoker` revokes the priv `priv` from `name`.
5258     * Note that the callback will be called twice if it's done by a player,
5259       once with revoker being the player name, and again with revoker being nil.
5260 * `minetest.register_can_bypass_userlimit(function(name, ip))`
5261     * Called when `name` user connects with `ip`.
5262     * Return `true` to by pass the player limit
5263 * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
5264     * Called when an incoming mod channel message is received
5265     * You should have joined some channels to receive events.
5266     * If message comes from a server mod, `sender` field is an empty string.
5267 * `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
5268     * Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
5269       engine's liquid transformation process.
5270     * `pos_list` is an array of all modified positions.
5271     * `node_list` is an array of the old node that was previously at the position
5272       with the corresponding index in pos_list.
5273
5274 Setting-related
5275 ---------------
5276
5277 * `minetest.settings`: Settings object containing all of the settings from the
5278   main config file (`minetest.conf`).
5279 * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
5280   parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
5281
5282 Authentication
5283 --------------
5284
5285 * `minetest.string_to_privs(str[, delim])`:
5286     * Converts string representation of privs into table form
5287     * `delim`: String separating the privs. Defaults to `","`.
5288     * Returns `{ priv1 = true, ... }`
5289 * `minetest.privs_to_string(privs[, delim])`:
5290     * Returns the string representation of `privs`
5291     * `delim`: String to delimit privs. Defaults to `","`.
5292 * `minetest.get_player_privs(name) -> {priv1=true,...}`
5293 * `minetest.check_player_privs(player_or_name, ...)`:
5294   returns `bool, missing_privs`
5295     * A quickhand for checking privileges.
5296     * `player_or_name`: Either a Player object or the name of a player.
5297     * `...` is either a list of strings, e.g. `"priva", "privb"` or
5298       a table, e.g. `{ priva = true, privb = true }`.
5299
5300 * `minetest.check_password_entry(name, entry, password)`
5301     * Returns true if the "password entry" for a player with name matches given
5302       password, false otherwise.
5303     * The "password entry" is the password representation generated by the
5304       engine as returned as part of a `get_auth()` call on the auth handler.
5305     * Only use this function for making it possible to log in via password from
5306       external protocols such as IRC, other uses are frowned upon.
5307 * `minetest.get_password_hash(name, raw_password)`
5308     * Convert a name-password pair to a password hash that Minetest can use.
5309     * The returned value alone is not a good basis for password checks based
5310       on comparing the password hash in the database with the password hash
5311       from the function, with an externally provided password, as the hash
5312       in the db might use the new SRP verifier format.
5313     * For this purpose, use `minetest.check_password_entry` instead.
5314 * `minetest.get_player_ip(name)`: returns an IP address string for the player
5315   `name`.
5316     * The player needs to be online for this to be successful.
5317
5318 * `minetest.get_auth_handler()`: Return the currently active auth handler
5319     * See the [Authentication handler definition]
5320     * Use this to e.g. get the authentication data for a player:
5321       `local auth_data = minetest.get_auth_handler().get_auth(playername)`
5322 * `minetest.notify_authentication_modified(name)`
5323     * Must be called by the authentication handler for privilege changes.
5324     * `name`: string; if omitted, all auth data should be considered modified
5325 * `minetest.set_player_password(name, password_hash)`: Set password hash of
5326   player `name`.
5327 * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
5328   `name`.
5329 * `minetest.auth_reload()`
5330     * See `reload()` in authentication handler definition
5331
5332 `minetest.set_player_password`, `minetest.set_player_privs`,
5333 `minetest.get_player_privs` and `minetest.auth_reload` call the authentication
5334 handler.
5335
5336 Chat
5337 ----
5338
5339 * `minetest.chat_send_all(text)`
5340 * `minetest.chat_send_player(name, text)`
5341 * `minetest.format_chat_message(name, message)`
5342     * Used by the server to format a chat message, based on the setting `chat_message_format`.
5343       Refer to the documentation of the setting for a list of valid placeholders.
5344     * Takes player name and message, and returns the formatted string to be sent to players.
5345     * Can be redefined by mods if required, for things like colored names or messages.
5346     * **Only** the first occurrence of each placeholder will be replaced.
5347
5348 Environment access
5349 ------------------
5350
5351 * `minetest.set_node(pos, node)`
5352 * `minetest.add_node(pos, node)`: alias to `minetest.set_node`
5353     * Set node at position `pos`
5354     * `node`: table `{name=string, param1=number, param2=number}`
5355     * If param1 or param2 is omitted, it's set to `0`.
5356     * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
5357 * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
5358     * Set node on all positions set in the first argument.
5359     * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
5360     * For node specification or position syntax see `minetest.set_node` call
5361     * Faster than set_node due to single call, but still considerably slower
5362       than Lua Voxel Manipulators (LVM) for large numbers of nodes.
5363       Unlike LVMs, this will call node callbacks. It also allows setting nodes
5364       in spread out positions which would cause LVMs to waste memory.
5365       For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
5366       times faster.
5367 * `minetest.swap_node(pos, node)`
5368     * Set node at position, but don't remove metadata
5369 * `minetest.remove_node(pos)`
5370     * By default it does the same as `minetest.set_node(pos, {name="air"})`
5371 * `minetest.get_node(pos)`
5372     * Returns the node at the given position as table in the format
5373       `{name="node_name", param1=0, param2=0}`,
5374       returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
5375 * `minetest.get_node_or_nil(pos)`
5376     * Same as `get_node` but returns `nil` for unloaded areas.
5377 * `minetest.get_node_light(pos, timeofday)`
5378     * Gets the light value at the given position. Note that the light value
5379       "inside" the node at the given position is returned, so you usually want
5380       to get the light value of a neighbor.
5381     * `pos`: The position where to measure the light.
5382     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5383     * Returns a number between `0` and `15` or `nil`
5384     * `nil` is returned e.g. when the map isn't loaded at `pos`
5385 * `minetest.get_natural_light(pos[, timeofday])`
5386     * Figures out the sunlight (or moonlight) value at pos at the given time of
5387       day.
5388     * `pos`: The position of the node
5389     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
5390     * Returns a number between `0` and `15` or `nil`
5391     * This function tests 203 nodes in the worst case, which happens very
5392       unlikely
5393 * `minetest.get_artificial_light(param1)`
5394     * Calculates the artificial light (light from e.g. torches) value from the
5395       `param1` value.
5396     * `param1`: The param1 value of a `paramtype = "light"` node.
5397     * Returns a number between `0` and `15`
5398     * Currently it's the same as `math.floor(param1 / 16)`, except that it
5399       ensures compatibility.
5400 * `minetest.place_node(pos, node)`
5401     * Place node with the same effects that a player would cause
5402 * `minetest.dig_node(pos)`
5403     * Dig node with the same effects that a player would cause
5404     * Returns `true` if successful, `false` on failure (e.g. protected location)
5405 * `minetest.punch_node(pos)`
5406     * Punch node with the same effects that a player would cause
5407 * `minetest.spawn_falling_node(pos)`
5408     * Change node into falling node
5409     * Returns `true` and the ObjectRef of the spawned entity if successful, `false` on failure
5410
5411 * `minetest.find_nodes_with_meta(pos1, pos2)`
5412     * Get a table of positions of nodes that have metadata within a region
5413       {pos1, pos2}.
5414 * `minetest.get_meta(pos)`
5415     * Get a `NodeMetaRef` at that position
5416 * `minetest.get_node_timer(pos)`
5417     * Get `NodeTimerRef`
5418
5419 * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
5420   position.
5421     * Returns `ObjectRef`, or `nil` if failed
5422 * `minetest.add_item(pos, item)`: Spawn item
5423     * Returns `ObjectRef`, or `nil` if failed
5424 * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
5425 * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
5426   ObjectRefs.
5427     * `radius`: using an euclidean metric
5428 * `minetest.get_objects_in_area(pos1, pos2)`: returns a list of
5429   ObjectRefs.
5430      * `pos1` and `pos2` are the min and max positions of the area to search.
5431 * `minetest.set_timeofday(val)`
5432     * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
5433 * `minetest.get_timeofday()`
5434 * `minetest.get_gametime()`: returns the time, in seconds, since the world was
5435   created.
5436 * `minetest.get_day_count()`: returns number days elapsed since world was
5437   created.
5438     * accounts for time changes.
5439 * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
5440   pos or `nil`.
5441     * `radius`: using a maximum metric
5442     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5443     * `search_center` is an optional boolean (default: `false`)
5444       If true `pos` is also checked for the nodes
5445 * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
5446     * `pos1` and `pos2` are the min and max positions of the area to search.
5447     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5448     * If `grouped` is true the return value is a table indexed by node name
5449       which contains lists of positions.
5450     * If `grouped` is false or absent the return values are as follows:
5451       first value: Table with all node positions
5452       second value: Table with the count of each node with the node name
5453       as index
5454     * Area volume is limited to 4,096,000 nodes
5455 * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
5456   list of positions.
5457     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
5458     * Return value: Table with all node positions with a node air above
5459     * Area volume is limited to 4,096,000 nodes
5460 * `minetest.get_perlin(noiseparams)`
5461     * Return world-specific perlin noise.
5462     * The actual seed used is the noiseparams seed plus the world seed.
5463 * `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
5464     * Deprecated: use `minetest.get_perlin(noiseparams)` instead.
5465     * Return world-specific perlin noise.
5466 * `minetest.get_voxel_manip([pos1, pos2])`
5467     * Return voxel manipulator object.
5468     * Loads the manipulator from the map if positions are passed.
5469 * `minetest.set_gen_notify(flags, {deco_ids})`
5470     * Set the types of on-generate notifications that should be collected.
5471     * `flags` is a flag field with the available flags:
5472         * dungeon
5473         * temple
5474         * cave_begin
5475         * cave_end
5476         * large_cave_begin
5477         * large_cave_end
5478         * decoration
5479     * The second parameter is a list of IDs of decorations which notification
5480       is requested for.
5481 * `minetest.get_gen_notify()`
5482     * Returns a flagstring and a table with the `deco_id`s.
5483 * `minetest.get_decoration_id(decoration_name)`
5484     * Returns the decoration ID number for the provided decoration name string,
5485       or `nil` on failure.
5486 * `minetest.get_mapgen_object(objectname)`
5487     * Return requested mapgen object if available (see [Mapgen objects])
5488 * `minetest.get_heat(pos)`
5489     * Returns the heat at the position, or `nil` on failure.
5490 * `minetest.get_humidity(pos)`
5491     * Returns the humidity at the position, or `nil` on failure.
5492 * `minetest.get_biome_data(pos)`
5493     * Returns a table containing:
5494         * `biome` the biome id of the biome at that position
5495         * `heat` the heat at the position
5496         * `humidity` the humidity at the position
5497     * Or returns `nil` on failure.
5498 * `minetest.get_biome_id(biome_name)`
5499     * Returns the biome id, as used in the biomemap Mapgen object and returned
5500       by `minetest.get_biome_data(pos)`, for a given biome_name string.
5501 * `minetest.get_biome_name(biome_id)`
5502     * Returns the biome name string for the provided biome id, or `nil` on
5503       failure.
5504     * If no biomes have been registered, such as in mgv6, returns `default`.
5505 * `minetest.get_mapgen_params()`
5506     * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
5507     * Returns a table containing:
5508         * `mgname`
5509         * `seed`
5510         * `chunksize`
5511         * `water_level`
5512         * `flags`
5513 * `minetest.set_mapgen_params(MapgenParams)`
5514     * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
5515       instead.
5516     * Set map generation parameters.
5517     * Function cannot be called after the registration period.
5518     * Takes a table as an argument with the fields:
5519         * `mgname`
5520         * `seed`
5521         * `chunksize`
5522         * `water_level`
5523         * `flags`
5524     * Leave field unset to leave that parameter unchanged.
5525     * `flags` contains a comma-delimited string of flags to set, or if the
5526       prefix `"no"` is attached, clears instead.
5527     * `flags` is in the same format and has the same options as `mg_flags` in
5528       `minetest.conf`.
5529 * `minetest.get_mapgen_setting(name)`
5530     * Gets the *active* mapgen setting (or nil if none exists) in string
5531       format with the following order of precedence:
5532         1) Settings loaded from map_meta.txt or overrides set during mod
5533            execution.
5534         2) Settings set by mods without a metafile override
5535         3) Settings explicitly set in the user config file, minetest.conf
5536         4) Settings set as the user config default
5537 * `minetest.get_mapgen_setting_noiseparams(name)`
5538     * Same as above, but returns the value as a NoiseParams table if the
5539       setting `name` exists and is a valid NoiseParams.
5540 * `minetest.set_mapgen_setting(name, value, [override_meta])`
5541     * Sets a mapgen param to `value`, and will take effect if the corresponding
5542       mapgen setting is not already present in map_meta.txt.
5543     * `override_meta` is an optional boolean (default: `false`). If this is set
5544       to true, the setting will become the active setting regardless of the map
5545       metafile contents.
5546     * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
5547 * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
5548     * Same as above, except value is a NoiseParams table.
5549 * `minetest.set_noiseparams(name, noiseparams, set_default)`
5550     * Sets the noiseparams setting of `name` to the noiseparams table specified
5551       in `noiseparams`.
5552     * `set_default` is an optional boolean (default: `true`) that specifies
5553       whether the setting should be applied to the default config or current
5554       active config.
5555 * `minetest.get_noiseparams(name)`
5556     * Returns a table of the noiseparams for name.
5557 * `minetest.generate_ores(vm, pos1, pos2)`
5558     * Generate all registered ores within the VoxelManip `vm` and in the area
5559       from `pos1` to `pos2`.
5560     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5561 * `minetest.generate_decorations(vm, pos1, pos2)`
5562     * Generate all registered decorations within the VoxelManip `vm` and in the
5563       area from `pos1` to `pos2`.
5564     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
5565 * `minetest.clear_objects([options])`
5566     * Clear all objects in the environment
5567     * Takes an optional table as an argument with the field `mode`.
5568         * mode = `"full"` : Load and go through every mapblock, clearing
5569                             objects (default).
5570         * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
5571                             clear objects in unloaded mapblocks only when the
5572                             mapblocks are next activated.
5573 * `minetest.load_area(pos1[, pos2])`
5574     * Load the mapblocks containing the area from `pos1` to `pos2`.
5575       `pos2` defaults to `pos1` if not specified.
5576     * This function does not trigger map generation.
5577 * `minetest.emerge_area(pos1, pos2, [callback], [param])`
5578     * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
5579       asynchronously fetched from memory, loaded from disk, or if inexistent,
5580       generates them.
5581     * If `callback` is a valid Lua function, this will be called for each block
5582       emerged.
5583     * The function signature of callback is:
5584       `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
5585         * `blockpos` is the *block* coordinates of the block that had been
5586           emerged.
5587         * `action` could be one of the following constant values:
5588             * `minetest.EMERGE_CANCELLED`
5589             * `minetest.EMERGE_ERRORED`
5590             * `minetest.EMERGE_FROM_MEMORY`
5591             * `minetest.EMERGE_FROM_DISK`
5592             * `minetest.EMERGE_GENERATED`
5593         * `calls_remaining` is the number of callbacks to be expected after
5594           this one.
5595         * `param` is the user-defined parameter passed to emerge_area (or
5596           nil if the parameter was absent).
5597 * `minetest.delete_area(pos1, pos2)`
5598     * delete all mapblocks in the area from pos1 to pos2, inclusive
5599 * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
5600     * Checks if there is anything other than air between pos1 and pos2.
5601     * Returns false if something is blocking the sight.
5602     * Returns the position of the blocking node when `false`
5603     * `pos1`: First position
5604     * `pos2`: Second position
5605 * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
5606     * Creates a `Raycast` object.
5607     * `pos1`: start of the ray
5608     * `pos2`: end of the ray
5609     * `objects`: if false, only nodes will be returned. Default is `true`.
5610     * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
5611                  returned. Default is `false`.
5612 * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
5613     * returns table containing path that can be walked on
5614     * returns a table of 3D points representing a path from `pos1` to `pos2` or
5615       `nil` on failure.
5616     * Reasons for failure:
5617         * No path exists at all
5618         * No path exists within `searchdistance` (see below)
5619         * Start or end pos is buried in land
5620     * `pos1`: start position
5621     * `pos2`: end position
5622     * `searchdistance`: maximum distance from the search positions to search in.
5623       In detail: Path must be completely inside a cuboid. The minimum
5624       `searchdistance` of 1 will confine search between `pos1` and `pos2`.
5625       Larger values will increase the size of this cuboid in all directions
5626     * `max_jump`: maximum height difference to consider walkable
5627     * `max_drop`: maximum height difference to consider droppable
5628     * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
5629       Difference between `"A*"` and `"A*_noprefetch"` is that
5630       `"A*"` will pre-calculate the cost-data, the other will calculate it
5631       on-the-fly
5632 * `minetest.spawn_tree (pos, {treedef})`
5633     * spawns L-system tree at given `pos` with definition in `treedef` table
5634 * `minetest.transforming_liquid_add(pos)`
5635     * add node to liquid flow update queue
5636 * `minetest.get_node_max_level(pos)`
5637     * get max available level for leveled node
5638 * `minetest.get_node_level(pos)`
5639     * get level of leveled node (water, snow)
5640 * `minetest.set_node_level(pos, level)`
5641     * set level of leveled node, default `level` equals `1`
5642     * if `totallevel > maxlevel`, returns rest (`total-max`).
5643 * `minetest.add_node_level(pos, level)`
5644     * increase level of leveled node by level, default `level` equals `1`
5645     * if `totallevel > maxlevel`, returns rest (`total-max`)
5646     * `level` must be between -127 and 127
5647 * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
5648     * resets the light in a cuboid-shaped part of
5649       the map and removes lighting bugs.
5650     * Loads the area if it is not loaded.
5651     * `pos1` is the corner of the cuboid with the least coordinates
5652       (in node coordinates), inclusive.
5653     * `pos2` is the opposite corner of the cuboid, inclusive.
5654     * The actual updated cuboid might be larger than the specified one,
5655       because only whole map blocks can be updated.
5656       The actual updated area consists of those map blocks that intersect
5657       with the given cuboid.
5658     * However, the neighborhood of the updated area might change
5659       as well, as light can spread out of the cuboid, also light
5660       might be removed.
5661     * returns `false` if the area is not fully generated,
5662       `true` otherwise
5663 * `minetest.check_single_for_falling(pos)`
5664     * causes an unsupported `group:falling_node` node to fall and causes an
5665       unattached `group:attached_node` node to fall.
5666     * does not spread these updates to neighbours.
5667 * `minetest.check_for_falling(pos)`
5668     * causes an unsupported `group:falling_node` node to fall and causes an
5669       unattached `group:attached_node` node to fall.
5670     * spread these updates to neighbours and can cause a cascade
5671       of nodes to fall.
5672 * `minetest.get_spawn_level(x, z)`
5673     * Returns a player spawn y co-ordinate for the provided (x, z)
5674       co-ordinates, or `nil` for an unsuitable spawn point.
5675     * For most mapgens a 'suitable spawn point' is one with y between
5676       `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
5677       so `nil` will be returned for many (x, z) co-ordinates.
5678     * The spawn level returned is for a player spawn in unmodified terrain.
5679     * The spawn level is intentionally above terrain level to cope with
5680       full-node biome 'dust' nodes.
5681
5682 Mod channels
5683 ------------
5684
5685 You can find mod channels communication scheme in `doc/mod_channels.png`.
5686
5687 * `minetest.mod_channel_join(channel_name)`
5688     * Server joins channel `channel_name`, and creates it if necessary. You
5689       should listen for incoming messages with
5690       `minetest.register_on_modchannel_message`
5691
5692 Inventory
5693 ---------
5694
5695 `minetest.get_inventory(location)`: returns an `InvRef`
5696
5697 * `location` = e.g.
5698     * `{type="player", name="celeron55"}`
5699     * `{type="node", pos={x=, y=, z=}}`
5700     * `{type="detached", name="creative"}`
5701 * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
5702   an `InvRef`.
5703     * `callbacks`: See [Detached inventory callbacks]
5704     * `player_name`: Make detached inventory available to one player
5705       exclusively, by default they will be sent to every player (even if not
5706       used).
5707       Note that this parameter is mostly just a workaround and will be removed
5708       in future releases.
5709     * Creates a detached inventory. If it already exists, it is cleared.
5710 * `minetest.remove_detached_inventory(name)`
5711     * Returns a `boolean` indicating whether the removal succeeded.
5712 * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
5713   returns leftover ItemStack or nil to indicate no inventory change
5714     * See `minetest.item_eat` and `minetest.register_on_item_eat`
5715
5716 Formspec
5717 --------
5718
5719 * `minetest.show_formspec(playername, formname, formspec)`
5720     * `playername`: name of player to show formspec
5721     * `formname`: name passed to `on_player_receive_fields` callbacks.
5722       It should follow the `"modname:<whatever>"` naming convention
5723     * `formspec`: formspec to display
5724 * `minetest.close_formspec(playername, formname)`
5725     * `playername`: name of player to close formspec
5726     * `formname`: has to exactly match the one given in `show_formspec`, or the
5727       formspec will not close.
5728     * calling `show_formspec(playername, formname, "")` is equal to this
5729       expression.
5730     * to close a formspec regardless of the formname, call
5731       `minetest.close_formspec(playername, "")`.
5732       **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
5733 * `minetest.formspec_escape(string)`: returns a string
5734     * escapes the characters "[", "]", "\", "," and ";", which can not be used
5735       in formspecs.
5736 * `minetest.explode_table_event(string)`: returns a table
5737     * returns e.g. `{type="CHG", row=1, column=2}`
5738     * `type` is one of:
5739         * `"INV"`: no row selected
5740         * `"CHG"`: selected
5741         * `"DCL"`: double-click
5742 * `minetest.explode_textlist_event(string)`: returns a table
5743     * returns e.g. `{type="CHG", index=1}`
5744     * `type` is one of:
5745         * `"INV"`: no row selected
5746         * `"CHG"`: selected
5747         * `"DCL"`: double-click
5748 * `minetest.explode_scrollbar_event(string)`: returns a table
5749     * returns e.g. `{type="CHG", value=500}`
5750     * `type` is one of:
5751         * `"INV"`: something failed
5752         * `"CHG"`: has been changed
5753         * `"VAL"`: not changed
5754
5755 Item handling
5756 -------------
5757
5758 * `minetest.inventorycube(img1, img2, img3)`
5759     * Returns a string for making an image of a cube (useful as an item image)
5760 * `minetest.get_pointed_thing_position(pointed_thing, above)`
5761     * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
5762       does not refer to a node or entity.
5763     * If the optional `above` parameter is true and the `pointed_thing` refers
5764       to a node, then it will return the `above` position of the `pointed_thing`.
5765 * `minetest.dir_to_facedir(dir, is6d)`
5766     * Convert a vector to a facedir value, used in `param2` for
5767       `paramtype2="facedir"`.
5768     * passing something non-`nil`/`false` for the optional second parameter
5769       causes it to take the y component into account.
5770 * `minetest.facedir_to_dir(facedir)`
5771     * Convert a facedir back into a vector aimed directly out the "back" of a
5772       node.
5773 * `minetest.dir_to_wallmounted(dir)`
5774     * Convert a vector to a wallmounted value, used for
5775       `paramtype2="wallmounted"`.
5776 * `minetest.wallmounted_to_dir(wallmounted)`
5777     * Convert a wallmounted value back into a vector aimed directly out the
5778       "back" of a node.
5779 * `minetest.dir_to_yaw(dir)`
5780     * Convert a vector into a yaw (angle)
5781 * `minetest.yaw_to_dir(yaw)`
5782     * Convert yaw (angle) to a vector
5783 * `minetest.is_colored_paramtype(ptype)`
5784     * Returns a boolean. Returns `true` if the given `paramtype2` contains
5785       color information (`color`, `colorwallmounted` or `colorfacedir`).
5786 * `minetest.strip_param2_color(param2, paramtype2)`
5787     * Removes everything but the color information from the
5788       given `param2` value.
5789     * Returns `nil` if the given `paramtype2` does not contain color
5790       information.
5791 * `minetest.get_node_drops(node, toolname)`
5792     * Returns list of itemstrings that are dropped by `node` when dug
5793       with the item `toolname` (not limited to tools).
5794     * `node`: node as table or node name
5795     * `toolname`: name of the item used to dig (can be `nil`)
5796 * `minetest.get_craft_result(input)`: returns `output, decremented_input`
5797     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5798     * `input.width` = for example `3`
5799     * `input.items` = for example
5800       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5801     * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
5802     * `output.time` = a number, if unsuccessful: `0`
5803     * `output.replacements` = List of replacement `ItemStack`s that couldn't be
5804       placed in `decremented_input.items`. Replacements can be placed in
5805       `decremented_input` if the stack of the replaced item has a count of 1.
5806     * `decremented_input` = like `input`
5807 * `minetest.get_craft_recipe(output)`: returns input
5808     * returns last registered recipe for output item (node)
5809     * `output` is a node or item type such as `"default:torch"`
5810     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
5811     * `input.width` = for example `3`
5812     * `input.items` = for example
5813       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
5814         * `input.items` = `nil` if no recipe found
5815 * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
5816     * returns indexed table with all registered recipes for query item (node)
5817       or `nil` if no recipe was found.
5818     * recipe entry table:
5819         * `method`: 'normal' or 'cooking' or 'fuel'
5820         * `width`: 0-3, 0 means shapeless recipe
5821         * `items`: indexed [1-9] table with recipe items
5822         * `output`: string with item name and quantity
5823     * Example result for `"default:gold_ingot"` with two recipes:
5824
5825           {
5826               {
5827                   method = "cooking", width = 3,
5828                   output = "default:gold_ingot", items = {"default:gold_lump"}
5829               },
5830               {
5831                   method = "normal", width = 1,
5832                   output = "default:gold_ingot 9", items = {"default:goldblock"}
5833               }
5834           }
5835
5836 * `minetest.handle_node_drops(pos, drops, digger)`
5837     * `drops`: list of itemstrings
5838     * Handles drops from nodes after digging: Default action is to put them
5839       into digger's inventory.
5840     * Can be overridden to get different functionality (e.g. dropping items on
5841       ground)
5842 * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
5843   string.
5844     * Creates an item string which contains palette index information
5845       for hardware colorization. You can use the returned string
5846       as an output in a craft recipe.
5847     * `item`: the item stack which becomes colored. Can be in string,
5848       table and native form.
5849     * `palette_index`: this index is added to the item stack
5850 * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
5851     * Creates an item string which contains static color information
5852       for hardware colorization. Use this method if you wish to colorize
5853       an item that does not own a palette. You can use the returned string
5854       as an output in a craft recipe.
5855     * `item`: the item stack which becomes colored. Can be in string,
5856       table and native form.
5857     * `colorstring`: the new color of the item stack
5858
5859 Rollback
5860 --------
5861
5862 * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
5863   returns `{{actor, pos, time, oldnode, newnode}, ...}`
5864     * Find who has done something to a node, or near a node
5865     * `actor`: `"player:<name>"`, also `"liquid"`.
5866 * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
5867   `boolean, log_messages`.
5868     * Revert latest actions of someone
5869     * `actor`: `"player:<name>"`, also `"liquid"`.
5870
5871 Defaults for the `on_place` and `on_drop` item definition functions
5872 -------------------------------------------------------------------
5873
5874 * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
5875     * Place item as a node
5876     * `param2` overrides `facedir` and wallmounted `param2`
5877     * `prevent_after_place`: if set to `true`, `after_place_node` is not called
5878       for the newly placed node to prevent a callback and placement loop
5879     * returns `itemstack, position`
5880       * `position`: the location the node was placed to. `nil` if nothing was placed.
5881 * `minetest.item_place_object(itemstack, placer, pointed_thing)`
5882     * Place item as-is
5883     * returns the leftover itemstack
5884     * **Note**: This function is deprecated and will never be called.
5885 * `minetest.item_place(itemstack, placer, pointed_thing[, param2])`
5886     * Wrapper that calls `minetest.item_place_node` if appropriate
5887     * Calls `on_rightclick` of `pointed_thing.under` if defined instead
5888     * **Note**: is not called when wielded item overrides `on_place`
5889     * `param2` overrides facedir and wallmounted `param2`
5890     * returns `itemstack, position`
5891       * `position`: the location the node was placed to. `nil` if nothing was placed.
5892 * `minetest.item_drop(itemstack, dropper, pos)`
5893     * Drop the item
5894     * returns the leftover itemstack
5895 * `minetest.item_eat(hp_change[, replace_with_item])`
5896     * Returns `function(itemstack, user, pointed_thing)` as a
5897       function wrapper for `minetest.do_item_eat`.
5898     * `replace_with_item` is the itemstring which is added to the inventory.
5899       If the player is eating a stack, then replace_with_item goes to a
5900       different spot.
5901
5902 Defaults for the `on_punch` and `on_dig` node definition callbacks
5903 ------------------------------------------------------------------
5904
5905 * `minetest.node_punch(pos, node, puncher, pointed_thing)`
5906     * Calls functions registered by `minetest.register_on_punchnode()`
5907 * `minetest.node_dig(pos, node, digger)`
5908     * Checks if node can be dug, puts item into inventory, removes node
5909     * Calls functions registered by `minetest.registered_on_dignodes()`
5910
5911 Sounds
5912 ------
5913
5914 * `minetest.sound_play(spec, parameters, [ephemeral])`: returns a handle
5915     * `spec` is a `SimpleSoundSpec`
5916     * `parameters` is a sound parameter table
5917     * `ephemeral` is a boolean (default: false)
5918       Ephemeral sounds will not return a handle and can't be stopped or faded.
5919       It is recommend to use this for short sounds that happen in response to
5920       player actions (e.g. door closing).
5921 * `minetest.sound_stop(handle)`
5922     * `handle` is a handle returned by `minetest.sound_play`
5923 * `minetest.sound_fade(handle, step, gain)`
5924     * `handle` is a handle returned by `minetest.sound_play`
5925     * `step` determines how fast a sound will fade.
5926       The gain will change by this much per second,
5927       until it reaches the target gain.
5928       Note: Older versions used a signed step. This is deprecated, but old
5929       code will still work. (the client uses abs(step) to correct it)
5930     * `gain` the target gain for the fade.
5931       Fading to zero will delete the sound.
5932
5933 Timing
5934 ------
5935
5936 * `minetest.after(time, func, ...)` : returns job table to use as below.
5937     * Call the function `func` after `time` seconds, may be fractional
5938     * Optional: Variable number of arguments that are passed to `func`
5939
5940 * `job:cancel()`
5941     * Cancels the job function from being called
5942
5943 Async environment
5944 -----------------
5945
5946 The engine allows you to submit jobs to be ran in an isolated environment
5947 concurrently with normal server operation.
5948 A job consists of a function to be ran in the async environment, any amount of
5949 arguments (will be serialized) and a callback that will be called with the return
5950 value of the job function once it is finished.
5951
5952 The async environment does *not* have access to the map, entities, players or any
5953 globals defined in the 'usual' environment. Consequently, functions like
5954 `minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it.
5955
5956 Arguments and return values passed through this can contain certain userdata
5957 objects that will be seamlessly copied (not shared) to the async environment.
5958 This allows you easy interoperability for delegating work to jobs.
5959
5960 * `minetest.handle_async(func, callback, ...)`:
5961     * Queue the function `func` to be ran in an async environment.
5962       Note that there are multiple persistent workers and any of them may
5963       end up running a given job. The engine will scale the amount of
5964       worker threads automatically.
5965     * When `func` returns the callback is called (in the normal environment)
5966       with all of the return values as arguments.
5967     * Optional: Variable number of arguments that are passed to `func`
5968 * `minetest.register_async_dofile(path)`:
5969     * Register a path to a Lua file to be imported when an async environment
5970       is initialized. You can use this to preload code which you can then call
5971       later using `minetest.handle_async()`.
5972
5973 ### List of APIs available in an async environment
5974
5975 Classes:
5976 * `ItemStack`
5977 * `PerlinNoise`
5978 * `PerlinNoiseMap`
5979 * `PseudoRandom`
5980 * `PcgRandom`
5981 * `SecureRandom`
5982 * `VoxelArea`
5983 * `VoxelManip`
5984     * only if transferred into environment; can't read/write to map
5985 * `Settings`
5986
5987 Class instances that can be transferred between environments:
5988 * `ItemStack`
5989 * `PerlinNoise`
5990 * `PerlinNoiseMap`
5991 * `VoxelManip`
5992
5993 Functions:
5994 * Standalone helpers such as logging, filesystem, encoding,
5995   hashing or compression APIs
5996 * `minetest.request_insecure_environment` (same restrictions apply)
5997
5998 Variables:
5999 * `minetest.settings`
6000 * `minetest.registered_items`, `registered_nodes`, `registered_tools`,
6001   `registered_craftitems` and `registered_aliases`
6002     * with all functions and userdata values replaced by `true`, calling any
6003       callbacks here is obviously not possible
6004
6005 Server
6006 ------
6007
6008 * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
6009   server shutdown. Will display `message` to clients.
6010     * `reconnect` == true displays a reconnect button
6011     * `delay` adds an optional delay (in seconds) before shutdown.
6012       Negative delay cancels the current active shutdown.
6013       Zero delay triggers an immediate shutdown.
6014 * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
6015 * `minetest.get_server_status(name, joined)`
6016     * Returns the server status string when a player joins or when the command
6017       `/status` is called. Returns `nil` or an empty string when the message is
6018       disabled.
6019     * `joined`: Boolean value, indicates whether the function was called when
6020       a player joined.
6021     * This function may be overwritten by mods to customize the status message.
6022 * `minetest.get_server_uptime()`: returns the server uptime in seconds
6023 * `minetest.get_server_max_lag()`: returns the current maximum lag
6024   of the server in seconds or nil if server is not fully loaded yet
6025 * `minetest.remove_player(name)`: remove player from database (if they are not
6026   connected).
6027     * As auth data is not removed, minetest.player_exists will continue to
6028       return true. Call the below method as well if you want to remove auth
6029       data too.
6030     * Returns a code (0: successful, 1: no such player, 2: player is connected)
6031 * `minetest.remove_player_auth(name)`: remove player authentication data
6032     * Returns boolean indicating success (false if player nonexistant)
6033 * `minetest.dynamic_add_media(options, callback)`
6034     * `options`: table containing the following parameters
6035         * `filepath`: path to a media file on the filesystem
6036         * `to_player`: name of the player the media should be sent to instead of
6037                        all players (optional)
6038         * `ephemeral`: boolean that marks the media as ephemeral,
6039                        it will not be cached on the client (optional, default false)
6040     * `callback`: function with arguments `name`, which is a player name
6041     * Pushes the specified media file to client(s). (details below)
6042       The file must be a supported image, sound or model format.
6043       Dynamically added media is not persisted between server restarts.
6044     * Returns false on error, true if the request was accepted
6045     * The given callback will be called for every player as soon as the
6046       media is available on the client.
6047     * Details/Notes:
6048       * If `ephemeral`=false and `to_player` is unset the file is added to the media
6049         sent to clients on startup, this means the media will appear even on
6050         old clients if they rejoin the server.
6051       * If `ephemeral`=false the file must not be modified, deleted, moved or
6052         renamed after calling this function.
6053       * Regardless of any use of `ephemeral`, adding media files with the same
6054         name twice is not possible/guaranteed to work. An exception to this is the
6055         use of `to_player` to send the same, already existent file to multiple
6056         chosen players.
6057     * Clients will attempt to fetch files added this way via remote media,
6058       this can make transfer of bigger files painless (if set up). Nevertheless
6059       it is advised not to use dynamic media for big media files.
6060
6061 Bans
6062 ----
6063
6064 * `minetest.get_ban_list()`: returns a list of all bans formatted as string
6065 * `minetest.get_ban_description(ip_or_name)`: returns list of bans matching
6066   IP address or name formatted as string
6067 * `minetest.ban_player(name)`: ban the IP of a currently connected player
6068     * Returns boolean indicating success
6069 * `minetest.unban_player_or_ip(ip_or_name)`: remove ban record matching
6070   IP address or name
6071 * `minetest.kick_player(name, [reason])`: disconnect a player with an optional
6072   reason.
6073     * Returns boolean indicating success (false if player nonexistant)
6074 * `minetest.disconnect_player(name, [reason])`: disconnect a player with an
6075   optional reason, this will not prefix with 'Kicked: ' like kick_player.
6076   If no reason is given, it will default to 'Disconnected.'
6077     * Returns boolean indicating success (false if player nonexistant)
6078
6079 Particles
6080 ---------
6081
6082 * `minetest.add_particle(particle definition)`
6083     * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
6084       expirationtime, size, collisiondetection, texture, playername)`
6085
6086 * `minetest.add_particlespawner(particlespawner definition)`
6087     * Add a `ParticleSpawner`, an object that spawns an amount of particles
6088       over `time` seconds.
6089     * Returns an `id`, and -1 if adding didn't succeed
6090     * Deprecated: `minetest.add_particlespawner(amount, time,
6091       minpos, maxpos,
6092       minvel, maxvel,
6093       minacc, maxacc,
6094       minexptime, maxexptime,
6095       minsize, maxsize,
6096       collisiondetection, texture, playername)`
6097
6098 * `minetest.delete_particlespawner(id, player)`
6099     * Delete `ParticleSpawner` with `id` (return value from
6100       `minetest.add_particlespawner`).
6101     * If playername is specified, only deletes on the player's client,
6102       otherwise on all clients.
6103
6104 Schematics
6105 ----------
6106
6107 * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
6108     * Create a schematic from the volume of map specified by the box formed by
6109       p1 and p2.
6110     * Apply the specified probability and per-node force-place to the specified
6111       nodes according to the `probability_list`.
6112         * `probability_list` is an array of tables containing two fields, `pos`
6113           and `prob`.
6114             * `pos` is the 3D vector specifying the absolute coordinates of the
6115               node being modified,
6116             * `prob` is an integer value from `0` to `255` that encodes
6117               probability and per-node force-place. Probability has levels
6118               0-127, then 128 may be added to encode per-node force-place.
6119               For probability stated as 0-255, divide by 2 and round down to
6120               get values 0-127, then add 128 to apply per-node force-place.
6121             * If there are two or more entries with the same pos value, the
6122               last entry is used.
6123             * If `pos` is not inside the box formed by `p1` and `p2`, it is
6124               ignored.
6125             * If `probability_list` equals `nil`, no probabilities are applied.
6126     * Apply the specified probability to the specified horizontal slices
6127       according to the `slice_prob_list`.
6128         * `slice_prob_list` is an array of tables containing two fields, `ypos`
6129           and `prob`.
6130             * `ypos` indicates the y position of the slice with a probability
6131               applied, the lowest slice being `ypos = 0`.
6132             * If slice probability list equals `nil`, no slice probabilities
6133               are applied.
6134     * Saves schematic in the Minetest Schematic format to filename.
6135
6136 * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
6137     * Place the schematic specified by schematic (see [Schematic specifier]) at
6138       `pos`.
6139     * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
6140     * If the `rotation` parameter is omitted, the schematic is not rotated.
6141     * `replacements` = `{["old_name"] = "convert_to", ...}`
6142     * `force_placement` is a boolean indicating whether nodes other than `air`
6143       and `ignore` are replaced by the schematic.
6144     * Returns nil if the schematic could not be loaded.
6145     * **Warning**: Once you have loaded a schematic from a file, it will be
6146       cached. Future calls will always use the cached version and the
6147       replacement list defined for it, regardless of whether the file or the
6148       replacement list parameter have changed. The only way to load the file
6149       anew is to restart the server.
6150     * `flags` is a flag field with the available flags:
6151         * place_center_x
6152         * place_center_y
6153         * place_center_z
6154
6155 * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
6156     * This function is analogous to minetest.place_schematic, but places a
6157       schematic onto the specified VoxelManip object `vmanip` instead of the
6158       map.
6159     * Returns false if any part of the schematic was cut-off due to the
6160       VoxelManip not containing the full area required, and true if the whole
6161       schematic was able to fit.
6162     * Returns nil if the schematic could not be loaded.
6163     * After execution, any external copies of the VoxelManip contents are
6164       invalidated.
6165     * `flags` is a flag field with the available flags:
6166         * place_center_x
6167         * place_center_y
6168         * place_center_z
6169
6170 * `minetest.serialize_schematic(schematic, format, options)`
6171     * Return the serialized schematic specified by schematic
6172       (see [Schematic specifier])
6173     * in the `format` of either "mts" or "lua".
6174     * "mts" - a string containing the binary MTS data used in the MTS file
6175       format.
6176     * "lua" - a string containing Lua code representing the schematic in table
6177       format.
6178     * `options` is a table containing the following optional parameters:
6179         * If `lua_use_comments` is true and `format` is "lua", the Lua code
6180           generated will have (X, Z) position comments for every X row
6181           generated in the schematic data for easier reading.
6182         * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
6183           the Lua code generated will use that number of spaces as indentation
6184           instead of a tab character.
6185
6186 * `minetest.read_schematic(schematic, options)`
6187     * Returns a Lua table representing the schematic (see: [Schematic specifier])
6188     * `schematic` is the schematic to read (see: [Schematic specifier])
6189     * `options` is a table containing the following optional parameters:
6190         * `write_yslice_prob`: string value:
6191             * `none`: no `write_yslice_prob` table is inserted,
6192             * `low`: only probabilities that are not 254 or 255 are written in
6193               the `write_ylisce_prob` table,
6194             * `all`: write all probabilities to the `write_yslice_prob` table.
6195             * The default for this option is `all`.
6196             * Any invalid value will be interpreted as `all`.
6197
6198 HTTP Requests
6199 -------------
6200
6201 * `minetest.request_http_api()`:
6202     * returns `HTTPApiTable` containing http functions if the calling mod has
6203       been granted access by being listed in the `secure.http_mods` or
6204       `secure.trusted_mods` setting, otherwise returns `nil`.
6205     * The returned table contains the functions `fetch`, `fetch_async` and
6206       `fetch_async_get` described below.
6207     * Only works at init time and must be called from the mod's main scope
6208       (not from a function).
6209     * Function only exists if minetest server was built with cURL support.
6210     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
6211       A LOCAL VARIABLE!**
6212 * `HTTPApiTable.fetch(HTTPRequest req, callback)`
6213     * Performs given request asynchronously and calls callback upon completion
6214     * callback: `function(HTTPRequestResult res)`
6215     * Use this HTTP function if you are unsure, the others are for advanced use
6216 * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
6217     * Performs given request asynchronously and returns handle for
6218       `HTTPApiTable.fetch_async_get`
6219 * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
6220     * Return response data for given asynchronous HTTP request
6221
6222 Storage API
6223 -----------
6224
6225 * `minetest.get_mod_storage()`:
6226     * returns reference to mod private `StorageRef`
6227     * must be called during mod load time
6228
6229 Misc.
6230 -----
6231
6232 * `minetest.get_connected_players()`: returns list of `ObjectRefs`
6233 * `minetest.is_player(obj)`: boolean, whether `obj` is a player
6234 * `minetest.player_exists(name)`: boolean, whether player exists
6235   (regardless of online status)
6236 * `minetest.hud_replace_builtin(name, hud_definition)`
6237     * Replaces definition of a builtin hud element
6238     * `name`: `"breath"` or `"health"`
6239     * `hud_definition`: definition to replace builtin definition
6240 * `minetest.send_join_message(player_name)`
6241     * This function can be overridden by mods to change the join message.
6242 * `minetest.send_leave_message(player_name, timed_out)`
6243     * This function can be overridden by mods to change the leave message.
6244 * `minetest.hash_node_position(pos)`: returns an 48-bit integer
6245     * `pos`: table {x=number, y=number, z=number},
6246     * Gives a unique hash number for a node position (16+16+16=48bit)
6247 * `minetest.get_position_from_hash(hash)`: returns a position
6248     * Inverse transform of `minetest.hash_node_position`
6249 * `minetest.get_item_group(name, group)`: returns a rating
6250     * Get rating of a group of an item. (`0` means: not in group)
6251 * `minetest.get_node_group(name, group)`: returns a rating
6252     * Deprecated: An alias for the former.
6253 * `minetest.raillike_group(name)`: returns a rating
6254     * Returns rating of the connect_to_raillike group corresponding to name
6255     * If name is not yet the name of a connect_to_raillike group, a new group
6256       id is created, with that name.
6257 * `minetest.get_content_id(name)`: returns an integer
6258     * Gets the internal content ID of `name`
6259 * `minetest.get_name_from_content_id(content_id)`: returns a string
6260     * Gets the name of the content with that content ID
6261 * `minetest.parse_json(string[, nullvalue])`: returns something
6262     * Convert a string containing JSON data into the Lua equivalent
6263     * `nullvalue`: returned in place of the JSON null; defaults to `nil`
6264     * On success returns a table, a string, a number, a boolean or `nullvalue`
6265     * On failure outputs an error message and returns `nil`
6266     * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
6267 * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
6268   message.
6269     * Convert a Lua table into a JSON string
6270     * styled: Outputs in a human-readable format if this is set, defaults to
6271       false.
6272     * Unserializable things like functions and userdata will cause an error.
6273     * **Warning**: JSON is more strict than the Lua table format.
6274         1. You can only use strings and positive integers of at least one as
6275            keys.
6276         2. You can not mix string and integer keys.
6277            This is due to the fact that JSON has two distinct array and object
6278            values.
6279     * Example: `write_json({10, {a = false}})`,
6280       returns `'[10, {"a": false}]'`
6281 * `minetest.serialize(table)`: returns a string
6282     * Convert a table containing tables, strings, numbers, booleans and `nil`s
6283       into string form readable by `minetest.deserialize`
6284     * Example: `serialize({foo="bar"})`, returns `'return { ["foo"] = "bar" }'`
6285 * `minetest.deserialize(string[, safe])`: returns a table
6286     * Convert a string returned by `minetest.serialize` into a table
6287     * `string` is loaded in an empty sandbox environment.
6288     * Will load functions if safe is false or omitted. Although these functions
6289       cannot directly access the global environment, they could bypass this
6290       restriction with maliciously crafted Lua bytecode if mod security is
6291       disabled.
6292     * This function should not be used on untrusted data, regardless of the
6293      value of `safe`. It is fine to serialize then deserialize user-provided
6294      data, but directly providing user input to deserialize is always unsafe.
6295     * Example: `deserialize('return { ["foo"] = "bar" }')`,
6296       returns `{foo="bar"}`
6297     * Example: `deserialize('print("foo")')`, returns `nil`
6298       (function call fails), returns
6299       `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
6300 * `minetest.compress(data, method, ...)`: returns `compressed_data`
6301     * Compress a string of data.
6302     * `method` is a string identifying the compression method to be used.
6303     * Supported compression methods:
6304         * Deflate (zlib): `"deflate"`
6305     * `...` indicates method-specific arguments. Currently defined arguments
6306       are:
6307         * Deflate: `level` - Compression level, `0`-`9` or `nil`.
6308 * `minetest.decompress(compressed_data, method, ...)`: returns data
6309     * Decompress a string of data (using ZLib).
6310     * See documentation on `minetest.compress()` for supported compression
6311       methods.
6312     * `...` indicates method-specific arguments. Currently, no methods use this
6313 * `minetest.rgba(red, green, blue[, alpha])`: returns a string
6314     * Each argument is a 8 Bit unsigned integer
6315     * Returns the ColorString from rgb or rgba values
6316     * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
6317 * `minetest.encode_base64(string)`: returns string encoded in base64
6318     * Encodes a string in base64.
6319 * `minetest.decode_base64(string)`: returns string or nil on failure
6320     * Padding characters are only supported starting at version 5.4.0, where
6321       5.5.0 and newer perform proper checks.
6322     * Decodes a string encoded in base64.
6323 * `minetest.is_protected(pos, name)`: returns boolean
6324     * Returning `true` restricts the player `name` from modifying (i.e. digging,
6325        placing) the node at position `pos`.
6326     * `name` will be `""` for non-players or unknown players.
6327     * This function should be overridden by protection mods. It is highly
6328       recommended to grant access to players with the `protection_bypass` privilege.
6329     * Cache and call the old version of this function if the position is
6330       not protected by the mod. This will allow using multiple protection mods.
6331     * Example:
6332
6333           local old_is_protected = minetest.is_protected
6334           function minetest.is_protected(pos, name)
6335               if mymod:position_protected_from(pos, name) then
6336                   return true
6337               end
6338               return old_is_protected(pos, name)
6339           end
6340 * `minetest.record_protection_violation(pos, name)`
6341     * This function calls functions registered with
6342       `minetest.register_on_protection_violation`.
6343 * `minetest.is_creative_enabled(name)`: returns boolean
6344     * Returning `true` means that Creative Mode is enabled for player `name`.
6345     * `name` will be `""` for non-players or if the player is unknown.
6346     * This function should be overridden by Creative Mode-related mods to
6347       implement a per-player Creative Mode.
6348     * By default, this function returns `true` if the setting
6349       `creative_mode` is `true` and `false` otherwise.
6350 * `minetest.is_area_protected(pos1, pos2, player_name, interval)`
6351     * Returns the position of the first node that `player_name` may not modify
6352       in the specified cuboid between `pos1` and `pos2`.
6353     * Returns `false` if no protections were found.
6354     * Applies `is_protected()` to a 3D lattice of points in the defined volume.
6355       The points are spaced evenly throughout the volume and have a spacing
6356       similar to, but no larger than, `interval`.
6357     * All corners and edges of the defined volume are checked.
6358     * `interval` defaults to 4.
6359     * `interval` should be carefully chosen and maximised to avoid an excessive
6360       number of points being checked.
6361     * Like `minetest.is_protected`, this function may be extended or
6362       overwritten by mods to provide a faster implementation to check the
6363       cuboid for intersections.
6364 * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
6365   orient_flags, prevent_after_place])`
6366     * Attempt to predict the desired orientation of the facedir-capable node
6367       defined by `itemstack`, and place it accordingly (on-wall, on the floor,
6368       or hanging from the ceiling).
6369     * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
6370       stacks are handled normally.
6371     * `orient_flags`: Optional table containing extra tweaks to the placement code:
6372         * `invert_wall`:   if `true`, place wall-orientation on the ground and
6373           ground-orientation on the wall.
6374         * `force_wall` :   if `true`, always place the node in wall orientation.
6375         * `force_ceiling`: if `true`, always place on the ceiling.
6376         * `force_floor`:   if `true`, always place the node on the floor.
6377         * `force_facedir`: if `true`, forcefully reset the facedir to north
6378           when placing on the floor or ceiling.
6379         * The first four options are mutually-exclusive; the last in the list
6380           takes precedence over the first.
6381     * `prevent_after_place` is directly passed to `minetest.item_place_node`
6382     * Returns the new itemstack after placement
6383 * `minetest.rotate_node(itemstack, placer, pointed_thing)`
6384     * calls `rotate_and_place()` with `infinitestacks` set according to the state
6385       of the creative mode setting, checks for "sneak" to set the `invert_wall`
6386       parameter and `prevent_after_place` set to `true`.
6387
6388 * `minetest.calculate_knockback(player, hitter, time_from_last_punch,
6389   tool_capabilities, dir, distance, damage)`
6390     * Returns the amount of knockback applied on the punched player.
6391     * Arguments are equivalent to `register_on_punchplayer`, except the following:
6392         * `distance`: distance between puncher and punched player
6393     * This function can be overriden by mods that wish to modify this behaviour.
6394     * You may want to cache and call the old function to allow multiple mods to
6395       change knockback behaviour.
6396
6397 * `minetest.forceload_block(pos[, transient])`
6398     * forceloads the position `pos`.
6399     * returns `true` if area could be forceloaded
6400     * If `transient` is `false` or absent, the forceload will be persistent
6401       (saved between server runs). If `true`, the forceload will be transient
6402       (not saved between server runs).
6403
6404 * `minetest.forceload_free_block(pos[, transient])`
6405     * stops forceloading the position `pos`
6406     * If `transient` is `false` or absent, frees a persistent forceload.
6407       If `true`, frees a transient forceload.
6408
6409 * `minetest.compare_block_status(pos, condition)`
6410     * Checks whether the mapblock at positition `pos` is in the wanted condition.
6411     * `condition` may be one of the following values:
6412         * `"unknown"`: not in memory
6413         * `"emerging"`: in the queue for loading from disk or generating
6414         * `"loaded"`: in memory but inactive (no ABMs are executed)
6415         * `"active"`: in memory and active
6416         * Other values are reserved for future functionality extensions
6417     * Return value, the comparison status:
6418         * `false`: Mapblock does not fulfil the wanted condition
6419         * `true`: Mapblock meets the requirement
6420         * `nil`: Unsupported `condition` value
6421
6422 * `minetest.request_insecure_environment()`: returns an environment containing
6423   insecure functions if the calling mod has been listed as trusted in the
6424   `secure.trusted_mods` setting or security is disabled, otherwise returns
6425   `nil`.
6426     * Only works at init time and must be called from the mod's main scope
6427       (ie: the init.lua of the mod, not from another Lua file or within a function).
6428     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
6429       IT IN A LOCAL VARIABLE!**
6430
6431 * `minetest.global_exists(name)`
6432     * Checks if a global variable has been set, without triggering a warning.
6433
6434 Global objects
6435 --------------
6436
6437 * `minetest.env`: `EnvRef` of the server environment and world.
6438     * Any function in the minetest namespace can be called using the syntax
6439       `minetest.env:somefunction(somearguments)`
6440       instead of `minetest.somefunction(somearguments)`
6441     * Deprecated, but support is not to be dropped soon
6442
6443 Global tables
6444 -------------
6445
6446 ### Registered definition tables
6447
6448 * `minetest.registered_items`
6449     * Map of registered items, indexed by name
6450 * `minetest.registered_nodes`
6451     * Map of registered node definitions, indexed by name
6452 * `minetest.registered_craftitems`
6453     * Map of registered craft item definitions, indexed by name
6454 * `minetest.registered_tools`
6455     * Map of registered tool definitions, indexed by name
6456 * `minetest.registered_entities`
6457     * Map of registered entity prototypes, indexed by name
6458     * Values in this table may be modified directly.
6459       Note: changes to initial properties will only affect entities spawned afterwards,
6460       as they are only read when spawning.
6461 * `minetest.object_refs`
6462     * Map of object references, indexed by active object id
6463 * `minetest.luaentities`
6464     * Map of Lua entities, indexed by active object id
6465 * `minetest.registered_abms`
6466     * List of ABM definitions
6467 * `minetest.registered_lbms`
6468     * List of LBM definitions
6469 * `minetest.registered_aliases`
6470     * Map of registered aliases, indexed by name
6471 * `minetest.registered_ores`
6472     * Map of registered ore definitions, indexed by the `name` field.
6473     * If `name` is nil, the key is the object handle returned by
6474       `minetest.register_ore`.
6475 * `minetest.registered_biomes`
6476     * Map of registered biome definitions, indexed by the `name` field.
6477     * If `name` is nil, the key is the object handle returned by
6478       `minetest.register_biome`.
6479 * `minetest.registered_decorations`
6480     * Map of registered decoration definitions, indexed by the `name` field.
6481     * If `name` is nil, the key is the object handle returned by
6482       `minetest.register_decoration`.
6483 * `minetest.registered_schematics`
6484     * Map of registered schematic definitions, indexed by the `name` field.
6485     * If `name` is nil, the key is the object handle returned by
6486       `minetest.register_schematic`.
6487 * `minetest.registered_chatcommands`
6488     * Map of registered chat command definitions, indexed by name
6489 * `minetest.registered_privileges`
6490     * Map of registered privilege definitions, indexed by name
6491     * Registered privileges can be modified directly in this table.
6492
6493 ### Registered callback tables
6494
6495 All callbacks registered with [Global callback registration functions] are added
6496 to corresponding `minetest.registered_*` tables.
6497
6498
6499
6500
6501 Class reference
6502 ===============
6503
6504 Sorted alphabetically.
6505
6506 `AreaStore`
6507 -----------
6508
6509 AreaStore is a data structure to calculate intersections of 3D cuboid volumes
6510 and points. The `data` field (string) may be used to store and retrieve any
6511 mod-relevant information to the specified area.
6512
6513 Despite its name, mods must take care of persisting AreaStore data. They may
6514 use the provided load and write functions for this.
6515
6516
6517 ### Methods
6518
6519 * `AreaStore(type_name)`
6520     * Returns a new AreaStore instance
6521     * `type_name`: optional, forces the internally used API.
6522         * Possible values: `"LibSpatial"` (default).
6523         * When other values are specified, or SpatialIndex is not available,
6524           the custom Minetest functions are used.
6525 * `get_area(id, include_corners, include_data)`
6526     * Returns the area information about the specified ID.
6527     * Returned values are either of these:
6528
6529             nil  -- Area not found
6530             true -- Without `include_corners` and `include_data`
6531             {
6532                 min = pos, max = pos -- `include_corners == true`
6533                 data = string        -- `include_data == true`
6534             }
6535
6536 * `get_areas_for_pos(pos, include_corners, include_data)`
6537     * Returns all areas as table, indexed by the area ID.
6538     * Table values: see `get_area`.
6539 * `get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data)`
6540     * Returns all areas that contain all nodes inside the area specified by`
6541       `corner1 and `corner2` (inclusive).
6542     * `accept_overlap`: if `true`, areas are returned that have nodes in
6543       common (intersect) with the specified area.
6544     * Returns the same values as `get_areas_for_pos`.
6545 * `insert_area(corner1, corner2, data, [id])`: inserts an area into the store.
6546     * Returns the new area's ID, or nil if the insertion failed.
6547     * The (inclusive) positions `corner1` and `corner2` describe the area.
6548     * `data` is a string stored with the area.
6549     * `id` (optional): will be used as the internal area ID if it is an unique
6550       number between 0 and 2^32-2.
6551 * `reserve(count)`
6552     * Requires SpatialIndex, no-op function otherwise.
6553     * Reserves resources for `count` many contained areas to improve
6554       efficiency when working with many area entries. Additional areas can still
6555       be inserted afterwards at the usual complexity.
6556 * `remove_area(id)`: removes the area with the given id from the store, returns
6557   success.
6558 * `set_cache_params(params)`: sets params for the included prefiltering cache.
6559   Calling invalidates the cache, so that its elements have to be newly
6560   generated.
6561     * `params` is a table with the following fields:
6562
6563           enabled = boolean,   -- Whether to enable, default true
6564           block_radius = int,  -- The radius (in nodes) of the areas the cache
6565                                -- generates prefiltered lists for, minimum 16,
6566                                -- default 64
6567           limit = int,         -- The cache size, minimum 20, default 1000
6568 * `to_string()`: Experimental. Returns area store serialized as a (binary)
6569   string.
6570 * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
6571   a file.
6572 * `from_string(str)`: Experimental. Deserializes string and loads it into the
6573   AreaStore.
6574   Returns success and, optionally, an error message.
6575 * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
6576   from a file.
6577
6578 `InvRef`
6579 --------
6580
6581 An `InvRef` is a reference to an inventory.
6582
6583 ### Methods
6584
6585 * `is_empty(listname)`: return `true` if list is empty
6586 * `get_size(listname)`: get size of a list
6587 * `set_size(listname, size)`: set size of a list
6588     * returns `false` on error (e.g. invalid `listname` or `size`)
6589 * `get_width(listname)`: get width of a list
6590 * `set_width(listname, width)`: set width of list; currently used for crafting
6591 * `get_stack(listname, i)`: get a copy of stack index `i` in list
6592 * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
6593 * `get_list(listname)`: return full list (list of `ItemStack`s)
6594 * `set_list(listname, list)`: set full list (size will not change)
6595 * `get_lists()`: returns table that maps listnames to inventory lists
6596 * `set_lists(lists)`: sets inventory lists (size will not change)
6597 * `add_item(listname, stack)`: add item somewhere in list, returns leftover
6598   `ItemStack`.
6599 * `room_for_item(listname, stack):` returns `true` if the stack of items
6600   can be fully added to the list
6601 * `contains_item(listname, stack, [match_meta])`: returns `true` if
6602   the stack of items can be fully taken from the list.
6603   If `match_meta` is false, only the items' names are compared
6604   (default: `false`).
6605 * `remove_item(listname, stack)`: take as many items as specified from the
6606   list, returns the items that were actually removed (as an `ItemStack`)
6607   -- note that any item metadata is ignored, so attempting to remove a specific
6608   unique item this way will likely remove the wrong one -- to do that use
6609   `set_stack` with an empty `ItemStack`.
6610 * `get_location()`: returns a location compatible to
6611   `minetest.get_inventory(location)`.
6612     * returns `{type="undefined"}` in case location is not known
6613
6614 ### Callbacks
6615
6616 Detached & nodemeta inventories provide the following callbacks for move actions:
6617
6618 #### Before
6619
6620 The `allow_*` callbacks return how many items can be moved.
6621
6622 * `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
6623 * `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
6624 * `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
6625
6626 #### After
6627
6628 The `on_*` callbacks are called after the items have been placed in the inventories.
6629
6630 * `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
6631 * `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
6632 * `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
6633
6634 #### Swapping
6635
6636 When a player tries to put an item to a place where another item is, the items are *swapped*.
6637 This means that all callbacks will be called twice (once for each action).
6638
6639 `ItemStack`
6640 -----------
6641
6642 An `ItemStack` is a stack of items.
6643
6644 It can be created via `ItemStack(x)`, where x is an `ItemStack`,
6645 an itemstring, a table or `nil`.
6646
6647 ### Methods
6648
6649 * `is_empty()`: returns `true` if stack is empty.
6650 * `get_name()`: returns item name (e.g. `"default:stone"`).
6651 * `set_name(item_name)`: returns a boolean indicating whether the item was
6652   cleared.
6653 * `get_count()`: Returns number of items on the stack.
6654 * `set_count(count)`: returns a boolean indicating whether the item was cleared
6655     * `count`: number, unsigned 16 bit integer
6656 * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
6657 * `set_wear(wear)`: returns boolean indicating whether item was cleared
6658     * `wear`: number, unsigned 16 bit integer
6659 * `get_meta()`: returns ItemStackMetaRef. See section for more details
6660 * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
6661   stack).
6662 * `set_metadata(metadata)`: (DEPRECATED) Returns true.
6663 * `get_description()`: returns the description shown in inventory list tooltips.
6664     * The engine uses this when showing item descriptions in tooltips.
6665     * Fields for finding the description, in order:
6666         * `description` in item metadata (See [Item Metadata].)
6667         * `description` in item definition
6668         * item name
6669 * `get_short_description()`: returns the short description or nil.
6670     * Unlike the description, this does not include new lines.
6671     * Fields for finding the short description, in order:
6672         * `short_description` in item metadata (See [Item Metadata].)
6673         * `short_description` in item definition
6674         * first line of the description (From item meta or def, see `get_description()`.)
6675         * Returns nil if none of the above are set
6676 * `clear()`: removes all items from the stack, making it empty.
6677 * `replace(item)`: replace the contents of this stack.
6678     * `item` can also be an itemstring or table.
6679 * `to_string()`: returns the stack in itemstring form.
6680 * `to_table()`: returns the stack in Lua table form.
6681 * `get_stack_max()`: returns the maximum size of the stack (depends on the
6682   item).
6683 * `get_free_space()`: returns `get_stack_max() - get_count()`.
6684 * `is_known()`: returns `true` if the item name refers to a defined item type.
6685 * `get_definition()`: returns the item definition table.
6686 * `get_tool_capabilities()`: returns the digging properties of the item,
6687   or those of the hand if none are defined for this item type
6688 * `add_wear(amount)`
6689     * Increases wear by `amount` if the item is a tool, otherwise does nothing
6690     * Valid `amount` range is [0,65536]
6691     * `amount`: number, integer
6692 * `add_wear_by_uses(max_uses)`
6693     * Increases wear in such a way that, if only this function is called,
6694       the item breaks after `max_uses` times
6695     * Valid `max_uses` range is [0,65536]
6696     * Does nothing if item is not a tool or if `max_uses` is 0
6697 * `add_item(item)`: returns leftover `ItemStack`
6698     * Put some item or stack onto this stack
6699 * `item_fits(item)`: returns `true` if item or stack can be fully added to
6700   this one.
6701 * `take_item(n)`: returns taken `ItemStack`
6702     * Take (and remove) up to `n` items from this stack
6703     * `n`: number, default: `1`
6704 * `peek_item(n)`: returns taken `ItemStack`
6705     * Copy (don't remove) up to `n` items from this stack
6706     * `n`: number, default: `1`
6707
6708 `ItemStackMetaRef`
6709 ------------------
6710
6711 ItemStack metadata: reference extra data and functionality stored in a stack.
6712 Can be obtained via `item:get_meta()`.
6713
6714 ### Methods
6715
6716 * All methods in MetaDataRef
6717 * `set_tool_capabilities([tool_capabilities])`
6718     * Overrides the item's tool capabilities
6719     * A nil value will clear the override data and restore the original
6720       behavior.
6721
6722 `MetaDataRef`
6723 -------------
6724
6725 Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
6726 and [`PlayerMetaRef`].
6727
6728 ### Methods
6729
6730 * `contains(key)`: Returns true if key present, otherwise false.
6731     * Returns `nil` when the MetaData is inexistent.
6732 * `get(key)`: Returns `nil` if key not present, else the stored string.
6733 * `set_string(key, value)`: Value of `""` will delete the key.
6734 * `get_string(key)`: Returns `""` if key not present.
6735 * `set_int(key, value)`
6736 * `get_int(key)`: Returns `0` if key not present.
6737 * `set_float(key, value)`
6738 * `get_float(key)`: Returns `0` if key not present.
6739 * `to_table()`: returns `nil` or a table with keys:
6740     * `fields`: key-value storage
6741     * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
6742 * `from_table(nil or {})`
6743     * Any non-table value will clear the metadata
6744     * See [Node Metadata] for an example
6745     * returns `true` on success
6746 * `equals(other)`
6747     * returns `true` if this metadata has the same key-value pairs as `other`
6748
6749 `ModChannel`
6750 ------------
6751
6752 An interface to use mod channels on client and server
6753
6754 ### Methods
6755
6756 * `leave()`: leave the mod channel.
6757     * Server leaves channel `channel_name`.
6758     * No more incoming or outgoing messages can be sent to this channel from
6759       server mods.
6760     * This invalidate all future object usage.
6761     * Ensure you set mod_channel to nil after that to free Lua resources.
6762 * `is_writeable()`: returns true if channel is writeable and mod can send over
6763   it.
6764 * `send_all(message)`: Send `message` though the mod channel.
6765     * If mod channel is not writeable or invalid, message will be dropped.
6766     * Message size is limited to 65535 characters by protocol.
6767
6768 `NodeMetaRef`
6769 -------------
6770
6771 Node metadata: reference extra data and functionality stored in a node.
6772 Can be obtained via `minetest.get_meta(pos)`.
6773
6774 ### Methods
6775
6776 * All methods in MetaDataRef
6777 * `get_inventory()`: returns `InvRef`
6778 * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
6779   This will prevent them from being sent to the client. Note that the "private"
6780   status will only be remembered if an associated key-value pair exists,
6781   meaning it's best to call this when initializing all other meta (e.g.
6782   `on_construct`).
6783
6784 `NodeTimerRef`
6785 --------------
6786
6787 Node Timers: a high resolution persistent per-node timer.
6788 Can be gotten via `minetest.get_node_timer(pos)`.
6789
6790 ### Methods
6791
6792 * `set(timeout,elapsed)`
6793     * set a timer's state
6794     * `timeout` is in seconds, and supports fractional values (0.1 etc)
6795     * `elapsed` is in seconds, and supports fractional values (0.1 etc)
6796     * will trigger the node's `on_timer` function after `(timeout - elapsed)`
6797       seconds.
6798 * `start(timeout)`
6799     * start a timer
6800     * equivalent to `set(timeout,0)`
6801 * `stop()`
6802     * stops the timer
6803 * `get_timeout()`: returns current timeout in seconds
6804     * if `timeout` equals `0`, timer is inactive
6805 * `get_elapsed()`: returns current elapsed time in seconds
6806     * the node's `on_timer` function will be called after `(timeout - elapsed)`
6807       seconds.
6808 * `is_started()`: returns boolean state of timer
6809     * returns `true` if timer is started, otherwise `false`
6810
6811 `ObjectRef`
6812 -----------
6813
6814 Moving things in the game are generally these.
6815 This is basically a reference to a C++ `ServerActiveObject`.
6816
6817 ### Advice on handling `ObjectRefs`
6818
6819 When you receive an `ObjectRef` as a callback argument or from another API
6820 function, it is possible to store the reference somewhere and keep it around.
6821 It will keep functioning until the object is unloaded or removed.
6822
6823 However, doing this is **NOT** recommended as there is (intentionally) no method
6824 to test if a previously acquired `ObjectRef` is still valid.
6825 Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
6826 Lua back to the engine.
6827 Doing so is much less error-prone and you will never need to wonder if the
6828 object you are working with still exists.
6829
6830 ### Attachments
6831
6832 It is possible to attach objects to other objects (`set_attach` method).
6833
6834 When an object is attached, it is positioned relative to the parent's position
6835 and rotation. `get_pos` and `get_rotation` will always return the parent's
6836 values and changes via their setter counterparts are ignored.
6837
6838 To change position or rotation call `set_attach` again with the new values.
6839
6840 **Note**: Just like model dimensions, the relative position in `set_attach`
6841 must be multiplied by 10 compared to world positions.
6842
6843 It is also possible to attach to a bone of the parent object. In that case the
6844 child will follow movement and rotation of that bone.
6845
6846 ### Methods
6847
6848 * `get_pos()`: returns `{x=num, y=num, z=num}`
6849 * `set_pos(pos)`: `pos`=`{x=num, y=num, z=num}`
6850 * `get_velocity()`: returns the velocity, a vector.
6851 * `add_velocity(vel)`
6852     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
6853     * In comparison to using get_velocity, adding the velocity and then using
6854       set_velocity, add_velocity is supposed to avoid synchronization problems.
6855       Additionally, players also do not support set_velocity.
6856     * If a player:
6857         * Does not apply during free_move.
6858         * Note that since the player speed is normalized at each move step,
6859           increasing e.g. Y velocity beyond what would usually be achieved
6860           (see: physics overrides) will cause existing X/Z velocity to be reduced.
6861         * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
6862           pressing the jump key (assuming default settings)
6863 * `move_to(pos, continuous=false)`
6864     * Does an interpolated move for Lua entities for visually smooth transitions.
6865     * If `continuous` is true, the Lua entity will not be moved to the current
6866       position before starting the interpolated move.
6867     * For players this does the same as `set_pos`,`continuous` is ignored.
6868 * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
6869     * `puncher` = another `ObjectRef`,
6870     * `time_from_last_punch` = time since last punch action of the puncher
6871     * `direction`: can be `nil`
6872 * `right_click(clicker)`; `clicker` is another `ObjectRef`
6873 * `get_hp()`: returns number of health points
6874 * `set_hp(hp, reason)`: set number of health points
6875     * See reason in register_on_player_hpchange
6876     * Is limited to the range of 0 ... 65535 (2^16 - 1)
6877     * For players: HP are also limited by `hp_max` specified in object properties
6878 * `get_inventory()`: returns an `InvRef` for players, otherwise returns `nil`
6879 * `get_wield_list()`: returns the name of the inventory list the wielded item
6880    is in.
6881 * `get_wield_index()`: returns the index of the wielded item
6882 * `get_wielded_item()`: returns an `ItemStack`
6883 * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
6884   successful.
6885 * `set_armor_groups({group1=rating, group2=rating, ...})`
6886 * `get_armor_groups()`: returns a table with the armor group ratings
6887 * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
6888     * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
6889     * `frame_speed`: number, default: `15.0`
6890     * `frame_blend`: number, default: `0.0`
6891     * `frame_loop`: boolean, default: `true`
6892 * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
6893   `frame_loop`.
6894 * `set_animation_frame_speed(frame_speed)`
6895     * `frame_speed`: number, default: `15.0`
6896 * `set_attach(parent[, bone, position, rotation, forced_visible])`
6897     * `parent`: `ObjectRef` to attach to
6898     * `bone`: default `""` (the root bone)
6899     * `position`: relative position, default `{x=0, y=0, z=0}`
6900     * `rotation`: relative rotation in degrees, default `{x=0, y=0, z=0}`
6901     * `forced_visible`: Boolean to control whether the attached entity
6902        should appear in first person, default `false`.
6903     * Please also read the [Attachments] section above.
6904     * This command may fail silently (do nothing) when it would result
6905       in circular attachments.
6906 * `get_attach()`: returns parent, bone, position, rotation, forced_visible,
6907     or nil if it isn't attached.
6908 * `get_children()`: returns a list of ObjectRefs that are attached to the
6909     object.
6910 * `set_detach()`
6911 * `set_bone_position([bone, position, rotation])`
6912     * `bone`: string. Default is `""`, the root bone
6913     * `position`: `{x=num, y=num, z=num}`, relative, `default {x=0, y=0, z=0}`
6914     * `rotation`: `{x=num, y=num, z=num}`, default `{x=0, y=0, z=0}`
6915 * `get_bone_position(bone)`: returns position and rotation of the bone
6916 * `set_properties(object property table)`
6917 * `get_properties()`: returns object property table
6918 * `is_player()`: returns true for players, false otherwise
6919 * `get_nametag_attributes()`
6920     * returns a table with the attributes of the nametag of an object
6921     * {
6922         text = "",
6923         color = {a=0..255, r=0..255, g=0..255, b=0..255},
6924         bgcolor = {a=0..255, r=0..255, g=0..255, b=0..255},
6925       }
6926 * `set_nametag_attributes(attributes)`
6927     * sets the attributes of the nametag of an object
6928     * `attributes`:
6929       {
6930         text = "My Nametag",
6931         color = ColorSpec,
6932         -- ^ Text color
6933         bgcolor = ColorSpec or false,
6934         -- ^ Sets background color of nametag
6935         -- `false` will cause the background to be set automatically based on user settings
6936         -- Default: false
6937       }
6938
6939 #### Lua entity only (no-op for other objects)
6940
6941 * `remove()`: remove object
6942     * The object is removed after returning from Lua. However the `ObjectRef`
6943       itself instantly becomes unusable with all further method calls having
6944       no effect and returning `nil`.
6945 * `set_velocity(vel)`
6946     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
6947 * `set_acceleration(acc)`
6948     * `acc` is a vector
6949 * `get_acceleration()`: returns the acceleration, a vector
6950 * `set_rotation(rot)`
6951     * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
6952       and Z is roll (bank).
6953 * `get_rotation()`: returns the rotation, a vector (radians)
6954 * `set_yaw(yaw)`: sets the yaw in radians (heading).
6955 * `get_yaw()`: returns number in radians
6956 * `set_texture_mod(mod)`
6957     * Set a texture modifier to the base texture, for sprites and meshes.
6958     * When calling `set_texture_mod` again, the previous one is discarded.
6959     * `mod` the texture modifier. See [Texture modifiers].
6960 * `get_texture_mod()` returns current texture modifier
6961 * `set_sprite(start_frame, num_frames, framelength, select_x_by_camera)`
6962     * Specifies and starts a sprite animation
6963     * Animations iterate along the frame `y` position.
6964     * `start_frame`: {x=column number, y=row number}, the coordinate of the
6965       first frame, default: `{x=0, y=0}`
6966     * `num_frames`: Total frames in the texture, default: `1`
6967     * `framelength`: Time per animated frame in seconds, default: `0.2`
6968     * `select_x_by_camera`: Only for visual = `sprite`. Changes the frame `x`
6969       position according to the view direction. default: `false`.
6970         * First column:  subject facing the camera
6971         * Second column: subject looking to the left
6972         * Third column:  subject backing the camera
6973         * Fourth column: subject looking to the right
6974         * Fifth column:  subject viewed from above
6975         * Sixth column:  subject viewed from below
6976 * `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead)
6977 * `get_luaentity()`
6978
6979 #### Player only (no-op for other objects)
6980
6981 * `get_player_name()`: returns `""` if is not a player
6982 * `get_player_velocity()`: **DEPRECATED**, use get_velocity() instead.
6983   table {x, y, z} representing the player's instantaneous velocity in nodes/s
6984 * `add_player_velocity(vel)`: **DEPRECATED**, use add_velocity(vel) instead.
6985 * `get_look_dir()`: get camera direction as a unit vector
6986 * `get_look_vertical()`: pitch in radians
6987     * Angle ranges between -pi/2 and pi/2, which are straight up and down
6988       respectively.
6989 * `get_look_horizontal()`: yaw in radians
6990     * Angle is counter-clockwise from the +z direction.
6991 * `set_look_vertical(radians)`: sets look pitch
6992     * radians: Angle from looking forward, where positive is downwards.
6993 * `set_look_horizontal(radians)`: sets look yaw
6994     * radians: Angle from the +z direction, where positive is counter-clockwise.
6995 * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
6996   `get_look_vertical`.
6997     * Angle ranges between -pi/2 and pi/2, which are straight down and up
6998       respectively.
6999 * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
7000   `get_look_horizontal`.
7001     * Angle is counter-clockwise from the +x direction.
7002 * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
7003   `set_look_vertical`.
7004 * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
7005   `set_look_horizontal`.
7006 * `get_breath()`: returns player's breath
7007 * `set_breath(value)`: sets player's breath
7008     * values:
7009         * `0`: player is drowning
7010         * max: bubbles bar is not shown
7011         * See [Object properties] for more information
7012     * Is limited to range 0 ... 65535 (2^16 - 1)
7013 * `set_fov(fov, is_multiplier, transition_time)`: Sets player's FOV
7014     * `fov`: FOV value.
7015     * `is_multiplier`: Set to `true` if the FOV value is a multiplier.
7016       Defaults to `false`.
7017     * `transition_time`: If defined, enables smooth FOV transition.
7018       Interpreted as the time (in seconds) to reach target FOV.
7019       If set to 0, FOV change is instantaneous. Defaults to 0.
7020     * Set `fov` to 0 to clear FOV override.
7021 * `get_fov()`: Returns the following:
7022     * Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
7023     * Boolean indicating whether the FOV value is a multiplier.
7024     * Time (in seconds) taken for the FOV transition. Set by `set_fov`.
7025 * `set_attribute(attribute, value)`:  DEPRECATED, use get_meta() instead
7026     * Sets an extra attribute with value on player.
7027     * `value` must be a string, or a number which will be converted to a
7028       string.
7029     * If `value` is `nil`, remove attribute from player.
7030 * `get_attribute(attribute)`:  DEPRECATED, use get_meta() instead
7031     * Returns value (a string) for extra attribute.
7032     * Returns `nil` if no attribute found.
7033 * `get_meta()`: Returns a PlayerMetaRef.
7034 * `set_inventory_formspec(formspec)`
7035     * Redefine player's inventory form
7036     * Should usually be called in `on_joinplayer`
7037     * If `formspec` is `""`, the player's inventory is disabled.
7038 * `get_inventory_formspec()`: returns a formspec string
7039 * `set_formspec_prepend(formspec)`:
7040     * the formspec string will be added to every formspec shown to the user,
7041       except for those with a no_prepend[] tag.
7042     * This should be used to set style elements such as background[] and
7043       bgcolor[], any non-style elements (eg: label) may result in weird behaviour.
7044     * Only affects formspecs shown after this is called.
7045 * `get_formspec_prepend(formspec)`: returns a formspec string.
7046 * `get_player_control()`: returns table with player pressed keys
7047     * The table consists of fields with the following boolean values
7048       representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
7049       `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
7050     * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
7051       and exist only to preserve backwards compatibility.
7052     * Returns an empty table `{}` if the object is not a player.
7053 * `get_player_control_bits()`: returns integer with bit packed player pressed
7054   keys.
7055     * Bits:
7056         * 0 - up
7057         * 1 - down
7058         * 2 - left
7059         * 3 - right
7060         * 4 - jump
7061         * 5 - aux1
7062         * 6 - sneak
7063         * 7 - dig
7064         * 8 - place
7065         * 9 - zoom
7066     * Returns `0` (no bits set) if the object is not a player.
7067 * `set_physics_override(override_table)`
7068     * `override_table` is a table with the following fields:
7069         * `speed`: multiplier to default walking speed value (default: `1`)
7070         * `jump`: multiplier to default jump value (default: `1`)
7071         * `gravity`: multiplier to default gravity value (default: `1`)
7072         * `sneak`: whether player can sneak (default: `true`)
7073         * `sneak_glitch`: whether player can use the new move code replications
7074           of the old sneak side-effects: sneak ladders and 2 node sneak jump
7075           (default: `false`)
7076         * `new_move`: use new move/sneak code. When `false` the exact old code
7077           is used for the specific old sneak behaviour (default: `true`)
7078 * `get_physics_override()`: returns the table given to `set_physics_override`
7079 * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
7080    number on success
7081 * `hud_remove(id)`: remove the HUD element of the specified id
7082 * `hud_change(id, stat, value)`: change a value of a previously added HUD
7083   element.
7084     * `stat` supports the same keys as in the hud definition table except for
7085       `"hud_elem_type"`.
7086 * `hud_get(id)`: gets the HUD element definition structure of the specified ID
7087 * `hud_set_flags(flags)`: sets specified HUD flags of player.
7088     * `flags`: A table with the following fields set to boolean values
7089         * `hotbar`
7090         * `healthbar`
7091         * `crosshair`
7092         * `wielditem`
7093         * `breathbar`
7094         * `minimap`: Modifies the client's permission to view the minimap.
7095           The client may locally elect to not view the minimap.
7096         * `minimap_radar`: is only usable when `minimap` is true
7097         * `basic_debug`: Allow showing basic debug info that might give a gameplay advantage.
7098           This includes map seed, player position, look direction, the pointed node and block bounds.
7099           Does not affect players with the `debug` privilege.
7100     * If a flag equals `nil`, the flag is not modified
7101 * `hud_get_flags()`: returns a table of player HUD flags with boolean values.
7102     * See `hud_set_flags` for a list of flags that can be toggled.
7103 * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
7104     * `count`: number of items, must be between `1` and `32`
7105 * `hud_get_hotbar_itemcount`: returns number of visible items
7106 * `hud_set_hotbar_image(texturename)`
7107     * sets background image for hotbar
7108 * `hud_get_hotbar_image`: returns texturename
7109 * `hud_set_hotbar_selected_image(texturename)`
7110     * sets image for selected item of hotbar
7111 * `hud_get_hotbar_selected_image`: returns texturename
7112 * `set_minimap_modes({mode, mode, ...}, selected_mode)`
7113     * Overrides the available minimap modes (and toggle order), and changes the
7114     selected mode.
7115     * `mode` is a table consisting of up to four fields:
7116         * `type`: Available type:
7117             * `off`: Minimap off
7118             * `surface`: Minimap in surface mode
7119             * `radar`: Minimap in radar mode
7120             * `texture`: Texture to be displayed instead of terrain map
7121               (texture is centered around 0,0 and can be scaled).
7122               Texture size is limited to 512 x 512 pixel.
7123         * `label`: Optional label to display on minimap mode toggle
7124           The translation must be handled within the mod.
7125         * `size`: Sidelength or diameter, in number of nodes, of the terrain
7126           displayed in minimap
7127         * `texture`: Only for texture type, name of the texture to display
7128         * `scale`: Only for texture type, scale of the texture map in nodes per
7129           pixel (for example a `scale` of 2 means each pixel represents a 2x2
7130           nodes square)
7131     * `selected_mode` is the mode index to be selected after modes have been changed
7132     (0 is the first mode).
7133 * `set_sky(sky_parameters)`
7134     * The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
7135       whether `set_sky` accepts this format. Check the legacy format otherwise.
7136     * Passing no arguments resets the sky to its default values.
7137     * `sky_parameters` is a table with the following optional fields:
7138         * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
7139           (default: `#ffffff`)
7140         * `type`: Available types:
7141             * `"regular"`: Uses 0 textures, `base_color` ignored
7142             * `"skybox"`: Uses 6 textures, `base_color` used as fog.
7143             * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
7144             (default: `"regular"`)
7145         * `textures`: A table containing up to six textures in the following
7146             order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
7147         * `clouds`: Boolean for whether clouds appear. (default: `true`)
7148         * `sky_color`: A table used in `"regular"` type only, containing the
7149           following values (alpha is ignored):
7150             * `day_sky`: ColorSpec, for the top half of the sky during the day.
7151               (default: `#61b5f5`)
7152             * `day_horizon`: ColorSpec, for the bottom half of the sky during the day.
7153               (default: `#90d3f6`)
7154             * `dawn_sky`: ColorSpec, for the top half of the sky during dawn/sunset.
7155               (default: `#b4bafa`)
7156               The resulting sky color will be a darkened version of the ColorSpec.
7157               Warning: The darkening of the ColorSpec is subject to change.
7158             * `dawn_horizon`: ColorSpec, for the bottom half of the sky during dawn/sunset.
7159               (default: `#bac1f0`)
7160               The resulting sky color will be a darkened version of the ColorSpec.
7161               Warning: The darkening of the ColorSpec is subject to change.
7162             * `night_sky`: ColorSpec, for the top half of the sky during the night.
7163               (default: `#006bff`)
7164               The resulting sky color will be a dark version of the ColorSpec.
7165               Warning: The darkening of the ColorSpec is subject to change.
7166             * `night_horizon`: ColorSpec, for the bottom half of the sky during the night.
7167               (default: `#4090ff`)
7168               The resulting sky color will be a dark version of the ColorSpec.
7169               Warning: The darkening of the ColorSpec is subject to change.
7170             * `indoors`: ColorSpec, for when you're either indoors or underground.
7171               (default: `#646464`)
7172             * `fog_sun_tint`: ColorSpec, changes the fog tinting for the sun
7173               at sunrise and sunset. (default: `#f47d1d`)
7174             * `fog_moon_tint`: ColorSpec, changes the fog tinting for the moon
7175               at sunrise and sunset. (default: `#7f99cc`)
7176             * `fog_tint_type`: string, changes which mode the directional fog
7177                 abides by, `"custom"` uses `sun_tint` and `moon_tint`, while
7178                 `"default"` uses the classic Minetest sun and moon tinting.
7179                 Will use tonemaps, if set to `"default"`. (default: `"default"`)
7180 * `set_sky(base_color, type, {texture names}, clouds)`
7181     * Deprecated. Use `set_sky(sky_parameters)`
7182     * `base_color`: ColorSpec, defaults to white
7183     * `type`: Available types:
7184         * `"regular"`: Uses 0 textures, `bgcolor` ignored
7185         * `"skybox"`: Uses 6 textures, `bgcolor` used
7186         * `"plain"`: Uses 0 textures, `bgcolor` used
7187     * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
7188       `"plain"` custom skyboxes (default: `true`)
7189 * `get_sky(as_table)`:
7190     * `as_table`: boolean that determines whether the deprecated version of this
7191     function is being used.
7192         * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
7193         * Deprecated: `false` or `nil` returns base_color, type, table of textures,
7194         clouds.
7195 * `get_sky_color()`:
7196     * Deprecated: Use `get_sky(as_table)` instead.
7197     * returns a table with the `sky_color` parameters as in `set_sky`.
7198 * `set_sun(sun_parameters)`:
7199     * Passing no arguments resets the sun to its default values.
7200     * `sun_parameters` is a table with the following optional fields:
7201         * `visible`: Boolean for whether the sun is visible.
7202             (default: `true`)
7203         * `texture`: A regular texture for the sun. Setting to `""`
7204             will re-enable the mesh sun. (default: "sun.png", if it exists)
7205         * `tonemap`: A 512x1 texture containing the tonemap for the sun
7206             (default: `"sun_tonemap.png"`)
7207         * `sunrise`: A regular texture for the sunrise texture.
7208             (default: `"sunrisebg.png"`)
7209         * `sunrise_visible`: Boolean for whether the sunrise texture is visible.
7210             (default: `true`)
7211         * `scale`: Float controlling the overall size of the sun. (default: `1`)
7212 * `get_sun()`: returns a table with the current sun parameters as in
7213     `set_sun`.
7214 * `set_moon(moon_parameters)`:
7215     * Passing no arguments resets the moon to its default values.
7216     * `moon_parameters` is a table with the following optional fields:
7217         * `visible`: Boolean for whether the moon is visible.
7218             (default: `true`)
7219         * `texture`: A regular texture for the moon. Setting to `""`
7220             will re-enable the mesh moon. (default: `"moon.png"`, if it exists)
7221             Note: Relative to the sun, the moon texture is rotated by 180°.
7222             You can use the `^[transformR180` texture modifier to achieve the same orientation.
7223         * `tonemap`: A 512x1 texture containing the tonemap for the moon
7224             (default: `"moon_tonemap.png"`)
7225         * `scale`: Float controlling the overall size of the moon (default: `1`)
7226 * `get_moon()`: returns a table with the current moon parameters as in
7227     `set_moon`.
7228 * `set_stars(star_parameters)`:
7229     * Passing no arguments resets stars to their default values.
7230     * `star_parameters` is a table with the following optional fields:
7231         * `visible`: Boolean for whether the stars are visible.
7232             (default: `true`)
7233         * `day_opacity`: Float for maximum opacity of stars at day.
7234             No effect if `visible` is false.
7235             (default: 0.0; maximum: 1.0; minimum: 0.0)
7236         * `count`: Integer number to set the number of stars in
7237             the skybox. Only applies to `"skybox"` and `"regular"` sky types.
7238             (default: `1000`)
7239         * `star_color`: ColorSpec, sets the colors of the stars,
7240             alpha channel is used to set overall star brightness.
7241             (default: `#ebebff69`)
7242         * `scale`: Float controlling the overall size of the stars (default: `1`)
7243 * `get_stars()`: returns a table with the current stars parameters as in
7244     `set_stars`.
7245 * `set_clouds(cloud_parameters)`: set cloud parameters
7246     * Passing no arguments resets clouds to their default values.
7247     * `cloud_parameters` is a table with the following optional fields:
7248         * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
7249         * `color`: basic cloud color with alpha channel, ColorSpec
7250           (default `#fff0f0e5`).
7251         * `ambient`: cloud color lower bound, use for a "glow at night" effect.
7252           ColorSpec (alpha ignored, default `#000000`)
7253         * `height`: cloud height, i.e. y of cloud base (default per conf,
7254           usually `120`)
7255         * `thickness`: cloud thickness in nodes (default `16`)
7256         * `speed`: 2D cloud speed + direction in nodes per second
7257           (default `{x=0, z=-2}`).
7258 * `get_clouds()`: returns a table with the current cloud parameters as in
7259   `set_clouds`.
7260 * `override_day_night_ratio(ratio or nil)`
7261     * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
7262       amount.
7263     * `nil`: Disables override, defaulting to sunlight based on day-night cycle
7264 * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
7265 * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`:
7266   set animation for player model in third person view.
7267     * Every animation equals to a `{x=starting frame, y=ending frame}` table.
7268     * `frame_speed` sets the animations frame speed. Default is 30.
7269 * `get_local_animation()`: returns idle, walk, dig, walk_while_dig tables and
7270   `frame_speed`.
7271 * `set_eye_offset([firstperson, thirdperson])`: defines offset vectors for
7272   camera per player. An argument defaults to `{x=0, y=0, z=0}` if unspecified.
7273     * in first person view
7274     * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
7275 * `get_eye_offset()`: returns first and third person offsets.
7276 * `send_mapblock(blockpos)`:
7277     * Sends an already loaded mapblock to the player.
7278     * Returns `false` if nothing was sent (note that this can also mean that
7279       the client already has the block)
7280     * Resource intensive - use sparsely
7281 * `set_lighting(light_definition)`: sets lighting for the player
7282     * `light_definition` is a table with the following optional fields:
7283       * `shadows` is a table that controls ambient shadows
7284         * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
7285 * `get_lighting()`: returns the current state of lighting for the player.
7286     * Result is a table with the same fields as `light_definition` in `set_lighting`.
7287 * `respawn()`: Respawns the player using the same mechanism as the death screen,
7288   including calling on_respawnplayer callbacks.
7289
7290 `PcgRandom`
7291 -----------
7292
7293 A 32-bit pseudorandom number generator.
7294 Uses PCG32, an algorithm of the permuted congruential generator family,
7295 offering very strong randomness.
7296
7297 It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
7298
7299 ### Methods
7300
7301 * `next()`: return next integer random number [`-2147483648`...`2147483647`]
7302 * `next(min, max)`: return next integer random number [`min`...`max`]
7303 * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
7304   random number [`min`...`max`].
7305     * This is only a rough approximation of a normal distribution with:
7306     * `mean = (max - min) / 2`, and
7307     * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
7308     * Increasing `num_trials` improves accuracy of the approximation
7309
7310 `PerlinNoise`
7311 -------------
7312
7313 A perlin noise generator.
7314 It can be created via `PerlinNoise()` or `minetest.get_perlin()`.
7315 For `minetest.get_perlin()`, the actual seed used is the noiseparams seed
7316 plus the world seed, to create world-specific noise.
7317
7318 `PerlinNoise(noiseparams)`
7319 `PerlinNoise(seed, octaves, persistence, spread)` (Deprecated).
7320
7321 `minetest.get_perlin(noiseparams)`
7322 `minetest.get_perlin(seeddiff, octaves, persistence, spread)` (Deprecated).
7323
7324 ### Methods
7325
7326 * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
7327 * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
7328
7329 `PerlinNoiseMap`
7330 ----------------
7331
7332 A fast, bulk perlin noise generator.
7333
7334 It can be created via `PerlinNoiseMap(noiseparams, size)` or
7335 `minetest.get_perlin_map(noiseparams, size)`.
7336 For `minetest.get_perlin_map()`, the actual seed used is the noiseparams seed
7337 plus the world seed, to create world-specific noise.
7338
7339 Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
7340 for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
7341 `nil` is returned).
7342
7343 For each of the functions with an optional `buffer` parameter: If `buffer` is
7344 not nil, this table will be used to store the result instead of creating a new
7345 table.
7346
7347 ### Methods
7348
7349 * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
7350   with values starting at `pos={x=,y=}`
7351 * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
7352   3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
7353 * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
7354   array of 2D noise with values starting at `pos={x=,y=}`
7355 * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
7356 * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
7357   is stored internally.
7358 * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
7359   is stored internally.
7360 * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
7361   returns a slice of the most recently computed noise results. The result slice
7362   begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
7363   E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
7364   offset y = 20:
7365   `noisevals = noise:get_map_slice({y=20}, {y=2})`
7366   It is important to note that `slice_offset` offset coordinates begin at 1,
7367   and are relative to the starting position of the most recently calculated
7368   noise.
7369   To grab a single vertical column of noise starting at map coordinates
7370   x = 1023, y=1000, z = 1000:
7371   `noise:calc_3d_map({x=1000, y=1000, z=1000})`
7372   `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
7373
7374 `PlayerMetaRef`
7375 ---------------
7376
7377 Player metadata.
7378 Uses the same method of storage as the deprecated player attribute API, so
7379 data there will also be in player meta.
7380 Can be obtained using `player:get_meta()`.
7381
7382 ### Methods
7383
7384 * All methods in MetaDataRef
7385
7386 `PseudoRandom`
7387 --------------
7388
7389 A 16-bit pseudorandom number generator.
7390 Uses a well-known LCG algorithm introduced by K&R.
7391
7392 It can be created via `PseudoRandom(seed)`.
7393
7394 ### Methods
7395
7396 * `next()`: return next integer random number [`0`...`32767`]
7397 * `next(min, max)`: return next integer random number [`min`...`max`]
7398     * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
7399       due to the simple implementation making bad distribution otherwise.
7400
7401 `Raycast`
7402 ---------
7403
7404 A raycast on the map. It works with selection boxes.
7405 Can be used as an iterator in a for loop as:
7406
7407     local ray = Raycast(...)
7408     for pointed_thing in ray do
7409         ...
7410     end
7411
7412 The map is loaded as the ray advances. If the map is modified after the
7413 `Raycast` is created, the changes may or may not have an effect on the object.
7414
7415 It can be created via `Raycast(pos1, pos2, objects, liquids)` or
7416 `minetest.raycast(pos1, pos2, objects, liquids)` where:
7417
7418 * `pos1`: start of the ray
7419 * `pos2`: end of the ray
7420 * `objects`: if false, only nodes will be returned. Default is true.
7421 * `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
7422              returned. Default is false.
7423
7424 ### Methods
7425
7426 * `next()`: returns a `pointed_thing` with exact pointing location
7427     * Returns the next thing pointed by the ray or nil.
7428
7429 `SecureRandom`
7430 --------------
7431
7432 Interface for the operating system's crypto-secure PRNG.
7433
7434 It can be created via `SecureRandom()`.  The constructor returns nil if a
7435 secure random device cannot be found on the system.
7436
7437 ### Methods
7438
7439 * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
7440   random bytes, as a string.
7441
7442 `Settings`
7443 ----------
7444
7445 An interface to read config files in the format of `minetest.conf`.
7446
7447 It can be created via `Settings(filename)`.
7448
7449 ### Methods
7450
7451 * `get(key)`: returns a value
7452 * `get_bool(key, [default])`: returns a boolean
7453     * `default` is the value returned if `key` is not found.
7454     * Returns `nil` if `key` is not found and `default` not specified.
7455 * `get_np_group(key)`: returns a NoiseParams table
7456 * `get_flags(key)`:
7457     * Returns `{flag = true/false, ...}` according to the set flags.
7458     * Is currently limited to mapgen flags `mg_flags` and mapgen-specific
7459       flags like `mgv5_spflags`.
7460 * `set(key, value)`
7461     * Setting names can't contain whitespace or any of `="{}#`.
7462     * Setting values can't contain the sequence `\n"""`.
7463     * Setting names starting with "secure." can't be set on the main settings
7464       object (`minetest.settings`).
7465 * `set_bool(key, value)`
7466     * See documentation for set() above.
7467 * `set_np_group(key, value)`
7468     * `value` is a NoiseParams table.
7469     * Also, see documentation for set() above.
7470 * `remove(key)`: returns a boolean (`true` for success)
7471 * `get_names()`: returns `{key1,...}`
7472 * `write()`: returns a boolean (`true` for success)
7473     * Writes changes to file.
7474 * `to_table()`: returns `{[key1]=value1,...}`
7475
7476 ### Format
7477
7478 The settings have the format `key = value`. Example:
7479
7480     foo = example text
7481     bar = """
7482     Multiline
7483     value
7484     """
7485
7486
7487 `StorageRef`
7488 ------------
7489
7490 Mod metadata: per mod metadata, saved automatically.
7491 Can be obtained via `minetest.get_mod_storage()` during load time.
7492
7493 WARNING: This storage backend is incapable of saving raw binary data due
7494 to restrictions of JSON.
7495
7496 ### Methods
7497
7498 * All methods in MetaDataRef
7499
7500
7501
7502
7503 Definition tables
7504 =================
7505
7506 Object properties
7507 -----------------
7508
7509 Used by `ObjectRef` methods. Part of an Entity definition.
7510 These properties are not persistent, but are applied automatically to the
7511 corresponding Lua entity using the given registration fields.
7512 Player properties need to be saved manually.
7513
7514     {
7515         hp_max = 10,
7516         -- Defines the maximum and default HP of the entity
7517         -- For Lua entities the maximum is not enforced.
7518         -- For players this defaults to `minetest.PLAYER_MAX_HP_DEFAULT`.
7519
7520         breath_max = 0,
7521         -- For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`.
7522
7523         zoom_fov = 0.0,
7524         -- For players only. Zoom FOV in degrees.
7525         -- Note that zoom loads and/or generates world beyond the server's
7526         -- maximum send and generate distances, so acts like a telescope.
7527         -- Smaller zoom_fov values increase the distance loaded/generated.
7528         -- Defaults to 15 in creative mode, 0 in survival mode.
7529         -- zoom_fov = 0 disables zooming for the player.
7530
7531         eye_height = 1.625,
7532         -- For players only. Camera height above feet position in nodes.
7533
7534         physical = false,
7535         -- Collide with `walkable` nodes.
7536
7537         collide_with_objects = true,
7538         -- Collide with other objects if physical = true
7539
7540         collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
7541         selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
7542         -- Selection box uses collision box dimensions when not set.
7543         -- For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
7544         -- object position.
7545
7546         pointable = true,
7547         -- Whether the object can be pointed at
7548
7549         visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
7550         -- "cube" is a node-sized cube.
7551         -- "sprite" is a flat texture always facing the player.
7552         -- "upright_sprite" is a vertical flat texture.
7553         -- "mesh" uses the defined mesh model.
7554         -- "wielditem" is used for dropped items.
7555         --   (see builtin/game/item_entity.lua).
7556         --   For this use 'wield_item = itemname' (Deprecated: 'textures = {itemname}').
7557         --   If the item has a 'wield_image' the object will be an extrusion of
7558         --   that, otherwise:
7559         --   If 'itemname' is a cubic node or nodebox the object will appear
7560         --   identical to 'itemname'.
7561         --   If 'itemname' is a plantlike node the object will be an extrusion
7562         --   of its texture.
7563         --   Otherwise for non-node items, the object will be an extrusion of
7564         --   'inventory_image'.
7565         --   If 'itemname' contains a ColorString or palette index (e.g. from
7566         --   `minetest.itemstring_with_palette()`), the entity will inherit the color.
7567         -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
7568
7569         visual_size = {x = 1, y = 1, z = 1},
7570         -- Multipliers for the visual size. If `z` is not specified, `x` will be used
7571         -- to scale the entity along both horizontal axes.
7572
7573         mesh = "model.obj",
7574         -- File name of mesh when using "mesh" visual
7575
7576         textures = {},
7577         -- Number of required textures depends on visual.
7578         -- "cube" uses 6 textures just like a node, but all 6 must be defined.
7579         -- "sprite" uses 1 texture.
7580         -- "upright_sprite" uses 2 textures: {front, back}.
7581         -- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
7582         -- "mesh" requires one texture for each mesh buffer/material (in order)
7583
7584         colors = {},
7585         -- Number of required colors depends on visual
7586
7587         use_texture_alpha = false,
7588         -- Use texture's alpha channel.
7589         -- Excludes "upright_sprite" and "wielditem".
7590         -- Note: currently causes visual issues when viewed through other
7591         -- semi-transparent materials such as water.
7592
7593         spritediv = {x = 1, y = 1},
7594         -- Used with spritesheet textures for animation and/or frame selection
7595         -- according to position relative to player.
7596         -- Defines the number of columns and rows in the spritesheet:
7597         -- {columns, rows}.
7598
7599         initial_sprite_basepos = {x = 0, y = 0},
7600         -- Used with spritesheet textures.
7601         -- Defines the {column, row} position of the initially used frame in the
7602         -- spritesheet.
7603
7604         is_visible = true,
7605         -- If false, object is invisible and can't be pointed.
7606
7607         makes_footstep_sound = false,
7608         -- If true, is able to make footstep sounds of nodes
7609         -- (see node sound definition for details).
7610
7611         automatic_rotate = 0,
7612         -- Set constant rotation in radians per second, positive or negative.
7613         -- Object rotates along the local Y-axis, and works with set_rotation.
7614         -- Set to 0 to disable constant rotation.
7615
7616         stepheight = 0,
7617         -- If positive number, object will climb upwards when it moves
7618         -- horizontally against a `walkable` node, if the height difference
7619         -- is within `stepheight`.
7620
7621         automatic_face_movement_dir = 0.0,
7622         -- Automatically set yaw to movement direction, offset in degrees.
7623         -- 'false' to disable.
7624
7625         automatic_face_movement_max_rotation_per_sec = -1,
7626         -- Limit automatic rotation to this value in degrees per second.
7627         -- No limit if value <= 0.
7628
7629         backface_culling = true,
7630         -- Set to false to disable backface_culling for model
7631
7632         glow = 0,
7633         -- Add this much extra lighting when calculating texture color.
7634         -- Value < 0 disables light's effect on texture color.
7635         -- For faking self-lighting, UI style entities, or programmatic coloring
7636         -- in mods.
7637
7638         nametag = "",
7639         -- The name to display on the head of the object. By default empty.
7640         -- If the object is a player, a nil or empty nametag is replaced by the player's name.
7641         -- For all other objects, a nil or empty string removes the nametag.
7642         -- To hide a nametag, set its color alpha to zero. That will disable it entirely.
7643
7644         nametag_color = <ColorSpec>,
7645         -- Sets text color of nametag
7646
7647         nametag_bgcolor = <ColorSpec>,
7648         -- Sets background color of nametag
7649         -- `false` will cause the background to be set automatically based on user settings.
7650         -- Default: false
7651
7652         infotext = "",
7653         -- Same as infotext for nodes. Empty by default
7654
7655         static_save = true,
7656         -- If false, never save this object statically. It will simply be
7657         -- deleted when the block gets unloaded.
7658         -- The get_staticdata() callback is never called then.
7659         -- Defaults to 'true'.
7660
7661         damage_texture_modifier = "^[brighten",
7662         -- Texture modifier to be applied for a short duration when object is hit
7663
7664         shaded = true,
7665         -- Setting this to 'false' disables diffuse lighting of entity
7666
7667         show_on_minimap = false,
7668         -- Defaults to true for players, false for other entities.
7669         -- If set to true the entity will show as a marker on the minimap.
7670     }
7671
7672 Entity definition
7673 -----------------
7674
7675 Used by `minetest.register_entity`.
7676
7677     {
7678         initial_properties = {
7679             visual = "mesh",
7680             mesh = "boats_boat.obj",
7681             ...,
7682         },
7683         -- A table of object properties, see the `Object properties` section.
7684         -- The properties in this table are applied to the object
7685         -- once when it is spawned.
7686
7687         -- Refer to the "Registered entities" section for explanations
7688         on_activate = function(self, staticdata, dtime_s),
7689         on_deactivate = function(self, removal),
7690         on_step = function(self, dtime, moveresult),
7691         on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage),
7692         on_death = function(self, killer),
7693         on_rightclick = function(self, clicker),
7694         on_attach_child = function(self, child),
7695         on_detach_child = function(self, child),
7696         on_detach = function(self, parent),
7697         get_staticdata = function(self),
7698
7699         _custom_field = whatever,
7700         -- You can define arbitrary member variables here (see Item definition
7701         -- for more info) by using a '_' prefix
7702     }
7703
7704
7705 ABM (ActiveBlockModifier) definition
7706 ------------------------------------
7707
7708 Used by `minetest.register_abm`.
7709
7710     {
7711         label = "Lava cooling",
7712         -- Descriptive label for profiling purposes (optional).
7713         -- Definitions with identical labels will be listed as one.
7714
7715         nodenames = {"default:lava_source"},
7716         -- Apply `action` function to these nodes.
7717         -- `group:groupname` can also be used here.
7718
7719         neighbors = {"default:water_source", "default:water_flowing"},
7720         -- Only apply `action` to nodes that have one of, or any
7721         -- combination of, these neighbors.
7722         -- If left out or empty, any neighbor will do.
7723         -- `group:groupname` can also be used here.
7724
7725         interval = 1.0,
7726         -- Operation interval in seconds
7727
7728         chance = 1,
7729         -- Chance of triggering `action` per-node per-interval is 1.0 / this
7730         -- value
7731
7732         min_y = -32768,
7733         max_y = 32767,
7734         -- min and max height levels where ABM will be processed (inclusive)
7735         -- can be used to reduce CPU usage
7736
7737         catch_up = true,
7738         -- If true, catch-up behaviour is enabled: The `chance` value is
7739         -- temporarily reduced when returning to an area to simulate time lost
7740         -- by the area being unattended. Note that the `chance` value can often
7741         -- be reduced to 1.
7742
7743         action = function(pos, node, active_object_count, active_object_count_wider),
7744         -- Function triggered for each qualifying node.
7745         -- `active_object_count` is number of active objects in the node's
7746         -- mapblock.
7747         -- `active_object_count_wider` is number of active objects in the node's
7748         -- mapblock plus all 26 neighboring mapblocks. If any neighboring
7749         -- mapblocks are unloaded an estmate is calculated for them based on
7750         -- loaded mapblocks.
7751     }
7752
7753 LBM (LoadingBlockModifier) definition
7754 -------------------------------------
7755
7756 Used by `minetest.register_lbm`.
7757
7758 A loading block modifier (LBM) is used to define a function that is called for
7759 specific nodes (defined by `nodenames`) when a mapblock which contains such nodes
7760 gets activated (not loaded!)
7761
7762     {
7763         label = "Upgrade legacy doors",
7764         -- Descriptive label for profiling purposes (optional).
7765         -- Definitions with identical labels will be listed as one.
7766
7767         name = "modname:replace_legacy_door",
7768         -- Identifier of the LBM, should follow the modname:<whatever> convention
7769
7770         nodenames = {"default:lava_source"},
7771         -- List of node names to trigger the LBM on.
7772         -- Names of non-registered nodes and groups (as group:groupname)
7773         -- will work as well.
7774
7775         run_at_every_load = false,
7776         -- Whether to run the LBM's action every time a block gets activated,
7777         -- and not only the first time the block gets activated after the LBM
7778         -- was introduced.
7779
7780         action = function(pos, node),
7781         -- Function triggered for each qualifying node.
7782     }
7783
7784 Tile definition
7785 ---------------
7786
7787 * `"image.png"`
7788 * `{name="image.png", animation={Tile Animation definition}}`
7789 * `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}`
7790     * backface culling enabled by default for most nodes
7791     * align style determines whether the texture will be rotated with the node
7792       or kept aligned with its surroundings. "user" means that client
7793       setting will be used, similar to `glasslike_framed_optional`.
7794       Note: supported by solid nodes and nodeboxes only.
7795     * scale is used to make texture span several (exactly `scale`) nodes,
7796       instead of just one, in each direction. Works for world-aligned
7797       textures only.
7798       Note that as the effect is applied on per-mapblock basis, `16` should
7799       be equally divisible by `scale` or you may get wrong results.
7800 * `{name="image.png", color=ColorSpec}`
7801     * the texture's color will be multiplied with this color.
7802     * the tile's color overrides the owning node's color in all cases.
7803 * deprecated, yet still supported field names:
7804     * `image` (name)
7805
7806 Tile animation definition
7807 -------------------------
7808
7809     {
7810         type = "vertical_frames",
7811
7812         aspect_w = 16,
7813         -- Width of a frame in pixels
7814
7815         aspect_h = 16,
7816         -- Height of a frame in pixels
7817
7818         length = 3.0,
7819         -- Full loop length
7820     }
7821
7822     {
7823         type = "sheet_2d",
7824
7825         frames_w = 5,
7826         -- Width in number of frames
7827
7828         frames_h = 3,
7829         -- Height in number of frames
7830
7831         frame_length = 0.5,
7832         -- Length of a single frame
7833     }
7834
7835 Item definition
7836 ---------------
7837
7838 Used by `minetest.register_node`, `minetest.register_craftitem`, and
7839 `minetest.register_tool`.
7840
7841     {
7842         description = "",
7843         -- Can contain new lines. "\n" has to be used as new line character.
7844         -- See also: `get_description` in [`ItemStack`]
7845
7846         short_description = "",
7847         -- Must not contain new lines.
7848         -- Defaults to nil.
7849         -- Use an [`ItemStack`] to get the short description, e.g.:
7850         --   ItemStack(itemname):get_short_description()
7851
7852         groups = {},
7853         -- key = name, value = rating; rating = <number>.
7854         -- If rating not applicable, use 1.
7855         -- e.g. {wool = 1, fluffy = 3}
7856         --      {soil = 2, outerspace = 1, crumbly = 1}
7857         --      {bendy = 2, snappy = 1},
7858         --      {hard = 1, metal = 1, spikes = 1}
7859
7860         inventory_image = "",
7861         -- Texture shown in the inventory GUI
7862         -- Defaults to a 3D rendering of the node if left empty.
7863
7864         inventory_overlay = "",
7865         -- An overlay texture which is not affected by colorization
7866
7867         wield_image = "",
7868         -- Texture shown when item is held in hand
7869         -- Defaults to a 3D rendering of the node if left empty.
7870
7871         wield_overlay = "",
7872         -- Like inventory_overlay but only used in the same situation as wield_image
7873
7874         wield_scale = {x = 1, y = 1, z = 1},
7875         -- Scale for the item when held in hand
7876
7877         palette = "",
7878         -- An image file containing the palette of a node.
7879         -- You can set the currently used color as the "palette_index" field of
7880         -- the item stack metadata.
7881         -- The palette is always stretched to fit indices between 0 and 255, to
7882         -- ensure compatibility with "colorfacedir" and "colorwallmounted" nodes.
7883
7884         color = "#ffffffff",
7885         -- Color the item is colorized with. The palette overrides this.
7886
7887         stack_max = 99,
7888         -- Maximum amount of items that can be in a single stack.
7889         -- The default can be changed by the setting `default_stack_max`
7890
7891         range = 4.0,
7892         -- Range of node and object pointing that is possible with this item held
7893
7894         liquids_pointable = false,
7895         -- If true, item can point to all liquid nodes (`liquidtype ~= "none"`),
7896         -- even those for which `pointable = false`
7897
7898         light_source = 0,
7899         -- When used for nodes: Defines amount of light emitted by node.
7900         -- Otherwise: Defines texture glow when viewed as a dropped item
7901         -- To set the maximum (14), use the value 'minetest.LIGHT_MAX'.
7902         -- A value outside the range 0 to minetest.LIGHT_MAX causes undefined
7903         -- behavior.
7904
7905         -- See "Tool Capabilities" section for an example including explanation
7906         tool_capabilities = {
7907             full_punch_interval = 1.0,
7908             max_drop_level = 0,
7909             groupcaps = {
7910                 -- For example:
7911                 choppy = {times = {2.50, 1.40, 1.00}, uses = 20, maxlevel = 2},
7912             },
7913             damage_groups = {groupname = damage},
7914             -- Damage values must be between -32768 and 32767 (2^15)
7915
7916             punch_attack_uses = nil,
7917             -- Amount of uses this tool has for attacking players and entities
7918             -- by punching them (0 = infinite uses).
7919             -- For compatibility, this is automatically set from the first
7920             -- suitable groupcap using the forumla "uses * 3^(maxlevel - 1)".
7921             -- It is recommend to set this explicitly instead of relying on the
7922             -- fallback behavior.
7923         },
7924
7925         node_placement_prediction = nil,
7926         -- If nil and item is node, prediction is made automatically.
7927         -- If nil and item is not a node, no prediction is made.
7928         -- If "" and item is anything, no prediction is made.
7929         -- Otherwise should be name of node which the client immediately places
7930         -- on ground when the player places the item. Server will always update
7931         -- with actual result shortly.
7932
7933         node_dig_prediction = "air",
7934         -- if "", no prediction is made.
7935         -- if "air", node is removed.
7936         -- Otherwise should be name of node which the client immediately places
7937         -- upon digging. Server will always update with actual result shortly.
7938
7939         sound = {
7940             -- Definition of item sounds to be played at various events.
7941             -- All fields in this table are optional.
7942
7943             breaks = <SimpleSoundSpec>,
7944             -- When tool breaks due to wear. Ignored for non-tools
7945
7946             eat = <SimpleSoundSpec>,
7947             -- When item is eaten with `minetest.do_item_eat`
7948         },
7949
7950         on_place = function(itemstack, placer, pointed_thing),
7951         -- When the 'place' key was pressed with the item in hand
7952         -- and a node was pointed at.
7953         -- Shall place item and return the leftover itemstack
7954         -- or nil to not modify the inventory.
7955         -- The placer may be any ObjectRef or nil.
7956         -- default: minetest.item_place
7957
7958         on_secondary_use = function(itemstack, user, pointed_thing),
7959         -- Same as on_place but called when not pointing at a node.
7960         -- Function must return either nil if inventory shall not be modified,
7961         -- or an itemstack to replace the original itemstack.
7962         -- The user may be any ObjectRef or nil.
7963         -- default: nil
7964
7965         on_drop = function(itemstack, dropper, pos),
7966         -- Shall drop item and return the leftover itemstack.
7967         -- The dropper may be any ObjectRef or nil.
7968         -- default: minetest.item_drop
7969
7970         on_use = function(itemstack, user, pointed_thing),
7971         -- default: nil
7972         -- When user pressed the 'punch/mine' key with the item in hand.
7973         -- Function must return either nil if inventory shall not be modified,
7974         -- or an itemstack to replace the original itemstack.
7975         -- e.g. itemstack:take_item(); return itemstack
7976         -- Otherwise, the function is free to do what it wants.
7977         -- The user may be any ObjectRef or nil.
7978         -- The default functions handle regular use cases.
7979
7980         after_use = function(itemstack, user, node, digparams),
7981         -- default: nil
7982         -- If defined, should return an itemstack and will be called instead of
7983         -- wearing out the item (if tool). If returns nil, does nothing.
7984         -- If after_use doesn't exist, it is the same as:
7985         --   function(itemstack, user, node, digparams)
7986         --     itemstack:add_wear(digparams.wear)
7987         --     return itemstack
7988         --   end
7989         -- The user may be any ObjectRef or nil.
7990
7991         _custom_field = whatever,
7992         -- Add your own custom fields. By convention, all custom field names
7993         -- should start with `_` to avoid naming collisions with future engine
7994         -- usage.
7995     }
7996
7997 Node definition
7998 ---------------
7999
8000 Used by `minetest.register_node`.
8001
8002     {
8003         -- <all fields allowed in item definitions>
8004
8005         drawtype = "normal",  -- See "Node drawtypes"
8006
8007         visual_scale = 1.0,
8008         -- Supported for drawtypes "plantlike", "signlike", "torchlike",
8009         -- "firelike", "mesh", "nodebox", "allfaces".
8010         -- For plantlike and firelike, the image will start at the bottom of the
8011         -- node. For torchlike, the image will start at the surface to which the
8012         -- node "attaches". For the other drawtypes the image will be centered
8013         -- on the node.
8014
8015         tiles = {tile definition 1, def2, def3, def4, def5, def6},
8016         -- Textures of node; +Y, -Y, +X, -X, +Z, -Z
8017         -- List can be shortened to needed length.
8018
8019         overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6},
8020         -- Same as `tiles`, but these textures are drawn on top of the base
8021         -- tiles. You can use this to colorize only specific parts of your
8022         -- texture. If the texture name is an empty string, that overlay is not
8023         -- drawn. Since such tiles are drawn twice, it is not recommended to use
8024         -- overlays on very common nodes.
8025
8026         special_tiles = {tile definition 1, Tile definition 2},
8027         -- Special textures of node; used rarely.
8028         -- List can be shortened to needed length.
8029
8030         color = ColorSpec,
8031         -- The node's original color will be multiplied with this color.
8032         -- If the node has a palette, then this setting only has an effect in
8033         -- the inventory and on the wield item.
8034
8035         use_texture_alpha = ...,
8036         -- Specifies how the texture's alpha channel will be used for rendering.
8037         -- possible values:
8038         -- * "opaque": Node is rendered opaque regardless of alpha channel
8039         -- * "clip": A given pixel is either fully see-through or opaque
8040         --           depending on the alpha channel being below/above 50% in value
8041         -- * "blend": The alpha channel specifies how transparent a given pixel
8042         --            of the rendered node is
8043         -- The default is "opaque" for drawtypes normal, liquid and flowingliquid;
8044         -- "clip" otherwise.
8045         -- If set to a boolean value (deprecated): true either sets it to blend
8046         -- or clip, false sets it to clip or opaque mode depending on the drawtype.
8047
8048         palette = "",
8049         -- The node's `param2` is used to select a pixel from the image.
8050         -- Pixels are arranged from left to right and from top to bottom.
8051         -- The node's color will be multiplied with the selected pixel's color.
8052         -- Tiles can override this behavior.
8053         -- Only when `paramtype2` supports palettes.
8054
8055         post_effect_color = "#00000000",
8056         -- Screen tint if player is inside node, see "ColorSpec"
8057
8058         paramtype = "none",  -- See "Nodes"
8059
8060         paramtype2 = "none",  -- See "Nodes"
8061
8062         place_param2 = 0,
8063         -- Value for param2 that is set when player places node
8064
8065         is_ground_content = true,
8066         -- If false, the cave generator and dungeon generator will not carve
8067         -- through this node.
8068         -- Specifically, this stops mod-added nodes being removed by caves and
8069         -- dungeons when those generate in a neighbor mapchunk and extend out
8070         -- beyond the edge of that mapchunk.
8071
8072         sunlight_propagates = false,
8073         -- If true, sunlight will go infinitely through this node
8074
8075         walkable = true,  -- If true, objects collide with node
8076
8077         pointable = true,  -- If true, can be pointed at
8078
8079         diggable = true,  -- If false, can never be dug
8080
8081         climbable = false,  -- If true, can be climbed on like a ladder
8082
8083         move_resistance = 0,
8084         -- Slows down movement of players through this node (max. 7).
8085         -- If this is nil, it will be equal to liquid_viscosity.
8086         -- Note: If liquid movement physics apply to the node
8087         -- (see `liquid_move_physics`), the movement speed will also be
8088         -- affected by the `movement_liquid_*` settings.
8089
8090         buildable_to = false,  -- If true, placed nodes can replace this node
8091
8092         floodable = false,
8093         -- If true, liquids flow into and replace this node.
8094         -- Warning: making a liquid node 'floodable' will cause problems.
8095
8096         liquidtype = "none",  -- specifies liquid flowing physics
8097         -- * "none":    no liquid flowing physics
8098         -- * "source":  spawns flowing liquid nodes at all 4 sides and below;
8099         --              recommended drawtype: "liquid".
8100         -- * "flowing": spawned from source, spawns more flowing liquid nodes
8101         --              around it until `liquid_range` is reached;
8102         --              will drain out without a source;
8103         --              recommended drawtype: "flowingliquid".
8104         -- If it's "source" or "flowing" and `liquid_range > 0`, then
8105         -- both `liquid_alternative_*` fields must be specified
8106
8107         liquid_alternative_flowing = "",
8108         -- Node that represents the flowing version of the liquid
8109
8110         liquid_alternative_source = "",
8111         -- Node that represents the source version of the liquid
8112
8113         liquid_viscosity = 0,
8114         -- Controls speed at which the liquid spreads/flows (max. 7).
8115         -- 0 is fastest, 7 is slowest.
8116         -- By default, this also slows down movement of players inside the node
8117         -- (can be overridden using `move_resistance`)
8118
8119         liquid_renewable = true,
8120         -- If true, a new liquid source can be created by placing two or more
8121         -- sources nearby
8122
8123         liquid_move_physics = nil, -- specifies movement physics if inside node
8124         -- * false: No liquid movement physics apply.
8125         -- * true: Enables liquid movement physics. Enables things like
8126         --   ability to "swim" up/down, sinking slowly if not moving,
8127         --   smoother speed change when falling into, etc. The `movement_liquid_*`
8128         --   settings apply.
8129         -- * nil: Will be treated as true if `liquidype ~= "none"`
8130         --   and as false otherwise.
8131
8132         leveled = 0,
8133         -- Only valid for "nodebox" drawtype with 'type = "leveled"'.
8134         -- Allows defining the nodebox height without using param2.
8135         -- The nodebox height is 'leveled' / 64 nodes.
8136         -- The maximum value of 'leveled' is `leveled_max`.
8137
8138         leveled_max = 127,
8139         -- Maximum value for `leveled` (0-127), enforced in
8140         -- `minetest.set_node_level` and `minetest.add_node_level`.
8141         -- Values above 124 might causes collision detection issues.
8142
8143         liquid_range = 8,
8144         -- Maximum distance that flowing liquid nodes can spread around
8145         -- source on flat land;
8146         -- maximum = 8; set to 0 to disable liquid flow
8147
8148         drowning = 0,
8149         -- Player will take this amount of damage if no bubbles are left
8150
8151         damage_per_second = 0,
8152         -- If player is inside node, this damage is caused
8153
8154         node_box = {type = "regular"},  -- See "Node boxes"
8155
8156         connects_to = {},
8157         -- Used for nodebox nodes with the type == "connected".
8158         -- Specifies to what neighboring nodes connections will be drawn.
8159         -- e.g. `{"group:fence", "default:wood"}` or `"default:stone"`
8160
8161         connect_sides = {},
8162         -- Tells connected nodebox nodes to connect only to these sides of this
8163         -- node. possible: "top", "bottom", "front", "left", "back", "right"
8164
8165         mesh = "",
8166         -- File name of mesh when using "mesh" drawtype
8167
8168         selection_box = {
8169             -- see [Node boxes] for possibilities
8170         },
8171         -- Custom selection box definition. Multiple boxes can be defined.
8172         -- If "nodebox" drawtype is used and selection_box is nil, then node_box
8173         -- definition is used for the selection box.
8174
8175         collision_box = {
8176             -- see [Node boxes] for possibilities
8177         },
8178         -- Custom collision box definition. Multiple boxes can be defined.
8179         -- If "nodebox" drawtype is used and collision_box is nil, then node_box
8180         -- definition is used for the collision box.
8181
8182         -- Support maps made in and before January 2012
8183         legacy_facedir_simple = false,
8184         legacy_wallmounted = false,
8185
8186         waving = 0,
8187         -- Valid for drawtypes:
8188         -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
8189         -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
8190         -- 2 - wave node like leaves (whole node moves side-to-side)
8191         -- 3 - wave node like liquids (whole node moves up and down)
8192         -- Not all models will properly wave.
8193         -- plantlike drawtype can only wave like plants.
8194         -- allfaces_optional drawtype can only wave like leaves.
8195         -- liquid, flowingliquid drawtypes can only wave like liquids.
8196
8197         sounds = {
8198             -- Definition of node sounds to be played at various events.
8199             -- All fields in this table are optional.
8200
8201             footstep = <SimpleSoundSpec>,
8202             -- If walkable, played when object walks on it. If node is
8203             -- climbable or a liquid, played when object moves through it
8204
8205             dig = <SimpleSoundSpec> or "__group",
8206             -- While digging node.
8207             -- If `"__group"`, then the sound will be
8208             -- `default_dig_<groupname>`, where `<groupname>` is the
8209             -- name of the item's digging group with the fastest digging time.
8210             -- In case of a tie, one of the sounds will be played (but we
8211             -- cannot predict which one)
8212             -- Default value: `"__group"`
8213
8214             dug = <SimpleSoundSpec>,
8215             -- Node was dug
8216
8217             place = <SimpleSoundSpec>,
8218             -- Node was placed. Also played after falling
8219
8220             place_failed = <SimpleSoundSpec>,
8221             -- When node placement failed.
8222             -- Note: This happens if the _built-in_ node placement failed.
8223             -- This sound will still be played if the node is placed in the
8224             -- `on_place` callback manually.
8225
8226             fall = <SimpleSoundSpec>,
8227             -- When node starts to fall or is detached
8228         },
8229
8230         drop = "",
8231         -- Name of dropped item when dug.
8232         -- Default dropped item is the node itself.
8233
8234         -- Using a table allows multiple items, drop chances and item filtering:
8235         drop = {
8236             max_items = 1,
8237             -- Maximum number of item lists to drop.
8238             -- The entries in 'items' are processed in order. For each:
8239             -- Item filtering is applied, chance of drop is applied, if both are
8240             -- successful the entire item list is dropped.
8241             -- Entry processing continues until the number of dropped item lists
8242             -- equals 'max_items'.
8243             -- Therefore, entries should progress from low to high drop chance.
8244             items = {
8245                 -- Examples:
8246                 {
8247                     -- 1 in 1000 chance of dropping a diamond.
8248                     -- Default rarity is '1'.
8249                     rarity = 1000,
8250                     items = {"default:diamond"},
8251                 },
8252                 {
8253                     -- Only drop if using an item whose name is identical to one
8254                     -- of these.
8255                     tools = {"default:shovel_mese", "default:shovel_diamond"},
8256                     rarity = 5,
8257                     items = {"default:dirt"},
8258                     -- Whether all items in the dropped item list inherit the
8259                     -- hardware coloring palette color from the dug node.
8260                     -- Default is 'false'.
8261                     inherit_color = true,
8262                 },
8263                 {
8264                     -- Only drop if using an item whose name contains
8265                     -- "default:shovel_" (this item filtering by string matching
8266                     -- is deprecated, use tool_groups instead).
8267                     tools = {"~default:shovel_"},
8268                     rarity = 2,
8269                     -- The item list dropped.
8270                     items = {"default:sand", "default:desert_sand"},
8271                 },
8272                 {
8273                     -- Only drop if using an item in the "magicwand" group, or
8274                     -- an item that is in both the "pickaxe" and the "lucky"
8275                     -- groups.
8276                     tool_groups = {
8277                         "magicwand",
8278                         {"pickaxe", "lucky"}
8279                     },
8280                     items = {"default:coal_lump"},
8281                 },
8282             },
8283         },
8284
8285         on_construct = function(pos),
8286         -- Node constructor; called after adding node.
8287         -- Can set up metadata and stuff like that.
8288         -- Not called for bulk node placement (i.e. schematics and VoxelManip).
8289         -- default: nil
8290
8291         on_destruct = function(pos),
8292         -- Node destructor; called before removing node.
8293         -- Not called for bulk node placement.
8294         -- default: nil
8295
8296         after_destruct = function(pos, oldnode),
8297         -- Node destructor; called after removing node.
8298         -- Not called for bulk node placement.
8299         -- default: nil
8300
8301         on_flood = function(pos, oldnode, newnode),
8302         -- Called when a liquid (newnode) is about to flood oldnode, if it has
8303         -- `floodable = true` in the nodedef. Not called for bulk node placement
8304         -- (i.e. schematics and VoxelManip) or air nodes. If return true the
8305         -- node is not flooded, but on_flood callback will most likely be called
8306         -- over and over again every liquid update interval.
8307         -- Default: nil
8308         -- Warning: making a liquid node 'floodable' will cause problems.
8309
8310         preserve_metadata = function(pos, oldnode, oldmeta, drops),
8311         -- Called when oldnode is about be converted to an item, but before the
8312         -- node is deleted from the world or the drops are added. This is
8313         -- generally the result of either the node being dug or an attached node
8314         -- becoming detached.
8315         -- oldmeta are the metadata fields (table) of the node before deletion.
8316         -- drops is a table of ItemStacks, so any metadata to be preserved can
8317         -- be added directly to one or more of the dropped items. See
8318         -- "ItemStackMetaRef".
8319         -- default: nil
8320
8321         after_place_node = function(pos, placer, itemstack, pointed_thing),
8322         -- Called after constructing node when node was placed using
8323         -- minetest.item_place_node / minetest.place_node.
8324         -- If return true no item is taken from itemstack.
8325         -- `placer` may be any valid ObjectRef or nil.
8326         -- default: nil
8327
8328         after_dig_node = function(pos, oldnode, oldmetadata, digger),
8329         -- oldmetadata is in table format.
8330         -- Called after destructing node when node was dug using
8331         -- minetest.node_dig / minetest.dig_node.
8332         -- default: nil
8333
8334         can_dig = function(pos, [player]),
8335         -- Returns true if node can be dug, or false if not.
8336         -- default: nil
8337
8338         on_punch = function(pos, node, puncher, pointed_thing),
8339         -- default: minetest.node_punch
8340         -- Called when puncher (an ObjectRef) punches the node at pos.
8341         -- By default calls minetest.register_on_punchnode callbacks.
8342
8343         on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
8344         -- default: nil
8345         -- Called when clicker (an ObjectRef) used the 'place/build' key
8346         -- (not neccessarily an actual rightclick)
8347         -- while pointing at the node at pos with 'node' being the node table.
8348         -- itemstack will hold clicker's wielded item.
8349         -- Shall return the leftover itemstack.
8350         -- Note: pointed_thing can be nil, if a mod calls this function.
8351         -- This function does not get triggered by clients <=0.4.16 if the
8352         -- "formspec" node metadata field is set.
8353
8354         on_dig = function(pos, node, digger),
8355         -- default: minetest.node_dig
8356         -- By default checks privileges, wears out item (if tool) and removes node.
8357         -- return true if the node was dug successfully, false otherwise.
8358         -- Deprecated: returning nil is the same as returning true.
8359
8360         on_timer = function(pos, elapsed),
8361         -- default: nil
8362         -- called by NodeTimers, see minetest.get_node_timer and NodeTimerRef.
8363         -- elapsed is the total time passed since the timer was started.
8364         -- return true to run the timer for another cycle with the same timeout
8365         -- value.
8366
8367         on_receive_fields = function(pos, formname, fields, sender),
8368         -- fields = {name1 = value1, name2 = value2, ...}
8369         -- Called when an UI form (e.g. sign text input) returns data.
8370         -- See minetest.register_on_player_receive_fields for more info.
8371         -- default: nil
8372
8373         allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8374         -- Called when a player wants to move items inside the inventory.
8375         -- Return value: number of items allowed to move.
8376
8377         allow_metadata_inventory_put = function(pos, listname, index, stack, player),
8378         -- Called when a player wants to put something into the inventory.
8379         -- Return value: number of items allowed to put.
8380         -- Return value -1: Allow and don't modify item count in inventory.
8381
8382         allow_metadata_inventory_take = function(pos, listname, index, stack, player),
8383         -- Called when a player wants to take something out of the inventory.
8384         -- Return value: number of items allowed to take.
8385         -- Return value -1: Allow and don't modify item count in inventory.
8386
8387         on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
8388         on_metadata_inventory_put = function(pos, listname, index, stack, player),
8389         on_metadata_inventory_take = function(pos, listname, index, stack, player),
8390         -- Called after the actual action has happened, according to what was
8391         -- allowed.
8392         -- No return value.
8393
8394         on_blast = function(pos, intensity),
8395         -- intensity: 1.0 = mid range of regular TNT.
8396         -- If defined, called when an explosion touches the node, instead of
8397         -- removing the node.
8398
8399         mod_origin = "modname",
8400         -- stores which mod actually registered a node
8401         -- If the source could not be determined it contains "??"
8402         -- Useful for getting which mod truly registered something
8403         -- example: if a node is registered as ":othermodname:nodename",
8404         -- nodename will show "othermodname", but mod_orgin will say "modname"
8405     }
8406
8407 Crafting recipes
8408 ----------------
8409
8410 Used by `minetest.register_craft`.
8411
8412 ### Shaped
8413
8414     {
8415         output = "default:pick_stone",
8416         recipe = {
8417             {"default:cobble", "default:cobble", "default:cobble"},
8418             {"", "default:stick", ""},
8419             {"", "default:stick", ""},  -- Also groups; e.g. "group:crumbly"
8420         },
8421         replacements = <list of item pairs>,
8422         -- replacements: replace one input item with another item on crafting
8423         -- (optional).
8424     }
8425
8426 ### Shapeless
8427
8428     {
8429         type = "shapeless",
8430         output = "mushrooms:mushroom_stew",
8431         recipe = {
8432             "mushrooms:bowl",
8433             "mushrooms:mushroom_brown",
8434             "mushrooms:mushroom_red",
8435         },
8436         replacements = <list of item pairs>,
8437     }
8438
8439 ### Tool repair
8440
8441     {
8442         type = "toolrepair",
8443         additional_wear = -0.02, -- multiplier of 65536
8444     }
8445
8446 Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
8447 group. Player can put 2 equal tools in the craft grid to get one "repaired" tool
8448 back.
8449 The wear of the output is determined by the wear of both tools, plus a
8450 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
8451 you want `additional_wear` to be negative.
8452
8453 The formula used to calculate the resulting wear is:
8454
8455     65536 * (1 - ( (1 - tool_1_wear) + (1 - tool_2_wear) + additional_wear ))
8456
8457 The result is rounded and can't be lower than 0. If the result is 65536 or higher,
8458 no crafting is possible.
8459
8460 ### Cooking
8461
8462     {
8463         type = "cooking",
8464         output = "default:glass",
8465         recipe = "default:sand",
8466         cooktime = 3,
8467     }
8468
8469 ### Furnace fuel
8470
8471     {
8472         type = "fuel",
8473         recipe = "bucket:bucket_lava",
8474         burntime = 60,
8475         replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
8476     }
8477
8478 The engine does not implement anything specific to cooking or fuels, but the
8479 recpies can be retrieved later using `minetest.get_craft_result` to have a
8480 consistent interface across different games/mods.
8481
8482 Ore definition
8483 --------------
8484
8485 Used by `minetest.register_ore`.
8486
8487 See [Ores] section above for essential information.
8488
8489     {
8490         ore_type = "",
8491         -- Supported: "scatter", "sheet", "puff", "blob", "vein", "stratum"
8492
8493         ore = "",
8494         -- Ore node to place
8495
8496         ore_param2 = 0,
8497         -- Param2 to set for ore (e.g. facedir rotation)
8498
8499         wherein = "",
8500         -- Node to place ore in. Multiple are possible by passing a list.
8501
8502         clust_scarcity = 8 * 8 * 8,
8503         -- Ore has a 1 out of clust_scarcity chance of spawning in a node.
8504         -- If the desired average distance between ores is 'd', set this to
8505         -- d * d * d.
8506
8507         clust_num_ores = 8,
8508         -- Number of ores in a cluster
8509
8510         clust_size = 3,
8511         -- Size of the bounding box of the cluster.
8512         -- In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
8513         -- nodes are coal ore.
8514
8515         y_min = -31000,
8516         y_max = 31000,
8517         -- Lower and upper limits for ore (inclusive)
8518
8519         flags = "",
8520         -- Attributes for the ore generation, see 'Ore attributes' section above
8521
8522         noise_threshold = 0,
8523         -- If noise is above this threshold, ore is placed. Not needed for a
8524         -- uniform distribution.
8525
8526         noise_params = {
8527             offset = 0,
8528             scale = 1,
8529             spread = {x = 100, y = 100, z = 100},
8530             seed = 23,
8531             octaves = 3,
8532             persistence = 0.7
8533         },
8534         -- NoiseParams structure describing one of the perlin noises used for
8535         -- ore distribution.
8536         -- Needed by "sheet", "puff", "blob" and "vein" ores.
8537         -- Omit from "scatter" ore for a uniform ore distribution.
8538         -- Omit from "stratum" ore for a simple horizontal strata from y_min to
8539         -- y_max.
8540
8541         biomes = {"desert", "rainforest"},
8542         -- List of biomes in which this ore occurs.
8543         -- Occurs in all biomes if this is omitted, and ignored if the Mapgen
8544         -- being used does not support biomes.
8545         -- Can be a list of (or a single) biome names, IDs, or definitions.
8546
8547         -- Type-specific parameters
8548
8549         -- "sheet"
8550         column_height_min = 1,
8551         column_height_max = 16,
8552         column_midpoint_factor = 0.5,
8553
8554         -- "puff"
8555         np_puff_top = {
8556             offset = 4,
8557             scale = 2,
8558             spread = {x = 100, y = 100, z = 100},
8559             seed = 47,
8560             octaves = 3,
8561             persistence = 0.7
8562         },
8563         np_puff_bottom = {
8564             offset = 4,
8565             scale = 2,
8566             spread = {x = 100, y = 100, z = 100},
8567             seed = 11,
8568             octaves = 3,
8569             persistence = 0.7
8570         },
8571
8572         -- "vein"
8573         random_factor = 1.0,
8574
8575         -- "stratum"
8576         np_stratum_thickness = {
8577             offset = 8,
8578             scale = 4,
8579             spread = {x = 100, y = 100, z = 100},
8580             seed = 17,
8581             octaves = 3,
8582             persistence = 0.7
8583         },
8584         stratum_thickness = 8, -- only used if no noise defined
8585     }
8586
8587 Biome definition
8588 ----------------
8589
8590 Used by `minetest.register_biome`.
8591
8592 The maximum number of biomes that can be used is 65535. However, using an
8593 excessive number of biomes will slow down map generation. Depending on desired
8594 performance and computing power the practical limit is much lower.
8595
8596     {
8597         name = "tundra",
8598
8599         node_dust = "default:snow",
8600         -- Node dropped onto upper surface after all else is generated
8601
8602         node_top = "default:dirt_with_snow",
8603         depth_top = 1,
8604         -- Node forming surface layer of biome and thickness of this layer
8605
8606         node_filler = "default:permafrost",
8607         depth_filler = 3,
8608         -- Node forming lower layer of biome and thickness of this layer
8609
8610         node_stone = "default:bluestone",
8611         -- Node that replaces all stone nodes between roughly y_min and y_max.
8612
8613         node_water_top = "default:ice",
8614         depth_water_top = 10,
8615         -- Node forming a surface layer in seawater with the defined thickness
8616
8617         node_water = "",
8618         -- Node that replaces all seawater nodes not in the surface layer
8619
8620         node_river_water = "default:ice",
8621         -- Node that replaces river water in mapgens that use
8622         -- default:river_water
8623
8624         node_riverbed = "default:gravel",
8625         depth_riverbed = 2,
8626         -- Node placed under river water and thickness of this layer
8627
8628         node_cave_liquid = "default:lava_source",
8629         node_cave_liquid = {"default:water_source", "default:lava_source"},
8630         -- Nodes placed inside 50% of the medium size caves.
8631         -- Multiple nodes can be specified, each cave will use a randomly
8632         -- chosen node from the list.
8633         -- If this field is left out or 'nil', cave liquids fall back to
8634         -- classic behaviour of lava and water distributed using 3D noise.
8635         -- For no cave liquid, specify "air".
8636
8637         node_dungeon = "default:cobble",
8638         -- Node used for primary dungeon structure.
8639         -- If absent, dungeon nodes fall back to the 'mapgen_cobble' mapgen
8640         -- alias, if that is also absent, dungeon nodes fall back to the biome
8641         -- 'node_stone'.
8642         -- If present, the following two nodes are also used.
8643
8644         node_dungeon_alt = "default:mossycobble",
8645         -- Node used for randomly-distributed alternative structure nodes.
8646         -- If alternative structure nodes are not wanted leave this absent.
8647
8648         node_dungeon_stair = "stairs:stair_cobble",
8649         -- Node used for dungeon stairs.
8650         -- If absent, stairs fall back to 'node_dungeon'.
8651
8652         y_max = 31000,
8653         y_min = 1,
8654         -- Upper and lower limits for biome.
8655         -- Alternatively you can use xyz limits as shown below.
8656
8657         max_pos = {x = 31000, y = 128, z = 31000},
8658         min_pos = {x = -31000, y = 9, z = -31000},
8659         -- xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
8660         -- Biome is limited to a cuboid defined by these positions.
8661         -- Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
8662         -- 31000 in 'max_pos'.
8663
8664         vertical_blend = 8,
8665         -- Vertical distance in nodes above 'y_max' over which the biome will
8666         -- blend with the biome above.
8667         -- Set to 0 for no vertical blend. Defaults to 0.
8668
8669         heat_point = 0,
8670         humidity_point = 50,
8671         -- Characteristic temperature and humidity for the biome.
8672         -- These values create 'biome points' on a voronoi diagram with heat and
8673         -- humidity as axes. The resulting voronoi cells determine the
8674         -- distribution of the biomes.
8675         -- Heat and humidity have average values of 50, vary mostly between
8676         -- 0 and 100 but can exceed these values.
8677     }
8678
8679 Decoration definition
8680 ---------------------
8681
8682 See [Decoration types]. Used by `minetest.register_decoration`.
8683
8684     {
8685         deco_type = "simple",
8686         -- Type. "simple" or "schematic" supported
8687
8688         place_on = "default:dirt_with_grass",
8689         -- Node (or list of nodes) that the decoration can be placed on
8690
8691         sidelen = 8,
8692         -- Size of the square (X / Z) divisions of the mapchunk being generated.
8693         -- Determines the resolution of noise variation if used.
8694         -- If the chunk size is not evenly divisible by sidelen, sidelen is made
8695         -- equal to the chunk size.
8696
8697         fill_ratio = 0.02,
8698         -- The value determines 'decorations per surface node'.
8699         -- Used only if noise_params is not specified.
8700         -- If >= 10.0 complete coverage is enabled and decoration placement uses
8701         -- a different and much faster method.
8702
8703         noise_params = {
8704             offset = 0,
8705             scale = 0.45,
8706             spread = {x = 100, y = 100, z = 100},
8707             seed = 354,
8708             octaves = 3,
8709             persistence = 0.7,
8710             lacunarity = 2.0,
8711             flags = "absvalue"
8712         },
8713         -- NoiseParams structure describing the perlin noise used for decoration
8714         -- distribution.
8715         -- A noise value is calculated for each square division and determines
8716         -- 'decorations per surface node' within each division.
8717         -- If the noise value >= 10.0 complete coverage is enabled and
8718         -- decoration placement uses a different and much faster method.
8719
8720         biomes = {"Oceanside", "Hills", "Plains"},
8721         -- List of biomes in which this decoration occurs. Occurs in all biomes
8722         -- if this is omitted, and ignored if the Mapgen being used does not
8723         -- support biomes.
8724         -- Can be a list of (or a single) biome names, IDs, or definitions.
8725
8726         y_min = -31000,
8727         y_max = 31000,
8728         -- Lower and upper limits for decoration (inclusive).
8729         -- These parameters refer to the Y co-ordinate of the 'place_on' node.
8730
8731         spawn_by = "default:water",
8732         -- Node (or list of nodes) that the decoration only spawns next to.
8733         -- Checks the 8 neighbouring nodes on the same Y, and also the ones
8734         -- at Y+1, excluding both center nodes.
8735
8736         num_spawn_by = 1,
8737         -- Number of spawn_by nodes that must be surrounding the decoration
8738         -- position to occur.
8739         -- If absent or -1, decorations occur next to any nodes.
8740
8741         flags = "liquid_surface, force_placement, all_floors, all_ceilings",
8742         -- Flags for all decoration types.
8743         -- "liquid_surface": Instead of placement on the highest solid surface
8744         --   in a mapchunk column, placement is on the highest liquid surface.
8745         --   Placement is disabled if solid nodes are found above the liquid
8746         --   surface.
8747         -- "force_placement": Nodes other than "air" and "ignore" are replaced
8748         --   by the decoration.
8749         -- "all_floors", "all_ceilings": Instead of placement on the highest
8750         --   surface in a mapchunk the decoration is placed on all floor and/or
8751         --   ceiling surfaces, for example in caves and dungeons.
8752         --   Ceiling decorations act as an inversion of floor decorations so the
8753         --   effect of 'place_offset_y' is inverted.
8754         --   Y-slice probabilities do not function correctly for ceiling
8755         --   schematic decorations as the behaviour is unchanged.
8756         --   If a single decoration registration has both flags the floor and
8757         --   ceiling decorations will be aligned vertically.
8758
8759         ----- Simple-type parameters
8760
8761         decoration = "default:grass",
8762         -- The node name used as the decoration.
8763         -- If instead a list of strings, a randomly selected node from the list
8764         -- is placed as the decoration.
8765
8766         height = 1,
8767         -- Decoration height in nodes.
8768         -- If height_max is not 0, this is the lower limit of a randomly
8769         -- selected height.
8770
8771         height_max = 0,
8772         -- Upper limit of the randomly selected height.
8773         -- If absent, the parameter 'height' is used as a constant.
8774
8775         param2 = 0,
8776         -- Param2 value of decoration nodes.
8777         -- If param2_max is not 0, this is the lower limit of a randomly
8778         -- selected param2.
8779
8780         param2_max = 0,
8781         -- Upper limit of the randomly selected param2.
8782         -- If absent, the parameter 'param2' is used as a constant.
8783
8784         place_offset_y = 0,
8785         -- Y offset of the decoration base node relative to the standard base
8786         -- node position.
8787         -- Can be positive or negative. Default is 0.
8788         -- Effect is inverted for "all_ceilings" decorations.
8789         -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
8790         -- to the 'place_on' node.
8791
8792         ----- Schematic-type parameters
8793
8794         schematic = "foobar.mts",
8795         -- If schematic is a string, it is the filepath relative to the current
8796         -- working directory of the specified Minetest schematic file.
8797         -- Could also be the ID of a previously registered schematic.
8798
8799         schematic = {
8800             size = {x = 4, y = 6, z = 4},
8801             data = {
8802                 {name = "default:cobble", param1 = 255, param2 = 0},
8803                 {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
8804                 {name = "air", param1 = 255, param2 = 0},
8805                  ...
8806             },
8807             yslice_prob = {
8808                 {ypos = 2, prob = 128},
8809                 {ypos = 5, prob = 64},
8810                  ...
8811             },
8812         },
8813         -- Alternative schematic specification by supplying a table. The fields
8814         -- size and data are mandatory whereas yslice_prob is optional.
8815         -- See 'Schematic specifier' for details.
8816
8817         replacements = {["oldname"] = "convert_to", ...},
8818         -- Map of node names to replace in the schematic after reading it.
8819
8820         flags = "place_center_x, place_center_y, place_center_z",
8821         -- Flags for schematic decorations. See 'Schematic attributes'.
8822
8823         rotation = "90",
8824         -- Rotation can be "0", "90", "180", "270", or "random"
8825
8826         place_offset_y = 0,
8827         -- If the flag 'place_center_y' is set this parameter is ignored.
8828         -- Y offset of the schematic base node layer relative to the 'place_on'
8829         -- node.
8830         -- Can be positive or negative. Default is 0.
8831         -- Effect is inverted for "all_ceilings" decorations.
8832         -- Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
8833         -- to the 'place_on' node.
8834     }
8835
8836 Chat command definition
8837 -----------------------
8838
8839 Used by `minetest.register_chatcommand`.
8840
8841     {
8842         params = "<name> <privilege>",  -- Short parameter description
8843
8844         description = "Remove privilege from player",  -- Full description
8845
8846         privs = {privs=true},  -- Require the "privs" privilege to run
8847
8848         func = function(name, param),
8849         -- Called when command is run. Returns boolean success and text output.
8850         -- Special case: The help message is shown to the player if `func`
8851         -- returns false without a text output.
8852     }
8853
8854 Note that in params, use of symbols is as follows:
8855
8856 * `<>` signifies a placeholder to be replaced when the command is used. For
8857   example, when a player name is needed: `<name>`
8858 * `[]` signifies param is optional and not required when the command is used.
8859   For example, if you require param1 but param2 is optional:
8860   `<param1> [<param2>]`
8861 * `|` signifies exclusive or. The command requires one param from the options
8862   provided. For example: `<param1> | <param2>`
8863 * `()` signifies grouping. For example, when param1 and param2 are both
8864   required, or only param3 is required: `(<param1> <param2>) | <param3>`
8865
8866 Privilege definition
8867 --------------------
8868
8869 Used by `minetest.register_privilege`.
8870
8871     {
8872         description = "",
8873         -- Privilege description
8874
8875         give_to_singleplayer = true,
8876         -- Whether to grant the privilege to singleplayer.
8877
8878         give_to_admin = true,
8879         -- Whether to grant the privilege to the server admin.
8880         -- Uses value of 'give_to_singleplayer' by default.
8881
8882         on_grant = function(name, granter_name),
8883         -- Called when given to player 'name' by 'granter_name'.
8884         -- 'granter_name' will be nil if the priv was granted by a mod.
8885
8886         on_revoke = function(name, revoker_name),
8887         -- Called when taken from player 'name' by 'revoker_name'.
8888         -- 'revoker_name' will be nil if the priv was revoked by a mod.
8889
8890         -- Note that the above two callbacks will be called twice if a player is
8891         -- responsible, once with the player name, and then with a nil player
8892         -- name.
8893         -- Return true in the above callbacks to stop register_on_priv_grant or
8894         -- revoke being called.
8895     }
8896
8897 Detached inventory callbacks
8898 ----------------------------
8899
8900 Used by `minetest.create_detached_inventory`.
8901
8902     {
8903         allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
8904         -- Called when a player wants to move items inside the inventory.
8905         -- Return value: number of items allowed to move.
8906
8907         allow_put = function(inv, listname, index, stack, player),
8908         -- Called when a player wants to put something into the inventory.
8909         -- Return value: number of items allowed to put.
8910         -- Return value -1: Allow and don't modify item count in inventory.
8911
8912         allow_take = function(inv, listname, index, stack, player),
8913         -- Called when a player wants to take something out of the inventory.
8914         -- Return value: number of items allowed to take.
8915         -- Return value -1: Allow and don't modify item count in inventory.
8916
8917         on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
8918         on_put = function(inv, listname, index, stack, player),
8919         on_take = function(inv, listname, index, stack, player),
8920         -- Called after the actual action has happened, according to what was
8921         -- allowed.
8922         -- No return value.
8923     }
8924
8925 HUD Definition
8926 --------------
8927
8928 Since most values have multiple different functions, please see the
8929 documentation in [HUD] section.
8930
8931 Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
8932
8933     {
8934         hud_elem_type = "image",
8935         -- Type of element, can be "image", "text", "statbar", "inventory",
8936         -- "waypoint", "image_waypoint", "compass" or "minimap"
8937
8938         position = {x=0.5, y=0.5},
8939         -- Top left corner position of element
8940
8941         name = "<name>",
8942
8943         scale = {x = 1, y = 1},
8944
8945         text = "<text>",
8946
8947         text2 = "<text>",
8948
8949         number = 0,
8950
8951         item = 0,
8952
8953         direction = 0,
8954         -- Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
8955
8956         alignment = {x=0, y=0},
8957
8958         offset = {x=0, y=0},
8959
8960         world_pos = {x=0, y=0, z=0},
8961
8962         size = {x=0, y=0},
8963
8964         z_index = 0,
8965         -- Z index: lower z-index HUDs are displayed behind higher z-index HUDs
8966
8967         style = 0,
8968     }
8969
8970 Particle definition
8971 -------------------
8972
8973 Used by `minetest.add_particle`.
8974
8975     {
8976         pos = {x=0, y=0, z=0},
8977         velocity = {x=0, y=0, z=0},
8978         acceleration = {x=0, y=0, z=0},
8979         -- Spawn particle at pos with velocity and acceleration
8980
8981         expirationtime = 1,
8982         -- Disappears after expirationtime seconds
8983
8984         size = 1,
8985         -- Scales the visual size of the particle texture.
8986         -- If `node` is set, size can be set to 0 to spawn a randomly-sized
8987         -- particle (just like actual node dig particles).
8988
8989         collisiondetection = false,
8990         -- If true collides with `walkable` nodes and, depending on the
8991         -- `object_collision` field, objects too.
8992
8993         collision_removal = false,
8994         -- If true particle is removed when it collides.
8995         -- Requires collisiondetection = true to have any effect.
8996
8997         object_collision = false,
8998         -- If true particle collides with objects that are defined as
8999         -- `physical = true,` and `collide_with_objects = true,`.
9000         -- Requires collisiondetection = true to have any effect.
9001
9002         vertical = false,
9003         -- If true faces player using y axis only
9004
9005         texture = "image.png",
9006         -- The texture of the particle
9007         -- v5.6.0 and later: also supports the table format described in the
9008         -- following section
9009
9010         playername = "singleplayer",
9011         -- Optional, if specified spawns particle only on the player's client
9012
9013         animation = {Tile Animation definition},
9014         -- Optional, specifies how to animate the particle texture
9015
9016         glow = 0
9017         -- Optional, specify particle self-luminescence in darkness.
9018         -- Values 0-14.
9019
9020         node = {name = "ignore", param2 = 0},
9021         -- Optional, if specified the particle will have the same appearance as
9022         -- node dig particles for the given node.
9023         -- `texture` and `animation` will be ignored if this is set.
9024
9025         node_tile = 0,
9026         -- Optional, only valid in combination with `node`
9027         -- If set to a valid number 1-6, specifies the tile from which the
9028         -- particle texture is picked.
9029         -- Otherwise, the default behavior is used. (currently: any random tile)
9030
9031         drag = {x=0, y=0, z=0},
9032         -- v5.6.0 and later: Optional drag value, consult the following section
9033
9034         bounce = {min = ..., max = ..., bias = 0},
9035         -- v5.6.0 and later: Optional bounce range, consult the following section
9036     }
9037
9038
9039 `ParticleSpawner` definition
9040 ----------------------------
9041
9042 Used by `minetest.add_particlespawner`.
9043
9044 Before v5.6.0, particlespawners used a different syntax and had a more limited set
9045 of features. Definition fields that are the same in both legacy and modern versions
9046 are shown in the next listing, and the fields that are used by legacy versions are
9047 shown separated by a comment; the modern fields are too complex to compactly
9048 describe in this manner and are documented after the listing.
9049
9050 The older syntax can be used in combination with the newer syntax (e.g. having
9051 `minpos`, `maxpos`, and `pos` all set) to support older servers. On newer servers,
9052 the new syntax will override the older syntax; on older servers, the newer syntax
9053 will be ignored.
9054
9055     {
9056         -- Common fields (same name and meaning in both new and legacy syntax)
9057
9058         amount = 1,
9059         -- Number of particles spawned over the time period `time`.
9060
9061         time = 1,
9062         -- Lifespan of spawner in seconds.
9063         -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
9064         -- a per-second basis.
9065
9066         collisiondetection = false,
9067         -- If true collide with `walkable` nodes and, depending on the
9068         -- `object_collision` field, objects too.
9069
9070         collision_removal = false,
9071         -- If true particles are removed when they collide.
9072         -- Requires collisiondetection = true to have any effect.
9073
9074         object_collision = false,
9075         -- If true particles collide with objects that are defined as
9076         -- `physical = true,` and `collide_with_objects = true,`.
9077         -- Requires collisiondetection = true to have any effect.
9078
9079         attached = ObjectRef,
9080         -- If defined, particle positions, velocities and accelerations are
9081         -- relative to this object's position and yaw
9082
9083         vertical = false,
9084         -- If true face player using y axis only
9085
9086         texture = "image.png",
9087         -- The texture of the particle
9088
9089         playername = "singleplayer",
9090         -- Optional, if specified spawns particles only on the player's client
9091
9092         animation = {Tile Animation definition},
9093         -- Optional, specifies how to animate the particles' texture
9094         -- v5.6.0 and later: set length to -1 to sychronize the length
9095         -- of the animation with the expiration time of individual particles.
9096         -- (-2 causes the animation to be played twice, and so on)
9097
9098         glow = 0,
9099         -- Optional, specify particle self-luminescence in darkness.
9100         -- Values 0-14.
9101
9102         node = {name = "ignore", param2 = 0},
9103         -- Optional, if specified the particles will have the same appearance as
9104         -- node dig particles for the given node.
9105         -- `texture` and `animation` will be ignored if this is set.
9106
9107         node_tile = 0,
9108         -- Optional, only valid in combination with `node`
9109         -- If set to a valid number 1-6, specifies the tile from which the
9110         -- particle texture is picked.
9111         -- Otherwise, the default behavior is used. (currently: any random tile)
9112
9113         -- Legacy definition fields
9114
9115         minpos = {x=0, y=0, z=0},
9116         maxpos = {x=0, y=0, z=0},
9117         minvel = {x=0, y=0, z=0},
9118         maxvel = {x=0, y=0, z=0},
9119         minacc = {x=0, y=0, z=0},
9120         maxacc = {x=0, y=0, z=0},
9121         minexptime = 1,
9122         maxexptime = 1,
9123         minsize = 1,
9124         maxsize = 1,
9125         -- The particles' properties are random values between the min and max
9126         -- values.
9127         -- applies to: pos, velocity, acceleration, expirationtime, size
9128         -- If `node` is set, min and maxsize can be set to 0 to spawn
9129         -- randomly-sized particles (just like actual node dig particles).
9130     }
9131
9132 ### Modern definition fields
9133
9134 After v5.6.0, spawner properties can be defined in several different ways depending
9135 on the level of control you need. `pos` for instance can be set as a single vector,
9136 in which case all particles will appear at that exact point throughout the lifetime
9137 of the spawner. Alternately, it can be specified as a min-max pair, specifying a
9138 cubic range the particles can appear randomly within. Finally, some properties can
9139 be animated by suffixing their key with `_tween` (e.g. `pos_tween`) and supplying
9140 a tween table.
9141
9142 The following definitions are all equivalent, listed in order of precedence from
9143 lowest (the legacy syntax) to highest (tween tables). If multiple forms of a
9144 property definition are present, the highest-precidence form will be selected
9145 and all lower-precedence fields will be ignored, allowing for graceful
9146 degradation in older clients).
9147
9148     {
9149       -- old syntax
9150       maxpos = {x = 0, y = 0, z = 0},
9151       minpos = {x = 0, y = 0, z = 0},
9152
9153       -- absolute value
9154       pos = 0,
9155       -- all components of every particle's position vector will be set to this
9156       -- value
9157
9158       -- vec3
9159       pos = vector.new(0,0,0),
9160       -- all particles will appear at this exact position throughout the lifetime
9161       -- of the particlespawner
9162
9163       -- vec3 range
9164       pos = {
9165             -- the particle will appear at a position that is picked at random from
9166             -- within a cubic range
9167
9168             min = vector.new(0,0,0),
9169             -- `min` is the minimum value this property will be set to in particles
9170             -- spawned by the generator
9171
9172             max = vector.new(0,0,0),
9173             -- `max` is the minimum value this property will be set to in particles
9174             -- spawned by the generator
9175
9176             bias = 0,
9177             -- when `bias` is 0, all random values are exactly as likely as any
9178             -- other. when it is positive, the higher it is, the more likely values
9179             -- will appear towards the minimum end of the allowed spectrum. when
9180             -- it is negative, the lower it is, the more likely values will appear
9181             -- towards the maximum end of the allowed spectrum. the curve is
9182             -- exponential and there is no particular maximum or minimum value
9183         },
9184
9185         -- tween table
9186         pos_tween = {...},
9187         -- a tween table should consist of a list of frames in the same form as the
9188         -- untweened pos property above, which the engine will interpolate between,
9189         -- and optionally a number of properties that control how the interpolation
9190         -- takes place. currently **only two frames**, the first and the last, are
9191         -- used, but extra frames are accepted for the sake of forward compatibility.
9192         -- any of the above definition styles can be used here as well in any combination
9193         -- supported by the property type
9194
9195         pos_tween = {
9196             style = "fwd",
9197             -- linear animation from first to last frame (default)
9198             style = "rev",
9199             -- linear animation from last to first frame
9200             style = "pulse",
9201             -- linear animation from first to last then back to first again
9202             style = "flicker",
9203             -- like "pulse", but slightly randomized to add a bit of stutter
9204
9205             reps = 1,
9206             -- number of times the animation is played over the particle's lifespan
9207
9208             start = 0.0,
9209             -- point in the spawner's lifespan at which the animation begins. 0 is
9210             -- the very beginning, 1 is the very end
9211
9212             -- frames can be defined in a number of different ways, depending on the
9213             -- underlying type of the property. for now, all but the first and last
9214             -- frame are ignored
9215
9216             -- frames
9217
9218                 -- floats
9219                 0, 0,
9220
9221                 -- vec3s
9222                 vector.new(0,0,0),
9223                 vector.new(0,0,0),
9224
9225                 -- vec3 ranges
9226                 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9227                 { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9228
9229                 -- mixed
9230                 0, { min = vector.new(0,0,0), max = vector.new(0,0,0), bias = 0 },
9231         },
9232     }
9233
9234 All of the properties that can be defined in this way are listed in the next
9235 section, along with the datatypes they accept.
9236
9237 #### List of particlespawner properties
9238 All of the properties in this list can be animated with `*_tween` tables
9239 unless otherwise specified. For example, `jitter` can be tweened by setting
9240 a `jitter_tween` table instead of (or in addition to) a `jitter` table/value.
9241 Types used are defined in the previous section.
9242
9243 * vec3 range `pos`: the position at which particles can appear
9244 * vec3 range `vel`: the initial velocity of the particle
9245 * vec3 range `acc`: the direction and speed with which the particle
9246   accelerates
9247 * vec3 range `jitter`: offsets the velocity of each particle by a random
9248   amount within the specified range each frame. used to create Brownian motion.
9249 * vec3 range `drag`: the amount by which absolute particle velocity along
9250   each axis is decreased per second.  a value of 1.0 means that the particle
9251   will be slowed to a stop over the space of a second; a value of -1.0 means
9252   that the particle speed will be doubled every second. to avoid interfering
9253   with gravity provided by `acc`, a drag vector like `vector.new(1,0,1)` can
9254   be used instead of a uniform value.
9255 * float range `bounce`: how bouncy the particles are when `collisiondetection`
9256   is turned on. values less than or equal to `0` turn off particle bounce;
9257   `1` makes the particles bounce without losing any velocity, and `2` makes
9258   them double their velocity with every bounce.  `bounce` is not bounded but
9259   values much larger than `1.0` probably aren't very useful.
9260 * float range `exptime`: the number of seconds after which the particle
9261   disappears.
9262 * table `attract`: sets the birth orientation of particles relative to various
9263   shapes defined in world coordinate space. this is an alternative means of
9264   setting the velocity which allows particles to emerge from or enter into
9265   some entity or node on the map, rather than simply being assigned random
9266   velocity values within a range. the velocity calculated by this method will
9267   be **added** to that specified by `vel` if `vel` is also set, so in most
9268   cases **`vel` should be set to 0**. `attract` has the fields:
9269   * string `kind`: selects the kind of shape towards which the particles will
9270     be oriented. it must have one of the following values:
9271     * `"none"`: no attractor is set and the `attractor` table is ignored
9272     * `"point"`: the particles are attracted to a specific point in space.
9273       use this also if you want a sphere-like effect, in combination with
9274       the `radius` property.
9275     * `"line"`: the particles are attracted to an (infinite) line passing
9276       through the points `origin` and `angle`. use this for e.g. beacon
9277       effects, energy beam effects, etc.
9278     * `"plane"`: the particles are attracted to an (infinite) plane on whose
9279       surface `origin` designates a point in world coordinate space. use this
9280       for e.g. particles entering or emerging from a portal.
9281   * float range `strength`: the speed with which particles will move towards
9282     `attractor`. If negative, the particles will instead move away from that
9283     point.
9284   * vec3 `origin`: the origin point of the shape towards which particles will
9285     initially be oriented. functions as an offset if `origin_attached` is also
9286     set.
9287   * vec3 `direction`: sets the direction in which the attractor shape faces. for
9288     lines, this sets the angle of the line; e.g. a vector of (0,1,0) will
9289     create a vertical line that passes through `origin`. for planes, `direction`
9290     is the surface normal of an infinite plane on whose surface `origin` is
9291     a point. functions as an offset if `direction_attached` is also set.
9292   * entity `origin_attached`: allows the origin to be specified as an offset
9293     from the position of an entity rather than a coordinate in world space.
9294   * entity `direction_attached`: allows the direction to be specified as an offset
9295     from the position of an entity rather than a coordinate in world space.
9296   * bool `die_on_contact`: if true, the particles' lifetimes are adjusted so
9297     that they will die as they cross the attractor threshold. this behavior
9298     is the default but is undesirable for some kinds of animations; set it to
9299     false to allow particles to live out their natural lives.
9300 * vec3 range `radius`: if set, particles will be arranged in a sphere around
9301   `pos`. A constant can be used to create a spherical shell of particles, a
9302   vector to create an ovoid shell, and a range to create a volume; e.g.
9303   `{min = 0.5, max = 1, bias = 1}` will allow particles to appear between 0.5
9304   and 1 nodes away from `pos` but will cluster them towards the center of the
9305   sphere. Usually if `radius` is used, `pos` should be a single point, but it
9306   can still be a range if you really know what you're doing (e.g. to create a
9307   "roundcube" emitter volume).
9308
9309 ### Textures
9310
9311 In versions before v5.6.0, particlespawner textures could only be specified as a single
9312 texture string. After v5.6.0, textures can now be specified as a table as well. This
9313 table contains options that allow simple animations to be applied to the texture.
9314
9315     texture = {
9316         name = "mymod_particle_texture.png",
9317         -- the texture specification string
9318
9319         alpha = 1.0,
9320         -- controls how visible the particle is; at 1.0 the particle is fully
9321         -- visible, at 0, it is completely invisible.
9322
9323         alpha_tween = {1, 0},
9324         -- can be used instead of `alpha` to animate the alpha value over the
9325         -- particle's lifetime. these tween tables work identically to the tween
9326         -- tables used in particlespawner properties, except that time references
9327         -- are understood with respect to the particle's lifetime, not the
9328         -- spawner's. {1,0} fades the particle out over its lifetime.
9329
9330         scale = 1,
9331         scale = {x = 1, y = 1},
9332         -- scales the texture onscreen
9333
9334         scale_tween = {
9335             {x = 1, y = 1},
9336             {x = 0, y = 1},
9337         },
9338         -- animates the scale over the particle's lifetime. works like the
9339         -- alpha_tween table, but can accept two-dimensional vectors as well as
9340         -- integer values. the example value would cause the particle to shrink
9341         -- in one dimension over the course of its life until it disappears
9342
9343         blend = "alpha",
9344         -- (default) blends transparent pixels with those they are drawn atop
9345         -- according to the alpha channel of the source texture. useful for
9346         -- e.g. material objects like rocks, dirt, smoke, or node chunks
9347         blend = "add",
9348         -- adds the value of pixels to those underneath them, modulo the sources
9349         -- alpha channel. useful for e.g. bright light effects like sparks or fire
9350         blend = "screen",
9351         -- like "add" but less bright. useful for subtler light effecs. note that
9352         -- this is NOT formally equivalent to the "screen" effect used in image
9353         -- editors and compositors, as it does not respect the alpha channel of
9354         -- of the image being blended
9355         blend = "sub",
9356         -- the inverse of "add"; the value of the source pixel is subtracted from
9357         -- the pixel underneath it. a white pixel will turn whatever is underneath
9358         -- it black; a black pixel will be "transparent". useful for creating
9359         -- darkening effects
9360
9361         animation = {Tile Animation definition},
9362         -- overrides the particlespawner's global animation property for a single
9363         -- specific texture
9364     }
9365
9366 Instead of setting a single texture definition, it is also possible to set a
9367 `texpool` property. A `texpool` consists of a list of possible particle textures.
9368 Every time a particle is spawned, the engine will pick a texture at random from
9369 the `texpool` and assign it as that particle's texture. You can also specify a
9370 `texture` in addition to a `texpool`; the `texture` value will be ignored on newer
9371 clients but will be sent to older (pre-v5.6.0) clients that do not implement
9372 texpools.
9373
9374     texpool = {
9375         "mymod_particle_texture.png";
9376         { name = "mymod_spark.png", fade = "out" },
9377         {
9378           name = "mymod_dust.png",
9379           alpha = 0.3,
9380           scale = 1.5,
9381           animation = {
9382                 type = "vertical_frames",
9383                 aspect_w = 16, aspect_h = 16,
9384
9385                 length = 3,
9386                 -- the animation lasts for 3s and then repeats
9387                 length = -3,
9388                 -- repeat the animation three times over the particle's lifetime
9389                 -- (post-v5.6.0 clients only)
9390           },
9391         },
9392   }
9393
9394 #### List of animatable texture properties
9395
9396 While animated particlespawner values vary over the course of the particlespawner's
9397 lifetime, animated texture properties vary over the lifespans of the individual
9398 particles spawned with that texture. So a particle with the texture property
9399
9400     alpha_tween = {
9401         0.0, 1.0,
9402         style = "pulse",
9403         reps = 4,
9404     }
9405
9406 would be invisible at its spawning, pulse visible four times throughout its
9407 lifespan, and then vanish again before expiring.
9408
9409 * float `alpha` (0.0 - 1.0): controls the visibility of the texture
9410 * vec2 `scale`: controls the size of the displayed billboard onscreen. Its units
9411   are multiples of the parent particle's assigned size (see the `size` property above)
9412
9413 `HTTPRequest` definition
9414 ------------------------
9415
9416 Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
9417
9418     {
9419         url = "http://example.org",
9420
9421         timeout = 10,
9422         -- Timeout for request to be completed in seconds. Default depends on engine settings.
9423
9424         method = "GET", "POST", "PUT" or "DELETE"
9425         -- The http method to use. Defaults to "GET".
9426
9427         data = "Raw request data string" OR {field1 = "data1", field2 = "data2"},
9428         -- Data for the POST, PUT or DELETE request.
9429         -- Accepts both a string and a table. If a table is specified, encodes
9430         -- table as x-www-form-urlencoded key-value pairs.
9431
9432         user_agent = "ExampleUserAgent",
9433         -- Optional, if specified replaces the default minetest user agent with
9434         -- given string
9435
9436         extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
9437         -- Optional, if specified adds additional headers to the HTTP request.
9438         -- You must make sure that the header strings follow HTTP specification
9439         -- ("Key: Value").
9440
9441         multipart = boolean
9442         -- Optional, if true performs a multipart HTTP request.
9443         -- Default is false.
9444         -- Post only, data must be array
9445
9446         post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
9447         -- Deprecated, use `data` instead. Forces `method = "POST"`.
9448     }
9449
9450 `HTTPRequestResult` definition
9451 ------------------------------
9452
9453 Passed to `HTTPApiTable.fetch` callback. Returned by
9454 `HTTPApiTable.fetch_async_get`.
9455
9456     {
9457         completed = true,
9458         -- If true, the request has finished (either succeeded, failed or timed
9459         -- out)
9460
9461         succeeded = true,
9462         -- If true, the request was successful
9463
9464         timeout = false,
9465         -- If true, the request timed out
9466
9467         code = 200,
9468         -- HTTP status code
9469
9470         data = "response"
9471     }
9472
9473 Authentication handler definition
9474 ---------------------------------
9475
9476 Used by `minetest.register_authentication_handler`.
9477
9478     {
9479         get_auth = function(name),
9480         -- Get authentication data for existing player `name` (`nil` if player
9481         -- doesn't exist).
9482         -- Returns following structure:
9483         -- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
9484
9485         create_auth = function(name, password),
9486         -- Create new auth data for player `name`.
9487         -- Note that `password` is not plain-text but an arbitrary
9488         -- representation decided by the engine.
9489
9490         delete_auth = function(name),
9491         -- Delete auth data of player `name`.
9492         -- Returns boolean indicating success (false if player is nonexistent).
9493
9494         set_password = function(name, password),
9495         -- Set password of player `name` to `password`.
9496         -- Auth data should be created if not present.
9497
9498         set_privileges = function(name, privileges),
9499         -- Set privileges of player `name`.
9500         -- `privileges` is in table form, auth data should be created if not
9501         -- present.
9502
9503         reload = function(),
9504         -- Reload authentication data from the storage location.
9505         -- Returns boolean indicating success.
9506
9507         record_login = function(name),
9508         -- Called when player joins, used for keeping track of last_login
9509
9510         iterate = function(),
9511         -- Returns an iterator (use with `for` loops) for all player names
9512         -- currently in the auth database
9513     }
9514
9515 Bit Library
9516 -----------
9517
9518 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
9519
9520 See http://bitop.luajit.org/ for advanced information.