Update mip mapping and textarea documentation (#7315)
[oweals/minetest.git] / doc / lua_api.txt
1 Minetest Lua Modding API Reference
2 ==================================
3 * More information at <http://www.minetest.net/>
4 * Developer Wiki: <http://dev.minetest.net/>
5
6
7 Introduction
8 ============
9
10 Content and functionality can be added to Minetest using Lua scripting
11 in run-time loaded mods.
12
13 A mod is a self-contained bunch of scripts, textures and other related
14 things, which is loaded by and interfaces with Minetest.
15
16 Mods are contained and ran solely on the server side. Definitions and media
17 files are automatically transferred to the client.
18
19 If you see a deficiency in the API, feel free to attempt to add the
20 functionality in the engine and API, and to document it here.
21
22 Programming in Lua
23 ------------------
24 If you have any difficulty in understanding this, please read
25 [Programming in Lua](http://www.lua.org/pil/).
26
27 Startup
28 -------
29 Mods are loaded during server startup from the mod load paths by running
30 the `init.lua` scripts in a shared environment.
31
32 Paths
33 -----
34 * `RUN_IN_PLACE=1` (Windows release, local build)
35     * `$path_user`: `<build directory>`
36     * `$path_share`: `<build directory>`
37 * `RUN_IN_PLACE=0`: (Linux release)
38     * `$path_share`:
39         * Linux: `/usr/share/minetest`
40         * Windows: `<install directory>/minetest-0.4.x`
41     * `$path_user`:
42         * Linux: `$HOME/.minetest`
43         * Windows: `C:/users/<user>/AppData/minetest` (maybe)
44
45
46
47
48 Games
49 =====
50
51 Games are looked up from:
52
53 * `$path_share/games/gameid/`
54 * `$path_user/games/gameid/`
55
56 Where `gameid` is unique to each game.
57
58 The game directory can contain the following files:
59
60 * `game.conf`, with the following keys:
61     * `name` - required, human readable name  e.g. `name = Minetest`
62     * `description` - Short description to be shown in the content tab
63     * `disallowed_mapgens = <comma-separated mapgens>`
64       e.g. `disallowed_mapgens = v5,v6,flat`
65       These mapgens are removed from the list of mapgens for the game.
66 * `minetest.conf`:
67   Used to set default settings when running this game.
68 * `settingtypes.txt`:
69   In the same format as the one in builtin.
70   This settingtypes.txt will be parsed by the menu and the settings will be
71   displayed in the "Games" category in the advanced settings tab.
72 * If the game contains a folder called `textures` the server will load it as a
73   texturepack, overriding mod textures.
74   Any server texturepack will override mod textures and the game texturepack.
75
76 Menu images
77 -----------
78
79 Games can provide custom main menu images. They are put inside a `menu`
80 directory inside the game directory.
81
82 The images are named `$identifier.png`, where `$identifier` is one of
83 `overlay`, `background`, `footer`, `header`.
84 If you want to specify multiple images for one identifier, add additional
85 images named like `$identifier.$n.png`, with an ascending number $n starting
86 with 1, and a random image will be chosen from the provided ones.
87
88
89
90
91 Mods
92 ====
93
94 Mod load path
95 -------------
96 Generic:
97
98 * `$path_share/games/gameid/mods/`
99 * `$path_share/mods/`
100 * `$path_user/games/gameid/mods/`
101 * `$path_user/mods/` (User-installed mods)
102 * `$worldpath/worldmods/`
103
104 In a run-in-place version (e.g. the distributed windows version):
105
106 * `minetest-0.4.x/games/gameid/mods/`
107 * `minetest-0.4.x/mods/` (User-installed mods)
108 * `minetest-0.4.x/worlds/worldname/worldmods/`
109
110 On an installed version on Linux:
111
112 * `/usr/share/minetest/games/gameid/mods/`
113 * `$HOME/.minetest/mods/` (User-installed mods)
114 * `$HOME/.minetest/worlds/worldname/worldmods`
115
116 Mod load path for world-specific games
117 --------------------------------------
118 It is possible to include a game in a world; in this case, no mods or
119 games are loaded or checked from anywhere else.
120
121 This is useful for e.g. adventure worlds.
122
123 This happens if the following directory exists:
124
125     $world/game/
126
127 Mods should then be placed in:
128
129     $world/game/mods/
130
131 Modpack support
132 ----------------
133 Mods can be put in a subdirectory, if the parent directory, which otherwise
134 should be a mod, contains a file named `modpack.txt`. This file shall be
135 empty, except for lines starting with `#`, which are comments.
136
137 Mod directory structure
138 -----------------------
139
140     mods
141     ├── modname
142     │   ├── mod.conf
143     │   ├── screenshot.png
144     │   ├── settingtypes.txt
145     │   ├── init.lua
146     │   ├── models
147     │   ├── textures
148     │   │   ├── modname_stuff.png
149     │   │   └── modname_something_else.png
150     │   ├── sounds
151     │   ├── media
152     │   ├── locale
153     │   └── <custom data>
154     └── another
155
156 ### modname
157 The location of this directory can be fetched by using
158 `minetest.get_modpath(modname)`.
159
160 ### mod.conf
161 A key-value store of mod details.
162
163 * `name` - the mod name. Allows Minetest to determine the mod name even if the
164            folder is wrongly named.
165 * `description` - Description of mod to be shown in the Mods tab of the mainmenu.
166 * `depends` - A comma separated list of dependencies. These are mods that must
167               be loaded before this mod.
168 * `optional_depends` - A comma separated list of optional dependencies.
169                        Like a dependency, but no error if the mod doesn't exist.
170
171 Note: to support 0.4.x, please also provide depends.txt.
172
173 ### `screenshot.png`
174 A screenshot shown in the mod manager within the main menu. It should
175 have an aspect ratio of 3:2 and a minimum size of 300×200 pixels.
176
177 ### `depends.txt`
178 **Deprecated:** you should use mod.conf instead.
179
180 This file is used if there are no dependencies in mod.conf.
181
182 List of mods that have to be loaded before loading this mod.
183
184 A single line contains a single modname.
185
186 Optional dependencies can be defined by appending a question mark
187 to a single modname. This means that if the specified mod
188 is missing, it does not prevent this mod from being loaded.
189
190 ### `description.txt`
191 **Deprecated:** you should use mod.conf instead.
192
193 This file is used if there is no description in mod.conf.
194
195 A file containing a description to be shown in the Mods tab of the mainmenu.
196
197 ### `settingtypes.txt`
198 A file in the same format as the one in builtin. It will be parsed by the
199 settings menu and the settings will be displayed in the "Mods" category.
200
201 ### `init.lua`
202 The main Lua script. Running this script should register everything it
203 wants to register. Subsequent execution depends on minetest calling the
204 registered callbacks.
205
206 `minetest.settings` can be used to read custom or existing settings at load
207 time, if necessary. (See `Settings`)
208
209 ### `models`
210 Models for entities or meshnodes.
211
212 ### `textures`, `sounds`, `media`
213 Media files (textures, sounds, whatever) that will be transferred to the
214 client and will be available for use by the mod.
215
216 ### `locale`
217 Translation files for the clients. (See `Translations`)
218
219 Naming convention for registered textual names
220 ----------------------------------------------
221 Registered names should generally be in this format:
222
223     `modname:<whatever>`
224
225 `<whatever>` can have these characters:
226
227     a-zA-Z0-9_
228
229 This is to prevent conflicting names from corrupting maps and is
230 enforced by the mod loader.
231
232 ### Example
233 In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
234 So the name should be `experimental:tnt`.
235
236 Enforcement can be overridden by prefixing the name with `:`. This can
237 be used for overriding the registrations of some other mod.
238
239 Example: Any mod can redefine `experimental:tnt` by using the name
240
241     :experimental:tnt
242
243 when registering it.
244 (also that mod is required to have `experimental` as a dependency)
245
246 The `:` prefix can also be used for maintaining backwards compatibility.
247
248
249
250
251 Aliases
252 =======
253
254 Aliases can be added by using `minetest.register_alias(name, convert_to)` or
255 `minetest.register_alias_force(name, convert_to)`.
256
257 This converts anything called `name` to `convert_to`.
258
259 The only difference between `minetest.register_alias` and
260 `minetest.register_alias_force` is that if an item called `name` exists,
261 `minetest.register_alias` will do nothing while
262 `minetest.register_alias_force` will unregister it.
263
264 This can be used for maintaining backwards compatibility.
265
266 This can also set quick access names for things, e.g. if
267 you have an item called `epiclylongmodname:stuff`, you could do
268
269     minetest.register_alias("stuff", "epiclylongmodname:stuff")
270
271 and be able to use `/giveme stuff`.
272
273 Mapgen aliases
274 --------------
275 In a game, a certain number of these must be set to tell core mapgens which
276 of the game's nodes are to be used by the core mapgens. For example:
277
278     minetest.register_alias("mapgen_stone", "default:stone")
279
280 ### Aliases needed for all mapgens except Mapgen v6
281
282 #### Base terrain
283 * mapgen_stone
284 * mapgen_water_source
285 * mapgen_river_water_source
286
287 #### Caves
288 * mapgen_lava_source
289
290 #### Dungeons
291 Only needed for registered biomes where 'node_stone' is stone:
292
293 * mapgen_cobble
294 * mapgen_stair_cobble
295 * mapgen_mossycobble
296
297 Only needed for registered biomes where 'node_stone' is desert stone:
298
299 * mapgen_desert_stone
300 * mapgen_stair_desert_stone
301
302 Only needed for registered biomes where 'node_stone' is sandstone:
303
304 * mapgen_sandstone
305 * mapgen_sandstonebrick
306 * mapgen_stair_sandstone_block
307
308 ### Aliases needed for Mapgen v6
309
310 #### Terrain and biomes
311 * mapgen_stone
312 * mapgen_water_source
313 * mapgen_lava_source
314 * mapgen_dirt
315 * mapgen_dirt_with_grass
316 * mapgen_sand
317 * mapgen_gravel
318 * mapgen_desert_stone
319 * mapgen_desert_sand
320 * mapgen_dirt_with_snow
321 * mapgen_snowblock
322 * mapgen_snow
323 * mapgen_ice
324
325 #### Flora
326 * mapgen_tree
327 * mapgen_leaves
328 * mapgen_apple
329 * mapgen_jungletree
330 * mapgen_jungleleaves
331 * mapgen_junglegrass
332 * mapgen_pine_tree
333 * mapgen_pine_needles
334
335 #### Dungeons
336 * mapgen_cobble
337 * mapgen_stair_cobble
338 * mapgen_mossycobble
339 * mapgen_stair_desert_stone
340
341
342
343
344 Textures
345 ========
346
347 Mods should generally prefix their textures with `modname_`, e.g. given
348 the mod name `foomod`, a texture could be called:
349
350     foomod_foothing.png
351
352 Textures are referred to by their complete name, or alternatively by
353 stripping out the file extension:
354
355 * e.g. `foomod_foothing.png`
356 * e.g. `foomod_foothing`
357
358 Texture modifiers
359 -----------------
360 There are various texture modifiers that can be used
361 to generate textures on-the-fly.
362
363 ### Texture overlaying
364 Textures can be overlaid by putting a `^` between them.
365
366 Example:
367
368     default_dirt.png^default_grass_side.png
369
370 `default_grass_side.png` is overlaid over `default_dirt.png`.
371 The texture with the lower resolution will be automatically upscaled to
372 the higher resolution texture.
373
374 ### Texture grouping
375 Textures can be grouped together by enclosing them in `(` and `)`.
376
377 Example: `cobble.png^(thing1.png^thing2.png)`
378
379 A texture for `thing1.png^thing2.png` is created and the resulting
380 texture is overlaid on top of `cobble.png`.
381
382 ### Escaping
383 Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow
384 passing complex texture names as arguments. Escaping is done with backslash and
385 is required for `^` and `:`.
386
387 Example: `cobble.png^[lowpart:50:color.png\^[mask\:trans.png`
388
389 The lower 50 percent of `color.png^[mask:trans.png` are overlaid
390 on top of `cobble.png`.
391
392 ### Advanced texture modifiers
393
394 #### Crack
395 * `[crack:<n>:<p>`
396 * `[cracko:<n>:<p>`
397 * `[crack:<t>:<n>:<p>`
398 * `[cracko:<t>:<n>:<p>`
399
400 Parameters:
401
402 * `<t>` = tile count (in each direction)
403 * `<n>` = animation frame count
404 * `<p>` = current animation frame
405
406 Draw a step of the crack animation on the texture.
407 `crack` draws it normally, while `cracko` lays it over, keeping transparent
408 pixels intact.
409
410 Example:
411
412     default_cobble.png^[crack:10:1
413
414 #### `[combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>:...`
415 * `<w>` = width
416 * `<h>` = height
417 * `<x>` = x position
418 * `<y>` = y position
419 * `<file>` = texture to combine
420
421 Creates a texture of size `<w>` times `<h>` and blits the listed files to their
422 specified coordinates.
423
424 Example:
425
426     [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
427
428 #### `[resize:<w>x<h>`
429 Resizes the texture to the given dimensions.
430
431 Example:
432
433     default_sandstone.png^[resize:16x16
434
435 #### `[opacity:<r>`
436 Makes the base image transparent according to the given ratio.
437
438 `r` must be between 0 and 255.
439 0 means totally transparent. 255 means totally opaque.
440
441 Example:
442
443     default_sandstone.png^[opacity:127
444
445 #### `[invert:<mode>`
446 Inverts the given channels of the base image.
447 Mode may contain the characters "r", "g", "b", "a".
448 Only the channels that are mentioned in the mode string will be inverted.
449
450 Example:
451
452     default_apple.png^[invert:rgb
453
454 #### `[brighten`
455 Brightens the texture.
456
457 Example:
458
459     tnt_tnt_side.png^[brighten
460
461 #### `[noalpha`
462 Makes the texture completely opaque.
463
464 Example:
465
466     default_leaves.png^[noalpha
467
468 #### `[makealpha:<r>,<g>,<b>`
469 Convert one color to transparency.
470
471 Example:
472
473     default_cobble.png^[makealpha:128,128,128
474
475 #### `[transform<t>`
476 * `<t>` = transformation(s) to apply
477
478 Rotates and/or flips the image.
479
480 `<t>` can be a number (between 0 and 7) or a transform name.
481 Rotations are counter-clockwise.
482
483     0  I      identity
484     1  R90    rotate by 90 degrees
485     2  R180   rotate by 180 degrees
486     3  R270   rotate by 270 degrees
487     4  FX     flip X
488     5  FXR90  flip X then rotate by 90 degrees
489     6  FY     flip Y
490     7  FYR90  flip Y then rotate by 90 degrees
491
492 Example:
493
494     default_stone.png^[transformFXR90
495
496 #### `[inventorycube{<top>{<left>{<right>`
497 Escaping does not apply here and `^` is replaced by `&` in texture names
498 instead.
499
500 Create an inventory cube texture using the side textures.
501
502 Example:
503
504     [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
505
506 Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and
507 `dirt.png^grass_side.png` textures
508
509 #### `[lowpart:<percent>:<file>`
510 Blit the lower `<percent>`% part of `<file>` on the texture.
511
512 Example:
513
514     base.png^[lowpart:25:overlay.png
515
516 #### `[verticalframe:<t>:<n>`
517 * `<t>` = animation frame count
518 * `<n>` = current animation frame
519
520 Crops the texture to a frame of a vertical animation.
521
522 Example:
523
524     default_torch_animated.png^[verticalframe:16:8
525
526 #### `[mask:<file>`
527 Apply a mask to the base image.
528
529 The mask is applied using binary AND.
530
531 #### `[sheet:<w>x<h>:<x>,<y>`
532 Retrieves a tile at position x,y from the base image
533 which it assumes to be a tilesheet with dimensions w,h.
534
535 #### `[colorize:<color>:<ratio>`
536 Colorize the textures with the given color.
537 `<color>` is specified as a `ColorString`.
538 `<ratio>` is an int ranging from 0 to 255 or the word "`alpha`".  If
539 it is an int, then it specifies how far to interpolate between the
540 colors where 0 is only the texture color and 255 is only `<color>`. If
541 omitted, the alpha of `<color>` will be used as the ratio.  If it is
542 the word "`alpha`", then each texture pixel will contain the RGB of
543 `<color>` and the alpha of `<color>` multiplied by the alpha of the
544 texture pixel.
545
546 #### `[multiply:<color>`
547 Multiplies texture colors with the given color.
548 `<color>` is specified as a `ColorString`.
549 Result is more like what you'd expect if you put a color on top of another
550 color. Meaning white surfaces get a lot of your new color while black parts
551 don't change very much.
552
553 Hardware coloring
554 -----------------
555 The goal of hardware coloring is to simplify the creation of
556 colorful nodes. If your textures use the same pattern, and they only
557 differ in their color (like colored wool blocks), you can use hardware
558 coloring instead of creating and managing many texture files.
559 All of these methods use color multiplication (so a white-black texture
560 with red coloring will result in red-black color).
561
562 ### Static coloring
563 This method is useful if you wish to create nodes/items with
564 the same texture, in different colors, each in a new node/item definition.
565
566 #### Global color
567 When you register an item or node, set its `color` field (which accepts a
568 `ColorSpec`) to the desired color.
569
570 An `ItemStack`'s static color can be overwritten by the `color` metadata
571 field. If you set that field to a `ColorString`, that color will be used.
572
573 #### Tile color
574 Each tile may have an individual static color, which overwrites every
575 other coloring method. To disable the coloring of a face,
576 set its color to white (because multiplying with white does nothing).
577 You can set the `color` property of the tiles in the node's definition
578 if the tile is in table format.
579
580 ### Palettes
581 For nodes and items which can have many colors, a palette is more
582 suitable. A palette is a texture, which can contain up to 256 pixels.
583 Each pixel is one possible color for the node/item.
584 You can register one node/item, which can have up to 256 colors.
585
586 #### Palette indexing
587 When using palettes, you always provide a pixel index for the given
588 node or `ItemStack`. The palette is read from left to right and from
589 top to bottom. If the palette has less than 256 pixels, then it is
590 stretched to contain exactly 256 pixels (after arranging the pixels
591 to one line). The indexing starts from 0.
592
593 Examples:
594
595 * 16x16 palette, index = 0: the top left corner
596 * 16x16 palette, index = 4: the fifth pixel in the first row
597 * 16x16 palette, index = 16: the pixel below the top left corner
598 * 16x16 palette, index = 255: the bottom right corner
599 * 2 (width)x4 (height) palette, index=31: the top left corner.
600   The palette has 8 pixels, so each pixel is stretched to 32 pixels,
601   to ensure the total 256 pixels.
602 * 2x4 palette, index=32: the top right corner
603 * 2x4 palette, index=63: the top right corner
604 * 2x4 palette, index=64: the pixel below the top left corner
605
606 #### Using palettes with items
607 When registering an item, set the item definition's `palette` field to
608 a texture. You can also use texture modifiers.
609
610 The `ItemStack`'s color depends on the `palette_index` field of the
611 stack's metadata. `palette_index` is an integer, which specifies the
612 index of the pixel to use.
613
614 #### Linking palettes with nodes
615 When registering a node, set the item definition's `palette` field to
616 a texture. You can also use texture modifiers.
617 The node's color depends on its `param2`, so you also must set an
618 appropriate `paramtype2`:
619
620 * `paramtype2 = "color"` for nodes which use their full `param2` for
621   palette indexing. These nodes can have 256 different colors.
622   The palette should contain 256 pixels.
623 * `paramtype2 = "colorwallmounted"` for nodes which use the first
624   five bits (most significant) of `param2` for palette indexing.
625   The remaining three bits are describing rotation, as in `wallmounted`
626   paramtype2. Division by 8 yields the palette index (without stretching the
627   palette). These nodes can have 32 different colors, and the palette
628   should contain 32 pixels.
629   Examples:
630     * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1)
631       pixel will be picked from the palette.
632     * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1)
633       pixel will be picked from the palette.
634 * `paramtype2 = "colorfacedir"` for nodes which use the first
635   three bits of `param2` for palette indexing. The remaining
636   five bits are describing rotation, as in `facedir` paramtype2.
637   Division by 32 yields the palette index (without stretching the
638   palette). These nodes can have 8 different colors, and the
639   palette should contain 8 pixels.
640   Examples:
641     * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the
642       first (= 0 + 1) pixel will be picked from the palette.
643     * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the
644       second (= 1 + 1) pixel will be picked from the palette.
645
646 To colorize a node on the map, set its `param2` value (according
647 to the node's paramtype2).
648
649 ### Conversion between nodes in the inventory and the on the map
650 Static coloring is the same for both cases, there is no need
651 for conversion.
652
653 If the `ItemStack`'s metadata contains the `color` field, it will be
654 lost on placement, because nodes on the map can only use palettes.
655
656 If the `ItemStack`'s metadata contains the `palette_index` field, it is
657 automatically transferred between node and item forms by the engine,
658 when a player digs or places a colored node.
659 You can disable this feature by setting the `drop` field of the node
660 to itself (without metadata).
661 To transfer the color to a special drop, you need a drop table.
662
663 Example:
664
665     minetest.register_node("mod:stone", {
666         description = "Stone",
667         tiles = {"default_stone.png"},
668         paramtype2 = "color",
669         palette = "palette.png",
670         drop = {
671             items = {
672                 -- assume that mod:cobblestone also has the same palette
673                 {items = {"mod:cobblestone"}, inherit_color = true },
674             }
675         }
676     })
677
678 ### Colored items in craft recipes
679 Craft recipes only support item strings, but fortunately item strings
680 can also contain metadata. Example craft recipe registration:
681
682     minetest.register_craft({
683         output = minetest.itemstring_with_palette("wool:block", 3),
684         type = "shapeless",
685         recipe = {
686             "wool:block",
687             "dye:red",
688         },
689     })
690
691 To set the `color` field, you can use `minetest.itemstring_with_color`.
692
693 Metadata field filtering in the `recipe` field are not supported yet,
694 so the craft output is independent of the color of the ingredients.
695
696 Soft texture overlay
697 --------------------
698 Sometimes hardware coloring is not enough, because it affects the
699 whole tile. Soft texture overlays were added to Minetest to allow
700 the dynamic coloring of only specific parts of the node's texture.
701 For example a grass block may have colored grass, while keeping the
702 dirt brown.
703
704 These overlays are 'soft', because unlike texture modifiers, the layers
705 are not merged in the memory, but they are simply drawn on top of each
706 other. This allows different hardware coloring, but also means that
707 tiles with overlays are drawn slower. Using too much overlays might
708 cause FPS loss.
709
710 For inventory and wield images you can specify overlays which
711 hardware coloring does not modify. You have to set `inventory_overlay`
712 and `wield_overlay` fields to an image name.
713
714 To define a node overlay, simply set the `overlay_tiles` field of the node
715 definition. These tiles are defined in the same way as plain tiles:
716 they can have a texture name, color etc.
717 To skip one face, set that overlay tile to an empty string.
718
719 Example (colored grass block):
720
721     minetest.register_node("default:dirt_with_grass", {
722         description = "Dirt with Grass",
723         -- Regular tiles, as usual
724         -- The dirt tile disables palette coloring
725         tiles = {{name = "default_grass.png"},
726             {name = "default_dirt.png", color = "white"}},
727         -- Overlay tiles: define them in the same style
728         -- The top and bottom tile does not have overlay
729         overlay_tiles = {"", "",
730             {name = "default_grass_side.png", tileable_vertical = false}},
731         -- Global color, used in inventory
732         color = "green",
733         -- Palette in the world
734         paramtype2 = "color",
735         palette = "default_foilage.png",
736     })
737
738
739
740
741 Sounds
742 ======
743
744 Only Ogg Vorbis files are supported.
745
746 For positional playing of sounds, only single-channel (mono) files are
747 supported. Otherwise OpenAL will play them non-positionally.
748
749 Mods should generally prefix their sounds with `modname_`, e.g. given
750 the mod name "`foomod`", a sound could be called:
751
752     foomod_foosound.ogg
753
754 Sounds are referred to by their name with a dot, a single digit and the
755 file extension stripped out. When a sound is played, the actual sound file
756 is chosen randomly from the matching sounds.
757
758 When playing the sound `foomod_foosound`, the sound is chosen randomly
759 from the available ones of the following files:
760
761 * `foomod_foosound.ogg`
762 * `foomod_foosound.0.ogg`
763 * `foomod_foosound.1.ogg`
764 * (...)
765 * `foomod_foosound.9.ogg`
766
767 Examples of sound parameter tables:
768
769     -- Play locationless on all clients
770     {
771         gain = 1.0, -- default
772         fade = 0.0, -- default, change to a value > 0 to fade the sound in
773         pitch = 1.0, -- default
774     }
775     -- Play locationless to one player
776     {
777         to_player = name,
778         gain = 1.0, -- default
779         fade = 0.0, -- default, change to a value > 0 to fade the sound in
780         pitch = 1.0, -- default
781     }
782     -- Play locationless to one player, looped
783     {
784         to_player = name,
785         gain = 1.0, -- default
786         loop = true,
787     }
788     -- Play in a location
789     {
790         pos = {x = 1, y = 2, z = 3},
791         gain = 1.0, -- default
792         max_hear_distance = 32, -- default, uses an euclidean metric
793     }
794     -- Play connected to an object, looped
795     {
796         object = <an ObjectRef>,
797         gain = 1.0, -- default
798         max_hear_distance = 32, -- default, uses an euclidean metric
799         loop = true,
800     }
801
802 Looped sounds must either be connected to an object or played locationless to
803 one player using `to_player = name,`
804
805 `SimpleSoundSpec`
806 -----------------
807 * e.g. `""`
808 * e.g. `"default_place_node"`
809 * e.g. `{}`
810 * e.g. `{name = "default_place_node"}`
811 * e.g. `{name = "default_place_node", gain = 1.0}`
812 * e.g. `{name = "default_place_node", gain = 1.0, pitch = 1.0}`
813
814
815
816
817 Registered definitions
818 ======================
819
820 Anything added using certain `minetest.register_*` functions gets added to
821 the global `minetest.registered_*` tables.
822
823 * `minetest.register_entity(name, prototype table)`
824     * added to `minetest.registered_entities[name]`
825
826 * `minetest.register_node(name, node definition)`
827     * added to `minetest.registered_items[name]`
828     * added to `minetest.registered_nodes[name]`
829
830 * `minetest.register_tool(name, item definition)`
831     * added to `minetest.registered_items[name]`
832
833 * `minetest.register_craftitem(name, item definition)`
834     * added to `minetest.registered_items[name]`
835
836 * `minetest.unregister_item(name)`
837     * Unregisters the item name from engine, and deletes the entry with key
838     * `name` from `minetest.registered_items` and from the associated item
839     * table according to its nature: `minetest.registered_nodes[]` etc
840
841 * `minetest.register_biome(biome definition)`
842     * returns an integer uniquely identifying the registered biome
843     * added to `minetest.registered_biome` with the key of `biome.name`
844     * if `biome.name` is nil, the key is the returned ID
845
846 * `minetest.unregister_biome(name)`
847     * Unregisters the biome name from engine, and deletes the entry with key
848     * `name` from `minetest.registered_biome`
849
850 * `minetest.register_ore(ore definition)`
851     * returns an integer uniquely identifying the registered ore
852     * added to `minetest.registered_ores` with the key of `ore.name`
853     * if `ore.name` is nil, the key is the returned ID
854
855 * `minetest.register_decoration(decoration definition)`
856     * returns an integer uniquely identifying the registered decoration
857     * added to `minetest.registered_decorations` with the key of
858       `decoration.name`.
859     * if `decoration.name` is nil, the key is the returned ID
860
861 * `minetest.register_schematic(schematic definition)`
862     * returns an integer uniquely identifying the registered schematic
863     * added to `minetest.registered_schematic` with the key of `schematic.name`
864     * if `schematic.name` is nil, the key is the returned ID
865     * if the schematic is loaded from a file, schematic.name is set to the
866       filename.
867     * if the function is called when loading the mod, and schematic.name is a
868       relative path, then the current mod path will be prepended to the
869       schematic filename.
870
871 * `minetest.clear_registered_biomes()`
872     * clears all biomes currently registered
873
874 * `minetest.clear_registered_ores()`
875     * clears all ores currently registered
876
877 * `minetest.clear_registered_decorations()`
878     * clears all decorations currently registered
879
880 * `minetest.clear_registered_schematics()`
881     * clears all schematics currently registered
882
883 Note that in some cases you will stumble upon things that are not contained
884 in these tables (e.g. when a mod has been removed). Always check for
885 existence before trying to access the fields.
886
887 Example: If you want to check the drawtype of a node, you could do:
888
889     local function get_nodedef_field(nodename, fieldname)
890         if not minetest.registered_nodes[nodename] then
891             return nil
892         end
893         return minetest.registered_nodes[nodename][fieldname]
894     end
895     local drawtype = get_nodedef_field(nodename, "drawtype")
896
897 Example: `minetest.get_item_group(name, group)` has been implemented as:
898
899     function minetest.get_item_group(name, group)
900         if not minetest.registered_items[name] or not
901                 minetest.registered_items[name].groups[group] then
902             return 0
903         end
904         return minetest.registered_items[name].groups[group]
905     end
906
907
908
909
910 Nodes
911 =====
912
913 Nodes are the bulk data of the world: cubes and other things that take the
914 space of a cube. Huge amounts of them are handled efficiently, but they
915 are quite static.
916
917 The definition of a node is stored and can be accessed by using
918
919     minetest.registered_nodes[node.name]
920
921 See "Registered definitions".
922
923 Nodes are passed by value between Lua and the engine.
924 They are represented by a table:
925
926     {name="name", param1=num, param2=num}
927
928 `param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses
929 them for certain automated functions. If you don't use these functions, you can
930 use them to store arbitrary values.
931
932 Node paramtypes
933 ---------------
934 The functions of `param1` and `param2` are determined by certain fields in the
935 node definition:
936
937 `param1` is reserved for the engine when `paramtype != "none"`:
938
939     paramtype = "light"
940     ^ The value stores light with and without sun in its upper and lower 4 bits
941       respectively.
942       Required by a light source node to enable spreading its light.
943       Required by the following drawtypes as they determine their visual
944       brightness from their internal light value:
945         torchlike,
946         signlike,
947         firelike,
948         fencelike,
949         raillike,
950         nodebox,
951         mesh,
952         plantlike,
953         plantlike_rooted.
954
955 `param2` is reserved for the engine when any of these are used:
956
957     liquidtype == "flowing"
958     ^ The level and some flags of the liquid is stored in param2
959     drawtype == "flowingliquid"
960     ^ The drawn liquid level is read from param2
961     drawtype == "torchlike"
962     drawtype == "signlike"
963     paramtype2 == "wallmounted"
964     ^ The rotation of the node is stored in param2. You can make this value
965       by using minetest.dir_to_wallmounted().
966     paramtype2 == "facedir"
967     ^ The rotation of the node is stored in param2. Furnaces and chests are
968       rotated this way. Can be made by using minetest.dir_to_facedir().
969       Values range 0 - 23
970       facedir / 4 = axis direction:
971       0 = y+    1 = z+    2 = z-    3 = x+    4 = x-    5 = y-
972       facedir modulo 4 = rotation around that axis
973     paramtype2 == "leveled"
974     ^ Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted".
975       Leveled nodebox:
976         The level of the top face of the nodebox is stored in param2.
977         The other faces are defined by 'fixed = {}' like 'type = "fixed"'
978         nodeboxes.
979         The nodebox height is (param2 / 64) nodes.
980         The maximum accepted value of param2 is 127.
981       Rooted plantlike:
982         The height of the 'plantlike' section is stored in param2.
983         The height is (param2 / 16) nodes.
984     paramtype2 == "degrotate"
985     ^ Only valid for "plantlike". The rotation of the node is stored in param2.
986       Values range 0 - 179. The value stored in param2 is multiplied by two to
987       get the actual rotation in degrees of the node.
988     paramtype2 == "meshoptions"
989     ^ Only valid for "plantlike". The value of param2 becomes a bitfield which
990       can be used to change how the client draws plantlike nodes.
991       Bits 0, 1 and 2 form a mesh selector.
992       Currently the following meshes are choosable:
993         0 = a "x" shaped plant (ordinary plant)
994         1 = a "+" shaped plant (just rotated 45 degrees)
995         2 = a "*" shaped plant with 3 faces instead of 2
996         3 = a "#" shaped plant with 4 faces instead of 2
997         4 = a "#" shaped plant with 4 faces that lean outwards
998         5-7 are unused and reserved for future meshes.
999       Bits 3 through 7 are optional flags that can be combined and give these
1000       effects:
1001         bit 3 (0x08) - Makes the plant slightly vary placement horizontally
1002         bit 4 (0x10) - Makes the plant mesh 1.4x larger
1003         bit 5 (0x20) - Moves each face randomly a small bit down (1/8 max)
1004         bits 6-7 are reserved for future use.
1005     paramtype2 == "color"
1006     ^ `param2` tells which color is picked from the palette.
1007       The palette should have 256 pixels.
1008     paramtype2 == "colorfacedir"
1009     ^ Same as `facedir`, but with colors.
1010       The first three bits of `param2` tells which color
1011       is picked from the palette.
1012       The palette should have 8 pixels.
1013     paramtype2 == "colorwallmounted"
1014     ^ Same as `wallmounted`, but with colors.
1015       The first five bits of `param2` tells which color
1016       is picked from the palette.
1017       The palette should have 32 pixels.
1018     paramtype2 == "glasslikeliquidlevel"
1019     ^ Only valid for "glasslike_framed" or "glasslike_framed_optional"
1020       drawtypes.
1021       param2 values 0-63 define 64 levels of internal liquid, 0 being empty and
1022       63 being full.
1023       Liquid texture is defined using `special_tiles = {"modname_tilename.png"},`
1024
1025 Nodes can also contain extra data. See "Node Metadata".
1026
1027 Node drawtypes
1028 --------------
1029 There are a bunch of different looking node types.
1030
1031 Look for examples in `games/minimal` or `games/minetest_game`.
1032
1033 * `normal`
1034     * A node-sized cube.
1035 * `airlike`
1036     * Invisible, uses no texture.
1037 * `liquid`
1038     * The cubic source node for a liquid.
1039 * `flowingliquid`
1040     * The flowing version of a liquid, appears with various heights and slopes.
1041 * `glasslike`
1042     * Often used for partially-transparent nodes.
1043     * Only external sides of textures are visible.
1044 * `glasslike_framed`
1045     * All face-connected nodes are drawn as one volume within a surrounding
1046       frame.
1047     * The frame appearence is generated from the edges of the first texture
1048       specified in `tiles`. The width of the edges used are 1/16th of texture
1049       size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
1050     * The glass 'shine' (or other desired detail) on each node face is supplied
1051       by the second texture specified in `tiles`.
1052 * `glasslike_framed_optional`
1053     * This switches between the above 2 drawtypes according to the menu setting
1054       'Connected Glass'.
1055 * `allfaces`
1056     * Often used for partially-transparent nodes.
1057     * External and internal sides of textures are visible.
1058 * `allfaces_optional`
1059     * Often used for leaves nodes.
1060     * This switches between `normal`, `glasslike` and `allfaces` according to
1061       the menu setting: Opaque Leaves / Simple Leaves / Fancy Leaves.
1062     * With 'Simple Leaves' selected, the texture specified in `special_tiles`
1063       is used instead, if present. This allows a visually thicker texture to be
1064       used to compensate for how `glasslike` reduces visual thickness.
1065 * `torchlike`
1066     * A single vertical texture.
1067     * If placed on top of a node, uses the first texture specified in `tiles`.
1068     * If placed against the underside of a node, uses the second texture
1069       specified in `tiles`.
1070     * If placed on the side of a node, uses the third texture specified in
1071       `tiles` and is perpendicular to that node.
1072 * `signlike`
1073     * A single texture parallel to, and mounted against, the top, underside or
1074       side of a node.
1075 * `plantlike`
1076     * Two vertical and diagonal textures at right-angles to each other.
1077     * See `paramtype2 == "meshoptions"` above for other options.
1078 * `firelike`
1079     * When above a flat surface, appears as 6 textures, the central 2 as
1080       `plantlike` plus 4 more surrounding those.
1081     * If not above a surface the central 2 do not appear, but the texture
1082       appears against the faces of surrounding nodes if they are present.
1083 * `fencelike`
1084     * A 3D model suitable for a wooden fence.
1085     * One placed node appears as a single vertical post.
1086     * Adjacently-placed nodes cause horizontal bars to appear between them.
1087 * `raillike`
1088     * Often used for tracks for mining carts.
1089     * Requires 4 textures to be specified in `tiles`, in order: Straight,
1090       curved, t-junction, crossing.
1091     * Each placed node automatically switches to a suitable rotated texture
1092       determined by the adjacent `raillike` nodes, in order to create a
1093       continuous track network.
1094     * Becomes a sloping node if placed against stepped nodes.
1095 * `nodebox`
1096     * Often used for stairs and slabs.
1097     * Allows defining nodes consisting of an arbitrary number of boxes.
1098     * See 'Node boxes' below for more information.
1099 * `mesh`
1100     * Uses models for nodes.
1101     * Tiles should hold model materials textures.
1102     * Only static meshes are implemented.
1103     * For supported model formats see Irrlicht engine documentation.
1104 * `plantlike_rooted`
1105     * Enables underwater `plantlike` without air bubbles around the nodes.
1106     * Consists of a base cube at the co-ordinates of the node plus a
1107       `plantlike` extension above with a height of `param2 / 16` nodes.
1108     * The `plantlike` extension visually passes through any nodes above the
1109       base cube without affecting them.
1110     * The base cube texture tiles are defined as normal, the `plantlike`
1111       extension uses the defined special tile, for example:
1112       `special_tiles = {{name = "default_papyrus.png", tileable_vertical = true}},`
1113
1114 `*_optional` drawtypes need less rendering time if deactivated
1115 (always client-side).
1116
1117 Node boxes
1118 ----------
1119 Node selection boxes are defined using "node boxes".
1120
1121 A nodebox is defined as any of:
1122
1123     {
1124         -- A normal cube; the default in most things
1125         type = "regular"
1126     }
1127     {
1128         -- A fixed box (or boxes) (facedir param2 is used, if applicable)
1129         type = "fixed",
1130         fixed = box OR {box1, box2, ...}
1131     }
1132     {
1133         -- A variable height box (or boxes) with the top face position defined
1134         -- by the node parameter 'leveled = ', or if 'paramtype2 == "leveled"'
1135         -- by param2.
1136         -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'.
1137         type = "leveled",
1138         fixed = box OR {box1, box2, ...}
1139     }
1140     {
1141         -- A box like the selection box for torches
1142         -- (wallmounted param2 is used, if applicable)
1143         type = "wallmounted",
1144         wall_top = box,
1145         wall_bottom = box,
1146         wall_side = box
1147     }
1148     {
1149         -- A node that has optional boxes depending on neighbouring nodes'
1150         -- presence and type. See also `connects_to`.
1151         type = "connected",
1152         fixed = box OR {box1, box2, ...}
1153         connect_top = box OR {box1, box2, ...}
1154         connect_bottom = box OR {box1, box2, ...}
1155         connect_front = box OR {box1, box2, ...}
1156         connect_left = box OR {box1, box2, ...}
1157         connect_back = box OR {box1, box2, ...}
1158         connect_right = box OR {box1, box2, ...}
1159         -- The following `disconnected_*` boxes are the opposites of the
1160         -- `connect_*` ones above, i.e. when a node has no suitable neighbour
1161         -- on the respective side, the corresponding disconnected box is drawn.
1162         disconnected_top = box OR {box1, box2, ...}
1163         disconnected_bottom = box OR {box1, box2, ...}
1164         disconnected_front = box OR {box1, box2, ...}
1165         disconnected_left = box OR {box1, box2, ...}
1166         disconnected_back = box OR {box1, box2, ...}
1167         disconnected_right = box OR {box1, box2, ...}
1168         disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour
1169         disconnected_sides = box OR {box1, box2, ...} -- when there are *no*
1170                                                         neighbours to the sides
1171     }
1172
1173 A `box` is defined as:
1174
1175     {x1, y1, z1, x2, y2, z2}
1176
1177 A box of a regular node would look like:
1178
1179     {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
1180
1181
1182
1183
1184 HUD
1185 ===
1186
1187 HUD element types
1188 -----------------
1189 The position field is used for all element types.
1190
1191 To account for differing resolutions, the position coordinates are the
1192 percentage of the screen, ranging in value from `0` to `1`.
1193
1194 The name field is not yet used, but should contain a description of what the
1195 HUD element represents. The direction field is the direction in which something
1196 is drawn.
1197
1198 `0` draws from left to right, `1` draws from right to left, `2` draws from
1199 top to bottom, and `3` draws from bottom to top.
1200
1201 The `alignment` field specifies how the item will be aligned. It ranges from
1202 `-1` to `1`, with `0` being the center. `-1` is moved to the left/up, and `1`
1203 is to the right/down. Fractional values can be used.
1204
1205 The `offset` field specifies a pixel offset from the position. Contrary to
1206 position, the offset is not scaled to screen size. This allows for some
1207 precisely positioned items in the HUD.
1208
1209 **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
1210 factor!
1211
1212 Below are the specific uses for fields in each type; fields not listed for that
1213 type are ignored.
1214
1215 ### `image`
1216 Displays an image on the HUD.
1217
1218 * `scale`: The scale of the image, with 1 being the original texture size.
1219   Only the X coordinate scale is used (positive values).
1220   Negative values represent that percentage of the screen it
1221   should take; e.g. `x=-100` means 100% (width).
1222 * `text`: The name of the texture that is displayed.
1223 * `alignment`: The alignment of the image.
1224 * `offset`: offset in pixels from position.
1225
1226 ### `text`
1227 Displays text on the HUD.
1228
1229 * `scale`: Defines the bounding rectangle of the text.
1230   A value such as `{x=100, y=100}` should work.
1231 * `text`: The text to be displayed in the HUD element.
1232 * `number`: An integer containing the RGB value of the color used to draw the
1233   text. Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
1234 * `alignment`: The alignment of the text.
1235 * `offset`: offset in pixels from position.
1236
1237 ### `statbar`
1238 Displays a horizontal bar made up of half-images.
1239
1240 * `text`: The name of the texture that is used.
1241 * `number`: The number of half-textures that are displayed.
1242   If odd, will end with a vertically center-split texture.
1243 * `direction`
1244 * `offset`: offset in pixels from position.
1245 * `size`: If used, will force full-image size to this value (override texture
1246   pack image size)
1247
1248 ### `inventory`
1249 * `text`: The name of the inventory list to be displayed.
1250 * `number`: Number of items in the inventory to be displayed.
1251 * `item`: Position of item that is selected.
1252 * `direction`
1253 * `offset`: offset in pixels from position.
1254
1255 ### `waypoint`
1256 Displays distance to selected world position.
1257
1258 * `name`: The name of the waypoint.
1259 * `text`: Distance suffix. Can be blank.
1260 * `number:` An integer containing the RGB value of the color used to draw the
1261   text.
1262 * `world_pos`: World position of the waypoint.
1263
1264
1265
1266
1267 Representations of simple things
1268 ================================
1269
1270 Position/vector
1271 ---------------
1272
1273     {x=num, y=num, z=num}
1274
1275 For helper functions see "Spatial Vectors".
1276
1277 `pointed_thing`
1278 ---------------
1279 * `{type="nothing"}`
1280 * `{type="node", under=pos, above=pos}`
1281 * `{type="object", ref=ObjectRef}`
1282
1283
1284
1285
1286 Flag Specifier Format
1287 =====================
1288
1289 Flags using the standardized flag specifier format can be specified in either
1290 of two ways, by string or table.
1291
1292 The string format is a comma-delimited set of flag names; whitespace and
1293 unrecognized flag fields are ignored. Specifying a flag in the string sets the
1294 flag, and specifying a flag prefixed by the string `"no"` explicitly
1295 clears the flag from whatever the default may be.
1296
1297 In addition to the standard string flag format, the schematic flags field can
1298 also be a table of flag names to boolean values representing whether or not the
1299 flag is set. Additionally, if a field with the flag name prefixed with `"no"`
1300 is present, mapped to a boolean of any value, the specified flag is unset.
1301
1302 E.g. A flag field of value
1303
1304     {place_center_x = true, place_center_y=false, place_center_z=true}
1305
1306 is equivalent to
1307
1308     {place_center_x = true, noplace_center_y=true, place_center_z=true}
1309
1310 which is equivalent to
1311
1312     "place_center_x, noplace_center_y, place_center_z"
1313
1314 or even
1315
1316     "place_center_x, place_center_z"
1317
1318 since, by default, no schematic attributes are set.
1319
1320
1321
1322
1323 Items
1324 =====
1325
1326 Item types
1327 ----------
1328 There are three kinds of items: nodes, tools and craftitems.
1329
1330 * Node (`register_node`): A node from the world.
1331 * Tool (`register_tool`): A tool/weapon that can dig and damage
1332   things according to `tool_capabilities`.
1333 * Craftitem (`register_craftitem`): A miscellaneous item.
1334
1335 Amount and wear
1336 ---------------
1337 All item stacks have an amount between 0 to 65535. It is 1 by
1338 default. Tool item stacks can not have an amount greater than 1.
1339
1340 Tools use a wear (=damage) value ranging from 0 to 65535. The
1341 value 0 is the default and used is for unworn tools. The values
1342 1 to 65535 are used for worn tools, where a higher value stands for
1343 a higher wear. Non-tools always have a wear value of 0.
1344
1345 Item formats
1346 ------------
1347 Items and item stacks can exist in three formats: Serializes, table format
1348 and `ItemStack`.
1349
1350 ### Serialized
1351 This is called "stackstring" or "itemstring". It is a simple string with
1352 1-3 components: the full item identifier, an optional amount and an optional
1353 wear value. Syntax:
1354
1355     <identifier> [<amount>[ <wear>]]
1356
1357 Examples:
1358
1359 * `'default:apple'`: 1 apple
1360 * `'default:dirt 5'`: 5 dirt
1361 * `'default:pick_stone'`: a new stone pickaxe
1362 * `'default:pick_wood 1 21323'`: a wooden pickaxe, ca. 1/3 worn out
1363
1364 ### Table format
1365 Examples:
1366
1367 5 dirt nodes:
1368
1369     {name="default:dirt", count=5, wear=0, metadata=""}
1370
1371 A wooden pick about 1/3 worn out:
1372
1373     {name="default:pick_wood", count=1, wear=21323, metadata=""}
1374
1375 An apple:
1376
1377     {name="default:apple", count=1, wear=0, metadata=""}
1378
1379 ### `ItemStack`
1380 A native C++ format with many helper methods. Useful for converting
1381 between formats. See the Class reference section for details.
1382
1383 When an item must be passed to a function, it can usually be in any of
1384 these formats.
1385
1386
1387
1388
1389 Groups
1390 ======
1391
1392 In a number of places, there is a group table. Groups define the
1393 properties of a thing (item, node, armor of entity, capabilities of
1394 tool) in such a way that the engine and other mods can can interact with
1395 the thing without actually knowing what the thing is.
1396
1397 Usage
1398 -----
1399 Groups are stored in a table, having the group names with keys and the
1400 group ratings as values. For example:
1401
1402     groups = {crumbly=3, soil=1}
1403     -- ^ Default dirt
1404
1405     groups = {crumbly=2, soil=1, level=2, outerspace=1}
1406     -- ^ A more special dirt-kind of thing
1407
1408 Groups always have a rating associated with them. If there is no
1409 useful meaning for a rating for an enabled group, it shall be `1`.
1410
1411 When not defined, the rating of a group defaults to `0`. Thus when you
1412 read groups, you must interpret `nil` and `0` as the same value, `0`.
1413
1414 You can read the rating of a group for an item or a node by using
1415
1416     minetest.get_item_group(itemname, groupname)
1417
1418 Groups of items
1419 ---------------
1420 Groups of items can define what kind of an item it is (e.g. wool).
1421
1422 Groups of nodes
1423 ---------------
1424 In addition to the general item things, groups are used to define whether
1425 a node is destroyable and how long it takes to destroy by a tool.
1426
1427 Groups of entities
1428 ------------------
1429 For entities, groups are, as of now, used only for calculating damage.
1430 The rating is the percentage of damage caused by tools with this damage group.
1431 See "Entity damage mechanism".
1432
1433     object.get_armor_groups() --> a group-rating table (e.g. {fleshy=100})
1434     object.set_armor_groups({fleshy=30, cracky=80})
1435
1436 Groups of tools
1437 ---------------
1438 Groups in tools define which groups of nodes and entities they are
1439 effective towards.
1440
1441 Groups in crafting recipes
1442 --------------------------
1443 An example: Make meat soup from any meat, any water and any bowl:
1444
1445     {
1446         output = 'food:meat_soup_raw',
1447         recipe = {
1448             {'group:meat'},
1449             {'group:water'},
1450             {'group:bowl'},
1451         },
1452         -- preserve = {'group:bowl'}, -- Not implemented yet (TODO)
1453     }
1454
1455 Another example: Make red wool from white wool and red dye:
1456
1457     {
1458         type = 'shapeless',
1459         output = 'wool:red',
1460         recipe = {'wool:white', 'group:dye,basecolor_red'},
1461     }
1462
1463 Special groups
1464 --------------
1465 * `immortal`: Disables the group damage system for an entity
1466 * `punch_operable`: For entities; disables the regular damage mechanism for
1467   players punching it by hand or a non-tool item, so that it can do something
1468   else than take damage.
1469 * `level`: Can be used to give an additional sense of progression in the game.
1470      * A larger level will cause e.g. a weapon of a lower level make much less
1471        damage, and get worn out much faster, or not be able to get drops
1472        from destroyed nodes.
1473      * `0` is something that is directly accessible at the start of gameplay
1474      * There is no upper limit
1475 * `dig_immediate`: (player can always pick up node without reducing tool wear)
1476     * `2`: the node always gets the digging time 0.5 seconds (rail, sign)
1477     * `3`: the node always gets the digging time 0 seconds (torch)
1478 * `disable_jump`: Player (and possibly other things) cannot jump from node
1479 * `fall_damage_add_percent`: damage speed = `speed * (1 + value/100)`
1480 * `bouncy`: value is bounce speed in percent
1481 * `falling_node`: if there is no walkable block under the node it will fall
1482 * `attached_node`: if the node under it is not a walkable block the node will be
1483   dropped as an item. If the node is wallmounted the wallmounted direction is
1484   checked.
1485 * `soil`: saplings will grow on nodes in this group
1486 * `connect_to_raillike`: makes nodes of raillike drawtype with same group value
1487   connect to each other
1488 * `slippery`: Players and items will slide on the node.
1489   Slipperiness rises steadily with `slippery` value, starting at 1.
1490
1491
1492 Known damage and digging time defining groups
1493 ---------------------------------------------
1494 * `crumbly`: dirt, sand
1495 * `cracky`: tough but crackable stuff like stone.
1496 * `snappy`: something that can be cut using fine tools; e.g. leaves, small
1497   plants, wire, sheets of metal
1498 * `choppy`: something that can be cut using force; e.g. trees, wooden planks
1499 * `fleshy`: Living things like animals and the player. This could imply
1500   some blood effects when hitting.
1501 * `explody`: Especially prone to explosions
1502 * `oddly_breakable_by_hand`:
1503    Can be added to nodes that shouldn't logically be breakable by the
1504    hand but are. Somewhat similar to `dig_immediate`, but times are more
1505    like `{[1]=3.50,[2]=2.00,[3]=0.70}` and this does not override the
1506    speed of a tool if the tool can dig at a faster speed than this
1507    suggests for the hand.
1508
1509 Examples of custom groups
1510 -------------------------
1511 Item groups are often used for defining, well, _groups of items_.
1512
1513 * `meat`: any meat-kind of a thing (rating might define the size or healing
1514   ability or be irrelevant -- it is not defined as of yet)
1515 * `eatable`: anything that can be eaten. Rating might define HP gain in half
1516   hearts.
1517 * `flammable`: can be set on fire. Rating might define the intensity of the
1518   fire, affecting e.g. the speed of the spreading of an open fire.
1519 * `wool`: any wool (any origin, any color)
1520 * `metal`: any metal
1521 * `weapon`: any weapon
1522 * `heavy`: anything considerably heavy
1523
1524 Digging time calculation specifics
1525 ----------------------------------
1526 Groups such as `crumbly`, `cracky` and `snappy` are used for this
1527 purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies
1528 faster digging time.
1529
1530 The `level` group is used to limit the toughness of nodes a tool can dig
1531 and to scale the digging times / damage to a greater extent.
1532
1533 **Please do understand this**, otherwise you cannot use the system to it's
1534 full potential.
1535
1536 Tools define their properties by a list of parameters for groups. They
1537 cannot dig other groups; thus it is important to use a standard bunch of
1538 groups to enable interaction with tools.
1539
1540
1541
1542
1543 Tools
1544 =====
1545
1546 Tools definition
1547 ----------------
1548 Tools define:
1549
1550 * Full punch interval
1551 * Maximum drop level
1552 * For an arbitrary list of groups:
1553     * Uses (until the tool breaks)
1554         * Maximum level (usually `0`, `1`, `2` or `3`)
1555         * Digging times
1556         * Damage groups
1557
1558 ### Full punch interval
1559
1560 When used as a weapon, the tool will do full damage if this time is spent
1561 between punches. If e.g. half the time is spent, the tool will do half
1562 damage.
1563
1564 ### Maximum drop level
1565
1566 Suggests the maximum level of node, when dug with the tool, that will drop
1567 it's useful item. (e.g. iron ore to drop a lump of iron).
1568
1569 This is not automated; it is the responsibility of the node definition
1570 to implement this.
1571
1572 ### Uses
1573
1574 Determines how many uses the tool has when it is used for digging a node,
1575 of this group, of the maximum level. For lower leveled nodes, the use count
1576 is multiplied by `3^leveldiff`.
1577
1578 * `uses=10, leveldiff=0`: actual uses: 10
1579 * `uses=10, leveldiff=1`: actual uses: 30
1580 * `uses=10, leveldiff=2`: actual uses: 90
1581
1582 ### Maximum level
1583
1584 Tells what is the maximum level of a node of this group that the tool will
1585 be able to dig.
1586
1587 ### Digging times
1588
1589 List of digging times for different ratings of the group, for nodes of the
1590 maximum level.
1591
1592 For example, as a Lua table, `times={2=2.00, 3=0.70}`. This would
1593 result in the tool to be able to dig nodes that have a rating of `2` or `3`
1594 for this group, and unable to dig the rating `1`, which is the toughest.
1595 Unless there is a matching group that enables digging otherwise.
1596
1597 If the result digging time is 0, a delay of 0.15 seconds is added between
1598 digging nodes; If the player releases LMB after digging, this delay is set to 0,
1599 i.e. players can more quickly click the nodes away instead of holding LMB.
1600
1601 ### Damage groups
1602
1603 List of damage for groups of entities. See "Entity damage mechanism".
1604
1605 Example definition of the capabilities of a tool
1606 ------------------------------------------------
1607
1608     tool_capabilities = {
1609         full_punch_interval=1.5,
1610         max_drop_level=1,
1611         groupcaps={
1612             crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
1613         }
1614         damage_groups = {fleshy=2},
1615     }
1616
1617 This makes the tool be able to dig nodes that fulfil both of these:
1618
1619 * Have the `crumbly` group
1620 * Have a `level` group less or equal to `2`
1621
1622 Table of resulting digging times:
1623
1624     crumbly        0     1     2     3     4  <- level
1625          ->  0     -     -     -     -     -
1626              1  0.80  1.60  1.60     -     -
1627              2  0.60  1.20  1.20     -     -
1628              3  0.40  0.80  0.80     -     -
1629
1630     level diff:    2     1     0    -1    -2
1631
1632 Table of resulting tool uses:
1633
1634     ->  0     -     -     -     -     -
1635         1   180    60    20     -     -
1636         2   180    60    20     -     -
1637         3   180    60    20     -     -
1638
1639 **Notes**:
1640
1641 * At `crumbly==0`, the node is not diggable.
1642 * At `crumbly==3`, the level difference digging time divider kicks in and makes
1643   easy nodes to be quickly breakable.
1644 * At `level > 2`, the node is not diggable, because it's `level > maxlevel`
1645
1646
1647
1648
1649 Entity damage mechanism
1650 =======================
1651
1652 Damage calculation:
1653
1654     damage = 0
1655     foreach group in cap.damage_groups:
1656         damage += cap.damage_groups[group] * limit(actual_interval /
1657                cap.full_punch_interval, 0.0, 1.0)
1658             * (object.armor_groups[group] / 100.0)
1659             -- Where object.armor_groups[group] is 0 for inexistent values
1660     return damage
1661
1662 Client predicts damage based on damage groups. Because of this, it is able to
1663 give an immediate response when an entity is damaged or dies; the response is
1664 pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
1665 TODO).
1666 Currently a smoke puff will appear when an entity dies.
1667
1668 The group `immortal` completely disables normal damage.
1669
1670 Entities can define a special armor group, which is `punch_operable`. This
1671 group disables the regular damage mechanism for players punching it by hand or
1672 a non-tool item, so that it can do something else than take damage.
1673
1674 On the Lua side, every punch calls:
1675
1676   entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, damage)
1677
1678 This should never be called directly, because damage is usually not handled by
1679 the entity itself.
1680
1681 * `puncher` is the object performing the punch. Can be `nil`. Should never be
1682   accessed unless absolutely required, to encourage interoperability.
1683 * `time_from_last_punch` is time from last punch (by `puncher`) or `nil`.
1684 * `tool_capabilities` can be `nil`.
1685 * `direction` is a unit vector, pointing from the source of the punch to
1686    the punched object.
1687 * `damage` damage that will be done to entity
1688 Return value of this function will determine if damage is done by this function
1689 (retval true) or shall be done by engine (retval false)
1690
1691 To punch an entity/object in Lua, call:
1692
1693   object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
1694
1695 * Return value is tool wear.
1696 * Parameters are equal to the above callback.
1697 * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
1698   will be automatically filled in based on the location of `puncher`.
1699
1700
1701
1702
1703 Metadata
1704 ========
1705
1706 Node Metadata
1707 -------------
1708 The instance of a node in the world normally only contains the three values
1709 mentioned in "Nodes". However, it is possible to insert extra data into a
1710 node. It is called "node metadata"; See `NodeMetaRef`.
1711
1712 Node metadata contains two things:
1713
1714 * A key-value store
1715 * An inventory
1716
1717 Some of the values in the key-value store are handled specially:
1718
1719 * `formspec`: Defines a right-click inventory menu. See "Formspec".
1720 * `infotext`: Text shown on the screen when the node is pointed at
1721
1722 Example stuff:
1723
1724     local meta = minetest.get_meta(pos)
1725     meta:set_string("formspec",
1726             "size[8,9]"..
1727             "list[context;main;0,0;8,4;]"..
1728             "list[current_player;main;0,5;8,4;]")
1729     meta:set_string("infotext", "Chest");
1730     local inv = meta:get_inventory()
1731     inv:set_size("main", 8*4)
1732     print(dump(meta:to_table()))
1733     meta:from_table({
1734         inventory = {
1735             main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "",
1736                     [5] = "", [6] = "", [7] = "", [8] = "", [9] = "",
1737                     [10] = "", [11] = "", [12] = "", [13] = "",
1738                     [14] = "default:cobble", [15] = "", [16] = "", [17] = "",
1739                     [18] = "", [19] = "", [20] = "default:cobble", [21] = "",
1740                     [22] = "", [23] = "", [24] = "", [25] = "", [26] = "",
1741                     [27] = "", [28] = "", [29] = "", [30] = "", [31] = "",
1742                     [32] = ""}
1743         },
1744         fields = {
1745             formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
1746             infotext = "Chest"
1747         }
1748     })
1749
1750 Item Metadata
1751 -------------
1752 Item stacks can store metadata too. See `ItemStackMetaRef`.
1753
1754 Item metadata only contains a key-value store.
1755
1756 Some of the values in the key-value store are handled specially:
1757
1758 * `description`: Set the item stack's description. Defaults to
1759   `idef.description`.
1760 * `color`: A `ColorString`, which sets the stack's color.
1761 * `palette_index`: If the item has a palette, this is used to get the
1762   current color from the palette.
1763
1764 Example stuff:
1765
1766     local meta = stack:get_meta()
1767     meta:set_string("key", "value")
1768     print(dump(meta:to_table()))
1769
1770
1771
1772
1773 Formspec
1774 ========
1775
1776 Formspec defines a menu. Currently not much else than inventories are
1777 supported. It is a string, with a somewhat strange format.
1778
1779 Spaces and newlines can be inserted between the blocks, as is used in the
1780 examples.
1781
1782 Position and size units are inventory slots, `X` and `Y` position the formspec
1783 element relative to the top left of the menu or container. `W` and `H` are its
1784 width and height values.
1785 When displaying text which can contain formspec code, e.g. text set by a player,
1786 use `minetest.formspec_escape`.
1787 For coloured text you can use `minetest.colorize`.
1788
1789 WARNING: Minetest allows you to add elements to every single formspec instance
1790 using player:set_formspec_prepend(), which may be the reason backgrounds are
1791 appearing when you don't expect them to. See `no_prepend[]`
1792
1793 Examples
1794 --------
1795
1796 ### Chest
1797
1798     size[8,9]
1799     list[context;main;0,0;8,4;]
1800     list[current_player;main;0,5;8,4;]
1801
1802 ### Furnace
1803
1804     size[8,9]
1805     list[context;fuel;2,3;1,1;]
1806     list[context;src;2,1;1,1;]
1807     list[context;dst;5,1;2,2;]
1808     list[current_player;main;0,5;8,4;]
1809
1810 ### Minecraft-like player inventory
1811
1812     size[8,7.5]
1813     image[1,0.6;1,2;player.png]
1814     list[current_player;main;0,3.5;8,4;]
1815     list[current_player;craft;3,0;3,3;]
1816     list[current_player;craftpreview;7,1;1,1;]
1817
1818 Elements
1819 --------
1820
1821 ### `size[<W>,<H>,<fixed_size>]`
1822 * Define the size of the menu in inventory slots
1823 * `fixed_size`: `true`/`false` (optional)
1824 * deprecated: `invsize[<W>,<H>;]`
1825
1826 ### `position[<X>,<Y>]`
1827 * Must be used after `size` element.
1828 * Defines the position on the game window of the formspec's `anchor` point.
1829 * For X and Y, 0.0 and 1.0 represent opposite edges of the game window,
1830   for example:
1831     * [0.0, 0.0] sets the position to the top left corner of the game window.
1832     * [1.0, 1.0] sets the position to the bottom right of the game window.
1833 * Defaults to the center of the game window [0.5, 0.5].
1834
1835 ### `anchor[<X>,<Y>]`
1836 * Must be used after both `size` and `position` (if present) elements.
1837 * Defines the location of the anchor point within the formspec.
1838 * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec,
1839   for example:
1840     * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec.
1841     * [1.0, 0.0] sets the anchor to the top right of the formspec.
1842 * Defaults to the center of the formspec [0.5, 0.5].
1843
1844 * `position` and `anchor` elements need suitable values to avoid a formspec
1845   extending off the game window due to particular game window sizes.
1846
1847 ### `no_prepend[]`
1848 * Must be used after the `size`, `position`, and `anchor` elements (if present).
1849 * Disables player:set_formspec_prepend() from applying to this formspec.
1850
1851 ### `container[<X>,<Y>]`
1852 * Start of a container block, moves all physical elements in the container by
1853   (X, Y).
1854 * Must have matching `container_end`
1855 * Containers can be nested, in which case the offsets are added
1856   (child containers are relative to parent containers)
1857
1858 ### `container_end[]`
1859 * End of a container, following elements are no longer relative to this
1860   container.
1861
1862 ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]`
1863 * Show an inventory list
1864
1865 ### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
1866 * Show an inventory list
1867
1868 ### `listring[<inventory location>;<list name>]`
1869 * Allows to create a ring of inventory lists
1870 * Shift-clicking on items in one element of the ring
1871   will send them to the next inventory list inside the ring
1872 * The first occurrence of an element inside the ring will
1873   determine the inventory where items will be sent to
1874
1875 ### `listring[]`
1876 * Shorthand for doing `listring[<inventory location>;<list name>]`
1877   for the last two inventory lists added by list[...]
1878
1879 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
1880 * Sets background color of slots as `ColorString`
1881 * Sets background color of slots on mouse hovering
1882
1883 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
1884 * Sets background color of slots as `ColorString`
1885 * Sets background color of slots on mouse hovering
1886 * Sets color of slots border
1887
1888 ### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
1889 * Sets background color of slots as `ColorString`
1890 * Sets background color of slots on mouse hovering
1891 * Sets color of slots border
1892 * Sets default background color of tooltips
1893 * Sets default font color of tooltips
1894
1895 ### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>;<fontcolor>]`
1896 * Adds tooltip for an element
1897 * `<bgcolor>` tooltip background color as `ColorString` (optional)
1898 * `<fontcolor>` tooltip font color as `ColorString` (optional)
1899
1900 ### `image[<X>,<Y>;<W>,<H>;<texture name>]`
1901 * Show an image
1902
1903 ### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
1904 * Show an inventory image of registered item/node
1905
1906 ### `bgcolor[<color>;<fullscreen>]`
1907 * Sets background color of formspec as `ColorString`
1908 * If `true`, the background color is drawn fullscreen (does not effect the size
1909   of the formspec).
1910
1911 ### `background[<X>,<Y>;<W>,<H>;<texture name>]`
1912 * Use a background. Inventory rectangles are not drawn then.
1913 * Example for formspec 8x4 in 16x resolution: image shall be sized
1914   8 times 16px  times  4 times 16px.
1915
1916 ### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
1917 * Use a background. Inventory rectangles are not drawn then.
1918 * Example for formspec 8x4 in 16x resolution:
1919   image shall be sized 8 times 16px  times  4 times 16px
1920 * If `auto_clip` is `true`, the background is clipped to the formspec size
1921   (`x` and `y` are used as offset values, `w` and `h` are ignored)
1922
1923 ### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
1924 * Textual password style field; will be sent to server when a button is clicked
1925 * When enter is pressed in field, fields.key_enter_field will be sent with the
1926   name of this field.
1927 * Fields are a set height, but will be vertically centred on `H`
1928 * `name` is the name of the field as returned in fields to `on_receive_fields`
1929 * `label`, if not blank, will be text printed on the top left above the field
1930 * See field_close_on_enter to stop enter closing the formspec
1931
1932 ### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
1933 * Textual field; will be sent to server when a button is clicked
1934 * When enter is pressed in field, `fields.key_enter_field` will be sent with
1935   the name of this field.
1936 * Fields are a set height, but will be vertically centred on `H`
1937 * `name` is the name of the field as returned in fields to `on_receive_fields`
1938 * `label`, if not blank, will be text printed on the top left above the field
1939 * `default` is the default value of the field
1940     * `default` may contain variable references such as `${text}'` which
1941       will fill the value from the metadata value `text`
1942     * **Note**: no extra text or more than a single variable is supported ATM.
1943 * See `field_close_on_enter` to stop enter closing the formspec
1944
1945 ### `field[<name>;<label>;<default>]`
1946 * As above, but without position/size units
1947 * When enter is pressed in field, `fields.key_enter_field` will be sent with
1948   the name of this field.
1949 * Special field for creating simple forms, such as sign text input
1950 * Must be used without a `size[]` element
1951 * A "Proceed" button will be added automatically
1952 * See `field_close_on_enter` to stop enter closing the formspec
1953
1954 ### `field_close_on_enter[<name>;<close_on_enter>]`
1955 * <name> is the name of the field
1956 * if <close_on_enter> is false, pressing enter in the field will submit the
1957   form but not close it.
1958 * defaults to true when not specified (ie: no tag for a field)
1959
1960 ### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
1961 * Same as fields above, but with multi-line input
1962 * If the text overflows, a vertical scrollbar is added.
1963 * If the name is empty, the textarea is read-only and
1964   the background is not shown, which corresponds to a multi-line label.
1965
1966 ### `label[<X>,<Y>;<label>]`
1967 * The label formspec element displays the text set in `label`
1968   at the specified position.
1969 * The text is displayed directly without automatic line breaking,
1970   so label should not be used for big text chunks.
1971
1972 ### `vertlabel[<X>,<Y>;<label>]`
1973 * Textual label drawn vertically
1974 * `label` is the text on the label
1975
1976 ### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
1977 * Clickable button. When clicked, fields will be sent.
1978 * Fixed button height. It will be vertically centred on `H`
1979 * `label` is the text on the button
1980
1981 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
1982 * `texture name` is the filename of an image
1983
1984 ### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
1985 * `texture name` is the filename of an image
1986 * `noclip=true` means the image button doesn't need to be within specified
1987   formsize.
1988 * `drawborder`: draw button border or not
1989 * `pressed texture name` is the filename of an image on pressed state
1990
1991 ### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
1992 * `item name` is the registered name of an item/node,
1993   tooltip will be made out of its description
1994   to override it use tooltip element
1995
1996 ### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
1997 * When clicked, fields will be sent and the form will quit.
1998
1999 ### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
2000 * When clicked, fields will be sent and the form will quit.
2001
2002 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
2003 * Scrollable item list showing arbitrary text elements
2004 * `name` fieldname sent to server on doubleclick value is current selected
2005   element.
2006 * `listelements` can be prepended by #color in hexadecimal format RRGGBB
2007   (only).
2008     * if you want a listelement to start with "#" write "##".
2009
2010 ### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
2011 * Scrollable itemlist showing arbitrary text elements
2012 * `name` fieldname sent to server on doubleclick value is current selected
2013   element.
2014 * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
2015     * if you want a listelement to start with "#" write "##"
2016 * Index to be selected within textlist
2017 * `true`/`false`: draw transparent background
2018 * See also `minetest.explode_textlist_event`
2019   (main menu: `core.explode_textlist_event`).
2020
2021 ### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
2022 * Show a tab**header** at specific position (ignores formsize)
2023 * `name` fieldname data is transferred to Lua
2024 * `caption 1`...: name shown on top of tab
2025 * `current_tab`: index of selected tab 1...
2026 * `transparent` (optional): show transparent
2027 * `draw_border` (optional): draw border
2028
2029 ### `box[<X>,<Y>;<W>,<H>;<color>]`
2030 * Simple colored box
2031 * `color` is color specified as a `ColorString`.
2032   If the alpha component is left blank, the box will be semitransparent.
2033
2034 ### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]`
2035 * Show a dropdown field
2036 * **Important note**: There are two different operation modes:
2037     1. handle directly on change (only changed dropdown is submitted)
2038     2. read the value on pressing a button (all dropdown values are available)
2039 * `x` and `y` position of dropdown
2040 * Width of dropdown
2041 * Fieldname data is transferred to Lua
2042 * Items to be shown in dropdown
2043 * Index of currently selected dropdown item
2044
2045 ### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
2046 * Show a checkbox
2047 * `name` fieldname data is transferred to Lua
2048 * `label` to be shown left of checkbox
2049 * `selected` (optional): `true`/`false`
2050
2051 ### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
2052 * Show a scrollbar
2053 * There are two ways to use it:
2054     1. handle the changed event (only changed scrollbar is available)
2055     2. read the value on pressing a button (all scrollbars are available)
2056 * `orientation`:  `vertical`/`horizontal`
2057 * Fieldname data is transferred to Lua
2058 * Value this trackbar is set to (`0`-`1000`)
2059 * See also `minetest.explode_scrollbar_event`
2060   (main menu: `core.explode_scrollbar_event`).
2061
2062 ### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
2063 * Show scrollable table using options defined by the previous `tableoptions[]`
2064 * Displays cells as defined by the previous `tablecolumns[]`
2065 * `name`: fieldname sent to server on row select or doubleclick
2066 * `cell 1`...`cell n`: cell contents given in row-major order
2067 * `selected idx`: index of row to be selected within table (first row = `1`)
2068 * See also `minetest.explode_table_event`
2069   (main menu: `core.explode_table_event`).
2070
2071 ### `tableoptions[<opt 1>;<opt 2>;...]`
2072 * Sets options for `table[]`
2073 * `color=#RRGGBB`
2074     * default text color (`ColorString`), defaults to `#FFFFFF`
2075 * `background=#RRGGBB`
2076     * table background color (`ColorString`), defaults to `#000000`
2077 * `border=<true/false>`
2078     * should the table be drawn with a border? (default: `true`)
2079 * `highlight=#RRGGBB`
2080     * highlight background color (`ColorString`), defaults to `#466432`
2081 * `highlight_text=#RRGGBB`
2082     * highlight text color (`ColorString`), defaults to `#FFFFFF`
2083 * `opendepth=<value>`
2084     * all subtrees up to `depth < value` are open (default value = `0`)
2085     * only useful when there is a column of type "tree"
2086
2087 ### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
2088 * Sets columns for `table[]`
2089 * Types: `text`, `image`, `color`, `indent`, `tree`
2090     * `text`:   show cell contents as text
2091     * `image`:  cell contents are an image index, use column options to define
2092                 images.
2093     * `color`:  cell contents are a ColorString and define color of following
2094                 cell.
2095     * `indent`: cell contents are a number and define indentation of following
2096                 cell.
2097     * `tree`:   same as indent, but user can open and close subtrees
2098                 (treeview-like).
2099 * Column options:
2100     * `align=<value>`
2101         * for `text` and `image`: content alignment within cells.
2102           Available values: `left` (default), `center`, `right`, `inline`
2103     * `width=<value>`
2104         * for `text` and `image`: minimum width in em (default: `0`)
2105         * for `indent` and `tree`: indent width in em (default: `1.5`)
2106     * `padding=<value>`: padding left of the column, in em (default `0.5`).
2107       Exception: defaults to 0 for indent columns
2108     * `tooltip=<value>`: tooltip text (default: empty)
2109     * `image` column options:
2110         * `0=<value>` sets image for image index 0
2111         * `1=<value>` sets image for image index 1
2112         * `2=<value>` sets image for image index 2
2113         * and so on; defined indices need not be contiguous empty or
2114           non-numeric cells are treated as `0`.
2115     * `color` column options:
2116         * `span=<value>`: number of following columns to affect
2117           (default: infinite).
2118
2119 **Note**: do _not_ use a element name starting with `key_`; those names are
2120 reserved to pass key press events to formspec!
2121
2122
2123
2124
2125 Inventory
2126 =========
2127
2128 Inventory locations
2129 -------------------
2130 * `"context"`: Selected node metadata (deprecated: `"current_name"`)
2131 * `"current_player"`: Player to whom the menu is shown
2132 * `"player:<name>"`: Any player
2133 * `"nodemeta:<X>,<Y>,<Z>"`: Any node metadata
2134 * `"detached:<name>"`: A detached inventory
2135
2136 Player Inventory lists
2137 ----------------------
2138 * `main`: list containing the default inventory
2139 * `craft`: list containing the craft input
2140 * `craftpreview`: list containing the craft output
2141 * `hand`: list containing an override for the empty hand
2142
2143
2144
2145
2146 Colors
2147 ======
2148
2149 `ColorString`
2150 -------------
2151 `#RGB` defines a color in hexadecimal format.
2152
2153 `#RGBA` defines a color in hexadecimal format and alpha channel.
2154
2155 `#RRGGBB` defines a color in hexadecimal format.
2156
2157 `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
2158
2159 Named colors are also supported and are equivalent to
2160 [CSS Color Module Level 4](http://dev.w3.org/csswg/css-color/#named-colors).
2161 To specify the value of the alpha channel, append `#AA` to the end of the color
2162 name (e.g. `colorname#08`). For named colors the hexadecimal string
2163 representing the alpha value must (always) be two hexadecimal digits.
2164
2165 `ColorSpec`
2166 -----------
2167 A ColorSpec specifies a 32-bit color.  It can be written in either:
2168 table form, each element ranging from 0..255 (a, if absent, defaults to 255):
2169     `colorspec = {a=255, r=0, g=255, b=0}`
2170 numerical form, the raw integer value of an ARGB8 quad:
2171     `colorspec = 0xFF00FF00`
2172 or string form, a ColorString (defined above):
2173     `colorspec = "green"`
2174
2175
2176
2177
2178 Escape sequences
2179 ================
2180
2181 Most text can contain escape sequences, that can for example color the text.
2182 There are a few exceptions: tab headers, dropdowns and vertical labels can't.
2183 The following functions provide escape sequences:
2184
2185 * `minetest.get_color_escape_sequence(color)`:
2186     * `color` is a ColorString
2187     * The escape sequence sets the text color to `color`
2188 * `minetest.colorize(color, message)`:
2189     * Equivalent to:
2190       `minetest.get_color_escape_sequence(color) ..
2191       message ..
2192       minetest.get_color_escape_sequence("#ffffff")`
2193 * `minetest.get_background_escape_sequence(color)`
2194     * `color` is a ColorString
2195     * The escape sequence sets the background of the whole text element to
2196       `color`. Only defined for item descriptions and tooltips.
2197 * `minetest.strip_foreground_colors(str)`
2198     * Removes foreground colors added by `get_color_escape_sequence`.
2199 * `minetest.strip_background_colors(str)`
2200     * Removes background colors added by `get_background_escape_sequence`.
2201 * `minetest.strip_colors(str)`
2202     * Removes all color escape sequences.
2203
2204
2205
2206
2207 Spatial Vectors
2208 ===============
2209
2210 For the following functions, `v`, `v1`, `v2` are vectors,
2211 `p1`, `p2` are positions:
2212
2213 * `vector.new(a[, b, c])`:
2214     * Returns a vector.
2215     * A copy of `a` if `a` is a vector.
2216     * `{x = a, y = b, z = c}`, if all of `a`, `b`, `c` are defined numbers.
2217 * `vector.direction(p1, p2)`:
2218     * Returns a vector of length 1 with direction `p1` to `p2`.
2219     * If `p1` and `p2` are identical, returns `{x = 0, y = 0, z = 0}`.
2220 * `vector.distance(p1, p2)`:
2221     * Returns zero or a positive number, the distance between `p1` and `p2`.
2222 * `vector.length(v)`:
2223     * Returns zero or a positive number, the length of vector `v`.
2224 * `vector.normalize(v)`:
2225     * Returns a vector of length 1 with direction of vector `v`.
2226     * If `v` has zero length, returns `{x = 0, y = 0, z = 0}`.
2227 * `vector.floor(v)`:
2228     * Returns a vector, each dimension rounded down.
2229 * `vector.round(v)`:
2230     * Returns a vector, each dimension rounded to nearest integer.
2231 * `vector.apply(v, func)`:
2232     * Returns a vector where the function `func` has been applied to each
2233       component.
2234 * `vector.equals(v1, v2)`:
2235     * Returns a boolean, `true` if the vectors are identical.
2236 * `vector.sort(v1, v2)`:
2237     * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
2238
2239 For the following functions `x` can be either a vector or a number:
2240
2241 * `vector.add(v, x)`:
2242     * Returns a vector.
2243 * `vector.subtract(v, x)`:
2244     * Returns a vector.
2245 * `vector.multiply(v, x)`:
2246     * Returns a scaled vector or Schur product.
2247 * `vector.divide(v, x)`:
2248     * Returns a scaled vector or Schur quotient.
2249
2250
2251
2252
2253 Helper functions
2254 ================
2255
2256 * `dump2(obj, name, dumped)`: returns a string which makes `obj`
2257   human-readable, handles reference loops.
2258     * `obj`: arbitrary variable
2259     * `name`: string, default: `"_"`
2260     * `dumped`: table, default: `{}`
2261 * `dump(obj, dumped)`: returns a string which makes `obj` human-readable
2262     * `obj`: arbitrary variable
2263     * `dumped`: table, default: `{}`
2264 * `math.hypot(x, y)`
2265     * Get the hypotenuse of a triangle with legs x and y.
2266       Useful for distance calculation.
2267 * `math.sign(x, tolerance)`: returns `-1`, `0` or `1`
2268     * Get the sign of a number.
2269     * tolerance: number, default: `0.0`
2270     * If the absolute value of `x` is within the `tolerance` or `x` is NaN,
2271       `0` is returned.
2272 * `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
2273     * `separator`: string, default: `","`
2274     * `include_empty`: boolean, default: `false`
2275     * `max_splits`: number, if it's positive, splits aren't limited,
2276       default: `-1`
2277     * `sep_is_pattern`: boolean, it specifies whether separator is a plain
2278       string or a pattern (regex), default: `false`
2279     * e.g. `"a,b":split","` returns `{"a","b"}`
2280 * `string:trim()`: returns the string without whitespace pre- and suffixes
2281     * e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
2282 * `minetest.wrap_text(str, limit, as_table)`: returns a string or table
2283     * Adds newlines to the string to keep it within the specified character
2284       limit
2285     * Note that the returned lines may be longer than the limit since it only
2286       splits at word borders.
2287     * `limit`: number, maximal amount of characters in one line
2288     * `as_table`: boolean, if set to true, a table of lines instead of a string
2289       is returned, default: `false`
2290 * `minetest.pos_to_string(pos, decimal_places)`: returns string `"(X,Y,Z)"`
2291     * `pos`: table {x=X, y=Y, z=Z}
2292     * Converts the position `pos` to a human-readable, printable string
2293     * `decimal_places`: number, if specified, the x, y and z values of
2294       the position are rounded to the given decimal place.
2295 * `minetest.string_to_pos(string)`: returns a position or `nil`
2296     * Same but in reverse.
2297     * If the string can't be parsed to a position, nothing is returned.
2298 * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")`: returns two positions
2299     * Converts a string representing an area box into two positions
2300 * `minetest.formspec_escape(string)`: returns a string
2301     * escapes the characters "[", "]", "\", "," and ";", which can not be used
2302       in formspecs.
2303 * `minetest.is_yes(arg)`
2304     * returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
2305 * `minetest.is_nan(arg)`
2306     * returns true when the passed number represents NaN.
2307 * `minetest.get_us_time()`
2308     * returns time with microsecond precision. May not return wall time.
2309 * `table.copy(table)`: returns a table
2310     * returns a deep copy of `table`
2311 * `table.insert_all(table, other_table)`:
2312     * Appends all values in `other_table` to `table` - uses `#table + 1` to
2313       find new indices.
2314 * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
2315   position.
2316     * returns the exact position on the surface of a pointed node
2317
2318
2319
2320
2321 Translations
2322 ============
2323
2324 Texts can be translated client-side with the help of `minetest.translate` and
2325 translation files.
2326
2327 Translating a string
2328 --------------------
2329 Two functions are provided to translate strings: `minetest.translate` and
2330 `minetest.get_translator`.
2331
2332 * `minetest.get_translator(textdomain)` is a simple wrapper around
2333   `minetest.translate`, and `minetest.get_translator(textdomain)(str, ...)` is
2334   equivalent to `minetest.translate(textdomain, str, ...)`.
2335   It is intended to be used in the following way, so that it avoids verbose
2336   repetitions of `minetest.translate`:
2337
2338     local S = minetest.get_translator(textdomain)
2339     S(str, ...)
2340
2341   As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.
2342
2343 * `minetest.translate(textdomain, str, ...)` translates the string `str` with
2344   the given `textdomain` for disambiguation. The textdomain must match the
2345   textdomain specified in the translation file in order to get the string
2346   translated. This can be used so that a string is translated differently in
2347   different contexts.
2348   It is advised to use the name of the mod as textdomain whenever possible, to
2349   avoid clashes with other mods.
2350   This function must be given a number of arguments equal to the number of
2351   arguments the translated string expects.
2352   Arguments are literal strings -- they will not be translated, so if you want
2353   them to be, they need to come as outputs of `minetest.translate` as well.
2354
2355   For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
2356   by the translation of "Red". We can do the following:
2357
2358     local S = minetest.get_translator()
2359     S("@1 Wool", S("Red"))
2360
2361   This will be displayed as "Red Wool" on old clients and on clients that do
2362   not have localization enabled. However, if we have for instance a translation
2363   file named `wool.fr.tr` containing the following:
2364
2365     @1 Wool=Laine @1
2366     Red=Rouge
2367
2368   this will be displayed as "Laine Rouge" on clients with a French locale.
2369
2370 Operations on translated strings
2371 --------------------------------
2372
2373 The output of `minetest.translate` is a string, with escape sequences adding
2374 additional information to that string so that it can be translated on the
2375 different clients. In particular, you can't expect operations like string.length
2376 to work on them like you would expect them to, or string.gsub to work in the
2377 expected manner. However, string concatenation will still work as expected
2378 (note that you should only use this for things like formspecs; do not translate
2379 sentences by breaking them into parts; arguments should be used instead), and
2380 operations such as `minetest.colorize` which are also concatenation.
2381
2382 Translation file format
2383 -----------------------
2384 A translation file has the suffix `.[lang].tr`, where `[lang]` is the language
2385 it corresponds to. It must be put into the `locale` subdirectory of the mod.
2386 The file should be a text file, with the following format:
2387
2388 * Lines beginning with `# textdomain:` (the space is significant) can be used
2389   to specify the text domain of all following translations in the file.
2390 * All other empty lines or lines beginning with `#` are ignored.
2391 * Other lines should be in the format `original=translated`. Both `original`
2392   and `translated` can contain escape sequences beginning with `@` to insert
2393   arguments, literal `@`, `=` or newline (See ### Escapes below).
2394   There must be no extraneous whitespace around the `=` or at the beginning or
2395   the end of the line.
2396
2397 Escapes
2398 -------
2399 Strings that need to be translated can contain several escapes, preceded by `@`.
2400
2401 * `@@` acts as a literal `@`.
2402 * `@n`, where `n` is a digit between 1 and 9, is an argument for the translated
2403   string that will be inlined when translation. Due to how translations are
2404   implemented, the original translation string **must** have its arguments in
2405   increasing order, without gaps or repetitions, starting from 1.
2406 * `@=` acts as a literal `=`. It is not required in strings given to
2407   `minetest.translate`, but is in translation files to avoid being confused
2408   with the `=` separating the original from the translation.
2409 * `@\n` (where the `\n` is a literal newline) acts as a literal newline.
2410   As with `@=`, this escape is not required in strings given to
2411   `minetest.translate`, but is in translation files.
2412 * `@n` acts as a literal newline as well.
2413
2414
2415
2416
2417 Perlin noise
2418 ============
2419
2420 Perlin noise creates a continuously-varying value depending on the input values.
2421 Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
2422 The result is used during map generation to create the terrain shape, vary heat
2423 and humidity to distribute biomes, vary the density of decorations or vary the
2424 structure of ores.
2425
2426 Structure of perlin noise
2427 -------------------------
2428 An 'octave' is a simple noise generator that outputs a value between -1 and 1.
2429 The smooth wavy noise it generates has a single characteristic scale, almost
2430 like a 'wavelength', so on its own does not create fine detail.
2431 Due to this perlin noise combines several octaves to create variation on
2432 multiple scales. Each additional octave has a smaller 'wavelength' than the
2433 previous.
2434
2435 This combination results in noise varying very roughly between -2.0 and 2.0 and
2436 with an average value of 0.0, so `scale` and `offset` are then used to multiply
2437 and offset the noise variation.
2438
2439 The final perlin noise variation is created as follows:
2440
2441 noise = offset + scale * (octave1 +
2442                           octave2 * persistence +
2443                           octave3 * persistence ^ 2 +
2444                           octave4 * persistence ^ 3 +
2445                           ...)
2446
2447 Noise Parameters
2448 ----------------
2449 Noise Parameters are commonly called `NoiseParams`.
2450
2451 ### `offset`
2452 After the multiplication by `scale` this is added to the result and is the final
2453 step in creating the noise value.
2454 Can be positive or negative.
2455
2456 ### `scale`
2457 Once all octaves have been combined, the result is multiplied by this.
2458 Can be positive or negative.
2459
2460 ### `spread`
2461 For octave1, this is roughly the change of input value needed for a very large
2462 variation in the noise value generated by octave1. It is almost like a
2463 'wavelength' for the wavy noise variation.
2464 Each additional octave has a 'wavelength' that is smaller than the previous
2465 octave, to create finer detail. `spread` will therefore roughly be the typical
2466 size of the largest structures in the final noise variation.
2467
2468 `spread` is a vector with values for x, y, z to allow the noise variation to be
2469 stretched or compressed in the desired axes.
2470 Values are positive numbers.
2471
2472 ### `seed`
2473 This is a whole number that determines the entire pattern of the noise
2474 variation. Altering it enables different noise patterns to be created.
2475 With other parameters equal, different seeds produce different noise patterns
2476 and identical seeds produce identical noise patterns.
2477
2478 For this parameter you can randomly choose any whole number. Usually it is
2479 preferable for this to be different from other seeds, but sometimes it is useful
2480 to be able to create identical noise patterns.
2481
2482 When used in mapgen this is actually a 'seed offset', it is added to the
2483 'world seed' to create the seed used by the noise, to ensure the noise has a
2484 different pattern in different worlds.
2485
2486 ### `octaves`
2487 The number of simple noise generators that are combined.
2488 A whole number, 1 or more.
2489 Each additional octave adds finer detail to the noise but also increases the
2490 noise calculation load.
2491 3 is a typical minimum for a high quality, complex and natural-looking noise
2492 variation. 1 octave has a slight 'gridlike' appearence.
2493
2494 Choose the number of octaves according to the `spread` and `lacunarity`, and the
2495 size of the finest detail you require. For example:
2496 if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
2497 nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
2498 512, 256, 128, 64, 32, 16 nodes.
2499 Warning: If the 'wavelength' of any octave falls below 1 an error will occur.
2500
2501 ### `persistence`
2502 Each additional octave has an amplitude that is the amplitude of the previous
2503 octave multiplied by `persistence`, to reduce the amplitude of finer details,
2504 as is often helpful and natural to do so.
2505 Since this controls the balance of fine detail to large-scale detail
2506 `persistence` can be thought of as the 'roughness' of the noise.
2507
2508 A positive or negative non-zero number, often between 0.3 and 1.0.
2509 A common medium value is 0.5, such that each octave has half the amplitude of
2510 the previous octave.
2511 This may need to be tuned when altering `lacunarity`; when doing so consider
2512 that a common medium value is 1 / lacunarity.
2513
2514 ### `lacunarity`
2515 Each additional octave has a 'wavelength' that is the 'wavelength' of the
2516 previous octave multiplied by 1 / lacunarity, to create finer detail.
2517 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
2518
2519 A positive number no smaller than 1.0.
2520 Values below 2.0 create higher quality noise at the expense of requiring more
2521 octaves to cover a paticular range of 'wavelengths'.
2522
2523 ### `flags`
2524 Leave this field unset for no special handling.
2525 Currently supported are `defaults`, `eased` and `absvalue`:
2526
2527 #### `defaults`
2528 Specify this if you would like to keep auto-selection of eased/not-eased while
2529 specifying some other flags.
2530
2531 #### `eased`
2532 Maps noise gradient values onto a quintic S-curve before performing
2533 interpolation. This results in smooth, rolling noise.
2534 Disable this (`noeased`) for sharp-looking noise with a slightly gridded
2535 appearence.
2536 If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
2537 not eased.
2538 Easing a 3D noise significantly increases the noise calculation load, so use
2539 with restraint.
2540
2541 #### `absvalue`
2542 The absolute value of each octave's noise variation is used when combining the
2543 octaves. The final perlin noise variation is created as follows:
2544
2545 noise = offset + scale * (abs(octave1) +
2546                           abs(octave2) * persistence +
2547                           abs(octave3) * persistence ^ 2 +
2548                           abs(octave4) * persistence ^ 3 +
2549                           ...)
2550
2551 ### Format example
2552 For 2D or 3D perlin noise or perlin noise maps:
2553
2554     np_terrain = {
2555         offset = 0,
2556         scale = 1,
2557         spread = {x = 500, y = 500, z = 500},
2558         seed = 571347,
2559         octaves = 5,
2560         persist = 0.63,
2561         lacunarity = 2.0,
2562         flags = "defaults, absvalue",
2563     }
2564
2565 For 2D noise the Z component of `spread` is still defined but is ignored.
2566 A single noise parameter table can be used for 2D or 3D noise.
2567
2568
2569
2570
2571 Ores
2572 ====
2573
2574 Ore types
2575 ---------
2576 These tell in what manner the ore is generated.
2577
2578 All default ores are of the uniformly-distributed scatter type.
2579
2580 ### `scatter`
2581 Randomly chooses a location and generates a cluster of ore.
2582
2583 If `noise_params` is specified, the ore will be placed if the 3D perlin noise
2584 at that point is greater than the `noise_threshold`, giving the ability to
2585 create a non-equal distribution of ore.
2586
2587 ### `sheet`
2588 Creates a sheet of ore in a blob shape according to the 2D perlin noise
2589 described by `noise_params` and `noise_threshold`. This is essentially an
2590 improved version of the so-called "stratus" ore seen in some unofficial mods.
2591
2592 This sheet consists of vertical columns of uniform randomly distributed height,
2593 varying between the inclusive range `column_height_min` and `column_height_max`.
2594 If `column_height_min` is not specified, this parameter defaults to 1.
2595 If `column_height_max` is not specified, this parameter defaults to `clust_size`
2596 for reverse compatibility. New code should prefer `column_height_max`.
2597
2598 The `column_midpoint_factor` parameter controls the position of the column at
2599 which ore emanates from.
2600 If 1, columns grow upward. If 0, columns grow downward. If 0.5, columns grow
2601 equally starting from each direction.
2602 `column_midpoint_factor` is a decimal number ranging in value from 0 to 1. If
2603 this parameter is not specified, the default is 0.5.
2604
2605 The ore parameters `clust_scarcity` and `clust_num_ores` are ignored for this
2606 ore type.
2607
2608 ### `puff`
2609 Creates a sheet of ore in a cloud-like puff shape.
2610
2611 As with the `sheet` ore type, the size and shape of puffs are described by
2612 `noise_params` and `noise_threshold` and are placed at random vertical
2613 positions within the currently generated chunk.
2614
2615 The vertical top and bottom displacement of each puff are determined by the
2616 noise parameters `np_puff_top` and `np_puff_bottom`, respectively.
2617
2618 ### `blob`
2619 Creates a deformed sphere of ore according to 3d perlin noise described by
2620 `noise_params`. The maximum size of the blob is `clust_size`, and
2621 `clust_scarcity` has the same meaning as with the `scatter` type.
2622
2623 ### `vein`
2624 Creates veins of ore varying in density by according to the intersection of two
2625 instances of 3d perlin noise with different seeds, both described by
2626 `noise_params`.
2627
2628 `random_factor` varies the influence random chance has on placement of an ore
2629 inside the vein, which is `1` by default. Note that modifying this parameter
2630 may require adjusting `noise_threshold`.
2631
2632 The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
2633 by this ore type.
2634
2635 This ore type is difficult to control since it is sensitive to small changes.
2636 The following is a decent set of parameters to work from:
2637
2638     noise_params = {
2639         offset  = 0,
2640         scale   = 3,
2641         spread  = {x=200, y=200, z=200},
2642         seed    = 5390,
2643         octaves = 4,
2644         persist = 0.5,
2645         lacunarity = 2.0,
2646         flags = "eased",
2647     },
2648     noise_threshold = 1.6
2649
2650 **WARNING**: Use this ore type *very* sparingly since it is ~200x more
2651 computationally expensive than any other ore.
2652
2653 ### `stratum`
2654 Creates a single undulating ore stratum that is continuous across mapchunk
2655 borders and horizontally spans the world.
2656
2657 The 2D perlin noise described by `noise_params` defines the Y co-ordinate of
2658 the stratum midpoint. The 2D perlin noise described by `np_stratum_thickness`
2659 defines the stratum's vertical thickness (in units of nodes). Due to being
2660 continuous across mapchunk borders the stratum's vertical thickness is
2661 unlimited.
2662
2663 If the noise parameter `noise_params` is omitted the ore will occur from y_min
2664 to y_max in a simple horizontal stratum.
2665
2666 A parameter `stratum_thickness` can be provided instead of the noise parameter
2667 `np_stratum_thickness`, to create a constant thickness.
2668
2669 Leaving out one or both noise parameters makes the ore generation less
2670 intensive, useful when adding multiple strata.
2671
2672 `y_min` and `y_max` define the limits of the ore generation and for performance
2673 reasons should be set as close together as possible but without clipping the
2674 stratum's Y variation.
2675
2676 Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a
2677 solid-ore stratum would require a `clust_scarcity` of 1.
2678
2679 The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and
2680 `random_factor` are ignored by this ore type.
2681
2682 Ore attributes
2683 --------------
2684 See section "Flag Specifier Format".
2685
2686 Currently supported flags:
2687 `puff_cliffs`, `puff_additive_composition`.
2688
2689 ### `puff_cliffs`
2690 If set, puff ore generation will not taper down large differences in
2691 displacement when approaching the edge of a puff. This flag has no effect for
2692 ore types other than `puff`.
2693
2694 ### `puff_additive_composition`
2695 By default, when noise described by `np_puff_top` or `np_puff_bottom` results
2696 in a negative displacement, the sub-column at that point is not generated. With
2697 this attribute set, puff ore generation will instead generate the absolute
2698 difference in noise displacement values. This flag has no effect for ore types
2699 other than `puff`.
2700
2701
2702
2703
2704 Decoration types
2705 ================
2706
2707 The varying types of decorations that can be placed.
2708
2709 `simple`
2710 --------
2711 Creates a 1 times `H` times 1 column of a specified node (or a random node from
2712 a list, if a decoration list is specified). Can specify a certain node it must
2713 spawn next to, such as water or lava, for example. Can also generate a
2714 decoration of random height between a specified lower and upper bound.
2715 This type of decoration is intended for placement of grass, flowers, cacti,
2716 papyri, waterlilies and so on.
2717
2718 `schematic`
2719 -----------
2720 Copies a box of `MapNodes` from a specified schematic file (or raw description).
2721 Can specify a probability of a node randomly appearing when placed.
2722 This decoration type is intended to be used for multi-node sized discrete
2723 structures, such as trees, cave spikes, rocks, and so on.
2724
2725
2726
2727
2728 Schematics
2729 ==========
2730
2731 Schematic specifier
2732 --------------------
2733 A schematic specifier identifies a schematic by either a filename to a
2734 Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
2735 in the form of a table.  This table specifies the following fields:
2736
2737 * The `size` field is a 3D vector containing the dimensions of the provided
2738   schematic. (required field)
2739 * The `yslice_prob` field is a table of {ypos, prob} slice tables. A slice table
2740   sets the probability of a particular horizontal slice of the schematic being
2741   placed. (optional field)
2742   `ypos` = 0 for the lowest horizontal slice of a schematic.
2743   The default of `prob` is 255.
2744 * The `data` field is a flat table of MapNode tables making up the schematic,
2745   in the order of `[z [y [x]]]`. (required field)
2746   Each MapNode table contains:
2747     * `name`: the name of the map node to place (required)
2748     * `prob` (alias `param1`): the probability of this node being placed
2749       (default: 255)
2750     * `param2`: the raw param2 value of the node being placed onto the map
2751       (default: 0)
2752     * `force_place`: boolean representing if the node should forcibly overwrite
2753       any previous contents (default: false)
2754
2755 About probability values:
2756
2757 * A probability value of `0` or `1` means that node will never appear
2758   (0% chance).
2759 * A probability value of `254` or `255` means the node will always appear
2760   (100% chance).
2761 * If the probability value `p` is greater than `1`, then there is a
2762   `(p / 256 * 100)` percent chance that node will appear when the schematic is
2763   placed on the map.
2764
2765 Schematic attributes
2766 --------------------
2767 See section "Flag Specifier Format".
2768
2769 Currently supported flags: `place_center_x`, `place_center_y`, `place_center_z`,
2770                            `force_placement`.
2771
2772 * `place_center_x`: Placement of this decoration is centered along the X axis.
2773 * `place_center_y`: Placement of this decoration is centered along the Y axis.
2774 * `place_center_z`: Placement of this decoration is centered along the Z axis.
2775 * `force_placement`: Schematic nodes other than "ignore" will replace existing
2776   nodes.
2777
2778
2779
2780
2781 Lua Voxel Manipulator
2782 =====================
2783
2784 About VoxelManip
2785 ----------------
2786 VoxelManip is a scripting interface to the internal 'Map Voxel Manipulator'
2787 facility. The purpose of this object is for fast, low-level, bulk access to
2788 reading and writing Map content. As such, setting map nodes through VoxelManip
2789 will lack many of the higher level features and concepts you may be used to
2790 with other methods of setting nodes. For example, nodes will not have their
2791 construction and destruction callbacks run, and no rollback information is
2792 logged.
2793
2794 It is important to note that VoxelManip is designed for speed, and *not* ease
2795 of use or flexibility. If your mod requires a map manipulation facility that
2796 will handle 100% of all edge cases, or the use of high level node placement
2797 features, perhaps `minetest.set_node()` is better suited for the job.
2798
2799 In addition, VoxelManip might not be faster, or could even be slower, for your
2800 specific use case. VoxelManip is most effective when setting large areas of map
2801 at once - for example, if only setting a 3x3x3 node area, a
2802 `minetest.set_node()` loop may be more optimal. Always profile code using both
2803 methods of map manipulation to determine which is most appropriate for your
2804 usage.
2805
2806 A recent simple test of setting cubic areas showed that `minetest.set_node()`
2807 is faster than a VoxelManip for a 3x3x3 node cube or smaller.
2808
2809 Using VoxelManip
2810 ----------------
2811 A VoxelManip object can be created any time using either:
2812 `VoxelManip([p1, p2])`, or `minetest.get_voxel_manip([p1, p2])`.
2813
2814 If the optional position parameters are present for either of these routines,
2815 the specified region will be pre-loaded into the VoxelManip object on creation.
2816 Otherwise, the area of map you wish to manipulate must first be loaded into the
2817 VoxelManip object using `VoxelManip:read_from_map()`.
2818
2819 Note that `VoxelManip:read_from_map()` returns two position vectors. The region
2820 formed by these positions indicate the minimum and maximum (respectively)
2821 positions of the area actually loaded in the VoxelManip, which may be larger
2822 than the area requested. For convenience, the loaded area coordinates can also
2823 be queried any time after loading map data with `VoxelManip:get_emerged_area()`.
2824
2825 Now that the VoxelManip object is populated with map data, your mod can fetch a
2826 copy of this data using either of two methods. `VoxelManip:get_node_at()`,
2827 which retrieves an individual node in a MapNode formatted table at the position
2828 requested is the simplest method to use, but also the slowest.
2829
2830 Nodes in a VoxelManip object may also be read in bulk to a flat array table
2831 using:
2832
2833 * `VoxelManip:get_data()` for node content (in Content ID form, see section
2834   'Content IDs'),
2835 * `VoxelManip:get_light_data()` for node light levels, and
2836 * `VoxelManip:get_param2_data()` for the node type-dependent "param2" values.
2837
2838 See section 'Flat array format' for more details.
2839
2840 It is very important to understand that the tables returned by any of the above
2841 three functions represent a snapshot of the VoxelManip's internal state at the
2842 time of the call. This copy of the data will not magically update itself if
2843 another function modifies the internal VoxelManip state.
2844 Any functions that modify a VoxelManip's contents work on the VoxelManip's
2845 internal state unless otherwise explicitly stated.
2846
2847 Once the bulk data has been edited to your liking, the internal VoxelManip
2848 state can be set using:
2849
2850 * `VoxelManip:set_data()` for node content (in Content ID form, see section
2851   'Content IDs'),
2852 * `VoxelManip:set_light_data()` for node light levels, and
2853 * `VoxelManip:set_param2_data()` for the node type-dependent `param2` values.
2854
2855 The parameter to each of the above three functions can use any table at all in
2856 the same flat array format as produced by `get_data()` etc. and is not required
2857 to be a table retrieved from `get_data()`.
2858
2859 Once the internal VoxelManip state has been modified to your liking, the
2860 changes can be committed back to the map by calling `VoxelManip:write_to_map()`
2861
2862
2863 ### Flat array format
2864 Let
2865     `Nx = p2.X - p1.X + 1`,
2866     `Ny = p2.Y - p1.Y + 1`, and
2867     `Nz = p2.Z - p1.Z + 1`.
2868
2869 Then, for a loaded region of p1..p2, this array ranges from `1` up to and
2870 including the value of the expression `Nx * Ny * Nz`.
2871
2872 Positions offset from p1 are present in the array with the format of:
2873
2874 ```
2875 [
2876     (0, 0, 0),   (1, 0, 0),   (2, 0, 0),   ... (Nx, 0, 0),
2877     (0, 1, 0),   (1, 1, 0),   (2, 1, 0),   ... (Nx, 1, 0),
2878     ...
2879     (0, Ny, 0),  (1, Ny, 0),  (2, Ny, 0),  ... (Nx, Ny, 0),
2880     (0, 0, 1),   (1, 0, 1),   (2, 0, 1),   ... (Nx, 0, 1),
2881     ...
2882     (0, Ny, 2),  (1, Ny, 2),  (2, Ny, 2),  ... (Nx, Ny, 2),
2883     ...
2884     (0, Ny, Nz), (1, Ny, Nz), (2, Ny, Nz), ... (Nx, Ny, Nz)
2885 ]
2886 ```
2887
2888 and the array index for a position p contained completely in p1..p2 is:
2889
2890 `(p.Z - p1.Z) * Ny * Nx + (p.Y - p1.Y) * Nx + (p.X - p1.X) + 1`
2891
2892 Note that this is the same "flat 3D array" format as
2893 `PerlinNoiseMap:get3dMap_flat()`.
2894 VoxelArea objects (see section 'VoxelArea') can be used to simplify calculation
2895 of the index for a single point in a flat VoxelManip array.
2896
2897 ### Content IDs
2898 A Content ID is a unique integer identifier for a specific node type.
2899 These IDs are used by VoxelManip in place of the node name string for
2900 `VoxelManip:get_data()` and `VoxelManip:set_data()`. You can use
2901 `minetest.get_content_id()` to look up the Content ID for the specified node
2902 name, and `minetest.get_name_from_content_id()` to look up the node name string
2903 for a given Content ID.
2904 After registration of a node, its Content ID will remain the same throughout
2905 execution of the mod.
2906 Note that the node being queried needs to have already been been registered.
2907
2908 The following builtin node types have their Content IDs defined as constants:
2909
2910 * `minetest.CONTENT_UNKNOWN`: ID for "unknown" nodes
2911 * `minetest.CONTENT_AIR`:     ID for "air" nodes
2912 * `minetest.CONTENT_IGNORE`:  ID for "ignore" nodes
2913
2914 ### Mapgen VoxelManip objects
2915 Inside of `on_generated()` callbacks, it is possible to retrieve the same
2916 VoxelManip object used by the core's Map Generator (commonly abbreviated
2917 Mapgen). Most of the rules previously described still apply but with a few
2918 differences:
2919
2920 * The Mapgen VoxelManip object is retrieved using:
2921   `minetest.get_mapgen_object("voxelmanip")`
2922 * This VoxelManip object already has the region of map just generated loaded
2923   into it; it's not necessary to call `VoxelManip:read_from_map()` before using
2924   a Mapgen VoxelManip.
2925 * The `on_generated()` callbacks of some mods may place individual nodes in the
2926   generated area using non-VoxelManip map modification methods. Because the
2927   same Mapgen VoxelManip object is passed through each `on_generated()`
2928   callback, it becomes necessary for the Mapgen VoxelManip object to maintain
2929   consistency with the current map state. For this reason, calling any of the
2930   following functions:
2931   `minetest.add_node()`, `minetest.set_node()`, or `minetest.swap_node()`
2932   will also update the Mapgen VoxelManip object's internal state active on the
2933   current thread.
2934 * After modifying the Mapgen VoxelManip object's internal buffer, it may be
2935   necessary to update lighting information using either:
2936   `VoxelManip:calc_lighting()` or `VoxelManip:set_lighting()`.
2937
2938 ### Other API functions operating on a VoxelManip
2939 If any VoxelManip contents were set to a liquid node,
2940 `VoxelManip:update_liquids()` must be called for these liquid nodes to begin
2941 flowing. It is recommended to call this function only after having written all
2942 buffered data back to the VoxelManip object, save for special situations where
2943 the modder desires to only have certain liquid nodes begin flowing.
2944
2945 The functions `minetest.generate_ores()` and `minetest.generate_decorations()`
2946 will generate all registered decorations and ores throughout the full area
2947 inside of the specified VoxelManip object.
2948
2949 `minetest.place_schematic_on_vmanip()` is otherwise identical to
2950 `minetest.place_schematic()`, except instead of placing the specified schematic
2951 directly on the map at the specified position, it will place the schematic
2952 inside the VoxelManip.
2953
2954 ### Notes
2955 * Attempting to read data from a VoxelManip object before map is read will
2956   result in a zero-length array table for `VoxelManip:get_data()`, and an
2957   "ignore" node at any position for `VoxelManip:get_node_at()`.
2958 * If either a region of map has not yet been generated or is out-of-bounds of
2959   the map, that region is filled with "ignore" nodes.
2960 * Other mods, or the core itself, could possibly modify the area of map
2961   currently loaded into a VoxelManip object. With the exception of Mapgen
2962   VoxelManips (see above section), the internal buffers are not updated. For
2963   this reason, it is strongly encouraged to complete the usage of a particular
2964   VoxelManip object in the same callback it had been created.
2965 * If a VoxelManip object will be used often, such as in an `on_generated()`
2966   callback, consider passing a file-scoped table as the optional parameter to
2967   `VoxelManip:get_data()`, which serves as a static buffer the function can use
2968   to write map data to instead of returning a new table each call. This greatly
2969   enhances performance by avoiding unnecessary memory allocations.
2970
2971 Methods
2972 -------
2973 * `read_from_map(p1, p2)`:  Loads a chunk of map into the VoxelManip object
2974   containing the region formed by `p1` and `p2`.
2975     * returns actual emerged `pmin`, actual emerged `pmax`
2976 * `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
2977   the map.
2978     * **important**: data must be set using `VoxelManip:set_data()` before
2979       calling this.
2980     * if `light` is true, then lighting is automatically recalculated.
2981       The default value is true.
2982       If `light` is false, no light calculations happen, and you should correct
2983       all modified blocks with `minetest.fix_light()` as soon as possible.
2984       Keep in mind that modifying the map where light is incorrect can cause
2985       more lighting bugs.
2986 * `get_node_at(pos)`: Returns a `MapNode` table of the node currently loaded in
2987   the `VoxelManip` at that position
2988 * `set_node_at(pos, node)`: Sets a specific `MapNode` in the `VoxelManip` at
2989   that position.
2990 * `get_data([buffer])`: Retrieves the node content data loaded into the
2991   `VoxelManip` object.
2992     * returns raw node data in the form of an array of node content IDs
2993     * if the param `buffer` is present, this table will be used to store the
2994       result instead.
2995 * `set_data(data)`: Sets the data contents of the `VoxelManip` object
2996 * `update_map()`: Does nothing, kept for compatibility.
2997 * `set_lighting(light, [p1, p2])`: Set the lighting within the `VoxelManip` to
2998   a uniform value.
2999     * `light` is a table, `{day=<0...15>, night=<0...15>}`
3000     * To be used only by a `VoxelManip` object from
3001       `minetest.get_mapgen_object`.
3002     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
3003       area if left out.
3004 * `get_light_data()`: Gets the light data read into the `VoxelManip` object
3005     * Returns an array (indices 1 to volume) of integers ranging from `0` to
3006       `255`.
3007     * Each value is the bitwise combination of day and night light values
3008       (`0` to `15` each).
3009     * `light = day + (night * 16)`
3010 * `set_light_data(light_data)`: Sets the `param1` (light) contents of each node
3011   in the `VoxelManip`.
3012     * expects lighting data in the same format that `get_light_data()` returns
3013 * `get_param2_data([buffer])`: Gets the raw `param2` data read into the
3014   `VoxelManip` object.
3015     * Returns an array (indices 1 to volume) of integers ranging from `0` to
3016       `255`.
3017     * If the param `buffer` is present, this table will be used to store the
3018       result instead.
3019 * `set_param2_data(param2_data)`: Sets the `param2` contents of each node in
3020   the `VoxelManip`.
3021 * `calc_lighting([p1, p2], [propagate_shadow])`:  Calculate lighting within the
3022   `VoxelManip`.
3023     * To be used only by a `VoxelManip` object from
3024       `minetest.get_mapgen_object`.
3025     * (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
3026       area if left out or nil.
3027     * `propagate_shadow` is an optional boolean deciding whether shadows in a
3028       generated mapchunk above are propagated down into the mapchunk, defaults
3029       to `true` if left out.
3030 * `update_liquids()`: Update liquid flow
3031 * `was_modified()`: Returns `true` or `false` if the data in the voxel
3032   manipulator had been modified since the last read from map, due to a call to
3033   `minetest.set_data()` on the loaded area elsewhere.
3034 * `get_emerged_area()`: Returns actual emerged minimum and maximum positions.
3035
3036 `VoxelArea`
3037 -----------
3038 A helper class for voxel areas.
3039 It can be created via `VoxelArea:new{MinEdge=pmin, MaxEdge=pmax}`.
3040 The coordinates are *inclusive*, like most other things in Minetest.
3041
3042 ### Methods
3043 * `getExtent()`: returns a 3D vector containing the size of the area formed by
3044   `MinEdge` and `MaxEdge`.
3045 * `getVolume()`: returns the volume of the area formed by `MinEdge` and
3046   `MaxEdge`.
3047 * `index(x, y, z)`: returns the index of an absolute position in a flat array
3048   starting at `1`.
3049     * `x`, `y` and `z` must be integers to avoid an incorrect index result.
3050     * The position (x, y, z) is not checked for being inside the area volume,
3051       being outside can cause an incorrect index result.
3052     * Useful for things like `VoxelManip`, raw Schematic specifiers,
3053       `PerlinNoiseMap:get2d`/`3dMap`, and so on.
3054 * `indexp(p)`: same functionality as `index(x, y, z)` but takes a vector.
3055     * As with `index(x, y, z)`, the components of `p` must be integers, and `p`
3056       is not checked for being inside the area volume.
3057 * `position(i)`: returns the absolute position vector corresponding to index
3058   `i`.
3059 * `contains(x, y, z)`: check if (`x`,`y`,`z`) is inside area formed by
3060   `MinEdge` and `MaxEdge`.
3061 * `containsp(p)`: same as above, except takes a vector
3062 * `containsi(i)`: same as above, except takes an index `i`
3063 * `iter(minx, miny, minz, maxx, maxy, maxz)`: returns an iterator that returns
3064   indices.
3065     * from (`minx`,`miny`,`minz`) to (`maxx`,`maxy`,`maxz`) in the order of
3066       `[z [y [x]]]`.
3067 * `iterp(minp, maxp)`: same as above, except takes a vector
3068
3069
3070
3071
3072 Mapgen objects
3073 ==============
3074
3075 A mapgen object is a construct used in map generation. Mapgen objects can be
3076 used by an `on_generate` callback to speed up operations by avoiding
3077 unnecessary recalculations, these can be retrieved using the
3078 `minetest.get_mapgen_object()` function. If the requested Mapgen object is
3079 unavailable, or `get_mapgen_object()` was called outside of an `on_generate()`
3080 callback, `nil` is returned.
3081
3082 The following Mapgen objects are currently available:
3083
3084 ### `voxelmanip`
3085
3086 This returns three values; the `VoxelManip` object to be used, minimum and
3087 maximum emerged position, in that order. All mapgens support this object.
3088
3089 ### `heightmap`
3090
3091 Returns an array containing the y coordinates of the ground levels of nodes in
3092 the most recently generated chunk by the current mapgen.
3093
3094 ### `biomemap`
3095
3096 Returns an array containing the biome IDs of nodes in the most recently
3097 generated chunk by the current mapgen.
3098
3099 ### `heatmap`
3100
3101 Returns an array containing the temperature values of nodes in the most
3102 recently generated chunk by the current mapgen.
3103
3104 ### `humiditymap`
3105
3106 Returns an array containing the humidity values of nodes in the most recently
3107 generated chunk by the current mapgen.
3108
3109 ### `gennotify`
3110
3111 Returns a table mapping requested generation notification types to arrays of
3112 positions at which the corresponding generated structures are located within
3113 the current chunk. To set the capture of positions of interest to be recorded
3114 on generate, use `minetest.set_gen_notify()`.
3115 For decorations, the returned positions are the ground surface 'place_on'
3116 nodes, not the decorations themselves. A 'simple' type decoration is often 1
3117 node above the returned position and possibly displaced by 'place_offset_y'.
3118
3119 Possible fields of the table returned are:
3120
3121 * `dungeon`
3122 * `temple`
3123 * `cave_begin`
3124 * `cave_end`
3125 * `large_cave_begin`
3126 * `large_cave_end`
3127 * `decoration`
3128
3129 Decorations have a key in the format of `"decoration#id"`, where `id` is the
3130 numeric unique decoration ID.
3131
3132
3133
3134
3135 Registered entities
3136 ===================
3137
3138 * Functions receive a "luaentity" as `self`:
3139     * It has the member `.name`, which is the registered name `("mod:thing")`
3140     * It has the member `.object`, which is an `ObjectRef` pointing to the
3141       object.
3142     * The original prototype stuff is visible directly via a metatable
3143 * Callbacks:
3144     * `on_activate(self, staticdata, dtime_s)`
3145         * Called when the object is instantiated.
3146         * `dtime_s` is the time passed since the object was unloaded, which can
3147           be used for updating the entity state.
3148     * `on_step(self, dtime)`
3149         * Called on every server tick, after movement and collision processing.
3150           `dtime` is usually 0.1 seconds, as per the `dedicated_server_step`
3151           setting `in minetest.conf`.
3152     * `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)`
3153         * Called when somebody punches the object.
3154         * Note that you probably want to handle most punches using the
3155           automatic armor group system.
3156         * `puncher`: an `ObjectRef` (can be `nil`)
3157         * `time_from_last_punch`: Meant for disallowing spamming of clicks
3158           (can be `nil`).
3159         * `tool_capabilities`: capability table of used tool (can be `nil`)
3160         * `dir`: unit vector of direction of punch. Always defined. Points from
3161           the puncher to the punched.
3162     * `on_death(self, killer)`
3163         * Called when the object dies.
3164         * `killer`: an `ObjectRef` (can be `nil`)
3165     * `on_rightclick(self, clicker)`
3166     * `on_attach_child(self, child)`
3167         * `child`: an `ObjectRef` of the child that attaches
3168     * `on_detach_child(self, child)`
3169         * `child`: an `ObjectRef` of the child that detaches
3170     * `on_detach(self, parent)`
3171         * `parent`: an `ObjectRef` (can be `nil`) from where it got detached
3172         * This happens before the parent object is removed from the world
3173     * `get_staticdata(self)`
3174         * Should return a string that will be passed to `on_activate` when
3175           the object is instantiated the next time.
3176
3177
3178
3179
3180 L-system trees
3181 ==============
3182
3183 Tree definition
3184 ---------------
3185
3186     treedef={
3187         axiom,         --string  initial tree axiom
3188         rules_a,       --string  rules set A
3189         rules_b,       --string  rules set B
3190         rules_c,       --string  rules set C
3191         rules_d,       --string  rules set D
3192         trunk,         --string  trunk node name
3193         leaves,        --string  leaves node name
3194         leaves2,       --string  secondary leaves node name
3195         leaves2_chance,--num     chance (0-100) to replace leaves with leaves2
3196         angle,         --num     angle in deg
3197         iterations,    --num     max # of iterations, usually 2 -5
3198         random_level,  --num     factor to lower nr of iterations, usually 0 - 3
3199         trunk_type,    --string  single/double/crossed) type of trunk: 1 node,
3200                        --        2x2 nodes or 3x3 in cross shape
3201         thin_branches, --boolean true -> use thin (1 node) branches
3202         fruit,         --string  fruit node name
3203         fruit_chance,  --num     chance (0-100) to replace leaves with fruit node
3204         seed,          --num     random seed, if no seed is provided, the engine
3205                                  will create one.
3206     }
3207
3208 Key for Special L-System Symbols used in Axioms
3209 -----------------------------------------------
3210
3211 * `G`: move forward one unit with the pen up
3212 * `F`: move forward one unit with the pen down drawing trunks and branches
3213 * `f`: move forward one unit with the pen down drawing leaves (100% chance)
3214 * `T`: move forward one unit with the pen down drawing trunks only
3215 * `R`: move forward one unit with the pen down placing fruit
3216 * `A`: replace with rules set A
3217 * `B`: replace with rules set B
3218 * `C`: replace with rules set C
3219 * `D`: replace with rules set D
3220 * `a`: replace with rules set A, chance 90%
3221 * `b`: replace with rules set B, chance 80%
3222 * `c`: replace with rules set C, chance 70%
3223 * `d`: replace with rules set D, chance 60%
3224 * `+`: yaw the turtle right by `angle` parameter
3225 * `-`: yaw the turtle left by `angle` parameter
3226 * `&`: pitch the turtle down by `angle` parameter
3227 * `^`: pitch the turtle up by `angle` parameter
3228 * `/`: roll the turtle to the right by `angle` parameter
3229 * `*`: roll the turtle to the left by `angle` parameter
3230 * `[`: save in stack current state info
3231 * `]`: recover from stack state info
3232
3233 Example
3234 -------
3235 Spawn a small apple tree:
3236
3237     pos = {x=230,y=20,z=4}
3238     apple_tree={
3239         axiom="FFFFFAFFBF",
3240         rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
3241         rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
3242         trunk="default:tree",
3243         leaves="default:leaves",
3244         angle=30,
3245         iterations=2,
3246         random_level=0,
3247         trunk_type="single",
3248         thin_branches=true,
3249         fruit_chance=10,
3250         fruit="default:apple"
3251     }
3252     minetest.spawn_tree(pos,apple_tree)
3253
3254
3255
3256
3257 'minetest' namespace reference
3258 ==============================
3259
3260 Utilities
3261 ---------
3262
3263 * `minetest.get_current_modname()`: returns the currently loading mod's name,
3264   when loading a mod.
3265 * `minetest.get_modpath(modname)`: returns e.g.
3266   `"/home/user/.minetest/usermods/modname"`.
3267     * Useful for loading additional `.lua` modules or static data from mod
3268 * `minetest.get_modnames()`: returns a list of installed mods
3269     * Return a list of installed mods, sorted alphabetically
3270 * `minetest.get_worldpath()`: returns e.g. `"/home/user/.minetest/world"`
3271     * Useful for storing custom data
3272 * `minetest.is_singleplayer()`
3273 * `minetest.features`: Table containing API feature flags
3274
3275         {
3276            glasslike_framed = true,
3277            nodebox_as_selectionbox = true,
3278            chat_send_player_param3 = true,
3279            get_all_craft_recipes_works = true,
3280            use_texture_alpha = true,
3281         -- ^ The transparency channel of textures can optionally be used on nodes
3282            no_legacy_abms = true,
3283         -- ^ Tree and grass ABMs are no longer done from C++
3284            texture_names_parens = true,
3285         -- ^ Texture grouping is possible using parentheses
3286            area_store_custom_ids = true,
3287         -- ^ Unique Area ID for AreaStore:insert_area
3288            add_entity_with_staticdata = true,
3289         -- ^ add_entity supports passing initial staticdata to on_activate
3290            no_chat_message_prediction = true,
3291         -- ^ Chat messages are no longer predicted
3292            object_use_texture_alpha = true
3293         -- ^ The transparency channel of textures can optionally be used on
3294         --   objects (ie: players and lua entities)
3295         }
3296 * `minetest.has_feature(arg)`: returns `boolean, missing_features`
3297     * `arg`: string or table in format `{foo=true, bar=true}`
3298     * `missing_features`: `{foo=true, bar=true}`
3299 * `minetest.get_player_information(player_name)`:
3300     * Returns a table containing information about a player.
3301       Example return value:
3302
3303             {
3304                 address = "127.0.0.1",     -- IP address of client
3305                 ip_version = 4,            -- IPv4 / IPv6
3306                 min_rtt = 0.01,            -- minimum round trip time
3307                 max_rtt = 0.2,             -- maximum round trip time
3308                 avg_rtt = 0.02,            -- average round trip time
3309                 min_jitter = 0.01,         -- minimum packet time jitter
3310                 max_jitter = 0.5,          -- maximum packet time jitter
3311                 avg_jitter = 0.03,         -- average packet time jitter
3312                 connection_uptime = 200,   -- seconds since client connected
3313                 protocol_version = 32,     -- protocol version used by client
3314                 -- following information is available on debug build only!!!
3315                 -- DO NOT USE IN MODS
3316                 --ser_vers = 26,             -- serialization version used by client
3317                 --major = 0,                 -- major version number
3318                 --minor = 4,                 -- minor version number
3319                 --patch = 10,                -- patch version number
3320                 --vers_string = "0.4.9-git", -- full version string
3321                 --state = "Active"           -- current client state
3322             }
3323 * `minetest.mkdir(path)`: returns success.
3324     * Creates a directory specified by `path`, creating parent directories
3325       if they don't exist.
3326 * `minetest.get_dir_list(path, [is_dir])`: returns list of entry names
3327     * is_dir is one of:
3328         * nil: return all entries,
3329         * true: return only subdirectory names, or
3330         * false: return only file names.
3331 * `minetest.safe_file_write(path, content)`: returns boolean indicating success
3332     * Replaces contents of file at path with new contents in a safe (atomic)
3333       way. Use this instead of below code when writing e.g. database files:
3334       `local f = io.open(path, "wb"); f:write(content); f:close()`
3335 * `minetest.get_version()`: returns a table containing components of the
3336    engine version.  Components:
3337     * `project`: Name of the project, eg, "Minetest"
3338     * `string`: Simple version, eg, "1.2.3-dev"
3339     * `hash`: Full git version (only set if available),
3340       eg, "1.2.3-dev-01234567-dirty".
3341   Use this for informational purposes only. The information in the returned
3342   table does not represent the capabilities of the engine, nor is it
3343   reliable or verifiable. Compatible forks will have a different name and
3344   version entirely. To check for the presence of engine features, test
3345   whether the functions exported by the wanted features exist. For example:
3346   `if minetest.check_for_falling then ... end`.
3347 * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
3348     * `data`: string of data to hash
3349     * `raw`: return raw bytes instead of hex digits, default: false
3350
3351 Logging
3352 -------
3353 * `minetest.debug(...)`
3354     * Equivalent to `minetest.log(table.concat({...}, "\t"))`
3355 * `minetest.log([level,] text)`
3356     * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
3357       `"info"`, or `"verbose"`.  Default is `"none"`.
3358
3359 Registration functions
3360 ----------------------
3361 Call these functions only at load time!
3362
3363 * `minetest.register_entity(name, prototype table)`
3364 * `minetest.register_abm(abm definition)`
3365 * `minetest.register_lbm(lbm definition)`
3366 * `minetest.register_node(name, node definition)`
3367 * `minetest.register_tool(name, item definition)`
3368 * `minetest.register_craftitem(name, item definition)`
3369 * `minetest.unregister_item(name)`
3370 * `minetest.register_alias(name, convert_to)`
3371     * Also use this to set the 'mapgen aliases' needed in a game for the core
3372     * mapgens. See 'Mapgen aliases' section above.
3373 * `minetest.register_alias_force(name, convert_to)`
3374 * `minetest.register_craft(recipe)`
3375     * Check recipe table syntax for different types below.
3376 * `minetest.clear_craft(recipe)`
3377     * Will erase existing craft based either on output item or on input recipe.
3378     * Specify either output or input only. If you specify both, input will be
3379       ignored. For input use the same recipe table syntax as for
3380       `minetest.register_craft(recipe)`. For output specify only the item,
3381       without a quantity.
3382     * If no erase candidate could be found, Lua exception will be thrown.
3383     * **Warning**! The type field ("shaped","cooking" or any other) will be
3384       ignored if the recipe contains output. Erasing is then done independently
3385       from the crafting method.
3386 * `minetest.register_ore(ore definition)`
3387 * `minetest.register_biome(biome definition)`
3388 * `minetest.register_decoration(decoration definition)`
3389 * `minetest.override_item(name, redefinition)`
3390     * Overrides fields of an item registered with register_node/tool/craftitem.
3391     * Note: Item must already be defined, (opt)depend on the mod defining it.
3392     * Example: `minetest.override_item("default:mese", {light_source=LIGHT_MAX})`
3393 * `minetest.clear_registered_ores()`
3394 * `minetest.clear_registered_biomes()`
3395 * `minetest.clear_registered_decorations()`
3396
3397 Global callback registration functions
3398 --------------------------------------
3399 Call these functions only at load time!
3400
3401 * `minetest.register_globalstep(func(dtime))`
3402     * Called every server step, usually interval of 0.1s
3403 * `minetest.register_on_mods_loaded(func())`
3404     * Called after mods have finished loading and before the media is cached or the
3405       aliases handled.
3406 * `minetest.register_on_shutdown(func())`
3407     * Called before server shutdown
3408     * **Warning**: If the server terminates abnormally (i.e. crashes), the
3409       registered callbacks **will likely not be run**. Data should be saved at
3410       semi-frequent intervals as well as on server shutdown.
3411 * `minetest.register_on_placenode(func(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
3412     * Called when a node has been placed
3413     * If return `true` no item is taken from `itemstack`
3414     * `placer` may be any valid ObjectRef or nil.
3415     * **Not recommended**; use `on_construct` or `after_place_node` in node
3416       definition whenever possible.
3417 * `minetest.register_on_dignode(func(pos, oldnode, digger))`
3418     * Called when a node has been dug.
3419     * **Not recommended**; Use `on_destruct` or `after_dig_node` in node
3420       definition whenever possible.
3421 * `minetest.register_on_punchnode(func(pos, node, puncher, pointed_thing))`
3422     * Called when a node is punched
3423 * `minetest.register_on_generated(func(minp, maxp, blockseed))`
3424     * Called after generating a piece of world. Modifying nodes inside the area
3425       is a bit faster than usually.
3426 * `minetest.register_on_newplayer(func(ObjectRef))`
3427     * Called after a new player has been created
3428 * `minetest.register_on_punchplayer(func(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
3429     * Called when a player is punched
3430     * `player` - ObjectRef - Player that was punched
3431     * `hitter` - ObjectRef - Player that hit
3432     * `time_from_last_punch`: Meant for disallowing spamming of clicks
3433       (can be nil).
3434     * `tool_capabilities`: capability table of used tool (can be nil)
3435     * `dir`: unit vector of direction of punch. Always defined. Points from
3436       the puncher to the punched.
3437     * `damage` - number that represents the damage calculated by the engine
3438     * should return `true` to prevent the default damage mechanism
3439 * `minetest.register_on_player_hpchange(func(player, hp_change, reason), modifier)`
3440     * Called when the player gets damaged or healed
3441     * `player`: ObjectRef of the player
3442     * `hp_change`: the amount of change. Negative when it is damage.
3443     * `reason`: a PlayerHPChangeReason table.
3444         * The `type` field will have one of the following values:
3445             * `set_hp` - A mod or the engine called `set_hp` without
3446                          giving a type - use this for custom damage types.
3447             * `punch` - Was punched. `reason.object` will hold the puncher, or nil if none.
3448             * `fall`
3449             * `node_damage` - damage_per_second from a neighbouring node.
3450             * `drown`
3451             * `respawn`
3452         * Any of the above types may have additional fields from mods.
3453         * `reason.from` will be `mod` or `engine`.
3454     * `modifier`: when true, the function should return the actual `hp_change`.
3455        Note: modifiers only get a temporary hp_change that can be modified by later modifiers.
3456        modifiers can return true as a second argument to stop the execution of further functions.
3457        Non-modifiers receive the final hp change calculated by the modifiers.
3458 * `minetest.register_on_dieplayer(func(ObjectRef, reason))`
3459     * Called when a player dies
3460     * `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
3461 * `minetest.register_on_respawnplayer(func(ObjectRef))`
3462     * Called when player is to be respawned
3463     * Called _before_ repositioning of player occurs
3464     * return true in func to disable regular player placement
3465 * `minetest.register_on_prejoinplayer(func(name, ip))`
3466     * Called before a player joins the game
3467     * If it returns a string, the player is disconnected with that string as
3468       reason.
3469 * `minetest.register_on_joinplayer(func(ObjectRef))`
3470     * Called when a player joins the game
3471 * `minetest.register_on_leaveplayer(func(ObjectRef, timed_out))`
3472     * Called when a player leaves the game
3473     * `timed_out`: True for timeout, false for other reasons.
3474 * `minetest.register_on_auth_fail(func(name, ip))`
3475     * Called when a client attempts to log into an account but supplies the
3476       wrong password.
3477     * `ip`: The IP address of the client.
3478     * `name`: The account the client attempted to log into.
3479 * `minetest.register_on_cheat(func(ObjectRef, cheat))`
3480     * Called when a player cheats
3481     * `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
3482         * `moved_too_fast`
3483         * `interacted_too_far`
3484         * `interacted_while_dead`
3485         * `finished_unknown_dig`
3486         * `dug_unbreakable`
3487         * `dug_too_fast`
3488 * `minetest.register_on_chat_message(func(name, message))`
3489     * Called always when a player says something
3490     * Return `true` to mark the message as handled, which means that it will
3491       not be sent to other players.
3492 * `minetest.register_on_player_receive_fields(func(player, formname, fields))`
3493     * Called when a button is pressed in player's inventory form
3494     * Newest functions are called first
3495     * If function returns `true`, remaining functions are not called
3496 * `minetest.register_on_craft(func(itemstack, player, old_craft_grid, craft_inv))`
3497     * Called when `player` crafts something
3498     * `itemstack` is the output
3499     * `old_craft_grid` contains the recipe (Note: the one in the inventory is
3500       cleared).
3501     * `craft_inv` is the inventory with the crafting grid
3502     * Return either an `ItemStack`, to replace the output, or `nil`, to not
3503       modify it.
3504 * `minetest.register_craft_predict(func(itemstack, player, old_craft_grid, craft_inv))`
3505     * The same as before, except that it is called before the player crafts, to
3506       make craft prediction, and it should not change anything.
3507 * `minetest.register_allow_player_inventory_action(func(player, inventory, action, inventory_info))`
3508     * Determinates how much of a stack may be taken, put or moved to a
3509       player inventory.
3510     * `player` (type `ObjectRef`) is the player who modified the inventory
3511       `inventory` (type `InvRef`).
3512     * List of possible `action` (string) values and their
3513       `inventory_info` (table) contents:
3514         * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
3515         * `put`:  `{listname=string, index=number, stack=ItemStack}`
3516         * `take`: Same as `put`
3517     * Return a numeric value to limit the amount of items to be taken, put or
3518       moved. A value of `-1` for `take` will make the source stack infinite.
3519 * `minetest.register_on_player_inventory_action(func(player, inventory, action, inventory_info))`
3520     * Called after a take, put or move event from/to/in a player inventory
3521     * Function arguments: see `minetest.register_allow_player_inventory_action`
3522     * Does not accept or handle any return value.
3523 * `minetest.register_on_protection_violation(func(pos, name))`
3524     * Called by `builtin` and mods when a player violates protection at a
3525       position (eg, digs a node or punches a protected entity).
3526     * The registered functions can be called using
3527       `minetest.record_protection_violation`.
3528     * The provided function should check that the position is protected by the
3529       mod calling this function before it prints a message, if it does, to
3530       allow for multiple protection mods.
3531 * `minetest.register_on_item_eat(func(hp_change, replace_with_item, itemstack, user, pointed_thing))`
3532     * Called when an item is eaten, by `minetest.item_eat`
3533     * Return `true` or `itemstack` to cancel the default item eat response
3534       (i.e.: hp increase).
3535 * `minetest.register_on_priv_grant(function(name, granter, priv))`
3536     * Called when `granter` grants the priv `priv` to `name`.
3537     * Note that the callback will be called twice if it's done by a player,
3538       once with granter being the player name, and again with granter being nil.
3539 * `minetest.register_on_priv_revoke(function(name, revoker, priv))`
3540     * Called when `revoker` revokes the priv `priv` from `name`.
3541     * Note that the callback will be called twice if it's done by a player,
3542       once with revoker being the player name, and again with revoker being nil.
3543 * `minetest.register_can_bypass_userlimit(function(name, ip))`
3544     * Called when `name` user connects with `ip`.
3545     * Return `true` to by pass the player limit
3546 * `minetest.register_on_modchannel_message(func(channel_name, sender, message))`
3547     * Called when an incoming mod channel message is received
3548     * You should have joined  some channels to receive events.
3549     * If message comes from a server mod, `sender` field is an empty string.
3550
3551 Other registration functions
3552 ----------------------------
3553 * `minetest.register_chatcommand(cmd, chatcommand definition)`
3554     * Adds definition to `minetest.registered_chatcommands`
3555 * `minetest.override_chatcommand(name, redefinition)`
3556     * Overrides fields of a chatcommand registered with `register_chatcommand`.
3557 * `minetest.unregister_chatcommand(name)`
3558     * Unregisters a chatcommands registered with `register_chatcommand`.
3559 * `minetest.register_privilege(name, definition)`
3560     * `definition`: `"description text"`
3561     * `definition`:
3562       `{description = "description text", give_to_singleplayer = boolean}`
3563       the default of `give_to_singleplayer` is true.
3564     * To allow players with `basic_privs` to grant, see `basic_privs`
3565       minetest.conf setting.
3566     * `on_grant(name, granter_name)`: Called when given to player `name` by
3567       `granter_name`.
3568       `granter_name` will be nil if the priv was granted by a mod.
3569     * `on_revoke(name, revoker_name)`: Called when taken from player `name` by
3570       `revoker_name`.
3571       `revoker_name` will be nil if the priv was revoked by a mod
3572     * Note that the above two callbacks will be called twice if a player is
3573       responsible, once with the player name, and then with a nil player name.
3574     * Return true in the above callbacks to stop register_on_priv_grant or
3575       revoke being called.
3576 * `minetest.register_authentication_handler(authentication handler definition)`
3577     * Registers an auth handler that overrides the builtin one
3578     * This function can be called by a single mod once only.
3579
3580 Setting-related
3581 ---------------
3582 * `minetest.settings`: Settings object containing all of the settings from the
3583   main config file (`minetest.conf`).
3584 * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
3585   parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
3586
3587 Authentication
3588 --------------
3589 * `minetest.string_to_privs(str)`: returns `{priv1=true,...}`
3590 * `minetest.privs_to_string(privs)`: returns `"priv1,priv2,..."`
3591     * Convert between two privilege representations
3592 * `minetest.get_player_privs(name) -> {priv1=true,...}`
3593 * `minetest.check_player_privs(player_or_name, ...)`:
3594   returns `bool, missing_privs`
3595     * A quickhand for checking privileges.
3596     * `player_or_name`: Either a Player object or the name of a player.
3597     * `...` is either a list of strings, e.g. `"priva", "privb"` or
3598       a table, e.g. `{ priva = true, privb = true }`.
3599
3600 * `minetest.check_password_entry(name, entry, password)`
3601     * Returns true if the "password entry" for a player with name matches given
3602       password, false otherwise.
3603     * The "password entry" is the password representation generated by the
3604       engine as returned as part of a `get_auth()` call on the auth handler.
3605     * Only use this function for making it possible to log in via password from
3606       external protocols such as IRC, other uses are frowned upon.
3607 * `minetest.get_password_hash(name, raw_password)`
3608     * Convert a name-password pair to a password hash that Minetest can use.
3609     * The returned value alone is not a good basis for password checks based
3610       on comparing the password hash in the database with the password hash
3611       from the function, with an externally provided password, as the hash
3612       in the db might use the new SRP verifier format.
3613     * For this purpose, use `minetest.check_password_entry` instead.
3614 * `minetest.get_player_ip(name)`: returns an IP address string for the player
3615   `name`.
3616     * The player needs to be online for this to be successful.
3617
3618 * `minetest.get_auth_handler()`: Return the currently active auth handler
3619     * See the `Authentication handler definition`
3620     * Use this to e.g. get the authentication data for a player:
3621       `local auth_data = minetest.get_auth_handler().get_auth(playername)`
3622 * `minetest.notify_authentication_modified(name)`
3623     * Must be called by the authentication handler for privilege changes.
3624     * `name`: string; if omitted, all auth data should be considered modified
3625 * `minetest.set_player_password(name, password_hash)`: Set password hash of
3626   player `name`.
3627 * `minetest.set_player_privs(name, {priv1=true,...})`: Set privileges of player
3628   `name`.
3629 * `minetest.auth_reload()`
3630     * See `reload()` in authentication handler definition
3631
3632 `minetest.set_player_password`, `minetest_set_player_privs`,
3633 `minetest_get_player_privs` and `minetest.auth_reload` call the authentication
3634 handler.
3635
3636 Chat
3637 ----
3638 * `minetest.chat_send_all(text)`
3639 * `minetest.chat_send_player(name, text)`
3640
3641 Environment access
3642 ------------------
3643 * `minetest.set_node(pos, node)`
3644 * `minetest.add_node(pos, node): alias to `minetest.set_node`
3645     * Set node at position `pos`
3646     * `node`: table `{name=string, param1=number, param2=number}`
3647     * If param1 or param2 is omitted, it's set to `0`.
3648     * e.g. `minetest.set_node({x=0, y=10, z=0}, {name="default:wood"})`
3649 * `minetest.bulk_set_node({pos1, pos2, pos3, ...}, node)`
3650     * Set node on all positions set in the first argument.
3651     * e.g. `minetest.bulk_set_node({{x=0, y=1, z=1}, {x=1, y=2, z=2}}, {name="default:stone"})`
3652     * For node specification or position syntax see `minetest.set_node` call
3653     * Faster than set_node due to single call, but still considerably slower
3654       than Lua Voxel Manipulators (LVM) for large numbers of nodes.
3655       Unlike LVMs, this will call node callbacks. It also allows setting nodes
3656       in spread out positions which would cause LVMs to waste memory.
3657       For setting a cube, this is 1.3x faster than set_node whereas LVM is 20
3658       times faster.
3659 * `minetest.swap_node(pos, node)`
3660     * Set node at position, but don't remove metadata
3661 * `minetest.remove_node(pos)`
3662     * By default it does the same as `minetest.set_node(pos, {name="air"})`
3663 * `minetest.get_node(pos)`
3664     * Returns the node at the given position as table in the format
3665       `{name="node_name", param1=0, param2=0}`,
3666       returns `{name="ignore", param1=0, param2=0}` for unloaded areas.
3667 * `minetest.get_node_or_nil(pos)`
3668     * Same as `get_node` but returns `nil` for unloaded areas.
3669 * `minetest.get_node_light(pos, timeofday)`
3670     * Gets the light value at the given position. Note that the light value
3671       "inside" the node at the given position is returned, so you usually want
3672       to get the light value of a neighbor.
3673     * `pos`: The position where to measure the light.
3674     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
3675     * Returns a number between `0` and `15` or `nil`
3676 * `minetest.place_node(pos, node)`
3677     * Place node with the same effects that a player would cause
3678 * `minetest.dig_node(pos)`
3679     * Dig node with the same effects that a player would cause
3680     * Returns `true` if successful, `false` on failure (e.g. protected location)
3681 * `minetest.punch_node(pos)`
3682     * Punch node with the same effects that a player would cause
3683 * `minetest.spawn_falling_node(pos)`
3684     * Change node into falling node
3685     * Returns `true` if successful, `false` on failure
3686
3687 * `minetest.find_nodes_with_meta(pos1, pos2)`
3688     * Get a table of positions of nodes that have metadata within a region
3689       {pos1, pos2}.
3690 * `minetest.get_meta(pos)`
3691     * Get a `NodeMetaRef` at that position
3692 * `minetest.get_node_timer(pos)`
3693     * Get `NodeTimerRef`
3694
3695 * `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at
3696   position.
3697     * Returns `ObjectRef`, or `nil` if failed
3698 * `minetest.add_item(pos, item)`: Spawn item
3699     * Returns `ObjectRef`, or `nil` if failed
3700 * `minetest.get_player_by_name(name)`: Get an `ObjectRef` to a player
3701 * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
3702   ObjectRefs.
3703     * `radius`: using an euclidean metric
3704 * `minetest.set_timeofday(val)`
3705     * `val` is between `0` and `1`; `0` for midnight, `0.5` for midday
3706 * `minetest.get_timeofday()`
3707 * `minetest.get_gametime()`: returns the time, in seconds, since the world was
3708   created.
3709 * `minetest.get_day_count()`: returns number days elapsed since world was
3710   created.
3711     * accounts for time changes.
3712 * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns
3713   pos or `nil`.
3714     * `radius`: using a maximum metric
3715     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
3716     * `search_center` is an optional boolean (default: `false`)
3717       If true `pos` is also checked for the nodes
3718 * `minetest.find_nodes_in_area(pos1, pos2, nodenames)`: returns a list of
3719   positions.
3720     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
3721     * First return value: Table with all node positions
3722     * Second return value: Table with the count of each node with the node name
3723       as index.
3724     * Area volume is limited to 4,096,000 nodes
3725 * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
3726   list of positions.
3727     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
3728     * Return value: Table with all node positions with a node air above
3729     * Area volume is limited to 4,096,000 nodes
3730 * `minetest.get_perlin(noiseparams)`
3731 * `minetest.get_perlin(seeddiff, octaves, persistence, scale)`
3732     * Return world-specific perlin noise (`int(worldseed)+seeddiff`)
3733 * `minetest.get_voxel_manip([pos1, pos2])`
3734     * Return voxel manipulator object.
3735     * Loads the manipulator from the map if positions are passed.
3736 * `minetest.set_gen_notify(flags, {deco_ids})`
3737     * Set the types of on-generate notifications that should be collected.
3738     * `flags` is a flag field with the available flags:
3739         * dungeon
3740         * temple
3741         * cave_begin
3742         * cave_end
3743         * large_cave_begin
3744         * large_cave_end
3745         * decoration
3746     * The second parameter is a list of IDS of decorations which notification
3747       is requested for.
3748 * `minetest.get_gen_notify()`
3749     * Returns a flagstring and a table with the `deco_id`s.
3750 * `minetest.get_decoration_id(decoration_name)
3751     * Returns the decoration ID number for the provided decoration name string,
3752       or `nil` on failure.
3753 * `minetest.get_mapgen_object(objectname)`
3754     * Return requested mapgen object if available (see "Mapgen objects")
3755 * `minetest.get_heat(pos)`
3756     * Returns the heat at the position, or `nil` on failure.
3757 * `minetest.get_humidity(pos)`
3758     * Returns the humidity at the position, or `nil` on failure.
3759 * `minetest.get_biome_data(pos)`
3760     * Returns a table containing:
3761         * `biome` the biome id of the biome at that position
3762         * `heat` the heat at the position
3763         * `humidity` the humidity at the position
3764     * Or returns `nil` on failure.
3765 * `minetest.get_biome_id(biome_name)`
3766     * Returns the biome id, as used in the biomemap Mapgen object and returned
3767       by `minetest.get_biome_data(pos)`, for a given biome_name string.
3768 * `minetest.get_biome_name(biome_id)`
3769     * Returns the biome name string for the provided biome id, or `nil` on
3770       failure.
3771     * If no biomes have been registered, such as in mgv6, returns `default`.
3772 * `minetest.get_mapgen_params()`
3773     * Deprecated: use `minetest.get_mapgen_setting(name)` instead.
3774     * Returns a table containing:
3775         * `mgname`
3776         * `seed`
3777         * `chunksize`
3778         * `water_level`
3779         * `flags`
3780 * `minetest.set_mapgen_params(MapgenParams)`
3781     * Deprecated: use `minetest.set_mapgen_setting(name, value, override)`
3782       instead.
3783     * Set map generation parameters.
3784     * Function cannot be called after the registration period; only
3785       initialization and `on_mapgen_init`.
3786     * Takes a table as an argument with the fields:
3787         * `mgname`
3788         * `seed`
3789         * `chunksize`
3790         * `water_level`
3791         * `flags`
3792     * Leave field unset to leave that parameter unchanged.
3793     * `flags` contains a comma-delimited string of flags to set, or if the
3794       prefix `"no"` is attached, clears instead.
3795     * `flags` is in the same format and has the same options as `mg_flags` in
3796       `minetest.conf`.
3797 * `minetest.get_mapgen_setting(name)`
3798     * Gets the *active* mapgen setting (or nil if none exists) in string
3799       format with the following order of precedence:
3800         1) Settings loaded from map_meta.txt or overrides set during mod
3801            execution.
3802         2) Settings set by mods without a metafile override
3803         3) Settings explicitly set in the user config file, minetest.conf
3804         4) Settings set as the user config default
3805 * `minetest.get_mapgen_setting_noiseparams(name)`
3806     * Same as above, but returns the value as a NoiseParams table if the
3807       setting `name` exists and is a valid NoiseParams.
3808 * `minetest.set_mapgen_setting(name, value, [override_meta])`
3809     * Sets a mapgen param to `value`, and will take effect if the corresponding
3810       mapgen setting is not already present in map_meta.txt.
3811     * `override_meta` is an optional boolean (default: `false`). If this is set
3812       to true, the setting will become the active setting regardless of the map
3813       metafile contents.
3814     * Note: to set the seed, use `"seed"`, not `"fixed_map_seed"`.
3815 * `minetest.set_mapgen_setting_noiseparams(name, value, [override_meta])`
3816     * Same as above, except value is a NoiseParams table.
3817 * `minetest.set_noiseparams(name, noiseparams, set_default)`
3818     * Sets the noiseparams setting of `name` to the noiseparams table specified
3819       in `noiseparams`.
3820     * `set_default` is an optional boolean (default: `true`) that specifies
3821       whether the setting should be applied to the default config or current
3822       active config.
3823 * `minetest.get_noiseparams(name)`
3824     * Returns a table of the noiseparams for name.
3825 * `minetest.generate_ores(vm, pos1, pos2)`
3826     * Generate all registered ores within the VoxelManip `vm` and in the area
3827       from `pos1` to `pos2`.
3828     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
3829 * `minetest.generate_decorations(vm, pos1, pos2)`
3830     * Generate all registered decorations within the VoxelManip `vm` and in the
3831       area from `pos1` to `pos2`.
3832     * `pos1` and `pos2` are optional and default to mapchunk minp and maxp.
3833 * `minetest.clear_objects([options])`
3834     * Clear all objects in the environment
3835     * Takes an optional table as an argument with the field `mode`.
3836         * mode = `"full"` : Load and go through every mapblock, clearing
3837                             objects (default).
3838         * mode = `"quick"`: Clear objects immediately in loaded mapblocks,
3839                             clear objects in unloaded mapblocks only when the
3840                             mapblocks are next activated.
3841 * `minetest.emerge_area(pos1, pos2, [callback], [param])`
3842     * Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
3843       asynchronously fetched from memory, loaded from disk, or if inexistent,
3844       generates them.
3845     * If `callback` is a valid Lua function, this will be called for each block
3846       emerged.
3847     * The function signature of callback is:
3848         * `function EmergeAreaCallback(blockpos, action, calls_remaining, param)`
3849             * `blockpos` is the *block* coordinates of the block that had been
3850               emerged.
3851             * `action` could be one of the following constant values:
3852                 * `minetest.EMERGE_CANCELLED`
3853                 * `minetest.EMERGE_ERRORED`
3854                 * `minetest.EMERGE_FROM_MEMORY`
3855                 * `minetest.EMERGE_FROM_DISK`
3856                 * `minetest.EMERGE_GENERATED`
3857             * `calls_remaining` is the number of callbacks to be expected after
3858               this one.
3859             * `param` is the user-defined parameter passed to emerge_area (or
3860               nil if the parameter was absent).
3861 * `minetest.delete_area(pos1, pos2)`
3862     * delete all mapblocks in the area from pos1 to pos2, inclusive
3863 * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
3864     * Checks if there is anything other than air between pos1 and pos2.
3865     * Returns false if something is blocking the sight.
3866     * Returns the position of the blocking node when `false`
3867     * `pos1`: First position
3868     * `pos2`: Second position
3869 * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
3870     * Creates a `Raycast` object.
3871     * `pos1`: start of the ray
3872     * `pos2`: end of the ray
3873     * `objects` : if false, only nodes will be returned. Default is `true`.
3874     * `liquids' : if false, liquid nodes won't be returned. Default is `false`.
3875 * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
3876     * returns table containing path
3877     * returns a table of 3D points representing a path from `pos1` to `pos2` or
3878       `nil`.
3879     * `pos1`: start position
3880     * `pos2`: end position
3881     * `searchdistance`: number of blocks to search in each direction using a
3882       maximum metric.
3883     * `max_jump`: maximum height difference to consider walkable
3884     * `max_drop`: maximum height difference to consider droppable
3885     * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`
3886 * `minetest.spawn_tree (pos, {treedef})`
3887     * spawns L-system tree at given `pos` with definition in `treedef` table
3888 * `minetest.transforming_liquid_add(pos)`
3889     * add node to liquid update queue
3890 * `minetest.get_node_max_level(pos)`
3891     * get max available level for leveled node
3892 * `minetest.get_node_level(pos)`
3893     * get level of leveled node (water, snow)
3894 * `minetest.set_node_level(pos, level)`
3895     * set level of leveled node, default `level` equals `1`
3896     * if `totallevel > maxlevel`, returns rest (`total-max`).
3897 * `minetest.add_node_level(pos, level)`
3898     * increase level of leveled node by level, default `level` equals `1`
3899     * if `totallevel > maxlevel`, returns rest (`total-max`)
3900     * can be negative for decreasing
3901 * `minetest.fix_light(pos1, pos2)`: returns `true`/`false`
3902     * resets the light in a cuboid-shaped part of
3903       the map and removes lighting bugs.
3904     * Loads the area if it is not loaded.
3905     * `pos1` is the corner of the cuboid with the least coordinates
3906       (in node coordinates), inclusive.
3907     * `pos2` is the opposite corner of the cuboid, inclusive.
3908     * The actual updated cuboid might be larger than the specified one,
3909       because only whole map blocks can be updated.
3910       The actual updated area consists of those map blocks that intersect
3911       with the given cuboid.
3912     * However, the neighborhood of the updated area might change
3913       as well, as light can spread out of the cuboid, also light
3914       might be removed.
3915     * returns `false` if the area is not fully generated,
3916       `true` otherwise
3917 * `minetest.check_single_for_falling(pos)`
3918     * causes an unsupported `group:falling_node` node to fall and causes an
3919       unattached `group:attached_node` node to fall.
3920     * does not spread these updates to neighbours.
3921 * `minetest.check_for_falling(pos)`
3922     * causes an unsupported `group:falling_node` node to fall and causes an
3923       unattached `group:attached_node` node to fall.
3924     * spread these updates to neighbours and can cause a cascade
3925       of nodes to fall.
3926 * `minetest.get_spawn_level(x, z)`
3927     * Returns a player spawn y co-ordinate for the provided (x, z)
3928       co-ordinates, or `nil` for an unsuitable spawn point.
3929     * For most mapgens a 'suitable spawn point' is one with y between
3930       `water_level` and `water_level + 16`, and in mgv7 well away from rivers,
3931       so `nil` will be returned for many (x, z) co-ordinates.
3932     * The spawn level returned is for a player spawn in unmodified terrain.
3933     * The spawn level is intentionally above terrain level to cope with
3934       full-node biome 'dust' nodes.
3935
3936 Mod channels
3937 ------------
3938 You can find mod channels communication scheme in `docs/mod_channels.png`.
3939
3940 * `minetest.mod_channel_join(channel_name)`
3941     * Server joins channel `channel_name`, and creates it if necessary. You
3942       should listen from incoming messages with
3943       `minetest.register_on_modchannel_message` call to receive incoming
3944       messages.
3945
3946 Inventory
3947 ---------
3948 `minetest.get_inventory(location)`: returns an `InvRef`
3949
3950 * `location` = e.g.
3951     * `{type="player", name="celeron55"}`
3952     * `{type="node", pos={x=, y=, z=}}`
3953     * `{type="detached", name="creative"}`
3954 * `minetest.create_detached_inventory(name, callbacks, [player_name])`: returns
3955   an `InvRef`.
3956     * callbacks: See "Detached inventory callbacks"
3957     * `player_name`: Make detached inventory available to one player
3958       exclusively, by default they will be sent to every player (even if not
3959       used).
3960       Note that this parameter is mostly just a workaround and will be removed
3961       in future releases.
3962     * Creates a detached inventory. If it already exists, it is cleared.
3963 * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
3964   returns left over ItemStack.
3965     * See `minetest.item_eat` and `minetest.register_on_item_eat`
3966
3967 Formspec
3968 --------
3969 * `minetest.show_formspec(playername, formname, formspec)`
3970     * `playername`: name of player to show formspec
3971     * `formname`: name passed to `on_player_receive_fields` callbacks.
3972       It should follow the `"modname:<whatever>"` naming convention
3973     * `formspec`: formspec to display
3974 * `minetest.close_formspec(playername, formname)`
3975     * `playername`: name of player to close formspec
3976     * `formname`: has to exactly match the one given in `show_formspec`, or the
3977       formspec will not close.
3978     * calling `show_formspec(playername, formname, "")` is equal to this
3979       expression.
3980     * to close a formspec regardless of the formname, call
3981       `minetest.close_formspec(playername, "")`.
3982       **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
3983 * `minetest.formspec_escape(string)`: returns a string
3984     * escapes the characters "[", "]", "\", "," and ";", which can not be used
3985       in formspecs.
3986 * `minetest.explode_table_event(string)`: returns a table
3987     * returns e.g. `{type="CHG", row=1, column=2}`
3988     * `type` is one of:
3989         * `"INV"`: no row selected)
3990         * `"CHG"`: selected)
3991         * `"DCL"`: double-click
3992 * `minetest.explode_textlist_event(string)`: returns a table
3993     * returns e.g. `{type="CHG", index=1}`
3994     * `type` is one of:
3995         * `"INV"`: no row selected)
3996         * `"CHG"`: selected)
3997         * `"DCL"`: double-click
3998 * `minetest.explode_scrollbar_event(string)`: returns a table
3999     * returns e.g. `{type="CHG", value=500}`
4000     * `type` is one of:
4001         * `"INV"`: something failed
4002         * `"CHG"`: has been changed
4003         * `"VAL"`: not changed
4004
4005 Item handling
4006 -------------
4007 * `minetest.inventorycube(img1, img2, img3)`
4008     * Returns a string for making an image of a cube (useful as an item image)
4009 * `minetest.get_pointed_thing_position(pointed_thing, above)`
4010     * Get position of a `pointed_thing` (that you can get from somewhere)
4011 * `minetest.dir_to_facedir(dir, is6d)`
4012     * Convert a vector to a facedir value, used in `param2` for
4013       `paramtype2="facedir"`.
4014     * passing something non-`nil`/`false` for the optional second parameter
4015       causes it to take the y component into account.
4016 * `minetest.facedir_to_dir(facedir)`
4017     * Convert a facedir back into a vector aimed directly out the "back" of a
4018       node.
4019 * `minetest.dir_to_wallmounted(dir)`
4020     * Convert a vector to a wallmounted value, used for
4021       `paramtype2="wallmounted"`.
4022 * `minetest.wallmounted_to_dir(wallmounted)`
4023     * Convert a wallmounted value back into a vector aimed directly out the
4024       "back" of a node.
4025 * `minetest.dir_to_yaw(dir)`
4026     * Convert a vector into a yaw (angle)
4027 * `minetest.yaw_to_dir(yaw)`
4028     * Convert yaw (angle) to a vector
4029 * `minetest.is_colored_paramtype(ptype)`
4030     * Returns a boolean. Returns `true` if the given `paramtype2` contains
4031       color information (`color`, `colorwallmounted` or `colorfacedir`).
4032 * `minetest.strip_param2_color(param2, paramtype2)`
4033     * Removes everything but the color information from the
4034       given `param2` value.
4035     * Returns `nil` if the given `paramtype2` does not contain color
4036       information.
4037 * `minetest.get_node_drops(nodename, toolname)`
4038     * Returns list of item names.
4039     * **Note**: This will be removed or modified in a future version.
4040 * `minetest.get_craft_result(input)`: returns `output, decremented_input`
4041     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
4042     * `input.width` = for example `3`
4043     * `input.items` = for example
4044       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
4045     * `output.item` = `ItemStack`, if unsuccessful: empty `ItemStack`
4046     * `output.time` = a number, if unsuccessful: `0`
4047     * `output.replacements` = list of `ItemStack`s that couldn't be placed in
4048       `decremented_input.items`
4049     * `decremented_input` = like `input`
4050 * `minetest.get_craft_recipe(output)`: returns input
4051     * returns last registered recipe for output item (node)
4052     * `output` is a node or item type such as `"default:torch"`
4053     * `input.method` = `"normal"` or `"cooking"` or `"fuel"`
4054     * `input.width` = for example `3`
4055     * `input.items` = for example
4056       `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}`
4057         * `input.items` = `nil` if no recipe found
4058 * `minetest.get_all_craft_recipes(query item)`: returns a table or `nil`
4059     * returns indexed table with all registered recipes for query item (node)
4060       or `nil` if no recipe was found.
4061     * recipe entry table:
4062
4063           {
4064               method = 'normal' or 'cooking' or 'fuel'
4065               width = 0-3, 0 means shapeless recipe
4066               items = indexed [1-9] table with recipe items
4067               output = string with item name and quantity
4068           }
4069     * Example query for `"default:gold_ingot"` will return table:
4070
4071           {
4072               [1]={method = "cooking", width = 3, output = "default:gold_ingot",
4073               items = {1 = "default:gold_lump"}},
4074               [2]={method = "normal", width = 1, output = "default:gold_ingot 9",
4075               items = {1 = "default:goldblock"}}
4076           }
4077 * `minetest.handle_node_drops(pos, drops, digger)`
4078     * `drops`: list of itemstrings
4079     * Handles drops from nodes after digging: Default action is to put them
4080       into digger's inventory.
4081     * Can be overridden to get different functionality (e.g. dropping items on
4082       ground)
4083 * `minetest.itemstring_with_palette(item, palette_index)`: returns an item
4084   string.
4085     * Creates an item string which contains palette index information
4086       for hardware colorization. You can use the returned string
4087       as an output in a craft recipe.
4088     * `item`: the item stack which becomes colored. Can be in string,
4089       table and native form.
4090     * `palette_index`: this index is added to the item stack
4091 * `minetest.itemstring_with_color(item, colorstring)`: returns an item string
4092     * Creates an item string which contains static color information
4093       for hardware colorization. Use this method if you wish to colorize
4094       an item that does not own a palette. You can use the returned string
4095       as an output in a craft recipe.
4096     * `item`: the item stack which becomes colored. Can be in string,
4097       table and native form.
4098     * `colorstring`: the new color of the item stack
4099
4100 Rollback
4101 --------
4102 * `minetest.rollback_get_node_actions(pos, range, seconds, limit)`:
4103   returns `{{actor, pos, time, oldnode, newnode}, ...}`
4104     * Find who has done something to a node, or near a node
4105     * `actor`: `"player:<name>"`, also `"liquid"`.
4106 * `minetest.rollback_revert_actions_by(actor, seconds)`: returns
4107   `boolean, log_messages`.
4108     * Revert latest actions of someone
4109     * `actor`: `"player:<name>"`, also `"liquid"`.
4110
4111 Defaults for the `on_*` item definition functions
4112 -------------------------------------------------
4113 These functions return the leftover itemstack.
4114
4115 * `minetest.item_place_node(itemstack, placer, pointed_thing[, param2, prevent_after_place])`
4116     * Place item as a node
4117     * `param2` overrides `facedir` and wallmounted `param2`
4118     * `prevent_after_place`: if set to `true`, `after_place_node` is not called
4119       for the newly placed node to prevent a callback and placement loop
4120     * returns `itemstack, success`
4121 * `minetest.item_place_object(itemstack, placer, pointed_thing)`
4122     * Place item as-is
4123 * `minetest.item_place(itemstack, placer, pointed_thing, param2)`
4124     * Use one of the above based on what the item is.
4125     * Calls `on_rightclick` of `pointed_thing.under` if defined instead
4126     * **Note**: is not called when wielded item overrides `on_place`
4127     * `param2` overrides `facedir` and wallmounted `param2`
4128     * returns `itemstack, success`
4129 * `minetest.item_drop(itemstack, dropper, pos)`
4130     * Drop the item
4131 * `minetest.item_eat(hp_change, replace_with_item)`
4132     * Eat the item.
4133     * `replace_with_item` is the itemstring which is added to the inventory.
4134       If the player is eating a stack, then replace_with_item goes to a
4135       different spot. Can be `nil`
4136     * See `minetest.do_item_eat`
4137
4138 Defaults for the `on_punch` and `on_dig` node definition callbacks
4139 ------------------------------------------------------------------
4140 * `minetest.node_punch(pos, node, puncher, pointed_thing)`
4141     * Calls functions registered by `minetest.register_on_punchnode()`
4142 * `minetest.node_dig(pos, node, digger)`
4143     * Checks if node can be dug, puts item into inventory, removes node
4144     * Calls functions registered by `minetest.registered_on_dignodes()`
4145
4146 Sounds
4147 ------
4148 * `minetest.sound_play(spec, parameters)`: returns a handle
4149     * `spec` is a `SimpleSoundSpec`
4150     * `parameters` is a sound parameter table
4151 * `minetest.sound_stop(handle)`
4152 * `minetest.sound_fade(handle, step, gain)`
4153     * `handle` is a handle returned by `minetest.sound_play`
4154     * `step` determines how fast a sound will fade.
4155       Negative step will lower the sound volume, positive step will increase
4156       the sound volume.
4157     * `gain` the target gain for the fade.
4158
4159 Timing
4160 ------
4161 * `minetest.after(time, func, ...)`
4162     * Call the function `func` after `time` seconds, may be fractional
4163     * Optional: Variable number of arguments that are passed to `func`
4164
4165 Server
4166 ------
4167 * `minetest.request_shutdown([message],[reconnect],[delay])`: request for
4168   server shutdown. Will display `message` to clients.
4169     * `reconnect` == true displays a reconnect button
4170     * `delay` adds an optional delay (in seconds) before shutdown.
4171       Negative delay cancels the current active shutdown.
4172       Zero delay triggers an immediate shutdown.
4173 * `minetest.cancel_shutdown_requests()`: cancel current delayed shutdown
4174 * `minetest.get_server_status(name, joined)`
4175     * Returns the server status string when a player joins or when the command
4176       `/status` is called. Returns `nil` or an empty string when the message is
4177       disabled.
4178     * `joined`: Boolean value, indicates whether the function was called when
4179       a player joined.
4180     * This function may be overwritten by mods to customize the status message.
4181 * `minetest.get_server_uptime()`: returns the server uptime in seconds
4182 * `minetest.remove_player(name)`: remove player from database (if they are not
4183   connected).
4184     * As auth data is not removed, minetest.player_exists will continue to
4185       return true. Call the below method as well if you want to remove auth
4186       data too.
4187     * Returns a code (0: successful, 1: no such player, 2: player is connected)
4188 * `minetest.remove_player_auth(name)`: remove player authentication data
4189     * Returns boolean indicating success (false if player nonexistant)
4190
4191 Bans
4192 ----
4193 * `minetest.get_ban_list()`: returns the ban list
4194   (same as `minetest.get_ban_description("")`).
4195 * `minetest.get_ban_description(ip_or_name)`: returns ban description (string)
4196 * `minetest.ban_player(name)`: ban a player
4197 * `minetest.unban_player_or_ip(name)`: unban player or IP address
4198 * `minetest.kick_player(name, [reason])`: disconnect a player with a optional
4199   reason.
4200
4201 Particles
4202 ---------
4203 * `minetest.add_particle(particle definition)`
4204     * Deprecated: `minetest.add_particle(pos, velocity, acceleration,
4205       expirationtime, size, collisiondetection, texture, playername)`
4206
4207 * `minetest.add_particlespawner(particlespawner definition)`
4208     * Add a `ParticleSpawner`, an object that spawns an amount of particles
4209       over `time` seconds.
4210     * Returns an `id`, and -1 if adding didn't succeed
4211     * `Deprecated: minetest.add_particlespawner(amount, time,
4212       minpos, maxpos,
4213       minvel, maxvel,
4214       minacc, maxacc,
4215       minexptime, maxexptime,
4216       minsize, maxsize,
4217       collisiondetection, texture, playername)`
4218
4219 * `minetest.delete_particlespawner(id, player)`
4220     * Delete `ParticleSpawner` with `id` (return value from
4221       `minetest.add_particlespawner`).
4222     * If playername is specified, only deletes on the player's client,
4223       otherwise on all clients.
4224
4225 Schematics
4226 ----------
4227 * `minetest.create_schematic(p1, p2, probability_list, filename, slice_prob_list)`
4228     * Create a schematic from the volume of map specified by the box formed by
4229       p1 and p2.
4230     * Apply the specified probability and per-node force-place to the specified
4231       nodes according to the `probability_list`.
4232         * `probability_list` is an array of tables containing two fields, `pos`
4233           and `prob`.
4234             * `pos` is the 3D vector specifying the absolute coordinates of the
4235               node being modified,
4236             * `prob` is an integer value from `0` to `255` that encodes
4237               probability and per-node force-place. Probability has levels
4238               0-127, then 128 may be added to encode per-node force-place.
4239               For probability stated as 0-255, divide by 2 and round down to
4240               get values 0-127, then add 128 to apply per-node force-place.
4241             * If there are two or more entries with the same pos value, the
4242               last entry is used.
4243             * If `pos` is not inside the box formed by `p1` and `p2`, it is
4244               ignored.
4245             * If `probability_list` equals `nil`, no probabilities are applied.
4246     * Apply the specified probability to the specified horizontal slices
4247       according to the `slice_prob_list`.
4248         * `slice_prob_list` is an array of tables containing two fields, `ypos`
4249           and `prob`.
4250             * `ypos` indicates the y position of the slice with a probability
4251               applied, the lowest slice being `ypos = 0`.
4252             * If slice probability list equals `nil`, no slice probabilities
4253               are applied.
4254     * Saves schematic in the Minetest Schematic format to filename.
4255
4256 * `minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
4257     * Place the schematic specified by schematic (see: Schematic specifier) at
4258       `pos`.
4259     * `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
4260     * If the `rotation` parameter is omitted, the schematic is not rotated.
4261     * `replacements` = `{["old_name"] = "convert_to", ...}`
4262     * `force_placement` is a boolean indicating whether nodes other than `air`
4263       and `ignore` are replaced by the schematic.
4264     * Returns nil if the schematic could not be loaded.
4265     * **Warning**: Once you have loaded a schematic from a file, it will be
4266       cached. Future calls will always use the cached version and the
4267       replacement list defined for it, regardless of whether the file or the
4268       replacement list parameter have changed. The only way to load the file
4269       anew is to restart the server.
4270     * `flags` is a flag field with the available flags:
4271         * place_center_x
4272         * place_center_y
4273         * place_center_z
4274
4275 * `minetest.place_schematic_on_vmanip(vmanip, pos, schematic, rotation, replacement, force_placement, flags)`:
4276     * This function is analogous to minetest.place_schematic, but places a
4277       schematic onto the specified VoxelManip object `vmanip` instead of the
4278       map.
4279     * Returns false if any part of the schematic was cut-off due to the
4280       VoxelManip not containing the full area required, and true if the whole
4281       schematic was able to fit.
4282     * Returns nil if the schematic could not be loaded.
4283     * After execution, any external copies of the VoxelManip contents are
4284       invalidated.
4285     * `flags` is a flag field with the available flags:
4286         * place_center_x
4287         * place_center_y
4288         * place_center_z
4289
4290 * `minetest.serialize_schematic(schematic, format, options)`
4291     * Return the serialized schematic specified by schematic
4292       (see: Schematic specifier)
4293     * in the `format` of either "mts" or "lua".
4294     * "mts" - a string containing the binary MTS data used in the MTS file
4295       format.
4296     * "lua" - a string containing Lua code representing the schematic in table
4297       format.
4298     * `options` is a table containing the following optional parameters:
4299         * If `lua_use_comments` is true and `format` is "lua", the Lua code
4300           generated will have (X, Z) position comments for every X row
4301           generated in the schematic data for easier reading.
4302         * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua",
4303           the Lua code generated will use that number of spaces as indentation
4304           instead of a tab character.
4305
4306 HTTP Requests:
4307 --------------
4308 * `minetest.request_http_api()`:
4309     * returns `HTTPApiTable` containing http functions if the calling mod has
4310       been granted access by being listed in the `secure.http_mods` or
4311       `secure.trusted_mods` setting, otherwise returns `nil`.
4312     * The returned table contains the functions `fetch`, `fetch_async` and
4313       `fetch_async_get` described below.
4314     * Only works at init time and must be called from the mod's main scope
4315       (not from a function).
4316     * Function only exists if minetest server was built with cURL support.
4317     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED TABLE, STORE IT IN
4318       A LOCAL VARIABLE!**
4319 * `HTTPApiTable.fetch(HTTPRequest req, callback)`
4320     * Performs given request asynchronously and calls callback upon completion
4321     * callback: `function(HTTPRequestResult res)`
4322     * Use this HTTP function if you are unsure, the others are for advanced use
4323 * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
4324     * Performs given request asynchronously and returns handle for
4325       `HTTPApiTable.fetch_async_get`
4326 * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
4327     * Return response data for given asynchronous HTTP request
4328
4329 Storage API:
4330 ------------
4331 * `minetest.get_mod_storage()`:
4332     * returns reference to mod private `StorageRef`
4333     * must be called during mod load time
4334
4335 Misc.
4336 -----
4337 * `minetest.get_connected_players()`: returns list of `ObjectRefs`
4338 * `minetest.is_player(o)`: boolean, whether `o` is a player
4339 * `minetest.player_exists(name)`: boolean, whether player exists
4340   (regardless of online status)
4341 * `minetest.hud_replace_builtin(name, hud_definition)`
4342     * Replaces definition of a builtin hud element
4343     * `name`: `"breath"` or `"health"`
4344     * `hud_definition`: definition to replace builtin definition
4345 * `minetest.send_join_message(player_name)`
4346     * This function can be overridden by mods to change the join message.
4347 * `minetest.send_leave_message(player_name, timed_out)`
4348     * This function can be overridden by mods to change the leave message.
4349 * `minetest.hash_node_position(pos)`: returns an 48-bit integer
4350     * `pos`: table {x=number, y=number, z=number},
4351     * Gives a unique hash number for a node position (16+16+16=48bit)
4352 * `minetest.get_position_from_hash(hash)`: returns a position
4353     * Inverse transform of `minetest.hash_node_position`
4354 * `minetest.get_item_group(name, group)`: returns a rating
4355     * Get rating of a group of an item. (`0` means: not in group)
4356 * `minetest.get_node_group(name, group)`: returns a rating
4357     * Deprecated: An alias for the former.
4358 * `minetest.raillike_group(name)`: returns a rating
4359     * Returns rating of the connect_to_raillike group corresponding to name
4360     * If name is not yet the name of a connect_to_raillike group, a new group
4361       id is created, with that name.
4362 * `minetest.get_content_id(name)`: returns an integer
4363     * Gets the internal content ID of `name`
4364 * `minetest.get_name_from_content_id(content_id)`: returns a string
4365     * Gets the name of the content with that content ID
4366 * `minetest.parse_json(string[, nullvalue])`: returns something
4367     * Convert a string containing JSON data into the Lua equivalent
4368     * `nullvalue`: returned in place of the JSON null; defaults to `nil`
4369     * On success returns a table, a string, a number, a boolean or `nullvalue`
4370     * On failure outputs an error message and returns `nil`
4371     * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
4372 * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error
4373   message.
4374     * Convert a Lua table into a JSON string
4375     * styled: Outputs in a human-readable format if this is set, defaults to
4376       false.
4377     * Unserializable things like functions and userdata will cause an error.
4378     * **Warning**: JSON is more strict than the Lua table format.
4379         1. You can only use strings and positive integers of at least one as
4380            keys.
4381         2. You can not mix string and integer keys.
4382            This is due to the fact that JSON has two distinct array and object
4383            values.
4384     * Example: `write_json({10, {a = false}})`,
4385       returns `"[10, {\"a\": false}]"`
4386 * `minetest.serialize(table)`: returns a string
4387     * Convert a table containing tables, strings, numbers, booleans and `nil`s
4388       into string form readable by `minetest.deserialize`
4389     * Example: `serialize({foo='bar'})`, returns `'return { ["foo"] = "bar" }'`
4390 * `minetest.deserialize(string)`: returns a table
4391     * Convert a string returned by `minetest.deserialize` into a table
4392     * `string` is loaded in an empty sandbox environment.
4393     * Will load functions, but they cannot access the global environment.
4394     * Example: `deserialize('return { ["foo"] = "bar" }')`,
4395       returns `{foo='bar'}`
4396     * Example: `deserialize('print("foo")')`, returns `nil`
4397       (function call fails), returns
4398       `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
4399 * `minetest.compress(data, method, ...)`: returns `compressed_data`
4400     * Compress a string of data.
4401     * `method` is a string identifying the compression method to be used.
4402     * Supported compression methods:
4403         * Deflate (zlib): `"deflate"`
4404     * `...` indicates method-specific arguments. Currently defined arguments
4405       are:
4406         * Deflate: `level` - Compression level, `0`-`9` or `nil`.
4407 * `minetest.decompress(compressed_data, method, ...)`: returns data
4408     * Decompress a string of data (using ZLib).
4409     * See documentation on `minetest.compress()` for supported compression
4410       methods.
4411     * `...` indicates method-specific arguments. Currently, no methods use this
4412 * `minetest.rgba(red, green, blue[, alpha])`: returns a string
4413     * Each argument is a 8 Bit unsigned integer
4414     * Returns the ColorString from rgb or rgba values
4415     * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
4416 * `minetest.encode_base64(string)`: returns string encoded in base64
4417     * Encodes a string in base64.
4418 * `minetest.decode_base64(string)`: returns string
4419     * Decodes a string encoded in base64.
4420 * `minetest.is_protected(pos, name)`: returns boolean
4421     * Returns true, if player `name` shouldn't be able to dig at `pos` or do
4422       other actions, definable by mods, due to some mod-defined ownership-like
4423       concept.
4424     * Returns false or nil, if the player is allowed to do such actions.
4425     * `name` will be "" for non-players or unknown players.
4426     * This function should be overridden by protection mods and should be used
4427       to check if a player can interact at a position.
4428     * This function should call the old version of itself if the position is
4429       not protected by the mod.
4430     * Example:
4431
4432             local old_is_protected = minetest.is_protected
4433             function minetest.is_protected(pos, name)
4434                 if mymod:position_protected_from(pos, name) then
4435                     return true
4436                 end
4437                     return old_is_protected(pos, name)
4438             end
4439 * `minetest.record_protection_violation(pos, name)`
4440     * This function calls functions registered with
4441       `minetest.register_on_protection_violation`.
4442 * `minetest.is_area_protected(pos1, pos2, player_name, interval)
4443     * Returns the position of the first node that `player_name` may not modify
4444       in the specified cuboid between `pos1` and `pos2`.
4445     * Returns `false` if no protections were found.
4446     * Applies `is_protected()` to a 3D lattice of points in the defined volume.
4447       The points are spaced evenly throughout the volume and have a spacing
4448       similar to, but no larger than, `interval`.
4449     * All corners and edges of the defined volume are checked.
4450     * `interval` defaults to 4.
4451     * `interval` should be carefully chosen and maximised to avoid an excessive
4452       number of points being checked.
4453     * Like `minetest.is_protected`, this function may be extended or
4454       overwritten by mods to provide a faster implementation to check the
4455       cuboid for intersections.
4456 * `minetest.rotate_and_place(itemstack, placer, pointed_thing[, infinitestacks,
4457         orient_flags, prevent_after_place])`
4458     * Attempt to predict the desired orientation of the facedir-capable node
4459       defined by `itemstack`, and place it accordingly (on-wall, on the floor,
4460       or hanging from the ceiling).
4461     * `infinitestacks`: if `true`, the itemstack is not changed. Otherwise the
4462       stacks are handled normally.
4463     * `orient_flags`: Optional table containing extra tweaks to the placement code:
4464         * `invert_wall`:   if `true`, place wall-orientation on the ground and
4465           ground-orientation on the wall.
4466         * `force_wall` :   if `true`, always place the node in wall orientation.
4467         * `force_ceiling`: if `true`, always place on the ceiling.
4468         * `force_floor`:   if `true`, always place the node on the floor.
4469         * `force_facedir`: if `true`, forcefully reset the facedir to north
4470           when placing on the floor or ceiling.
4471         * The first four options are mutually-exclusive; the last in the list
4472           takes precedence over the first.
4473     * `prevent_after_place` is directly passed to `minetest.item_place_node`
4474     * Returns the new itemstack after placement
4475 * `minetest.rotate_node(itemstack, placer, pointed_thing)`
4476     * calls `rotate_and_place()` with `infinitestacks` set according to the state
4477       of the creative mode setting, checks for "sneak" to set the `invert_wall`
4478       parameter and `prevent_after_place` set to `true`.
4479
4480 * `minetest.forceload_block(pos[, transient])`
4481     * forceloads the position `pos`.
4482     * returns `true` if area could be forceloaded
4483     * If `transient` is `false` or absent, the forceload will be persistent
4484       (saved between server runs). If `true`, the forceload will be transient
4485       (not saved between server runs).
4486
4487 * `minetest.forceload_free_block(pos[, transient])`
4488     * stops forceloading the position `pos`
4489     * If `transient` is `false` or absent, frees a persistent forceload.
4490       If `true`, frees a transient forceload.
4491
4492 * `minetest.request_insecure_environment()`: returns an environment containing
4493   insecure functions if the calling mod has been listed as trusted in the
4494   `secure.trusted_mods` setting or security is disabled, otherwise returns
4495   `nil`.
4496     * Only works at init time and must be called from the mod's main scope (not
4497       from a function).
4498     * **DO NOT ALLOW ANY OTHER MODS TO ACCESS THE RETURNED ENVIRONMENT, STORE
4499       IT IN A LOCAL VARIABLE!**
4500
4501 * `minetest.global_exists(name)`
4502     * Checks if a global variable has been set, without triggering a warning.
4503
4504 Global objects
4505 --------------
4506 * `minetest.env`: `EnvRef` of the server environment and world.
4507     * Any function in the minetest namespace can be called using the syntax
4508       `minetest.env:somefunction(somearguments)`
4509       instead of `minetest.somefunction(somearguments)`
4510     * Deprecated, but support is not to be dropped soon
4511
4512 Global tables
4513 -------------
4514 * `minetest.registered_items`
4515     * Map of registered items, indexed by name
4516 * `minetest.registered_nodes`
4517     * Map of registered node definitions, indexed by name
4518 * `minetest.registered_craftitems`
4519     * Map of registered craft item definitions, indexed by name
4520 * `minetest.registered_tools`
4521     * Map of registered tool definitions, indexed by name
4522 * `minetest.registered_entities`
4523     * Map of registered entity prototypes, indexed by name
4524 * `minetest.object_refs`
4525     * Map of object references, indexed by active object id
4526 * `minetest.luaentities`
4527     * Map of Lua entities, indexed by active object id
4528 * `minetest.registered_chatcommands`
4529     * Map of registered chat command definitions, indexed by name
4530 * `minetest.registered_ores`
4531     * List of registered ore definitions.
4532 * `minetest.registered_biomes`
4533     * List of registered biome definitions.
4534 * `minetest.registered_decorations`
4535     * List of registered decoration definitions.
4536
4537
4538
4539
4540 Class reference
4541 ===============
4542
4543 Sorted alphabetically.
4544
4545 `AreaStore`
4546 -----------
4547 A fast access data structure to store areas, and find areas near a given
4548 position or area.
4549 Every area has a `data` string attribute to store additional information.
4550 You can create an empty `AreaStore` by calling `AreaStore()`, or
4551 `AreaStore(type_name)`.
4552 If you chose the parameter-less constructor, a fast implementation will be
4553 automatically chosen for you.
4554
4555 ### Methods
4556 * `get_area(id, include_borders, include_data)`: returns the area with the id
4557   `id`.
4558   (optional) Boolean values `include_borders` and `include_data` control what's
4559   copied.
4560   Returns nil if specified area id does not exist.
4561 * `get_areas_for_pos(pos, include_borders, include_data)`: returns all areas
4562   that contain the position `pos`.
4563   (optional) Boolean values `include_borders` and `include_data` control what's
4564   copied.
4565 * `get_areas_in_area(edge1, edge2, accept_overlap, include_borders, include_data)`:
4566   returns all areas that contain all nodes inside the area specified by `edge1`
4567   and `edge2` (inclusive).
4568   If `accept_overlap` is true, also areas are returned that have nodes in
4569   common with the specified area.
4570   (optional) Boolean values `include_borders` and `include_data` control what's
4571   copied.
4572 * `insert_area(edge1, edge2, data, [id])`: inserts an area into the store.
4573   Returns the new area's ID, or nil if the insertion failed.
4574   The (inclusive) positions `edge1` and `edge2` describe the area.
4575   `data` is a string stored with the area.  If passed, `id` will be used as the
4576   internal area ID, it must be a unique number between 0 and 2^32-2. If you use
4577   the `id` parameter you must always use it, or insertions are likely to fail
4578   due to conflicts.
4579 * `reserve(count)`: reserves resources for at most `count` many contained
4580   areas.
4581   Only needed for efficiency, and only some implementations profit.
4582 * `remove_area(id)`: removes the area with the given id from the store, returns
4583   success.
4584 * `set_cache_params(params)`: sets params for the included prefiltering cache.
4585   Calling invalidates the cache, so that its elements have to be newly
4586   generated.
4587     * `params`:
4588       {
4589         enabled = boolean,     -- whether to enable, default true
4590         block_radius = number, -- the radius (in nodes) of the areas the cache
4591                                   generates prefiltered lists for, minimum 16,
4592                                   default 64.
4593         limit = number,        -- the cache's size, minimum 20, default 1000
4594       }
4595 * `to_string()`: Experimental. Returns area store serialized as a (binary)
4596   string.
4597 * `to_file(filename)`: Experimental. Like `to_string()`, but writes the data to
4598   a file.
4599 * `from_string(str)`: Experimental. Deserializes string and loads it into the
4600   AreaStore.
4601   Returns success and, optionally, an error message.
4602 * `from_file(filename)`: Experimental. Like `from_string()`, but reads the data
4603   from a file.
4604
4605 `InvRef`
4606 --------
4607 An `InvRef` is a reference to an inventory.
4608
4609 ### Methods
4610 * `is_empty(listname)`: return `true` if list is empty
4611 * `get_size(listname)`: get size of a list
4612 * `set_size(listname, size)`: set size of a list
4613     * returns `false` on error (e.g. invalid `listname` or `size`)
4614 * `get_width(listname)`: get width of a list
4615 * `set_width(listname, width)`: set width of list; currently used for crafting
4616 * `get_stack(listname, i)`: get a copy of stack index `i` in list
4617 * `set_stack(listname, i, stack)`: copy `stack` to index `i` in list
4618 * `get_list(listname)`: return full list
4619 * `set_list(listname, list)`: set full list (size will not change)
4620 * `get_lists()`: returns list of inventory lists
4621 * `set_lists(lists)`: sets inventory lists (size will not change)
4622 * `add_item(listname, stack)`: add item somewhere in list, returns leftover
4623   `ItemStack`.
4624 * `room_for_item(listname, stack):` returns `true` if the stack of items
4625   can be fully added to the list
4626 * `contains_item(listname, stack, [match_meta])`: returns `true` if
4627   the stack of items can be fully taken from the list.
4628   If `match_meta` is false, only the items' names are compared
4629   (default: `false`).
4630 * `remove_item(listname, stack)`: take as many items as specified from the
4631   list, returns the items that were actually removed (as an `ItemStack`)
4632   -- note that any item metadata is ignored, so attempting to remove a specific
4633   unique item this way will likely remove the wrong one -- to do that use
4634   `set_stack` with an empty `ItemStack`.
4635 * `get_location()`: returns a location compatible to
4636   `minetest.get_inventory(location)`.
4637     * returns `{type="undefined"}` in case location is not known
4638
4639 `ItemStack`
4640 -----------
4641 An `ItemStack` is a stack of items.
4642
4643 It can be created via `ItemStack(x)`, where x is an `ItemStack`,
4644 an itemstring, a table or `nil`.
4645
4646 ### Methods
4647 * `is_empty()`: returns `true` if stack is empty.
4648 * `get_name()`: returns item name (e.g. `"default:stone"`).
4649 * `set_name(item_name)`: returns a boolean indicating whether the item was
4650   cleared.
4651 * `get_count()`: Returns number of items on the stack.
4652 * `set_count(count)`: returns a boolean indicating whether the item was cleared
4653     * `count`: number, unsigned 16 bit integer
4654 * `get_wear()`: returns tool wear (`0`-`65535`), `0` for non-tools.
4655 * `set_wear(wear)`: returns boolean indicating whether item was cleared
4656     * `wear`: number, unsigned 16 bit integer
4657 * `get_meta()`: returns ItemStackMetaRef. See section for more details
4658 * `get_metadata()`: (DEPRECATED) Returns metadata (a string attached to an item
4659   stack).
4660 * `set_metadata(metadata)`: (DEPRECATED) Returns true.
4661 * `clear()`: removes all items from the stack, making it empty.
4662 * `replace(item)`: replace the contents of this stack.
4663     * `item` can also be an itemstring or table.
4664 * `to_string()`: returns the stack in itemstring form.
4665 * `to_table()`: returns the stack in Lua table form.
4666 * `get_stack_max()`: returns the maximum size of the stack (depends on the
4667   item).
4668 * `get_free_space()`: returns `get_stack_max() - get_count()`.
4669 * `is_known()`: returns `true` if the item name refers to a defined item type.
4670 * `get_definition()`: returns the item definition table.
4671 * `get_tool_capabilities()`: returns the digging properties of the item,
4672   or those of the hand if none are defined for this item type
4673 * `add_wear(amount)`
4674     * Increases wear by `amount` if the item is a tool
4675     * `amount`: number, integer
4676 * `add_item(item)`: returns leftover `ItemStack`
4677     * Put some item or stack onto this stack
4678 * `item_fits(item)`: returns `true` if item or stack can be fully added to
4679   this one.
4680 * `take_item(n)`: returns taken `ItemStack`
4681     * Take (and remove) up to `n` items from this stack
4682     * `n`: number, default: `1`
4683 * `peek_item(n)`: returns taken `ItemStack`
4684     * Copy (don't remove) up to `n` items from this stack
4685     * `n`: number, default: `1`
4686
4687 `ItemStackMetaRef`
4688 ------------------
4689 ItemStack metadata: reference extra data and functionality stored in a stack.
4690 Can be obtained via `item:get_meta()`.
4691
4692 ### Methods
4693 * All methods in MetaDataRef
4694 * `set_tool_capabilities([tool_capabilities])`
4695     * Overrides the item's tool capabilities
4696     * A nil value will clear the override data and restore the original
4697       behavior.
4698
4699 `MetaDataRef`
4700 -------------
4701 See `StorageRef`, `NodeMetaRef`, `ItemStackMetaRef`, and `PlayerMetaRef`.
4702
4703 ### Methods
4704 * `contains(key)`: Returns true if key present, otherwise false.
4705     * Returns `nil` when the MetaData is inexistent.
4706 * `get(key)`: Returns `nil` if key not present, else the stored string.
4707 * `set_string(key, value)`: Value of `""` will delete the key.
4708 * `get_string(key)`: Returns `""` if key not present.
4709 * `set_int(key, value)`
4710 * `get_int(key)`: Returns `0` if key not present.
4711 * `set_float(key, value)`
4712 * `get_float(key)`: Returns `0` if key not present.
4713 * `to_table()`: returns `nil` or a table with keys:
4714     * `fields`: key-value storage
4715     * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
4716 * `from_table(nil or {})`
4717     * Any non-table value will clear the metadata
4718     * See "Node Metadata" for an example
4719     * returns `true` on success
4720 * `equals(other)`
4721     * returns `true` if this metadata has the same key-value pairs as `other`
4722
4723 ModChannel
4724 ----------
4725 An interface to use mod channels on client and server
4726
4727 ### Methods
4728 * `leave()`: leave the mod channel.
4729     * Server leaves channel `channel_name`.
4730     * No more incoming or outgoing messages can be sent to this channel from
4731       server mods.
4732     * This invalidate all future object usage.
4733     * Ensure you set mod_channel to nil after that to free Lua resources.
4734 * `is_writeable()`: returns true if channel is writeable and mod can send over
4735   it.
4736 * `send_all(message)`: Send `message` though the mod channel.
4737     * If mod channel is not writeable or invalid, message will be dropped.
4738     * Message size is limited to 65535 characters by protocol.
4739
4740 `NodeMetaRef`
4741 -------------
4742 Node metadata: reference extra data and functionality stored in a node.
4743 Can be obtained via `minetest.get_meta(pos)`.
4744
4745 ### Methods
4746 * All methods in MetaDataRef
4747 * `get_inventory()`: returns `InvRef`
4748 * `mark_as_private(name or {name1, name2, ...})`: Mark specific vars as private
4749   This will prevent them from being sent to the client. Note that the "private"
4750   status will only be remembered if an associated key-value pair exists,
4751   meaning it's best to call this when initializing all other meta (e.g.
4752   `on_construct`).
4753
4754 `NodeTimerRef`
4755 --------------
4756 Node Timers: a high resolution persistent per-node timer.
4757 Can be gotten via `minetest.get_node_timer(pos)`.
4758
4759 ### Methods
4760 * `set(timeout,elapsed)`
4761     * set a timer's state
4762     * `timeout` is in seconds, and supports fractional values (0.1 etc)
4763     * `elapsed` is in seconds, and supports fractional values (0.1 etc)
4764     * will trigger the node's `on_timer` function after `(timeout - elapsed)`
4765       seconds.
4766 * `start(timeout)`
4767     * start a timer
4768     * equivalent to `set(timeout,0)`
4769 * `stop()`
4770     * stops the timer
4771 * `get_timeout()`: returns current timeout in seconds
4772     * if `timeout` equals `0`, timer is inactive
4773 * `get_elapsed()`: returns current elapsed time in seconds
4774     * the node's `on_timer` function will be called after `(timeout - elapsed)`
4775       seconds.
4776 * `is_started()`: returns boolean state of timer
4777     * returns `true` if timer is started, otherwise `false`
4778
4779 `ObjectRef`
4780 -----------
4781 Moving things in the game are generally these.
4782
4783 This is basically a reference to a C++ `ServerActiveObject`
4784
4785 ### Methods
4786 * `remove()`: remove object (after returning from Lua)
4787     * Note: Doesn't work on players, use `minetest.kick_player` instead
4788 * `get_pos()`: returns `{x=num, y=num, z=num}`
4789 * `set_pos(pos)`; `pos`=`{x=num, y=num, z=num}`
4790 * `move_to(pos, continuous=false)`: interpolated move
4791 * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
4792     * `puncher` = another `ObjectRef`,
4793     * `time_from_last_punch` = time since last punch action of the puncher
4794     * `direction`: can be `nil`
4795 * `right_click(clicker)`; `clicker` is another `ObjectRef`
4796 * `get_hp()`: returns number of hitpoints (2 * number of hearts)
4797 * `set_hp(hp, reason)`: set number of hitpoints (2 * number of hearts).
4798     * See reason in register_on_player_hpchange
4799 * `get_inventory()`: returns an `InvRef`
4800 * `get_wield_list()`: returns the name of the inventory list the wielded item
4801    is in.
4802 * `get_wield_index()`: returns the index of the wielded item
4803 * `get_wielded_item()`: returns an `ItemStack`
4804 * `set_wielded_item(item)`: replaces the wielded item, returns `true` if
4805   successful.
4806 * `set_armor_groups({group1=rating, group2=rating, ...})`
4807 * `get_armor_groups()`: returns a table with the armor group ratings
4808 * `set_animation(frame_range, frame_speed, frame_blend, frame_loop)`
4809     * `frame_range`: table {x=num, y=num}, default: `{x=1, y=1}`
4810     * `frame_speed`: number, default: `15.0`
4811     * `frame_blend`: number, default: `0.0`
4812     * `frame_loop`: boolean, default: `true`
4813 * `get_animation()`: returns `range`, `frame_speed`, `frame_blend` and
4814   `frame_loop`.
4815 * `set_animation_frame_speed(frame_speed)`
4816     * `frame_speed`: number, default: `15.0`
4817 * `set_attach(parent, bone, position, rotation)`
4818     * `bone`: string
4819     * `position`: `{x=num, y=num, z=num}` (relative)
4820     * `rotation`: `{x=num, y=num, z=num}` = Rotation on each axis, in degrees
4821 * `get_attach()`: returns parent, bone, position, rotation or nil if it isn't
4822   attached.
4823 * `set_detach()`
4824 * `set_bone_position(bone, position, rotation)`
4825     * `bone`: string
4826     * `position`: `{x=num, y=num, z=num}` (relative)
4827     * `rotation`: `{x=num, y=num, z=num}`
4828 * `get_bone_position(bone)`: returns position and rotation of the bone
4829 * `set_properties(object property table)`
4830 * `get_properties()`: returns object property table
4831 * `is_player()`: returns true for players, false otherwise
4832 * `get_nametag_attributes()`
4833     * returns a table with the attributes of the nametag of an object
4834     * {
4835         color = {a=0..255, r=0..255, g=0..255, b=0..255},
4836         text = "",
4837       }
4838 * `set_nametag_attributes(attributes)`
4839     * sets the attributes of the nametag of an object
4840     * `attributes`:
4841       {
4842         color = ColorSpec,
4843         text = "My Nametag",
4844       }
4845
4846 #### LuaEntitySAO-only (no-op for other objects)
4847 * `set_velocity(vel)`
4848     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
4849 * `add_velocity(vel)`
4850     * `vel` is a vector, e.g. `{x=0.0, y=2.3, z=1.0}`
4851     * In comparison to using get_velocity, adding the velocity and then using
4852       set_velocity, add_velocity is supposed to avoid synchronization problems.
4853 * `get_velocity()`: returns the velocity, a vector
4854 * `set_acceleration(acc)`
4855     * `acc` is a vector
4856 * `get_acceleration()`: returns the acceleration, a vector
4857 * `set_yaw(radians)`
4858 * `get_yaw()`: returns number in radians
4859 * `set_texture_mod(mod)`
4860 * `get_texture_mod()` returns current texture modifier
4861 * `set_sprite(p, num_frames, framelength, select_horiz_by_yawpitch)`
4862     * Select sprite from spritesheet with optional animation and Dungeon Master
4863       style texture selection based on yaw relative to camera
4864     * `p`: {x=number, y=number}, the coordinate of the first frame
4865       (x: column, y: row), default: `{x=0, y=0}`
4866     * `num_frames`: number, default: `1`
4867     * `framelength`: number, default: `0.2`
4868     * `select_horiz_by_yawpitch`: boolean, this was once used for the Dungeon
4869       Master mob, default: `false`
4870 * `get_entity_name()` (**Deprecated**: Will be removed in a future version)
4871 * `get_luaentity()`
4872
4873 #### Player-only (no-op for other objects)
4874 * `get_player_name()`: returns `""` if is not a player
4875 * `get_player_velocity()`: returns `nil` if is not a player, otherwise a
4876   table {x, y, z} representing the player's instantaneous velocity in nodes/s
4877 * `get_look_dir()`: get camera direction as a unit vector
4878 * `get_look_vertical()`: pitch in radians
4879     * Angle ranges between -pi/2 and pi/2, which are straight up and down
4880       respectively.
4881 * `get_look_horizontal()`: yaw in radians
4882     * Angle is counter-clockwise from the +z direction.
4883 * `set_look_vertical(radians)`: sets look pitch
4884     * radians - Angle from looking forward, where positive is downwards.
4885 * `set_look_horizontal(radians)`: sets look yaw
4886     * radians - Angle from the +z direction, where positive is
4887       counter-clockwise.
4888 * `get_look_pitch()`: pitch in radians - Deprecated as broken. Use
4889   `get_look_vertical`.
4890     * Angle ranges between -pi/2 and pi/2, which are straight down and up
4891       respectively.
4892 * `get_look_yaw()`: yaw in radians - Deprecated as broken. Use
4893   `get_look_horizontal`.
4894     * Angle is counter-clockwise from the +x direction.
4895 * `set_look_pitch(radians)`: sets look pitch - Deprecated. Use
4896   `set_look_vertical`.
4897 * `set_look_yaw(radians)`: sets look yaw - Deprecated. Use
4898   `set_look_horizontal`.
4899 * `get_breath()`: returns players breath
4900 * `set_breath(value)`: sets players breath
4901     * values:
4902         * `0`: player is drowning
4903         * max: bubbles bar is not shown
4904         * See Object Properties for more information
4905 * `set_attribute(attribute, value)`:  DEPRECATED, use get_meta() instead
4906     * Sets an extra attribute with value on player.
4907     * `value` must be a string, or a number which will be converted to a
4908       string.
4909     * If `value` is `nil`, remove attribute from player.
4910 * `get_attribute(attribute)`:  DEPRECATED, use get_meta() instead
4911     * Returns value (a string) for extra attribute.
4912     * Returns `nil` if no attribute found.
4913 * `get_meta()`: Returns a PlayerMetaRef.
4914 * `set_inventory_formspec(formspec)`
4915     * Redefine player's inventory form
4916     * Should usually be called in `on_joinplayer`
4917 * `get_inventory_formspec()`: returns a formspec string
4918 * `set_formspec_prepend(formspec)`:
4919     * the formspec string will be added to every formspec shown to the user,
4920       except for those with a no_prepend[] tag.
4921     * This should be used to set style elements such as background[] and
4922       bgcolor[], any non-style elements (eg: label) may result in weird behaviour.
4923     * Only affects formspecs shown after this is called.
4924 * `get_formspec_prepend(formspec)`: returns a formspec string.
4925 * `get_player_control()`: returns table with player pressed keys
4926     * The table consists of fields with boolean value representing the pressed
4927       keys, the fields are jump, right, left, LMB, RMB, sneak, aux1, down, up.
4928     * example: `{jump=false, right=true, left=false, LMB=false, RMB=false,
4929       sneak=true, aux1=false, down=false, up=false}`
4930 * `get_player_control_bits()`: returns integer with bit packed player pressed
4931   keys.
4932     * bit nr/meaning: 0/up, 1/down, 2/left, 3/right, 4/jump, 5/aux1, 6/sneak,
4933       7/LMB, 8/RMB
4934 * `set_physics_override(override_table)`
4935     * `override_table` is a table with the following fields:
4936         * `speed`: multiplier to default walking speed value (default: `1`)
4937         * `jump`: multiplier to default jump value (default: `1`)
4938         * `gravity`: multiplier to default gravity value (default: `1`)
4939         * `sneak`: whether player can sneak (default: `true`)
4940         * `sneak_glitch`: whether player can use the new move code replications
4941           of the old sneak side-effects: sneak ladders and 2 node sneak jump
4942           (default: `false`)
4943         * `new_move`: use new move/sneak code. When `false` the exact old code
4944           is used for the specific old sneak behaviour (default: `true`)
4945 * `get_physics_override()`: returns the table given to `set_physics_override`
4946 * `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
4947    number on success
4948 * `hud_remove(id)`: remove the HUD element of the specified id
4949 * `hud_change(id, stat, value)`: change a value of a previously added HUD
4950   element.
4951     * element `stat` values:
4952       `position`, `name`, `scale`, `text`, `number`, `item`, `dir`
4953 * `hud_get(id)`: gets the HUD element definition structure of the specified ID
4954 * `hud_set_flags(flags)`: sets specified HUD flags to `true`/`false`
4955     * `flags`: (is visible) `hotbar`, `healthbar`, `crosshair`, `wielditem`,
4956       `breathbar`, `minimap`, `minimap_radar`
4957     * pass a table containing a `true`/`false` value of each flag to be set or
4958       unset.
4959     * if a flag equals `nil`, the flag is not modified
4960     * note that setting `minimap` modifies the client's permission to view the
4961       minimap - the client may locally elect to not view the minimap.
4962     * minimap `radar` is only usable when `minimap` is true
4963 * `hud_get_flags()`: returns a table containing status of hud flags
4964     * returns `{hotbar=true, healthbar=true, crosshair=true, wielditem=true,
4965       breathbar=true, minimap=true, minimap_radar=true}`
4966 * `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
4967     * `count`: number of items, must be between `1` and `23`
4968 * `hud_get_hotbar_itemcount`: returns number of visible items
4969 * `hud_set_hotbar_image(texturename)`
4970     * sets background image for hotbar
4971 * `hud_get_hotbar_image`: returns texturename
4972 * `hud_set_hotbar_selected_image(texturename)`
4973     * sets image for selected item of hotbar
4974 * `hud_get_hotbar_selected_image`: returns texturename
4975 * `set_sky(bgcolor, type, {texture names}, clouds)`
4976     * `bgcolor`: ColorSpec, defaults to white
4977     * `type`: Available types:
4978         * `"regular"`: Uses 0 textures, `bgcolor` ignored
4979         * `"skybox"`: Uses 6 textures, `bgcolor` used
4980         * `"plain"`: Uses 0 textures, `bgcolor` used
4981     * `clouds`: Boolean for whether clouds appear in front of `"skybox"` or
4982       `"plain"` custom skyboxes (default: `true`)
4983 * `get_sky()`: returns bgcolor, type, table of textures, clouds
4984 * `set_clouds(parameters)`: set cloud parameters
4985     * `parameters` is a table with the following optional fields:
4986         * `density`: from `0` (no clouds) to `1` (full clouds) (default `0.4`)
4987         * `color`: basic cloud color with alpha channel, ColorSpec
4988           (default `#fff0f0e5`).
4989         * `ambient`: cloud color lower bound, use for a "glow at night" effect.
4990           ColorSpec (alpha ignored, default `#000000`)
4991         * `height`: cloud height, i.e. y of cloud base (default per conf,
4992           usually `120`)
4993         * `thickness`: cloud thickness in nodes (default `16`)
4994         * `speed`: 2D cloud speed + direction in nodes per second
4995           (default `{x=0, z=-2}`).
4996 * `get_clouds()`: returns a table with the current cloud parameters as in
4997   `set_clouds`.
4998 * `override_day_night_ratio(ratio or nil)`
4999     * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
5000       amount.
5001     * `nil`: Disables override, defaulting to sunlight based on day-night cycle
5002 * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden
5003 * `set_local_animation(stand/idle, walk, dig, walk+dig, frame_speed=frame_speed)`:
5004   set animation for player model in third person view
5005
5006         set_local_animation({x=0, y=79}, -- < stand/idle animation key frames
5007             {x=168, y=187}, -- < walk animation key frames
5008             {x=189, y=198}, -- <  dig animation key frames
5009             {x=200, y=219}, -- <  walk+dig animation key frames
5010             frame_speed=30): -- <  animation frame speed
5011 * `get_local_animation()`: returns stand, walk, dig, dig+walk tables and
5012   `frame_speed`.
5013 * `set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})`: defines offset value for
5014   camera per player.
5015     * in first person view
5016     * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
5017 * `get_eye_offset()`: returns `offset_first` and `offset_third`
5018
5019 `PcgRandom`
5020 -----------
5021 A 32-bit pseudorandom number generator.
5022 Uses PCG32, an algorithm of the permuted congruential generator family,
5023 offering very strong randomness.
5024
5025 It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
5026
5027 ### Methods
5028 * `next()`: return next integer random number [`-2147483648`...`2147483647`]
5029 * `next(min, max)`: return next integer random number [`min`...`max`]
5030 * `rand_normal_dist(min, max, num_trials=6)`: return normally distributed
5031   random number [`min`...`max`].
5032     * This is only a rough approximation of a normal distribution with:
5033     * `mean = (max - min) / 2`, and
5034     * `variance = (((max - min + 1) ^ 2) - 1) / (12 * num_trials)`
5035     * Increasing `num_trials` improves accuracy of the approximation
5036
5037 `PerlinNoise`
5038 -------------
5039 A perlin noise generator.
5040 It can be created via `PerlinNoise(seed, octaves, persistence, scale)`
5041 or `PerlinNoise(noiseparams)`.
5042 Alternatively with `minetest.get_perlin(seeddiff, octaves, persistence, scale)`
5043 or `minetest.get_perlin(noiseparams)`.
5044
5045 ### Methods
5046 * `get_2d(pos)`: returns 2D noise value at `pos={x=,y=}`
5047 * `get_3d(pos)`: returns 3D noise value at `pos={x=,y=,z=}`
5048
5049 `PerlinNoiseMap`
5050 ----------------
5051 A fast, bulk perlin noise generator.
5052
5053 It can be created via `PerlinNoiseMap(noiseparams, size)` or
5054 `minetest.get_perlin_map(noiseparams, size)`.
5055
5056 Format of `size` is `{x=dimx, y=dimy, z=dimz}`. The `z` component is omitted
5057 for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise
5058 `nil` is returned).
5059
5060 For each of the functions with an optional `buffer` parameter: If `buffer` is
5061 not nil, this table will be used to store the result instead of creating a new
5062 table.
5063
5064 ### Methods
5065 * `get_2d_map(pos)`: returns a `<size.x>` times `<size.y>` 2D array of 2D noise
5066   with values starting at `pos={x=,y=}`
5067 * `get_3d_map(pos)`: returns a `<size.x>` times `<size.y>` times `<size.z>`
5068   3D array of 3D noise with values starting at `pos={x=,y=,z=}`.
5069 * `get_2d_map_flat(pos, buffer)`: returns a flat `<size.x * size.y>` element
5070   array of 2D noise with values starting at `pos={x=,y=}`
5071 * `get_3d_map_flat(pos, buffer)`: Same as `get2dMap_flat`, but 3D noise
5072 * `calc_2d_map(pos)`: Calculates the 2d noise map starting at `pos`. The result
5073   is stored internally.
5074 * `calc_3d_map(pos)`: Calculates the 3d noise map starting at `pos`. The result
5075   is stored internally.
5076 * `get_map_slice(slice_offset, slice_size, buffer)`: In the form of an array,
5077   returns a slice of the most recently computed noise results. The result slice
5078   begins at coordinates `slice_offset` and takes a chunk of `slice_size`.
5079   E.g. to grab a 2-slice high horizontal 2d plane of noise starting at buffer
5080   offset y = 20:
5081   `noisevals = noise:get_map_slice({y=20}, {y=2})`
5082   It is important to note that `slice_offset` offset coordinates begin at 1,
5083   and are relative to the starting position of the most recently calculated
5084   noise.
5085   To grab a single vertical column of noise starting at map coordinates
5086   x = 1023, y=1000, z = 1000:
5087   `noise:calc_3d_map({x=1000, y=1000, z=1000})`
5088   `noisevals = noise:get_map_slice({x=24, z=1}, {x=1, z=1})`
5089
5090 `PlayerMetaRef`
5091 ---------------
5092 Player metadata.
5093 Uses the same method of storage as the deprecated player attribute API, so
5094 data there will also be in player meta.
5095 Can be obtained using `player:get_meta()`.
5096
5097 ### Methods
5098 * All methods in MetaDataRef
5099
5100 `PseudoRandom`
5101 --------------
5102 A 16-bit pseudorandom number generator.
5103 Uses a well-known LCG algorithm introduced by K&R.
5104
5105 It can be created via `PseudoRandom(seed)`.
5106
5107 ### Methods
5108 * `next()`: return next integer random number [`0`...`32767`]
5109 * `next(min, max)`: return next integer random number [`min`...`max`]
5110     * `((max - min) == 32767) or ((max-min) <= 6553))` must be true
5111       due to the simple implementation making bad distribution otherwise.
5112
5113 `Raycast`
5114 ---------
5115 A raycast on the map. It works with selection boxes.
5116 Can be used as an iterator in a for loop.
5117
5118 The map is loaded as the ray advances. If the
5119 map is modified after the `Raycast` is created,
5120 the changes may or may not have an effect on
5121 the object.
5122
5123 It can be created via `Raycast(pos1, pos2, objects, liquids)` or
5124 `minetest.raycast(pos1, pos2, objects, liquids)` where:
5125 * `pos1`: start of the ray
5126 * `pos2`: end of the ray
5127 * `objects` : if false, only nodes will be returned. Default is true.
5128 * `liquids' : if false, liquid nodes won't be returned. Default is false.
5129
5130 ### Methods
5131 * `next()`: returns a `pointed_thing`
5132     * Returns the next thing pointed by the ray or nil.
5133
5134 `SecureRandom`
5135 --------------
5136 Interface for the operating system's crypto-secure PRNG.
5137
5138 It can be created via `SecureRandom()`.  The constructor returns nil if a
5139 secure random device cannot be found on the system.
5140
5141 ### Methods
5142 * `next_bytes([count])`: return next `count` (default 1, capped at 2048) many
5143   random bytes, as a string.
5144
5145 `Settings`
5146 ----------
5147 An interface to read config files in the format of `minetest.conf`.
5148
5149 It can be created via `Settings(filename)`.
5150
5151 ### Methods
5152 * `get(key)`: returns a value
5153 * `get_bool(key, [default])`: returns a boolean
5154     * `default` is the value returned if `key` is not found.
5155     * Returns `nil` if `key` is not found and `default` not specified.
5156 * `get_np_group(key)`: returns a NoiseParams table
5157 * `set(key, value)`
5158     * Setting names can't contain whitespace or any of `="{}#`.
5159     * Setting values can't contain the sequence `\n"""`.
5160     * Setting names starting with "secure." can't be set on the main settings
5161       object (`minetest.settings`).
5162 * `set_bool(key, value)`
5163     * See documentation for set() above.
5164 * `set_np_group(key, value)`
5165     * `value` is a NoiseParams table.
5166     * Also, see documentation for set() above.
5167 * `remove(key)`: returns a boolean (`true` for success)
5168 * `get_names()`: returns `{key1,...}`
5169 * `write()`: returns a boolean (`true` for success)
5170     * Writes changes to file.
5171 * `to_table()`: returns `{[key1]=value1,...}`
5172
5173 `StorageRef`
5174 ------------
5175 Mod metadata: per mod metadata, saved automatically.
5176 Can be obtained via `minetest.get_mod_storage()` during load time.
5177
5178 ### Methods
5179 * All methods in MetaDataRef
5180
5181
5182
5183
5184 Definition tables
5185 =================
5186
5187 Object Properties
5188 -----------------
5189
5190     {
5191         hp_max = 1,
5192     --  ^ For players: Defaults to `minetest.PLAYER_MAX_HP_DEFAULT`
5193         breath_max = 0,
5194     --  ^ For players only. Defaults to `minetest.PLAYER_MAX_BREATH_DEFAULT`
5195         zoom_fov = 0.0,
5196     --  ^ For players only. Zoom FOV in degrees.
5197     --    Note that zoom loads and/or generates world beyond the server's
5198     --    maximum send and generate distances, so acts like a telescope.
5199     --    Smaller zoomFOV values increase the distance loaded and/or generated.
5200     --    Defaults to 15 in creative mode, 0 in survival mode.
5201     --    zoom_fov = 0 disables zooming for the player.
5202         eye_height = 1.625,
5203     --  ^ For players only. Camera height above feet position in nodes.
5204     --    Defaults to 1.625.
5205         physical = true,
5206         collide_with_objects = true,
5207     --  ^ Collide with other objects if physical = true.
5208         weight = 5,
5209         collisionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5},
5210         selectionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5},
5211     --  ^ Default, uses collision box dimensions when not set.
5212     --  ^ For both boxes: {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from
5213     --    object position.
5214         pointable = true,
5215     --  ^ Overrides selection box when false.
5216         visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem",
5217     --  ^ "cube" is a node-sized cube.
5218     --  ^ "sprite" is a flat texture always facing the player.
5219     --  ^ "upright_sprite" is a vertical flat texture.
5220     --  ^ "mesh" uses the defined mesh model.
5221     --  ^ "wielditem" is used for dropped items
5222     --    (see builtin/game/item_entity.lua).
5223     --    For this use 'textures = {itemname}'.
5224     --    If the item has a 'wield_image' the object will be an extrusion of
5225     --    that, otherwise:
5226     --    If 'itemname' is a cubic node or nodebox the object will appear
5227     --    identical to 'itemname'.
5228     --    If 'itemname' is a plantlike node the object will be an extrusion of
5229     --    its texture.
5230     --    Otherwise for non-node items, the object will be an extrusion of
5231     --    'inventory_image'.
5232         visual_size = {x = 1, y = 1},
5233     --  ^ `x` multiplies horizontal (X and Z) visual size.
5234     --  ^ `y` multiplies vertical (Y) visual size.
5235         mesh = "model",
5236         textures = {},
5237     --  ^ Number of required textures depends on visual.
5238     --  ^ "cube" uses 6 textures in the way a node does.
5239     --  ^ "sprite" uses 1 texture.
5240     --  ^ "upright_sprite" uses 2 textures: {front, back}.
5241     --  ^ "wielditem" expects 'textures = {itemname}' (see 'visual' above).
5242         colors = {},
5243     --  ^ Number of required colors depends on visual.
5244         use_texture_alpha = false,
5245     --  ^ Use texture's alpha channel, excludes "upright_sprite" and "wielditem"
5246         --  ^ Note: currently causes visual issues when viewed through other
5247         --  ^ semi-transparent materials such as water.
5248         spritediv = {x = 1, y = 1},
5249     --  ^ Used with spritesheet textures for animation and/or frame selection
5250     --    according to position relative to player.
5251     --  ^ Defines the number of columns and rows in the spritesheet:
5252     --    {columns, rows}.
5253         initial_sprite_basepos = {x = 0, y = 0},
5254     --  ^ Used with spritesheet textures.
5255     --  ^ Defines the {column, row} position of the initially used frame in the
5256     --    spritesheet.
5257         is_visible = true,
5258         makes_footstep_sound = false,
5259         automatic_rotate = 0,
5260     --  ^ Set constant rotation in radians per second, positive or negative.
5261     --  ^ Set to 0 to disable constant rotation.
5262         stepheight = 0,
5263         automatic_face_movement_dir = 0.0,
5264     --  ^ Automatically set yaw to movement direction, offset in degrees,
5265     --    'false' to disable.
5266         automatic_face_movement_max_rotation_per_sec = -1,
5267     --  ^ Limit automatic rotation to this value in degrees per second,
5268     --    value < 0 no limit.
5269         backface_culling = true,
5270     --  ^ Set to false to disable backface_culling for model.
5271         glow = 0,
5272     --  ^ Add this much extra lighting when calculating texture color.
5273     --    Value < 0 disables light's effect on texture color.
5274     --    For faking self-lighting, UI style entities, or programmatic coloring
5275     --    in mods.
5276         nametag = "",
5277     --  ^ By default empty, for players their name is shown if empty.
5278         nametag_color = <color>,
5279     --  ^ Sets color of nametag as ColorSpec.
5280         infotext = "",
5281     --  ^ By default empty, text to be shown when pointed at object.
5282         static_save = true,
5283     --  ^ If false, never save this object statically. It will simply be
5284     --    deleted when the block gets unloaded.
5285     --    The get_staticdata() callback is never called then.
5286     --    Defaults to 'true'
5287     }
5288
5289 Entity definition (`register_entity`)
5290 -------------------------------------
5291
5292     {
5293     --  Deprecated: Everything in object properties is read directly from here
5294
5295         initial_properties = --[[<initial object properties>]],
5296
5297         on_activate = function(self, staticdata, dtime_s),
5298         on_step = function(self, dtime),
5299         on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir),
5300         on_rightclick = function(self, clicker),
5301         get_staticdata = function(self),
5302     --  ^ Called sometimes; the string returned is passed to on_activate when
5303     --    the entity is re-activated from static state
5304
5305         _custom_field = whatever,
5306     --  ^ You can define arbitrary member variables here (see item definition
5307     --    for more info) by using a '_' prefix.
5308     }
5309
5310 ABM (ActiveBlockModifier) definition (`register_abm`)
5311 -----------------------------------------------------
5312
5313     {
5314         label = "Lava cooling",
5315         ^ Descriptive label for profiling purposes (optional).
5316           Definitions with identical labels will be listed as one.
5317         nodenames = {"default:lava_source"},
5318         ^ Apply `action` function to these nodes.
5319         ^ `group:groupname` can also be used here.
5320         neighbors = {"default:water_source", "default:water_flowing"},
5321         ^ Only apply `action` to nodes that have one of, or any
5322           combination of, these neighbors.
5323         ^ If left out or empty, any neighbor will do.
5324         ^ `group:groupname` can also be used here.
5325         interval = 1.0,
5326         ^ Operation interval in seconds.
5327         chance = 1,
5328         ^ Chance of triggering `action` per-node per-interval is 1.0 / this
5329           value.
5330         catch_up = true,
5331         ^ If true, catch-up behaviour is enabled: The `chance` value is
5332           temporarily reduced when returning to an area to simulate time lost
5333           by the area being unattended. Note that the `chance` value can often
5334           be reduced to 1.
5335         action = function(pos, node, active_object_count, active_object_count_wider),
5336         ^ Function triggered for each qualifying node.
5337         ^ `active_object_count` is number of active objects in the node's
5338           mapblock.
5339         ^ `active_object_count_wider` is number of active objects in the node's
5340           mapblock plus all 26 neighboring mapblocks. If any neighboring
5341           mapblocks are unloaded an estmate is calculated for them based on
5342           loaded mapblocks.
5343     }
5344
5345 LBM (LoadingBlockModifier) definition (`register_lbm`)
5346 ------------------------------------------------------
5347
5348     {
5349         label = "Upgrade legacy doors",
5350     --  ^ Descriptive label for profiling purposes (optional).
5351     --    Definitions with identical labels will be listed as one.
5352         name = "modname:replace_legacy_door",
5353         nodenames = {"default:lava_source"},
5354     --  ^ List of node names to trigger the LBM on.
5355     --    Also non-registered nodes will work.
5356     --    Groups (as of group:groupname) will work as well.
5357         run_at_every_load = false,
5358     --  ^ Whether to run the LBM's action every time a block gets loaded,
5359     --    and not just for blocks that were saved last time before LBMs were
5360     --    introduced to the world.
5361         action = func(pos, node),
5362     }
5363
5364 Item definition (`register_node`, `register_craftitem`, `register_tool`)
5365 ------------------------------------------------------------------------
5366
5367     {
5368         description = "Steel Axe",
5369         groups = {}, -- key = name, value = rating; rating = 1..3.
5370                         if rating not applicable, use 1.
5371                         e.g. {wool = 1, fluffy = 3}
5372                             {soil = 2, outerspace = 1, crumbly = 1}
5373                             {bendy = 2, snappy = 1},
5374                             {hard = 1, metal = 1, spikes = 1}
5375         inventory_image = "default_tool_steelaxe.png",
5376         inventory_overlay = "overlay.png",
5377         ^ An overlay which does not get colorized.
5378         wield_image = "",
5379         wield_overlay = "",
5380         palette = "",
5381         --[[
5382         ^ An image file containing the palette of a node.
5383         ^ You can set the currently used color as the
5384         ^ "palette_index" field of the item stack metadata.
5385         ^ The palette is always stretched to fit indices
5386         ^ between 0 and 255, to ensure compatibility with
5387         ^ "colorfacedir" and "colorwallmounted" nodes.
5388         ]]
5389         color = "0xFFFFFFFF",
5390         ^ The color of the item. The palette overrides this.
5391         wield_scale = {x = 1, y = 1, z = 1},
5392         stack_max = 99,
5393         range = 4.0,
5394         liquids_pointable = false,
5395         tool_capabilities = {
5396             full_punch_interval = 1.0,
5397             max_drop_level = 0,
5398             groupcaps = {
5399                 -- For example:
5400                 choppy = {times = {[1] = 2.50, [2] = 1.40, [3] = 1.00},
5401                          uses = 20, maxlevel = 2},
5402             },
5403             damage_groups = {groupname = damage},
5404         },
5405         node_placement_prediction = nil,
5406         --[[
5407         ^ If nil and item is node, prediction is made automatically
5408         ^ If nil and item is not a node, no prediction is made
5409         ^ If "" and item is anything, no prediction is made
5410         ^ Otherwise should be name of node which the client immediately places
5411           on ground when the player places the item. Server will always update
5412           actual result to client in a short moment.
5413         ]]
5414         node_dig_prediction = "air",
5415         --[[
5416         ^ if "", no prediction is made
5417         ^ if "air", node is removed
5418         ^ Otherwise should be name of node which the client immediately places
5419           upon digging. Server will always update actual result shortly.
5420         ]]
5421         sound = {
5422             breaks = "default_tool_break", -- tools only
5423             place = --[[<SimpleSoundSpec>]],
5424         },
5425
5426         on_place = func(itemstack, placer, pointed_thing),
5427         --[[
5428         ^ Shall place item and return the leftover itemstack
5429         ^ The placer may be any ObjectRef or nil.
5430         ^ default: minetest.item_place ]]
5431         on_secondary_use = func(itemstack, user, pointed_thing),
5432         --[[
5433         ^ Same as on_place but called when pointing at nothing.
5434         ^ The user may be any ObjectRef or nil.
5435         ^ pointed_thing : always { type = "nothing" }
5436         ]]
5437         on_drop = func(itemstack, dropper, pos),
5438         --[[
5439         ^ Shall drop item and return the leftover itemstack
5440         ^ The dropper may be any ObjectRef or nil.
5441         ^ default: minetest.item_drop ]]
5442         on_use = func(itemstack, user, pointed_thing),
5443         --[[
5444         ^  default: nil
5445         ^ Function must return either nil if no item shall be removed from
5446           inventory, or an itemstack to replace the original itemstack.
5447           e.g. itemstack:take_item(); return itemstack
5448         ^ Otherwise, the function is free to do what it wants.
5449         ^ The user may be any ObjectRef or nil.
5450         ^ The default functions handle regular use cases.
5451         ]]
5452         after_use = func(itemstack, user, node, digparams),
5453         --[[
5454         ^  default: nil
5455         ^ If defined, should return an itemstack and will be called instead of
5456           wearing out the tool. If returns nil, does nothing.
5457           If after_use doesn't exist, it is the same as:
5458             function(itemstack, user, node, digparams)
5459               itemstack:add_wear(digparams.wear)
5460               return itemstack
5461             end
5462         ^ The user may be any ObjectRef or nil.
5463         ]]
5464         _custom_field = whatever,
5465         --[[
5466         ^ Add your own custom fields. By convention, all custom field names
5467           should start with `_` to avoid naming collisions with future engine
5468           usage.
5469         ]]
5470     }
5471
5472 Tile definition
5473 ---------------
5474 * `"image.png"`
5475 * `{name="image.png", animation={Tile Animation definition}}`
5476 * `{name="image.png", backface_culling=bool, tileable_vertical=bool,
5477     tileable_horizontal=bool, align_style="node"/"world"/"user", scale=int}`
5478     * backface culling enabled by default for most nodes
5479     * tileable flags are info for shaders, how they should treat texture
5480       when displacement mapping is used
5481       Directions are from the point of view of the tile texture,
5482       not the node it's on
5483     * align style determines whether the texture will be rotated with the node
5484       or kept aligned with its surroundings. "user" means that client
5485       setting will be used, similar to `glasslike_framed_optional`.
5486       Note: supported by solid nodes and nodeboxes only.
5487     * scale is used to make texture span several (exactly `scale`) nodes,
5488       instead of just one, in each direction. Works for world-aligned
5489       textures only.
5490       Note that as the effect is applied on per-mapblock basis, `16` should
5491       be equally divisible by `scale` or you may get wrong results.
5492 * `{name="image.png", color=ColorSpec}`
5493     * the texture's color will be multiplied with this color.
5494     * the tile's color overrides the owning node's color in all cases.
5495 * deprecated, yet still supported field names:
5496     * `image` (name)
5497
5498 Tile animation definition
5499 -------------------------
5500
5501     {
5502         type = "vertical_frames",
5503         aspect_w = 16,
5504         -- ^ specify width of a frame in pixels
5505         aspect_h = 16,
5506         -- ^ specify height of a frame in pixels
5507         length = 3.0,
5508         -- ^ specify full loop length
5509     }
5510
5511     {
5512         type = "sheet_2d",
5513         frames_w = 5,
5514         -- ^ specify width in number of frames
5515         frames_h = 3,
5516         -- ^ specify height in number of frames
5517         frame_length = 0.5,
5518         -- ^ specify length of a single frame
5519     }
5520
5521 Node definition (`register_node`)
5522 ---------------------------------
5523
5524     {
5525         -- <all fields allowed in item definitions>,
5526
5527         drawtype = "normal", -- See "Node drawtypes"
5528         visual_scale = 1.0, --[[
5529         ^ Supported for drawtypes "plantlike", "signlike", "torchlike",
5530         ^ "firelike", "mesh".
5531         ^ For plantlike and firelike, the image will start at the bottom of the
5532         ^ node, for the other drawtypes the image will be centered on the node.
5533         ^ Note that positioning for "torchlike" may still change. ]]
5534         tiles = {tile definition 1, def2, def3, def4, def5, def6}, --[[
5535         ^ Textures of node; +Y, -Y, +X, -X, +Z, -Z
5536         ^ Old field name was 'tile_images'.
5537         ^ List can be shortened to needed length ]]
5538         overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6}, --[[
5539         ^ Same as `tiles`, but these textures are drawn on top of the
5540         ^ base tiles. You can use this to colorize only specific parts of
5541         ^ your texture. If the texture name is an empty string, that
5542         ^ overlay is not drawn. Since such tiles are drawn twice, it
5543         ^ is not recommended to use overlays on very common nodes. ]]
5544         special_tiles = {tile definition 1, Tile definition 2}, --[[
5545         ^ Special textures of node; used rarely
5546         ^ Old field name was 'special_materials'.
5547         ^ List can be shortened to needed length ]]
5548         color = ColorSpec, --[[
5549         ^ The node's original color will be multiplied with this color.
5550         ^ If the node has a palette, then this setting only has an effect
5551         ^ in the inventory and on the wield item. ]]
5552         use_texture_alpha = false,
5553         ^ Use texture's alpha channel.
5554         palette = "palette.png", --[[
5555         ^ The node's `param2` is used to select a pixel from the image
5556         ^ (pixels are arranged from left to right and from top to bottom).
5557         ^ The node's color will be multiplied with the selected pixel's
5558         ^ color. Tiles can override this behavior.
5559         ^ Only when `paramtype2` supports palettes. ]]
5560         post_effect_color = "green#0F",
5561         ^ Screen tint if player is inside node, see "ColorSpec".
5562         paramtype = "none", -- See "Nodes".
5563         paramtype2 = "none", -- See "Nodes"
5564         place_param2 = nil, -- Force value for param2 when player places node
5565         is_ground_content = true,
5566         ^ If false, the cave generator will not carve through this node.
5567         sunlight_propagates = false,
5568         ^ If true, sunlight will go infinitely through this.
5569         walkable = true, -- If true, objects collide with node
5570         pointable = true, -- If true, can be pointed at
5571         diggable = true, -- If false, can never be dug
5572         climbable = false, -- If true, can be climbed on (ladder)
5573         buildable_to = false, -- If true, placed nodes can replace this node
5574         floodable = false, --[[
5575         ^ If true, liquids flow into and replace this node.
5576         ^ Warning: making a liquid node 'floodable' will cause problems. ]]
5577         liquidtype = "none", -- "none"/"source"/"flowing"
5578         liquid_alternative_flowing = "", -- Flowing version of source liquid
5579         liquid_alternative_source = "", -- Source version of flowing liquid
5580         liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
5581         liquid_renewable = true, --[[
5582         ^ If true, a new liquid source can be created by placing two or more
5583           sources nearby. ]]
5584         leveled = 16, --[[
5585         ^ Only valid for "nodebox" drawtype with 'type = "leveled"'.
5586         ^ Allows defining the nodebox height without using param2.
5587         ^ The nodebox height is 'leveled' / 64 nodes.
5588         ^ The maximum value of 'leveled' is 127. ]]
5589         liquid_range = 8, -- number of flowing nodes around source (max. 8)
5590         drowning = 0,
5591         ^ Player will take this amount of damage if no bubbles are left.
5592         light_source = 0, --[[
5593         ^ Amount of light emitted by node.
5594         ^ To set the maximum (currently 14), use the value
5595         ^ 'minetest.LIGHT_MAX'.
5596         ^ A value outside the range 0 to minetest.LIGHT_MAX causes undefined
5597         ^ behavior.]]
5598         damage_per_second = 0,
5599         ^ If player is inside node, this damage is caused.
5600         node_box = {type="regular"}, -- See "Node boxes"
5601         connects_to = nodenames, --[[
5602         ^ Used for nodebox nodes with the type == "connected"
5603         ^ Specifies to what neighboring nodes connections will be drawn
5604         ^ e.g. `{"group:fence", "default:wood"}` or `"default:stone"` ]]
5605         connect_sides = { "top", "bottom", "front", "left", "back", "right" },
5606                 -- [[
5607         ^ Tells connected nodebox nodes to connect only to these sides of this
5608         ^ node. ]]
5609         mesh = "model",
5610         selection_box = {
5611             type = "fixed",
5612             fixed = {
5613                 {-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
5614             },
5615         },
5616         ^ Custom selection box definition. Multiple boxes can be defined.
5617         ^ If drawtype "nodebox" is used and selection_box is nil, then node_box
5618         ^ definition is used for the selection box.
5619         collision_box = {
5620             type = "fixed",
5621             fixed = {
5622                 {-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
5623             },
5624         },
5625         ^ Custom collision box definition. Multiple boxes can be defined.
5626         ^ If drawtype "nodebox" is used and collision_box is nil, then node_box
5627         ^ definition is used for the collision box.
5628         ^ For both of the above a box is defined as:
5629         ^ {xmin, ymin, zmin, xmax, ymax, zmax} in nodes from node center.
5630         legacy_facedir_simple = false,
5631         ^ Support maps made in and before January 2012.
5632         legacy_wallmounted = false,
5633         ^ Support maps made in and before January 2012.
5634         waving = 0, --[[
5635         ^ Valid for mesh, nodebox, plantlike, allfaces_optional nodes.
5636         ^ 1 - wave node like plants (top of node moves, bottom is fixed)
5637         ^ 2 - wave node like leaves (whole node moves side-to-side)
5638         ^ caveats: not all models will properly wave.
5639         ^ plantlike drawtype nodes can only wave like plants.
5640         ^ allfaces_optional drawtype nodes can only wave like leaves. --]]
5641         sounds = {
5642             footstep = <SimpleSoundSpec>,
5643             dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
5644             dug = <SimpleSoundSpec>,
5645             place = <SimpleSoundSpec>,
5646             place_failed = <SimpleSoundSpec>,
5647         },
5648         drop = "",
5649         ^ Name of dropped node when dug. Default is the node itself.
5650         ^ Alternatively:
5651         drop = {
5652             max_items = 1,  -- Maximum number of items to drop.
5653             items = {  -- Choose max_items randomly from this list.
5654                 {
5655                     items = {"foo:bar", "baz:frob"},  -- Items to drop.
5656                     rarity = 1,  -- Probability of dropping is 1 / rarity.
5657                     inherit_color = true, -- To inherit palette color from the
5658                                              node.
5659                 },
5660             },
5661         },
5662
5663         on_construct = func(pos), --[[
5664         ^ Node constructor; called after adding node
5665         ^ Can set up metadata and stuff like that
5666         ^ Not called for bulk node placement (i.e. schematics and VoxelManip)
5667         ^ default: nil ]]
5668
5669         on_destruct = func(pos), --[[
5670         ^ Node destructor; called before removing node
5671         ^ Not called for bulk node placement (i.e. schematics and VoxelManip)
5672         ^ default: nil ]]
5673
5674         after_destruct = func(pos, oldnode), --[[
5675         ^ Node destructor; called after removing node
5676         ^ Not called for bulk node placement (i.e. schematics and VoxelManip)
5677         ^ default: nil ]]
5678
5679         on_flood = func(pos, oldnode, newnode), --[[
5680         ^ Called when a liquid (newnode) is about to flood oldnode, if
5681         ^ it has `floodable = true` in the nodedef. Not called for bulk
5682         ^ node placement (i.e. schematics and VoxelManip) or air nodes. If
5683         ^ return true the node is not flooded, but on_flood callback will
5684         ^ most likely be called over and over again every liquid update
5685         ^ interval. Default: nil.
5686         ^ Warning: making a liquid node 'floodable' will cause problems. ]]
5687
5688         preserve_metadata = func(pos, oldnode, oldmeta, drops) --[[
5689         ^ Called when oldnode is about be converted to an item, but before the
5690         ^ node is deleted from the world or the drops are added. This is
5691         ^ generally the result of either the node being dug or an attached node
5692         ^ becoming detached.
5693         ^ drops is a table of ItemStacks, so any metadata to be preserved can
5694         ^ be added directly to one or more of the dropped items. See
5695         ^ "ItemStackMetaRef".
5696         ^ default: nil ]]
5697
5698         after_place_node = func(pos, placer, itemstack, pointed_thing) --[[
5699         ^ Called after constructing node when node was placed using
5700         ^ minetest.item_place_node / minetest.place_node
5701         ^ If return true no item is taken from itemstack
5702         ^ `placer` may be any valid ObjectRef or nil
5703         ^ default: nil ]]
5704
5705         after_dig_node = func(pos, oldnode, oldmetadata, digger), --[[
5706         ^ oldmetadata is in table format
5707         ^ Called after destructing node when node was dug using
5708         ^ minetest.node_dig / minetest.dig_node
5709         ^ default: nil ]]
5710
5711         can_dig = function(pos, [player]) --[[
5712         ^ returns true if node can be dug, or false if not
5713         ^ default: nil ]]
5714
5715         on_punch = func(pos, node, puncher, pointed_thing), --[[
5716         ^ default: minetest.node_punch
5717         ^ By default: Calls minetest.register_on_punchnode callbacks ]]
5718
5719         on_rightclick = func(pos, node, clicker, itemstack, pointed_thing),
5720         --[[
5721         ^ default: nil
5722         ^ itemstack will hold clicker's wielded item
5723         ^ Shall return the leftover itemstack
5724         ^ Note: pointed_thing can be nil, if a mod calls this function
5725         ^ This function does not get triggered by clients <=0.4.16 if the
5726         ^ "formspec" node metadata field is set ]]
5727
5728         on_dig = func(pos, node, digger), --[[
5729         ^ default: minetest.node_dig
5730         ^ By default: checks privileges, wears out tool and removes node ]]
5731
5732         on_timer = function(pos,elapsed), --[[
5733         ^ default: nil
5734         ^ called by NodeTimers, see minetest.get_node_timer and NodeTimerRef
5735         ^ elapsed is the total time passed since the timer was started
5736         ^ return true to run the timer for another cycle with the same timeout
5737         ^ value. ]]
5738
5739         on_receive_fields = func(pos, formname, fields, sender), --[[
5740         ^ fields = {name1 = value1, name2 = value2, ...}
5741         ^ Called when an UI form (e.g. sign text input) returns data
5742         ^ default: nil ]]
5743
5744         allow_metadata_inventory_move = func(pos, from_list, from_index, to_list, to_index, count, player),
5745         --[[
5746         ^ Called when a player wants to move items inside the inventory
5747         ^ Return value: number of items allowed to move ]]
5748
5749         allow_metadata_inventory_put = func(pos, listname, index, stack, player),
5750         --[[
5751         ^ Called when a player wants to put something into the inventory
5752         ^ Return value: number of items allowed to put
5753         ^ Return value: -1: Allow and don't modify item count in inventory ]]
5754
5755         allow_metadata_inventory_take = func(pos, listname, index, stack, player),
5756         --[[
5757         ^ Called when a player wants to take something out of the inventory
5758         ^ Return value: number of items allowed to take
5759         ^ Return value: -1: Allow and don't modify item count in inventory ]]
5760
5761         on_metadata_inventory_move = func(pos, from_list, from_index, to_list, to_index, count, player),
5762         on_metadata_inventory_put = func(pos, listname, index, stack, player),
5763         on_metadata_inventory_take = func(pos, listname, index, stack, player),
5764         --[[
5765         ^ Called after the actual action has happened, according to what was
5766         ^ allowed.
5767         ^ No return value ]]
5768
5769         on_blast = func(pos, intensity), --[[
5770         ^ intensity: 1.0 = mid range of regular TNT
5771         ^ If defined, called when an explosion touches the node, instead of
5772           removing the node ]]
5773     }
5774
5775 Recipe for `register_craft` (shaped)
5776 ------------------------------------
5777
5778     {
5779         output = 'default:pick_stone',
5780         recipe = {
5781             {'default:cobble', 'default:cobble', 'default:cobble'},
5782             {'', 'default:stick', ''},
5783             {'', 'default:stick', ''}, -- Also groups; e.g. 'group:crumbly'
5784         },
5785         replacements = --[[<optional list of item pairs,
5786                         replace one input item with another item on crafting>]]
5787     }
5788
5789 Recipe for `register_craft` (shapeless)
5790 ---------------------------------------
5791
5792     {
5793        type = "shapeless",
5794        output = 'mushrooms:mushroom_stew',
5795        recipe = {
5796            "mushrooms:bowl",
5797            "mushrooms:mushroom_brown",
5798            "mushrooms:mushroom_red",
5799        },
5800        replacements = --[[<optional list of item pairs,
5801                        replace one input item with another item on crafting>]]
5802    }
5803
5804 Recipe for `register_craft` (tool repair)
5805 -----------------------------------------
5806
5807     {
5808         type = "toolrepair",
5809         additional_wear = -0.02,
5810     }
5811
5812 Recipe for `register_craft` (cooking)
5813 -------------------------------------
5814
5815     {
5816         type = "cooking",
5817         output = "default:glass",
5818         recipe = "default:sand",
5819         cooktime = 3,
5820     }
5821
5822 Recipe for `register_craft` (furnace fuel)
5823 ------------------------------------------
5824
5825     {
5826         type = "fuel",
5827         recipe = "default:leaves",
5828         burntime = 1,
5829     }
5830
5831 Ore definition (`register_ore`)
5832 -------------------------------
5833
5834     See 'Ore types' section above for essential information.
5835
5836     {
5837         ore_type = "scatter",
5838         ore = "default:stone_with_coal",
5839         ore_param2 = 3,
5840     --  ^ Facedir rotation. Default is 0 (unchanged rotation)
5841         wherein = "default:stone",
5842     --  ^ a list of nodenames is supported too
5843         clust_scarcity = 8 * 8 * 8,
5844     --  ^ Ore has a 1 out of clust_scarcity chance of spawning in a node
5845     --  ^ If the desired average distance between ores is 'd', set this to
5846     --  ^ d * d * d.
5847         clust_num_ores = 8,
5848     --  ^ Number of ores in a cluster
5849         clust_size = 3,
5850     --  ^ Size of the bounding box of the cluster
5851     --  ^ In this example, there is a 3 * 3 * 3 cluster where 8 out of the 27
5852     --  ^ nodes are coal ore.
5853         y_min = -31000,
5854         y_max = 64,
5855     --  ^ Lower and upper limits for ore.
5856         flags = "",
5857     --  ^ Attributes for this ore generation, see 'Ore attributes' section
5858     --  ^ above.
5859         noise_threshold = 0.5,
5860     --  ^ If noise is above this threshold, ore is placed. Not needed for a
5861     --  ^ uniform distribution.
5862         noise_params = {
5863             offset = 0,
5864             scale = 1,
5865             spread = {x = 100, y = 100, z = 100},
5866             seed = 23,
5867             octaves = 3,
5868             persist = 0.7
5869         },
5870     --  ^ NoiseParams structure describing one of the perlin noises used for
5871     --  ^ ore distribution.
5872     --  ^ Needed by "sheet", "puff", "blob" and "vein" ores.
5873     --  ^ Omit from "scatter" ore for a uniform ore distribution.
5874     --  ^ Omit from "stratum ore for a simple horizontal strata from y_min to
5875     --  ^ y_max.
5876         biomes = {"desert", "rainforest"}
5877     --  ^ List of biomes in which this decoration occurs.
5878     --  ^ Occurs in all biomes if this is omitted, and ignored if the Mapgen
5879     --  ^ being used does not support biomes.
5880     --  ^ Can be a list of (or a single) biome names, IDs, or definitions.
5881         column_height_min = 1,
5882         column_height_max = 16,
5883         column_midpoint_factor = 0.5,
5884     --  ^ See 'Ore types' section above.
5885     --  ^ The above 3 parameters are only valid for "sheet" ore.
5886         np_puff_top = {
5887             offset = 4,
5888             scale = 2,
5889             spread = {x = 100, y = 100, z = 100},
5890             seed = 47,
5891             octaves = 3,
5892             persist = 0.7
5893         },
5894         np_puff_bottom = {
5895             offset = 4,
5896             scale = 2,
5897             spread = {x = 100, y = 100, z = 100},
5898             seed = 11,
5899             octaves = 3,
5900             persist = 0.7
5901         },
5902     --  ^ See 'Ore types' section above.
5903     --  ^ The above 2 parameters are only valid for "puff" ore.
5904         random_factor = 1.0,
5905     --  ^ See 'Ore types' section above.
5906     --  ^ Only valid for "vein" ore.
5907         np_stratum_thickness = {
5908             offset = 8,
5909             scale = 4,
5910             spread = {x = 100, y = 100, z = 100},
5911             seed = 17,
5912             octaves = 3,
5913             persist = 0.7
5914         },
5915         stratum_thickness = 8,
5916     --  ^ See 'Ore types' section above.
5917     --  ^ The above 2 parameters are only valid for "stratum" ore.
5918     }
5919
5920 Biome definition (`register_biome`)
5921 -----------------------------------
5922
5923     {
5924         name = "tundra",
5925         node_dust = "default:snow",
5926     --  ^ Node dropped onto upper surface after all else is generated.
5927         node_top = "default:dirt_with_snow",
5928         depth_top = 1,
5929     --  ^ Node forming surface layer of biome and thickness of this layer.
5930         node_filler = "default:permafrost",
5931         depth_filler = 3,
5932     --  ^ Node forming lower layer of biome and thickness of this layer.
5933         node_stone = "default:bluestone",
5934     --  ^ Node that replaces all stone nodes between roughly y_min and y_max.
5935         node_water_top = "default:ice",
5936         depth_water_top = 10,
5937     --  ^ Node forming a surface layer in seawater with the defined thickness.
5938         node_water = "",
5939     --  ^ Node that replaces all seawater nodes not in the defined surface
5940     --  ^ layer.
5941         node_river_water = "default:ice",
5942     --  ^ Node that replaces river water in mapgens that use
5943     --  ^ default:river_water.
5944         node_riverbed = "default:gravel",
5945         depth_riverbed = 2,
5946     --  ^ Node placed under river water and thickness of this layer.
5947         node_cave_liquid = "default:water_source",
5948     --  ^ Nodes placed as a blob of liquid in 50% of large caves.
5949     --  ^ If absent, cave liquids fall back to classic behaviour of lava or
5950     --  ^ water distributed according to a hardcoded 3D noise.
5951         node_dungeon = "default:cobble",
5952     --  ^ Node used for primary dungeon structure.
5953     --  ^ If absent, dungeon materials fall back to classic behaviour.
5954     --  ^ If present, the following two nodes are also used.
5955         node_dungeon_alt = "default:mossycobble",
5956     --  ^ Node used for randomly-distributed alternative structure nodes.
5957     --  ^ If alternative structure nodes are not wanted leave this absent for
5958     --  ^ performance reasons.
5959         node_dungeon_stair = "stairs:stair_cobble",
5960     --  ^ Node used for dungeon stairs.
5961     --  ^ If absent, stairs fall back to 'node_dungeon'.
5962         y_max = 31000,
5963         y_min = 1,
5964     --  ^ Upper and lower limits for biome.
5965     --  ^ Alternatively you can use xyz limits as shown below.
5966         max_pos = {x = 31000, y = 128, z = 31000},
5967         min_pos = {x = -31000, y = 9, z = -31000},
5968     --  ^ xyz limits for biome, an alternative to using 'y_min' and 'y_max'.
5969     --  ^ Biome is limited to a cuboid defined by these positions.
5970     --  ^ Any x, y or z field left undefined defaults to -31000 in 'min_pos' or
5971     --  ^ 31000 in 'max_pos'.
5972         vertical_blend = 8,
5973     --  ^ Vertical distance in nodes above 'y_max' over which the biome will
5974     --  ^ blend with the biome above.
5975     --  ^ Set to 0 for no vertical blend. Defaults to 0.
5976         heat_point = 0,
5977         humidity_point = 50,
5978     --  ^ Characteristic temperature and humidity for the biome.
5979     --  ^ These values create 'biome points' on a voronoi diagram with heat and
5980     --  ^ humidity as axes. The resulting voronoi cells determine the
5981     --  ^ distribution of the biomes.
5982     --  ^ Heat and humidity have average values of 50, vary mostly between
5983     --  ^ 0 and 100 but can exceed these values.
5984     }
5985
5986 Decoration definition (`register_decoration`)
5987 ---------------------------------------------
5988
5989     {
5990         deco_type = "simple", -- See "Decoration types"
5991         place_on = "default:dirt_with_grass",
5992     --  ^ Node (or list of nodes) that the decoration can be placed on
5993         sidelen = 8,
5994     --  ^ Size of the square divisions of the mapchunk being generated.
5995     --  ^ Determines the resolution of noise variation if used.
5996     --  ^ If the chunk size is not evenly divisible by sidelen, sidelen is made
5997     --  ^ equal to the chunk size.
5998         fill_ratio = 0.02,
5999     --  ^ The value determines 'decorations per surface node'.
6000     --  ^ Used only if noise_params is not specified.
6001     --  ^ If >= 10.0 complete coverage is enabled and decoration placement uses
6002     --  ^ a different and much faster method.
6003         noise_params = {
6004             offset = 0,
6005             scale = 0.45,
6006             spread = {x = 100, y = 100, z = 100},
6007             seed = 354,
6008             octaves = 3,
6009             persist = 0.7,
6010             lacunarity = 2.0,
6011             flags = "absvalue"
6012         },
6013     --  ^ NoiseParams structure describing the perlin noise used for decoration
6014     --  ^ distribution.
6015     --  ^ A noise value is calculated for each square division and determines
6016     --  ^ 'decorations per surface node' within each division.
6017     --  ^ If the noise value >= 10.0 complete coverage is enabled and decoration
6018     --  ^ placement uses a different and much faster method.
6019         biomes = {"Oceanside", "Hills", "Plains"},
6020     --  ^ List of biomes in which this decoration occurs. Occurs in all biomes
6021     --  ^ if this is omitted, and ignored if the Mapgen being used does not
6022     --  ^ support biomes.
6023     --  ^ Can be a list of (or a single) biome names, IDs, or definitions.
6024         y_min = -31000
6025         y_max = 31000
6026     --  ^ Lower and upper limits for decoration.
6027     --  ^ These parameters refer to the Y co-ordinate of the 'place_on' node.
6028         spawn_by = "default:water",
6029     --  ^ Node (or list of nodes) that the decoration only spawns next to.
6030     --  ^ Checks two horizontal planes of 8 neighbouring nodes (including
6031     --  ^ diagonal neighbours), one plane level with the 'place_on' node and a
6032     --  ^ plane one node above that.
6033         num_spawn_by = 1,
6034     --  ^ Number of spawn_by nodes that must be surrounding the decoration
6035     --  ^ position to occur.
6036     --  ^ If absent or -1, decorations occur next to any nodes.
6037         flags = "liquid_surface, force_placement, all_floors, all_ceilings",
6038     --  ^ Flags for all decoration types.
6039     --  ^ "liquid_surface": Instead of placement on the highest solid surface
6040     --  ^   in a mapchunk column, placement is on the highest liquid surface.
6041     --  ^   Placement is disabled if solid nodes are found above the liquid
6042     --  ^   surface.
6043     --  ^ "force_placement": Nodes other than "air" and "ignore" are replaced
6044     --  ^   by the decoration.
6045     --  ^ "all_floors", "all_ceilings": Instead of placement on the highest
6046     --  ^   surface in a mapchunk the decoration is placed on all floor and/or
6047     --  ^   ceiling surfaces, for example in caves and dungeons.
6048     --  ^   Ceiling decorations act as an inversion of floor decorations so the
6049     --  ^   effect of 'place_offset_y' is inverted.
6050     --  ^   Y-slice probabilities do not function correctly for ceiling
6051     --  ^   schematic decorations as the behaviour is unchanged.
6052     --  ^   If a single decoration registration has both flags the floor and
6053     --  ^   ceiling decorations will be aligned vertically.
6054
6055         ----- Simple-type parameters
6056         decoration = "default:grass",
6057     --  ^ The node name used as the decoration.
6058     --  ^ If instead a list of strings, a randomly selected node from the list
6059     --  ^ is placed as the decoration.
6060         height = 1,
6061     --  ^ Decoration height in nodes.
6062     --  ^ If height_max is not 0, this is the lower limit of a randomly
6063     --  ^ selected height.
6064         height_max = 0,
6065     --  ^ Upper limit of the randomly selected height.
6066     --  ^ If absent, the parameter 'height' is used as a constant.
6067         param2 = 0,
6068     --  ^ Param2 value of decoration nodes.
6069     --  ^ If param2_max is not 0, this is the lower limit of a randomly
6070     --  ^ selected param2.
6071         param2_max = 0,
6072     --  ^ Upper limit of the randomly selected param2.
6073     --  ^ If absent, the parameter 'param2' is used as a constant.
6074         place_offset_y = 0,
6075     --  ^ Y offset of the decoration base node relative to the standard base
6076     --  ^ node position.
6077     --  ^ Can be positive or negative. Default is 0.
6078     --  ^ Effect is inverted for "all_ceilings" decorations.
6079     --  ^ Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
6080     --  ^ to the 'place_on' node.
6081
6082         ----- Schematic-type parameters
6083         schematic = "foobar.mts",
6084     --  ^ If schematic is a string, it is the filepath relative to the current
6085     --  ^ working directory of the specified Minetest schematic file.
6086     --  ^  - OR -, could be the ID of a previously registered schematic
6087     --  ^  - OR -, could instead be a table containing two mandatory fields,
6088     --  ^ size and data, and an optional table yslice_prob:
6089         schematic = {
6090             size = {x = 4, y = 6, z = 4},
6091             data = {
6092                 {name = "default:cobble", param1 = 255, param2 = 0},
6093                 {name = "default:dirt_with_grass", param1 = 255, param2 = 0},
6094                 {name = "air", param1 = 255, param2 = 0},
6095                  ...
6096             },
6097             yslice_prob = {
6098                 {ypos = 2, prob = 128},
6099                 {ypos = 5, prob = 64},
6100                  ...
6101             },
6102         },
6103     --  ^ See 'Schematic specifier' for details.
6104         replacements = {["oldname"] = "convert_to", ...},
6105         flags = "place_center_x, place_center_y, place_center_z",
6106     --  ^ Flags for schematic decorations.  See 'Schematic attributes'.
6107         rotation = "90",
6108     --  ^ Rotation can be "0", "90", "180", "270", or "random".
6109         place_offset_y = 0,
6110     --  ^ If the flag 'place_center_y' is set this parameter is ignored.
6111     --  ^ Y offset of the schematic base node layer relative to the 'place_on'
6112     --  ^ node.
6113     --  ^ Can be positive or negative. Default is 0.
6114     --  ^ Effect is inverted for "all_ceilings" decorations.
6115     --  ^ Ignored by 'y_min', 'y_max' and 'spawn_by' checks, which always refer
6116     --  ^ to the 'place_on' node.
6117     }
6118
6119 Chat command definition (`register_chatcommand`)
6120 ------------------------------------------------
6121
6122     {
6123         params = "<name> <privilege>", -- Short parameter description
6124         description = "Remove privilege from player", -- Full description
6125         privs = {privs=true}, -- Require the "privs" privilege to run
6126         func = function(name, param), -- Called when command is run.
6127                                       -- Returns boolean success and text
6128                                       -- output.
6129     }
6130
6131 Note that in params, use of symbols is as follows:
6132
6133 * `<>` signifies a placeholder to be replaced when the command is used. For
6134   example, when a player name is needed: `<name>`
6135 * `[]` signifies param is optional and not required when the command is used.
6136   For example, if you require param1 but param2 is optional:
6137   `<param1> [<param2>]`
6138 * `|` signifies exclusive or. The command requires one param from the options
6139   provided. For example: `<param1> | <param2>`
6140 * `()` signifies grouping. For example, when param1 and param2 are both
6141   required, or only param3 is required: `(<param1> <param2>) | <param3>`
6142
6143 Detached inventory callbacks
6144 ----------------------------
6145
6146     {
6147         allow_move = func(inv, from_list, from_index, to_list, to_index, count, player),
6148     --  ^ Called when a player wants to move items inside the inventory
6149     --  ^ Return value: number of items allowed to move
6150
6151         allow_put = func(inv, listname, index, stack, player),
6152     --  ^ Called when a player wants to put something into the inventory
6153     --  ^ Return value: number of items allowed to put
6154     --  ^ Return value: -1: Allow and don't modify item count in inventory
6155
6156         allow_take = func(inv, listname, index, stack, player),
6157     --  ^ Called when a player wants to take something out of the inventory
6158     --  ^ Return value: number of items allowed to take
6159     --  ^ Return value: -1: Allow and don't modify item count in inventory
6160
6161         on_move = func(inv, from_list, from_index, to_list, to_index, count, player),
6162         on_put = func(inv, listname, index, stack, player),
6163         on_take = func(inv, listname, index, stack, player),
6164     --  ^ Called after the actual action has happened, according to what was
6165     --  ^ allowed.
6166     --  ^ No return value
6167     }
6168
6169 HUD Definition (`hud_add`, `hud_get`)
6170 -------------------------------------
6171
6172     {
6173         hud_elem_type = "image", -- see HUD element types
6174     --  ^ type of HUD element, can be either of "image", "text", "statbar",
6175           "inventory".
6176         position = {x=0.5, y=0.5},
6177     --  ^ Left corner position of element
6178         name = "<name>",
6179         scale = {x = 2, y = 2},
6180         text = "<text>",
6181         number = 2,
6182         item = 3,
6183     --  ^ Selected item in inventory.  0 for no item selected.
6184         direction = 0,
6185     --  ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
6186         alignment = {x=0, y=0},
6187     --  ^ See "HUD Element Types"
6188         offset = {x=0, y=0},
6189     --  ^ See "HUD Element Types"
6190         size = { x=100, y=100 },
6191     --  ^ Size of element in pixels
6192     }
6193
6194 Particle definition (`add_particle`)
6195 ------------------------------------
6196
6197     {
6198         pos = {x=0, y=0, z=0},
6199         velocity = {x=0, y=0, z=0},
6200         acceleration = {x=0, y=0, z=0},
6201     --  ^ Spawn particle at pos with velocity and acceleration
6202         expirationtime = 1,
6203     --  ^ Disappears after expirationtime seconds
6204         size = 1,
6205         collisiondetection = false,
6206     --  ^ collisiondetection: if true collides with physical objects
6207         collision_removal = false,
6208     --  ^ collision_removal: if true then particle is removed when it collides,
6209     --  ^ requires collisiondetection = true to have any effect
6210         vertical = false,
6211     --  ^ vertical: if true faces player using y axis only
6212         texture = "image.png",
6213     --  ^ Uses texture (string)
6214         playername = "singleplayer",
6215     --  ^ Optional, if specified spawns particle only on the player's client
6216         animation = {Tile Animation definition},
6217     --  ^ Optional, specifies how to animate the particle texture
6218         glow = 0
6219     --  ^ Optional, specify particle self-luminescence in darkness.
6220     --  ^ Values 0-14.
6221     }
6222
6223
6224 `ParticleSpawner` definition (`add_particlespawner`)
6225 ----------------------------------------------------
6226
6227     {
6228         amount = 1,
6229         time = 1,
6230     --  ^ If time is 0 has infinite lifespan and spawns the amount on a
6231     --  ^ per-second basis.
6232         minpos = {x=0, y=0, z=0},
6233         maxpos = {x=0, y=0, z=0},
6234         minvel = {x=0, y=0, z=0},
6235         maxvel = {x=0, y=0, z=0},
6236         minacc = {x=0, y=0, z=0},
6237         maxacc = {x=0, y=0, z=0},
6238         minexptime = 1,
6239         maxexptime = 1,
6240         minsize = 1,
6241         maxsize = 1,
6242     --  ^ The particle's properties are random values in between the bounds:
6243     --  ^ minpos/maxpos, minvel/maxvel (velocity),
6244     --  ^ minacc/maxacc (acceleration), minsize/maxsize,
6245     --  ^ minexptime/maxexptime (expirationtime).
6246         collisiondetection = false,
6247     --  ^ collisiondetection: if true uses collision detection
6248         collision_removal = false,
6249     --  ^ collision_removal: if true then particle is removed when it collides,
6250     --  ^ requires collisiondetection = true to have any effect
6251         attached = ObjectRef,
6252     --  ^ attached: if defined, particle positions, velocities and
6253     --  ^ accelerations are relative to this object's position and yaw.
6254         vertical = false,
6255     --  ^ vertical: if true faces player using y axis only
6256         texture = "image.png",
6257     --  ^ Uses texture (string)
6258         playername = "singleplayer"
6259     --  ^ Playername is optional, if specified spawns particle only on the
6260     --  ^ player's client.
6261         animation = {Tile Animation definition},
6262     --  ^ Optional, specifies how to animate the particle texture
6263         glow = 0
6264     --  ^ Optional, specify particle self-luminescence in darkness.
6265     --  ^ Values 0-14.
6266     }
6267
6268 `HTTPRequest` definition (`HTTPApiTable.fetch_async`, `HTTPApiTable.fetch_async`)
6269 ---------------------------------------------------------------------------------
6270
6271     {
6272         url = "http://example.org",
6273         timeout = 10,
6274     --  ^ Timeout for connection in seconds. Default is 3 seconds.
6275         post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
6276     --  ^ Optional, if specified a POST request with post_data is performed.
6277     --  ^ Accepts both a string and a table. If a table is specified, encodes
6278     --  ^ table as x-www-form-urlencoded key-value pairs.
6279     --  ^ If post_data ist not specified, a GET request is performed instead.
6280         user_agent = "ExampleUserAgent",
6281     --  ^ Optional, if specified replaces the default minetest user agent with
6282     --  ^ given string.
6283         extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
6284     --  ^ Optional, if specified adds additional headers to the HTTP request.
6285     --  ^ You must make sure that the header strings follow HTTP specification
6286     --  ^ ("Key: Value").
6287         multipart = boolean
6288     --  ^ Optional, if true performs a multipart HTTP request.
6289     --  ^ Default is false.
6290     }
6291
6292 `HTTPRequestResult` definition (`HTTPApiTable.fetch` callback, `HTTPApiTable.fetch_async_get`)
6293 ----------------------------------------------------------------------------------------------
6294
6295     {
6296         completed = true,
6297     --  ^ If true, the request has finished (either succeeded, failed or timed
6298           out).
6299         succeeded = true,
6300     --  ^ If true, the request was successful
6301         timeout = false,
6302     --  ^ If true, the request timed out
6303         code = 200,
6304     --  ^ HTTP status code
6305         data = "response"
6306     }
6307
6308 Authentication handler definition
6309 ---------------------------------
6310
6311     {
6312         get_auth = func(name),
6313     --  ^ Get authentication data for existing player `name` (`nil` if player
6314           doesn't exist).
6315     --  ^ returns following structure:
6316     --  ^ `{password=<string>, privileges=<table>, last_login=<number or nil>}`
6317         create_auth = func(name, password),
6318     --  ^ Create new auth data for player `name`
6319     --  ^ Note that `password` is not plain-text but an arbitrary
6320     --  ^ representation decided by the engine
6321         delete_auth = func(name),
6322     --  ^ Delete auth data of player `name`, returns boolean indicating success
6323     --  ^ (false if player nonexistant).
6324         set_password = func(name, password),
6325     --  ^ Set password of player `name` to `password`
6326            Auth data should be created if not present
6327         set_privileges = func(name, privileges),
6328     --  ^ Set privileges of player `name`
6329     --  ^ `privileges` is in table form, auth data should be created if not
6330     --  ^ present.
6331         reload = func(),
6332     --  ^ Reload authentication data from the storage location
6333     --  ^ Returns boolean indicating success
6334         record_login = func(name),
6335     --  ^ Called when player joins, used for keeping track of last_login
6336         iterate = func(),
6337     --  ^ Returns an iterator (use with `for` loops) for all player names
6338     --  ^ currently in the auth database.
6339     }