]> git.lizzy.rs Git - dragonfireclient.git/blob - doc/client_lua_api.txt
Merge branch 'master' of https://github.com/EliasFleckenstein03/dragonfireclient
[dragonfireclient.git] / doc / client_lua_api.txt
1 Minetest Lua Client Modding API Reference 5.4.0
2 ================================================
3 * More information at <http://www.minetest.net/>
4 * Developer Wiki: <http://dev.minetest.net/>
5
6 Introduction
7 ------------
8
9 ** WARNING: The client API is currently unstable, and may break/change without warning. **
10
11 Content and functionality can be added to Minetest 0.4.15-dev+ by using Lua
12 scripting in run-time loaded mods.
13
14 A mod is a self-contained bunch of scripts, textures and other related
15 things that is loaded by and interfaces with Minetest.
16
17 Transferring client-sided mods from the server to the client is planned, but not implemented yet.
18
19 If you see a deficiency in the API, feel free to attempt to add the
20 functionality in the engine and API. You can send such improvements as
21 source code patches on GitHub (https://github.com/minetest/minetest).
22
23 Programming in Lua
24 ------------------
25 If you have any difficulty in understanding this, please read
26 [Programming in Lua](http://www.lua.org/pil/).
27
28 Startup
29 -------
30 Mods are loaded during client startup from the mod load paths by running
31 the `init.lua` scripts in a shared environment.
32
33 In order to load client-side mods, the following conditions need to be satisfied:
34
35 1) `$path_user/minetest.conf` contains the setting `enable_client_modding = true`
36
37 2) The client-side mod located in `$path_user/clientmods/<modname>` is added to
38     `$path_user/clientmods/mods.conf` as `load_mod_<modname> = true`.
39
40 Note: Depending on the remote server's settings, client-side mods might not
41 be loaded or have limited functionality. See setting `csm_restriction_flags` for reference.
42
43 Paths
44 -----
45 * `RUN_IN_PLACE=1` (Windows release, local build)
46     * `$path_user`: `<build directory>`
47     * `$path_share`: `<build directory>`
48 * `RUN_IN_PLACE=0`: (Linux release)
49     * `$path_share`:
50         * Linux: `/usr/share/minetest`
51         * Windows: `<install directory>/minetest-0.4.x`
52     * `$path_user`:
53         * Linux: `$HOME/.minetest`
54         * Windows: `C:/users/<user>/AppData/minetest` (maybe)
55
56 Mod load path
57 -------------
58 Generic:
59
60 * `$path_share/clientmods/`
61 * `$path_user/clientmods/` (User-installed mods)
62
63 In a run-in-place version (e.g. the distributed windows version):
64
65 * `minetest-0.4.x/clientmods/` (User-installed mods)
66
67 On an installed version on Linux:
68
69 * `/usr/share/minetest/clientmods/`
70 * `$HOME/.minetest/clientmods/` (User-installed mods)
71
72 Modpack support
73 ----------------
74
75 Mods can be put in a subdirectory, if the parent directory, which otherwise
76 should be a mod, contains a file named `modpack.conf`.
77 The file is a key-value store of modpack details.
78
79 * `name`: The modpack name.
80 * `description`: Description of mod to be shown in the Mods tab of the main
81                  menu.
82
83 Mod directory structure
84 ------------------------
85
86     clientmods
87     ├── modname
88     │   ├── mod.conf
89     |   ├── settingtypes.txt
90     │   ├── init.lua
91     └── another
92
93 ### `settingtypes.txt`
94
95 The format is documented in `builtin/settingtypes.txt`.
96 It is parsed by the main menu settings dialogue to list mod-specific
97 settings in the "Clientmods" category.    
98
99 ### modname
100
101 The location of this directory.
102
103 ### mod.conf
104
105 An (optional) settings file that provides meta information about the mod.
106
107 * `name`: The mod name. Allows Minetest to determine the mod name even if the
108           folder is wrongly named.
109 * `description`: Description of mod to be shown in the Mods tab of the main
110                  menu.
111 * `depends`: A comma separated list of dependencies. These are mods that must be
112              loaded before this mod.
113 * `optional_depends`: A comma separated list of optional dependencies.
114                       Like a dependency, but no error if the mod doesn't exist.
115
116 ### `init.lua`
117
118 The main Lua script. Running this script should register everything it
119 wants to register. Subsequent execution depends on minetest calling the
120 registered callbacks.
121
122 **NOTE**: Client mods currently can't provide textures, sounds, or models by
123 themselves. Any media referenced in function calls must already be loaded
124 (provided by mods that exist on the server).
125
126 Naming convention for registered textual names
127 ----------------------------------------------
128 Registered names should generally be in this format:
129
130     "modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
131
132 This is to prevent conflicting names from corrupting maps and is
133 enforced by the mod loader.
134
135 ### Example
136 In the mod `experimental`, there is the ideal item/node/entity name `tnt`.
137 So the name should be `experimental:tnt`.
138
139 Enforcement can be overridden by prefixing the name with `:`. This can
140 be used for overriding the registrations of some other mod.
141
142 Example: Any mod can redefine `experimental:tnt` by using the name
143
144     :experimental:tnt
145
146 when registering it.
147 (also that mod is required to have `experimental` as a dependency)
148
149 The `:` prefix can also be used for maintaining backwards compatibility.
150
151 Sounds
152 ------
153 **NOTE: Connecting sounds to objects is not implemented.**
154
155 Only Ogg Vorbis files are supported.
156
157 For positional playing of sounds, only single-channel (mono) files are
158 supported. Otherwise OpenAL will play them non-positionally.
159
160 Mods should generally prefix their sounds with `modname_`, e.g. given
161 the mod name "`foomod`", a sound could be called:
162
163     foomod_foosound.ogg
164
165 Sounds are referred to by their name with a dot, a single digit and the
166 file extension stripped out. When a sound is played, the actual sound file
167 is chosen randomly from the matching sounds.
168
169 When playing the sound `foomod_foosound`, the sound is chosen randomly
170 from the available ones of the following files:
171
172 * `foomod_foosound.ogg`
173 * `foomod_foosound.0.ogg`
174 * `foomod_foosound.1.ogg`
175 * (...)
176 * `foomod_foosound.9.ogg`
177
178 Examples of sound parameter tables:
179
180     -- Play locationless
181     {
182         gain = 1.0, -- default
183     }
184     -- Play locationless, looped
185     {
186         gain = 1.0, -- default
187         loop = true,
188     }
189     -- Play in a location
190     {
191         pos = {x = 1, y = 2, z = 3},
192         gain = 1.0, -- default
193     }
194     -- Play connected to an object, looped
195     {
196         object = <an ObjectRef>,
197         gain = 1.0, -- default
198         loop = true,
199     }
200
201 Looped sounds must either be connected to an object or played locationless.
202
203 ### SimpleSoundSpec
204 * e.g. `""`
205 * e.g. `"default_place_node"`
206 * e.g. `{}`
207 * e.g. `{name = "default_place_node"}`
208 * e.g. `{name = "default_place_node", gain = 1.0}`
209
210 Representations of simple things
211 --------------------------------
212
213 ### Position/vector
214
215     {x=num, y=num, z=num}
216
217 For helper functions see "Vector helpers".
218
219 ### pointed_thing
220 * `{type="nothing"}`
221 * `{type="node", under=pos, above=pos}`
222 * `{type="object", ref=ClientObjectRef}`
223
224 Flag Specifier Format
225 ---------------------
226 Flags using the standardized flag specifier format can be specified in either of
227 two ways, by string or table.
228
229 The string format is a comma-delimited set of flag names; whitespace and
230 unrecognized flag fields are ignored. Specifying a flag in the string sets the
231 flag, and specifying a flag prefixed by the string `"no"` explicitly
232 clears the flag from whatever the default may be.
233
234 In addition to the standard string flag format, the schematic flags field can
235 also be a table of flag names to boolean values representing whether or not the
236 flag is set. Additionally, if a field with the flag name prefixed with `"no"`
237 is present, mapped to a boolean of any value, the specified flag is unset.
238
239 E.g. A flag field of value
240
241     {place_center_x = true, place_center_y=false, place_center_z=true}
242
243 is equivalent to
244
245     {place_center_x = true, noplace_center_y=true, place_center_z=true}
246
247 which is equivalent to
248
249     "place_center_x, noplace_center_y, place_center_z"
250
251 or even
252
253     "place_center_x, place_center_z"
254
255 since, by default, no schematic attributes are set.
256
257 Formspec
258 --------
259 Formspec defines a menu. It is a string, with a somewhat strange format.
260
261 Spaces and newlines can be inserted between the blocks, as is used in the
262 examples.
263
264 ### Examples
265
266 #### Chest
267
268     size[8,9]
269     list[context;main;0,0;8,4;]
270     list[current_player;main;0,5;8,4;]
271
272 #### Furnace
273
274     size[8,9]
275     list[context;fuel;2,3;1,1;]
276     list[context;src;2,1;1,1;]
277     list[context;dst;5,1;2,2;]
278     list[current_player;main;0,5;8,4;]
279
280 #### Minecraft-like player inventory
281
282     size[8,7.5]
283     image[1,0.6;1,2;player.png]
284     list[current_player;main;0,3.5;8,4;]
285     list[current_player;craft;3,0;3,3;]
286     list[current_player;craftpreview;7,1;1,1;]
287
288 ### Elements
289
290 #### `size[<W>,<H>,<fixed_size>]`
291 * Define the size of the menu in inventory slots
292 * `fixed_size`: `true`/`false` (optional)
293 * deprecated: `invsize[<W>,<H>;]`
294
295 #### `container[<X>,<Y>]`
296 * Start of a container block, moves all physical elements in the container by (X, Y)
297 * Must have matching container_end
298 * Containers can be nested, in which case the offsets are added
299   (child containers are relative to parent containers)
300
301 #### `container_end[]`
302 * End of a container, following elements are no longer relative to this container
303
304 #### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]`
305 * Show an inventory list
306
307 #### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
308 * Show an inventory list
309
310 #### `listring[<inventory location>;<list name>]`
311 * Allows to create a ring of inventory lists
312 * Shift-clicking on items in one element of the ring
313   will send them to the next inventory list inside the ring
314 * The first occurrence of an element inside the ring will
315   determine the inventory where items will be sent to
316
317 #### `listring[]`
318 * Shorthand for doing `listring[<inventory location>;<list name>]`
319   for the last two inventory lists added by list[...]
320
321 #### `listcolors[<slot_bg_normal>;<slot_bg_hover>]`
322 * Sets background color of slots as `ColorString`
323 * Sets background color of slots on mouse hovering
324
325 #### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]`
326 * Sets background color of slots as `ColorString`
327 * Sets background color of slots on mouse hovering
328 * Sets color of slots border
329
330 #### `listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]`
331 * Sets background color of slots as `ColorString`
332 * Sets background color of slots on mouse hovering
333 * Sets color of slots border
334 * Sets default background color of tooltips
335 * Sets default font color of tooltips
336
337 #### `tooltip[<gui_element_name>;<tooltip_text>;<bgcolor>,<fontcolor>]`
338 * Adds tooltip for an element
339 * `<bgcolor>` tooltip background color as `ColorString` (optional)
340 * `<fontcolor>` tooltip font color as `ColorString` (optional)
341
342 #### `image[<X>,<Y>;<W>,<H>;<texture name>]`
343 * Show an image
344 * Position and size units are inventory slots
345
346 #### `item_image[<X>,<Y>;<W>,<H>;<item name>]`
347 * Show an inventory image of registered item/node
348 * Position and size units are inventory slots
349
350 #### `bgcolor[<color>;<fullscreen>]`
351 * Sets background color of formspec as `ColorString`
352 * If `true`, the background color is drawn fullscreen (does not effect the size of the formspec)
353
354 #### `background[<X>,<Y>;<W>,<H>;<texture name>]`
355 * Use a background. Inventory rectangles are not drawn then.
356 * Position and size units are inventory slots
357 * Example for formspec 8x4 in 16x resolution: image shall be sized
358   8 times 16px  times  4 times 16px.
359
360 #### `background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]`
361 * Use a background. Inventory rectangles are not drawn then.
362 * Position and size units are inventory slots
363 * Example for formspec 8x4 in 16x resolution:
364   image shall be sized 8 times 16px  times  4 times 16px
365 * If `true` the background is clipped to formspec size
366   (`x` and `y` are used as offset values, `w` and `h` are ignored)
367
368 #### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
369 * Textual password style field; will be sent to server when a button is clicked
370 * When enter is pressed in field, fields.key_enter_field will be sent with the name
371   of this field.
372 * `x` and `y` position the field relative to the top left of the menu
373 * `w` and `h` are the size of the field
374 * Fields are a set height, but will be vertically centred on `h`
375 * Position and size units are inventory slots
376 * `name` is the name of the field as returned in fields to `on_receive_fields`
377 * `label`, if not blank, will be text printed on the top left above the field
378 * See field_close_on_enter to stop enter closing the formspec
379
380 #### `field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
381 * Textual field; will be sent to server when a button is clicked
382 * When enter is pressed in field, fields.key_enter_field will be sent with the name
383   of this field.
384 * `x` and `y` position the field relative to the top left of the menu
385 * `w` and `h` are the size of the field
386 * Fields are a set height, but will be vertically centred on `h`
387 * Position and size units are inventory slots
388 * `name` is the name of the field as returned in fields to `on_receive_fields`
389 * `label`, if not blank, will be text printed on the top left above the field
390 * `default` is the default value of the field
391     * `default` may contain variable references such as `${text}'` which
392       will fill the value from the metadata value `text`
393     * **Note**: no extra text or more than a single variable is supported ATM.
394 * See field_close_on_enter to stop enter closing the formspec
395
396 #### `field[<name>;<label>;<default>]`
397 * As above, but without position/size units
398 * When enter is pressed in field, fields.key_enter_field will be sent with the name
399   of this field.
400 * Special field for creating simple forms, such as sign text input
401 * Must be used without a `size[]` element
402 * A "Proceed" button will be added automatically
403 * See field_close_on_enter to stop enter closing the formspec
404
405 #### `field_close_on_enter[<name>;<close_on_enter>]`
406 * <name> is the name of the field
407 * if <close_on_enter> is false, pressing enter in the field will submit the form but not close it
408 * defaults to true when not specified (ie: no tag for a field)
409
410 #### `textarea[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]`
411 * Same as fields above, but with multi-line input
412
413 #### `label[<X>,<Y>;<label>]`
414 * `x` and `y` work as per field
415 * `label` is the text on the label
416 * Position and size units are inventory slots
417
418 #### `vertlabel[<X>,<Y>;<label>]`
419 * Textual label drawn vertically
420 * `x` and `y` work as per field
421 * `label` is the text on the label
422 * Position and size units are inventory slots
423
424 #### `button[<X>,<Y>;<W>,<H>;<name>;<label>]`
425 * Clickable button. When clicked, fields will be sent.
426 * `x`, `y` and `name` work as per field
427 * `w` and `h` are the size of the button
428 * Fixed button height. It will be vertically centred on `h`
429 * `label` is the text on the button
430 * Position and size units are inventory slots
431
432 #### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
433 * `x`, `y`, `w`, `h`, and `name` work as per button
434 * `texture name` is the filename of an image
435 * Position and size units are inventory slots
436
437 #### `image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
438 * `x`, `y`, `w`, `h`, and `name` work as per button
439 * `texture name` is the filename of an image
440 * Position and size units are inventory slots
441 * `noclip=true` means the image button doesn't need to be within specified formsize
442 * `drawborder`: draw button border or not
443 * `pressed texture name` is the filename of an image on pressed state
444
445 #### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
446 * `x`, `y`, `w`, `h`, `name` and `label` work as per button
447 * `item name` is the registered name of an item/node,
448    tooltip will be made out of its description
449    to override it use tooltip element
450 * Position and size units are inventory slots
451
452 #### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
453 * When clicked, fields will be sent and the form will quit.
454
455 #### `image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]`
456 * When clicked, fields will be sent and the form will quit.
457
458 #### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]`
459 * Scrollable item list showing arbitrary text elements
460 * `x` and `y` position the itemlist relative to the top left of the menu
461 * `w` and `h` are the size of the itemlist
462 * `name` fieldname sent to server on doubleclick value is current selected element
463 * `listelements` can be prepended by #color in hexadecimal format RRGGBB (only),
464      * if you want a listelement to start with "#" write "##".
465
466 #### `textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]`
467 * Scrollable itemlist showing arbitrary text elements
468 * `x` and `y` position the item list relative to the top left of the menu
469 * `w` and `h` are the size of the item list
470 * `name` fieldname sent to server on doubleclick value is current selected element
471 * `listelements` can be prepended by #RRGGBB (only) in hexadecimal format
472      * if you want a listelement to start with "#" write "##"
473 * Index to be selected within textlist
474 * `true`/`false`: draw transparent background
475 * See also `minetest.explode_textlist_event` (main menu: `engine.explode_textlist_event`)
476
477 #### `tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]`
478 * Show a tab**header** at specific position (ignores formsize)
479 * `x` and `y` position the itemlist relative to the top left of the menu
480 * `name` fieldname data is transferred to Lua
481 * `caption 1`...: name shown on top of tab
482 * `current_tab`: index of selected tab 1...
483 * `transparent` (optional): show transparent
484 * `draw_border` (optional): draw border
485
486 #### `box[<X>,<Y>;<W>,<H>;<color>]`
487 * Simple colored semitransparent box
488 * `x` and `y` position the box relative to the top left of the menu
489 * `w` and `h` are the size of box
490 * `color` is color specified as a `ColorString`
491
492 #### `dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]`
493 * Show a dropdown field
494 * **Important note**: There are two different operation modes:
495      1. handle directly on change (only changed dropdown is submitted)
496      2. read the value on pressing a button (all dropdown values are available)
497 * `x` and `y` position of dropdown
498 * Width of dropdown
499 * Fieldname data is transferred to Lua
500 * Items to be shown in dropdown
501 * Index of currently selected dropdown item
502
503 #### `checkbox[<X>,<Y>;<name>;<label>;<selected>]`
504 * Show a checkbox
505 * `x` and `y`: position of checkbox
506 * `name` fieldname data is transferred to Lua
507 * `label` to be shown left of checkbox
508 * `selected` (optional): `true`/`false`
509
510 #### `scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]`
511 * Show a scrollbar
512 * There are two ways to use it:
513      1. handle the changed event (only changed scrollbar is available)
514      2. read the value on pressing a button (all scrollbars are available)
515 * `x` and `y`: position of trackbar
516 * `w` and `h`: width and height
517 * `orientation`:  `vertical`/`horizontal`
518 * Fieldname data is transferred to Lua
519 * Value this trackbar is set to (`0`-`1000`)
520 * See also `minetest.explode_scrollbar_event` (main menu: `engine.explode_scrollbar_event`)
521
522 #### `table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]`
523 * Show scrollable table using options defined by the previous `tableoptions[]`
524 * Displays cells as defined by the previous `tablecolumns[]`
525 * `x` and `y`: position the itemlist relative to the top left of the menu
526 * `w` and `h` are the size of the itemlist
527 * `name`: fieldname sent to server on row select or doubleclick
528 * `cell 1`...`cell n`: cell contents given in row-major order
529 * `selected idx`: index of row to be selected within table (first row = `1`)
530 * See also `minetest.explode_table_event` (main menu: `engine.explode_table_event`)
531
532 #### `tableoptions[<opt 1>;<opt 2>;...]`
533 * Sets options for `table[]`
534 * `color=#RRGGBB`
535      * default text color (`ColorString`), defaults to `#FFFFFF`
536 * `background=#RRGGBB`
537      * table background color (`ColorString`), defaults to `#000000`
538 * `border=<true/false>`
539      * should the table be drawn with a border? (default: `true`)
540 * `highlight=#RRGGBB`
541      * highlight background color (`ColorString`), defaults to `#466432`
542 * `highlight_text=#RRGGBB`
543      * highlight text color (`ColorString`), defaults to `#FFFFFF`
544 * `opendepth=<value>`
545      * all subtrees up to `depth < value` are open (default value = `0`)
546      * only useful when there is a column of type "tree"
547
548 #### `tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]`
549 * Sets columns for `table[]`
550 * Types: `text`, `image`, `color`, `indent`, `tree`
551     * `text`:   show cell contents as text
552     * `image`:  cell contents are an image index, use column options to define images
553     * `color`:   cell contents are a ColorString and define color of following cell
554     * `indent`: cell contents are a number and define indentation of following cell
555     * `tree`:   same as indent, but user can open and close subtrees (treeview-like)
556 * Column options:
557     * `align=<value>`
558         * for `text` and `image`: content alignment within cells.
559           Available values: `left` (default), `center`, `right`, `inline`
560     * `width=<value>`
561         * for `text` and `image`: minimum width in em (default: `0`)
562         * for `indent` and `tree`: indent width in em (default: `1.5`)
563     * `padding=<value>`: padding left of the column, in em (default `0.5`).
564       Exception: defaults to 0 for indent columns
565     * `tooltip=<value>`: tooltip text (default: empty)
566     * `image` column options:
567         * `0=<value>` sets image for image index 0
568         * `1=<value>` sets image for image index 1
569         * `2=<value>` sets image for image index 2
570         * and so on; defined indices need not be contiguous empty or
571           non-numeric cells are treated as `0`.
572     * `color` column options:
573         * `span=<value>`: number of following columns to affect (default: infinite)
574
575 **Note**: do _not_ use a element name starting with `key_`; those names are reserved to
576 pass key press events to formspec!
577
578 Spatial Vectors
579 ---------------
580 * `vector.new(a[, b, c])`: returns a vector:
581     * A copy of `a` if `a` is a vector.
582     * `{x = a, y = b, z = c}`, if all `a, b, c` are defined
583 * `vector.direction(p1, p2)`: returns a vector
584 * `vector.distance(p1, p2)`: returns a number
585 * `vector.length(v)`: returns a number
586 * `vector.normalize(v)`: returns a vector
587 * `vector.floor(v)`: returns a vector, each dimension rounded down
588 * `vector.round(v)`: returns a vector, each dimension rounded to nearest int
589 * `vector.apply(v, func)`: returns a vector
590 * `vector.equals(v1, v2)`: returns a boolean
591
592 For the following functions `x` can be either a vector or a number:
593
594 * `vector.add(v, x)`: returns a vector
595 * `vector.subtract(v, x)`: returns a vector
596 * `vector.multiply(v, x)`: returns a scaled vector or Schur product
597 * `vector.divide(v, x)`: returns a scaled vector or Schur quotient
598
599 Helper functions
600 ----------------
601 * `dump2(obj, name="_", dumped={})`
602      * Return object serialized as a string, handles reference loops
603 * `dump(obj, dumped={})`
604     * Return object serialized as a string
605 * `math.hypot(x, y)`
606     * Get the hypotenuse of a triangle with legs x and y.
607       Useful for distance calculation.
608 * `math.sign(x, tolerance)`
609     * Get the sign of a number.
610       Optional: Also returns `0` when the absolute value is within the tolerance (default: `0`)
611 * `string.split(str, separator=",", include_empty=false, max_splits=-1, sep_is_pattern=false)`
612     * If `max_splits` is negative, do not limit splits.
613     * `sep_is_pattern` specifies if separator is a plain string or a pattern (regex).
614     * e.g. `string:split("a,b", ",") == {"a","b"}`
615 * `string:trim()`
616     * e.g. `string.trim("\n \t\tfoo bar\t ") == "foo bar"`
617 * `minetest.wrap_text(str, limit)`: returns a string
618     * Adds new lines to the string to keep it within the specified character limit
619     * limit: Maximal amount of characters in one line
620 * `minetest.pos_to_string({x=X,y=Y,z=Z}, decimal_places))`: returns string `"(X,Y,Z)"`
621     * Convert position to a printable string
622       Optional: 'decimal_places' will round the x, y and z of the pos to the given decimal place.
623 * `minetest.string_to_pos(string)`: returns a position
624     * Same but in reverse. Returns `nil` if the string can't be parsed to a position.
625 * `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")`: returns two positions
626     * Converts a string representing an area box into two positions
627 * `minetest.is_yes(arg)`
628     * returns whether `arg` can be interpreted as yes
629 * `minetest.is_nan(arg)`
630     * returns true when the passed number represents NaN.
631 * `table.copy(table)`: returns a table
632     * returns a deep copy of `table`
633
634 Minetest namespace reference
635 ------------------------------
636
637 ### Utilities
638
639 * `minetest.get_current_modname()`: returns the currently loading mod's name, when we are loading a mod
640 * `minetest.get_modpath(modname)`: returns virtual path of given mod including
641    the trailing separator. This is useful to load additional Lua files
642    contained in your mod:
643    e.g. `dofile(minetest.get_modpath(minetest.get_current_modname()) .. "stuff.lua")`
644 * `minetest.get_language()`: returns two strings
645    * the current gettext locale
646    * the current language code (the same as used for client-side translations)
647 * `minetest.get_version()`: returns a table containing components of the
648    engine version.  Components:
649     * `project`: Name of the project, eg, "Minetest"
650     * `string`: Simple version, eg, "1.2.3-dev"
651     * `hash`: Full git version (only set if available), eg, "1.2.3-dev-01234567-dirty"
652   Use this for informational purposes only. The information in the returned
653   table does not represent the capabilities of the engine, nor is it
654   reliable or verifiable. Compatible forks will have a different name and
655   version entirely. To check for the presence of engine features, test
656   whether the functions exported by the wanted features exist. For example:
657   `if minetest.check_for_falling then ... end`.
658 * `minetest.sha1(data, [raw])`: returns the sha1 hash of data
659     * `data`: string of data to hash
660     * `raw`: return raw bytes instead of hex digits, default: false
661 * `minetest.get_csm_restrictions()`: returns a table of `Flags` indicating the
662    restrictions applied to the current mod.
663    * If a flag in this table is set to true, the feature is RESTRICTED.
664    * Possible flags: `load_client_mods`, `chat_messages`, `read_itemdefs`,
665                    `read_nodedefs`, `lookup_nodes`, `read_playerinfo`
666
667 ### Logging
668 * `minetest.debug(...)`
669     * Equivalent to `minetest.log(table.concat({...}, "\t"))`
670 * `minetest.log([level,] text)`
671     * `level` is one of `"none"`, `"error"`, `"warning"`, `"action"`,
672       `"info"`, or `"verbose"`.  Default is `"none"`.
673
674 ### Global callback registration functions
675 Call these functions only at load time!
676
677 * `minetest.open_enderchest()`
678     * This function is called if the client uses the Keybind for it (by default "O")
679     * You can override it
680 * `minetest.register_globalstep(function(dtime))`
681     * Called every client environment step, usually interval of 0.1s
682 * `minetest.register_on_mods_loaded(function())`
683     * Called just after mods have finished loading.
684 * `minetest.register_on_shutdown(function())`
685     * Called before client shutdown
686     * **Warning**: If the client terminates abnormally (i.e. crashes), the registered
687       callbacks **will likely not be run**. Data should be saved at
688       semi-frequent intervals as well as on server shutdown.
689 * `minetest.register_on_receiving_chat_message(function(message))`
690     * Called always when a client receive a message
691     * Return `true` to mark the message as handled, which means that it will not be shown to chat
692 * `minetest.register_on_sending_chat_message(function(message))`
693     * Called always when a client send a message from chat
694     * Return `true` to mark the message as handled, which means that it will not be sent to server
695 * `minetest.register_chatcommand(cmd, chatcommand definition)`
696     * Adds definition to minetest.registered_chatcommands
697 * `minetest.unregister_chatcommand(name)`
698     * Unregisters a chatcommands registered with register_chatcommand.
699 * `minetest.register_list_command(command, desc, setting)`
700     * Registers a chatcommand `command` to manage a list that takes the args `del | add | list <param>`
701     * The list is stored comma-seperated in `setting`
702     * `desc` is the description
703     * `add` adds something to the list 
704     * `del` del removes something from the list
705     * `list` lists all items on the list
706 * `minetest.register_on_chatcommand(function(command, params))`
707     * Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
708       is checked to see if that the command exists, but after the input is parsed.
709     * Return `true` to mark the command as handled, which means that the default
710       handlers will be prevented.
711 * `minetest.register_on_death(function())`
712     * Called when the local player dies
713 * `minetest.register_on_hp_modification(function(hp))`
714     * Called when server modified player's HP
715 * `minetest.register_on_damage_taken(function(hp))`
716     * Called when the local player take damages
717 * `minetest.register_on_formspec_input(function(formname, fields))`
718     * Called when a button is pressed in the local player's inventory form
719     * Newest functions are called first
720     * If function returns `true`, remaining functions are not called
721 * `minetest.register_on_dignode(function(pos, node))`
722     * Called when the local player digs a node
723     * Newest functions are called first
724     * If any function returns true, the node isn't dug
725 * `minetest.register_on_punchnode(function(pos, node))`
726     * Called when the local player punches a node
727     * Newest functions are called first
728     * If any function returns true, the punch is ignored
729 * `minetest.register_on_placenode(function(pointed_thing, node))`
730     * Called when a node has been placed
731 * `minetest.register_on_item_use(function(item, pointed_thing))`
732     * Called when the local player uses an item.
733     * Newest functions are called first.
734     * If any function returns true, the item use is not sent to server.
735 * `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
736     * Called when an incoming mod channel message is received
737     * You must have joined some channels before, and server must acknowledge the
738       join request.
739     * If message comes from a server mod, `sender` field is an empty string.
740 * `minetest.register_on_modchannel_signal(function(channel_name, signal))`
741     * Called when a valid incoming mod channel signal is received
742     * Signal id permit to react to server mod channel events
743     * Possible values are:
744       0: join_ok
745       1: join_failed
746       2: leave_ok
747       3: leave_failed
748       4: event_on_not_joined_channel
749       5: state_changed
750 * `minetest.register_on_inventory_open(function(inventory))`
751     * Called when the local player open inventory
752     * Newest functions are called first
753     * If any function returns true, inventory doesn't open
754 * `minetest.register_on_recieve_physics_override(function(override))`
755     * Called when recieving physics_override from server
756     * Newest functions are called first
757     * If any function returns true, the physics override does not change
758 * `minetest.register_on_play_sound(function(SimpleSoundSpec))`
759     * Called when recieving a play sound command from server
760     * Newest functions are called first
761     * If any function returns true, the sound does not play
762 * `minetest.register_on_spawn_partice(function(particle definition))`
763     * Called when recieving a spawn particle command from server
764     * Newest functions are called first
765     * If any function returns true, the particel does not spawn
766
767 ### Setting-related
768 * `minetest.settings`: Settings object containing all of the settings from the
769   main config file (`minetest.conf`).
770 * `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
771   parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
772
773 ### Sounds
774 * `minetest.sound_play(spec, parameters)`: returns a handle
775     * `spec` is a `SimpleSoundSpec`
776     * `parameters` is a sound parameter table
777 * `minetest.sound_stop(handle)`
778     * `handle` is a handle returned by `minetest.sound_play`
779 * `minetest.sound_fade(handle, step, gain)`
780     * `handle` is a handle returned by `minetest.sound_play`
781     * `step` determines how fast a sound will fade.
782       Negative step will lower the sound volume, positive step will increase
783       the sound volume.
784     * `gain` the target gain for the fade.
785
786 ### Timing
787 * `minetest.after(time, func, ...)`
788     * Call the function `func` after `time` seconds, may be fractional
789     * Optional: Variable number of arguments that are passed to `func`
790 * `minetest.get_us_time()`
791     * Returns time with microsecond precision. May not return wall time.
792 * `minetest.get_timeofday()`
793     * Returns the time of day: `0` for midnight, `0.5` for midday
794
795 ### Map
796 * `minetest.interact(action, pointed_thing)`
797     * Sends an interaction to the server
798     * `pointed_thing` is a pointed_thing
799     * `action` is one of
800         * "start_digging": Use to punch nodes / objects
801         * "stop_digging": Use to abort digging a "start_digging" command
802         * "digging_completed": Use to finish a "start_digging" command or dig a node instantly
803         * "place": Use to rightclick nodes and objects
804         * "use": Use to leftclick an item in air (pointed_thing.type is usually "nothing")
805         * "activate": Same as "use", but rightclick
806 * `minetest.place_node(pos)`
807     * Places the wielded node/item of the player at pos.
808 * `minetest.dig_node(pos)`
809     * Instantly digs the node at pos. This may fuck up with anticheat.
810 * `minetest.get_node_or_nil(pos)`
811     * Returns the node at the given position as table in the format
812       `{name="node_name", param1=0, param2=0}`, returns `nil`
813       for unloaded areas or flavor limited areas.
814 * `minetest.get_node_light(pos, timeofday)`
815     * Gets the light value at the given position. Note that the light value
816       "inside" the node at the given position is returned, so you usually want
817       to get the light value of a neighbor.
818     * `pos`: The position where to measure the light.
819     * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
820     * Returns a number between `0` and `15` or `nil`
821 * `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns pos or `nil`
822     * `radius`: using a maximum metric
823     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
824     * `search_center` is an optional boolean (default: `false`)
825       If true `pos` is also checked for the nodes
826 * `minetest.find_nodes_near(pos, radius, nodenames, [search_center])`: returns a
827   list of positions.
828     * `radius`: using a maximum metric
829     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
830     * `search_center` is an optional boolean (default: `false`)
831       If true `pos` is also checked for the nodes
832 * `minetest.find_nodes_near_under_air(pos, radius, nodenames, [search_center])`: returns a
833   list of positions.
834     * `radius`: using a maximum metric
835     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
836     * `search_center` is an optional boolean (default: `false`)
837       If true `pos` is also checked for the nodes
838     * Return value: Table with all node positions with a node air above
839 * `minetest.find_nodes_near_under_air_except(pos, radius, nodenames, [search_center])`: returns a
840   list of positions.
841     * `radius`: using a maximum metric
842     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`, specifies the nodes to be ignored
843     * `search_center` is an optional boolean (default: `false`)
844       If true `pos` is also checked for the nodes
845     * Return value: Table with all node positions with a node air above
846 * `minetest.find_nodes_in_area(pos1, pos2, nodenames, [grouped])`
847     * `pos1` and `pos2` are the min and max positions of the area to search.
848     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
849     * If `grouped` is true the return value is a table indexed by node name
850       which contains lists of positions.
851     * If `grouped` is false or absent the return values are as follows:
852       first value: Table with all node positions
853       second value: Table with the count of each node with the node name
854       as index
855     * Area volume is limited to 4,096,000 nodes
856 * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
857   list of positions.
858     * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
859     * Return value: Table with all node positions with a node air above
860     * Area volume is limited to 4,096,000 nodes
861 * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
862     * Checks if there is anything other than air between pos1 and pos2.
863     * Returns false if something is blocking the sight.
864     * Returns the position of the blocking node when `false`
865     * `pos1`: First position
866     * `pos2`: Second position
867 * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
868     * Creates a `Raycast` object.
869     * `pos1`: start of the ray
870     * `pos2`: end of the ray
871     * `objects`: if false, only nodes will be returned. Default is `true`.
872     * `liquids`: if false, liquid nodes won't be returned. Default is `false`.
873 * `minetest.get_pointed_thing()` returns `PointedThing`
874     * Returns the thing currently pointed by player
875 * `minetest.get_pointed_thing_position(pointed_thing, above)`
876     * Returns the position of a `pointed_thing` or `nil` if the `pointed_thing`
877       does not refer to a node or entity.
878     * If the optional `above` parameter is true and the `pointed_thing` refers
879       to a node, then it will return the `above` position of the `pointed_thing`.
880 * `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
881     * returns table containing path that can be walked on
882     * returns a table of 3D points representing a path from `pos1` to `pos2` or
883       `nil` on failure.
884     * Reasons for failure:
885         * No path exists at all
886         * No path exists within `searchdistance` (see below)
887         * Start or end pos is buried in land
888     * `pos1`: start position
889     * `pos2`: end position
890     * `searchdistance`: maximum distance from the search positions to search in.
891       In detail: Path must be completely inside a cuboid. The minimum
892       `searchdistance` of 1 will confine search between `pos1` and `pos2`.
893       Larger values will increase the size of this cuboid in all directions
894     * `max_jump`: maximum height difference to consider walkable
895     * `max_drop`: maximum height difference to consider droppable
896     * `algorithm`: One of `"A*_noprefetch"` (default), `"A*"`, `"Dijkstra"`.
897       Difference between `"A*"` and `"A*_noprefetch"` is that
898       `"A*"` will pre-calculate the cost-data, the other will calculate it
899       on-the-fly
900 * `minetest.find_nodes_with_meta(pos1, pos2)`
901     * Get a table of positions of nodes that have metadata within a region
902       {pos1, pos2}.
903 * `minetest.get_meta(pos)`
904     * Get a `NodeMetaRef` at that position
905 * `minetest.get_node_level(pos)`
906     * get level of leveled node (water, snow)
907 * `minetest.get_node_max_level(pos)`
908     * get max available level for leveled node
909
910 ### Player
911 * `minetest.send_damage(hp)`
912     * Sends fall damage to server
913 * `minetest.send_chat_message(message)`
914     * Act as if `message` was typed by the player into the terminal.
915 * `minetest.run_server_chatcommand(cmd, param)`
916     * Alias for `minetest.send_chat_message("/" .. cmd .. " " .. param)`
917 * `minetest.clear_out_chat_queue()`
918     * Clears the out chat queue
919 * `minetest.drop_selected_item()`
920     * Drops the selected item
921 * `minetest.localplayer`
922     * Reference to the LocalPlayer object. See [`LocalPlayer`](#localplayer) class reference for methods.
923
924 ### Privileges
925 * `minetest.get_privilege_list()`
926     * Returns a list of privileges the current player has in the format `{priv1=true,...}`
927 * `minetest.string_to_privs(str)`: returns `{priv1=true,...}`
928 * `minetest.privs_to_string(privs)`: returns `"priv1,priv2,..."`
929     * Convert between two privilege representations
930
931 ### Client Environment
932 * `minetest.get_player_names()`
933     * Returns list of player names on server (nil if CSM_RF_READ_PLAYERINFO is enabled by server)
934 * `minetest.get_objects_inside_radius(pos, radius)`: returns a list of
935   ClientObjectRefs.
936     * `radius`: using an euclidean metric
937 * `minetest.get_nearby_objects(radius)`
938     * alias for minetest.get_objects_inside_radius(minetest.localplayer:get_pos(), radius)
939 * `minetest.disconnect()`
940     * Disconnect from the server and exit to main menu.
941     * Returns `false` if the client is already disconnecting otherwise returns `true`.
942 * `minetest.get_server_info()`
943     * Returns [server info](#server-info).
944 * `minetest.send_respawn()`
945     * Sends a respawn request to the server.
946
947 ### HTTP Requests
948
949 * `minetest.get_http_api()`
950     * returns `HTTPApiTable` containing http functions.
951     * The returned table contains the functions `fetch_sync`, `fetch_async` and
952       `fetch_async_get` described below.
953     * Function only exists if minetest server was built with cURL support.
954 * `HTTPApiTable.fetch_sync(HTTPRequest req)`: returns HTTPRequestResult
955     * Performs given request synchronously
956 * `HTTPApiTable.fetch_async(HTTPRequest req)`: returns handle
957     * Performs given request asynchronously and returns handle for
958       `HTTPApiTable.fetch_async_get`
959 * `HTTPApiTable.fetch_async_get(handle)`: returns HTTPRequestResult
960     * Return response data for given asynchronous HTTP request
961
962 ### `HTTPRequest` definition
963
964 Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
965
966     {
967         url = "http://example.org",
968
969         timeout = 10,
970         -- Timeout for connection in seconds. Default is 3 seconds.
971
972         post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
973         -- Optional, if specified a POST request with post_data is performed.
974         -- Accepts both a string and a table. If a table is specified, encodes
975         -- table as x-www-form-urlencoded key-value pairs.
976         -- If post_data is not specified, a GET request is performed instead.
977
978         user_agent = "ExampleUserAgent",
979         -- Optional, if specified replaces the default minetest user agent with
980         -- given string
981
982         extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
983         -- Optional, if specified adds additional headers to the HTTP request.
984         -- You must make sure that the header strings follow HTTP specification
985         -- ("Key: Value").
986
987         multipart = boolean
988         -- Optional, if true performs a multipart HTTP request.
989         -- Default is false.
990     }
991
992 ### `HTTPRequestResult` definition
993
994 Passed to `HTTPApiTable.fetch` callback. Returned by
995 `HTTPApiTable.fetch_async_get`.
996
997     {
998         completed = true,
999         -- If true, the request has finished (either succeeded, failed or timed
1000         -- out)
1001
1002         succeeded = true,
1003         -- If true, the request was successful
1004
1005         timeout = false,
1006         -- If true, the request timed out
1007
1008         code = 200,
1009         -- HTTP status code
1010
1011         data = "response"
1012     }
1013
1014 ### Storage API
1015 * `minetest.get_mod_storage()`:
1016     * returns reference to mod private `StorageRef`
1017     * must be called during mod load time
1018
1019 ### Mod channels
1020 ![Mod channels communication scheme](docs/mod channels.png)
1021
1022 * `minetest.mod_channel_join(channel_name)`
1023     * Client joins channel `channel_name`, and creates it, if necessary. You
1024       should listen from incoming messages with `minetest.register_on_modchannel_message`
1025       call to receive incoming messages. Warning, this function is asynchronous.
1026
1027 ### Particles
1028 * `minetest.add_particle(particle definition)`
1029
1030 * `minetest.add_particlespawner(particlespawner definition)`
1031     * Add a `ParticleSpawner`, an object that spawns an amount of particles over `time` seconds
1032     * Returns an `id`, and -1 if adding didn't succeed
1033
1034 * `minetest.delete_particlespawner(id)`
1035     * Delete `ParticleSpawner` with `id` (return value from `minetest.add_particlespawner`)
1036
1037 ### Misc
1038 * `minetest.set_keypress(key, value)`
1039     * Act as if a key was pressed (value = true) / released (value = false)
1040     * The key must be an keymap_* setting
1041     * e.g. minetest.set_keypress("jump", true) will cause te player to jump until minetest.set_keypress("jump", false) is called or the player presses & releases the space bar himself
1042 * `minetest.get_inventory(location)`
1043     * Returns the inventory at location
1044 * `minetest.find_item(item)`
1045     * finds and an item in the inventory
1046     * returns index on success or nil if item is not found
1047 * `minetest.switch_to_item(item)`
1048     * `item` is an Itemstring
1049     * searches to item in inventory, sets the wield index to it if found
1050     * returns true on success, false if item was not found
1051 * `minetest.register_cheat(name, category, setting | function)`
1052     * Register an entry for the cheat menu
1053     * If the Category is nonexistant, it will be created
1054     * If the 3rd argument is a string it will be interpreted as a setting and toggled 
1055         when the player selects the entry in the cheat menu
1056     * If the 3rd argument is a function it will be called
1057         when the player selects the entry in the cheat menu
1058 * `minetest.parse_json(string[, nullvalue])`: returns something
1059     * Convert a string containing JSON data into the Lua equivalent
1060     * `nullvalue`: returned in place of the JSON null; defaults to `nil`
1061     * On success returns a table, a string, a number, a boolean or `nullvalue`
1062     * On failure outputs an error message and returns `nil`
1063     * Example: `parse_json("[10, {\"a\":false}]")`, returns `{10, {a = false}}`
1064 * `minetest.write_json(data[, styled])`: returns a string or `nil` and an error message
1065     * Convert a Lua table into a JSON string
1066     * styled: Outputs in a human-readable format if this is set, defaults to false
1067     * Unserializable things like functions and userdata are saved as null.
1068     * **Warning**: JSON is more strict than the Lua table format.
1069         1. You can only use strings and positive integers of at least one as keys.
1070         2. You can not mix string and integer keys.
1071            This is due to the fact that JSON has two distinct array and object values.
1072     * Example: `write_json({10, {a = false}})`, returns `"[10, {\"a\": false}]"`
1073 * `minetest.serialize(table)`: returns a string
1074     * Convert a table containing tables, strings, numbers, booleans and `nil`s
1075       into string form readable by `minetest.deserialize`
1076     * Example: `serialize({foo='bar'})`, returns `'return { ["foo"] = "bar" }'`
1077 * `minetest.deserialize(string)`: returns a table
1078     * Convert a string returned by `minetest.deserialize` into a table
1079     * `string` is loaded in an empty sandbox environment.
1080     * Will load functions, but they cannot access the global environment.
1081     * Example: `deserialize('return { ["foo"] = "bar" }')`, returns `{foo='bar'}`
1082     * Example: `deserialize('print("foo")')`, returns `nil` (function call fails)
1083         * `error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)`
1084 * `minetest.compress(data, method, ...)`: returns `compressed_data`
1085     * Compress a string of data.
1086     * `method` is a string identifying the compression method to be used.
1087     * Supported compression methods:
1088     *     Deflate (zlib): `"deflate"`
1089     * `...` indicates method-specific arguments.  Currently defined arguments are:
1090     *     Deflate: `level` - Compression level, `0`-`9` or `nil`.
1091 * `minetest.decompress(compressed_data, method, ...)`: returns data
1092     * Decompress a string of data (using ZLib).
1093     * See documentation on `minetest.compress()` for supported compression methods.
1094     * currently supported.
1095     * `...` indicates method-specific arguments. Currently, no methods use this.
1096 * `minetest.rgba(red, green, blue[, alpha])`: returns a string
1097     * Each argument is a 8 Bit unsigned integer
1098     * Returns the ColorString from rgb or rgba values
1099     * Example: `minetest.rgba(10, 20, 30, 40)`, returns `"#0A141E28"`
1100 * `minetest.encode_base64(string)`: returns string encoded in base64
1101     * Encodes a string in base64.
1102 * `minetest.decode_base64(string)`: returns string
1103     * Decodes a string encoded in base64.
1104 * `minetest.gettext(string)` : returns string
1105     * look up the translation of a string in the gettext message catalog
1106 * `fgettext_ne(string, ...)`
1107     * call minetest.gettext(string), replace "$1"..."$9" with the given
1108       extra arguments and return the result
1109 * `fgettext(string, ...)` : returns string
1110     * same as fgettext_ne(), but calls minetest.formspec_escape before returning result
1111 * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a position
1112     * returns the exact position on the surface of a pointed node
1113 * `minetest.global_exists(name)`
1114     * Checks if a global variable has been set, without triggering a warning.
1115 * `minetest.make_screenshot()`
1116     * Triggers the MT makeScreenshot functionality
1117
1118 ### UI
1119 * `minetest.ui.minimap`
1120     * Reference to the minimap object. See [`Minimap`](#minimap) class reference for methods.
1121     * If client disabled minimap (using enable_minimap setting) this reference will be nil.
1122 * `minetest.camera`
1123     * Reference to the camera object. See [`Camera`](#camera) class reference for methods.
1124 * `minetest.show_formspec(formname, formspec)` : returns true on success
1125         * Shows a formspec to the player
1126 * `minetest.close_formspec(formname)`
1127     * `formname`: has to exactly match the one given in `show_formspec`, or the
1128       formspec will not close.
1129     * calling `show_formspec(formname, "")` is equal to this
1130       expression.
1131     * to close a formspec regardless of the formname, call
1132       `minetest.close_formspec("")`.
1133       **USE THIS ONLY WHEN ABSOLUTELY NECESSARY!**
1134 * `minetest.display_chat_message(message)` returns true on success
1135         * Shows a chat message to the current player.
1136
1137 Class reference
1138 ---------------
1139
1140 ### ModChannel
1141
1142 An interface to use mod channels on client and server
1143
1144 #### Methods
1145 * `leave()`: leave the mod channel.
1146     * Client leaves channel `channel_name`.
1147     * No more incoming or outgoing messages can be sent to this channel from client mods.
1148     * This invalidate all future object usage
1149     * Ensure your set mod_channel to nil after that to free Lua resources
1150 * `is_writeable()`: returns true if channel is writable and mod can send over it.
1151 * `send_all(message)`: Send `message` though the mod channel.
1152     * If mod channel is not writable or invalid, message will be dropped.
1153     * Message size is limited to 65535 characters by protocol.
1154
1155 ### Minimap
1156 An interface to manipulate minimap on client UI
1157
1158 #### Methods
1159 * `show()`: shows the minimap (if not disabled by server)
1160 * `hide()`: hides the minimap
1161 * `set_pos(pos)`: sets the minimap position on screen
1162 * `get_pos()`: returns the minimap current position
1163 * `set_angle(deg)`: sets the minimap angle in degrees
1164 * `get_angle()`: returns the current minimap angle in degrees
1165 * `set_mode(mode)`: sets the minimap mode (0 to 6)
1166 * `get_mode()`: returns the current minimap mode
1167 * `set_shape(shape)`: Sets the minimap shape. (0 = square, 1 = round)
1168 * `get_shape()`: Gets the minimap shape. (0 = square, 1 = round)
1169
1170 ### Camera
1171 An interface to get or set information about the camera and camera-node.
1172 Please do not try to access the reference until the camera is initialized, otherwise the reference will be nil.
1173
1174 #### Methods
1175 * `set_camera_mode(mode)`
1176     * Pass `0` for first-person, `1` for third person, and `2` for third person front
1177 * `get_camera_mode()`
1178     * Returns 0, 1, or 2 as described above
1179 * `get_fov()`
1180     * Returns a table with X, Y, maximum and actual FOV in degrees:
1181
1182 ```lua
1183      {
1184          x = number,
1185          y = number,
1186          max = number,
1187          actual = number
1188      }
1189 ```
1190
1191 * `get_pos()`
1192     * Returns position of camera with view bobbing
1193 * `get_offset()`
1194     * Returns eye offset vector
1195 * `get_look_dir()`
1196     * Returns eye direction unit vector
1197 * `get_look_vertical()`
1198     * Returns pitch in radians
1199 * `get_look_horizontal()`
1200     * Returns yaw in radians
1201 * `get_aspect_ratio()`
1202     * Returns aspect ratio of screen
1203
1204 ### LocalPlayer
1205 An interface to retrieve information about the player.
1206 This object will only be available after the client is initialized. Earlier accesses will yield a `nil` value.
1207
1208 Methods:
1209
1210 * `get_pos()`
1211     * returns current player current position
1212 * `set_pos(pos)`
1213     * sets the position (anticheat may not like this)
1214 * `get_yaw()`
1215     * returns the yaw (degrees)
1216 * `set_yaw(yaw)`
1217     * sets the yaw (degrees)
1218 * `get_pitch()`
1219     * returns the pitch (degrees)
1220 * `set_pitch(pitch)`
1221     * sets the pitch (degrees)
1222 * `get_velocity()`
1223     * returns player speed vector
1224 * `set_velocity(vel)`
1225     * sets player speed vector
1226 * `get_hp()`
1227     * returns player HP
1228 * `get_name()`
1229     * returns player name
1230 * `get_wield_index()`
1231     * returns the index of the wielded item (starts at 1)
1232 * `set_wield_index()`
1233     * sets the index (starts at 1)
1234 * `get_wielded_item()`
1235     * returns the itemstack the player is holding
1236 * `is_attached()`
1237     * returns true if player is attached
1238 * `is_touching_ground()`
1239     * returns true if player touching ground
1240 * `is_in_liquid()`
1241     * returns true if player is in a liquid (This oscillates so that the player jumps a bit above the surface)
1242 * `is_in_liquid_stable()`
1243     * returns true if player is in a stable liquid (This is more stable and defines the maximum speed of the player)
1244 * `get_liquid_viscosity()`
1245     * returns liquid viscosity (Gets the viscosity of liquid to calculate friction)
1246 * `is_climbing()`
1247     * returns true if player is climbing
1248 * `swimming_vertical()`
1249     * returns true if player is swimming in vertical
1250 * `get_physics_override()`
1251     * returns:
1252
1253 ```lua
1254     {
1255         speed = float,
1256         jump = float,
1257         gravity = float,
1258         sneak = boolean,
1259         sneak_glitch = boolean,
1260         new_move = boolean,
1261     }
1262 ```
1263
1264 * `set_physics_override(override_table)`
1265     * `override_table` is a table with the following fields:
1266         * `speed`: multiplier to default walking speed value (default: `1`)
1267         * `jump`: multiplier to default jump value (default: `1`)
1268         * `gravity`: multiplier to default gravity value (default: `1`)
1269         * `sneak`: whether player can sneak (default: `true`)
1270         * `sneak_glitch`: whether player can use the new move code replications
1271           of the old sneak side-effects: sneak ladders and 2 node sneak jump
1272           (default: `false`)
1273         * `new_move`: use new move/sneak code. When `false` the exact old code
1274           is used for the specific old sneak behaviour (default: `true`)
1275 * `get_override_pos()`
1276     * returns override position
1277 * `get_last_pos()`
1278     * returns last player position before the current client step
1279 * `get_last_velocity()`
1280     * returns last player speed
1281 * `get_breath()`
1282     * returns the player's breath
1283 * `get_movement_acceleration()`
1284     * returns acceleration of the player in different environments:
1285
1286 ```lua
1287     {
1288        fast = float,
1289        air = float,
1290        default = float,
1291     }
1292 ```
1293
1294 * `get_movement_speed()`
1295     * returns player's speed in different environments:
1296
1297 ```lua
1298     {
1299        walk = float,
1300        jump = float,
1301        crouch = float,
1302        fast = float,
1303        climb = float,
1304     }
1305 ```
1306
1307 * `get_movement()`
1308     * returns player's movement in different environments:
1309
1310 ```lua
1311     {
1312        liquid_fluidity = float,
1313        liquid_sink = float,
1314        liquid_fluidity_smooth = float,
1315        gravity = float,
1316     }
1317 ```
1318
1319 * `get_last_look_horizontal()`:
1320     * returns last look horizontal angle
1321 * `get_last_look_vertical()`:
1322     * returns last look vertical angle
1323 * `get_control()`:
1324     * returns pressed player controls
1325
1326 ```lua
1327     {
1328        up = boolean,
1329        down = boolean,
1330        left = boolean,
1331        right = boolean,
1332        jump = boolean,
1333        aux1 = boolean,
1334        sneak = boolean,
1335        zoom = boolean,
1336        dig = boolean,
1337        place = boolean,
1338     }
1339 ```
1340
1341 * `get_armor_groups()`
1342     * returns a table with the armor group ratings
1343 * `hud_add(definition)`
1344     * add a HUD element described by HUD def, returns ID number on success and `nil` on failure.
1345     * See [`HUD definition`](#hud-definition-hud_add-hud_get)
1346 * `hud_get(id)`
1347     * returns the [`definition`](#hud-definition-hud_add-hud_get) of the HUD with that ID number or `nil`, if non-existent.
1348 * `hud_remove(id)`
1349     * remove the HUD element of the specified id, returns `true` on success
1350 * `hud_change(id, stat, value)`
1351     * change a value of a previously added HUD element
1352     * element `stat` values: `position`, `name`, `scale`, `text`, `number`, `item`, `dir`
1353     * Returns `true` on success, otherwise returns `nil`
1354 * `get_object()`
1355     * Returns the ClientObjectRef for the player
1356
1357 ### Settings
1358 An interface to read config files in the format of `minetest.conf`.
1359
1360 It can be created via `Settings(filename)`.
1361
1362 #### Methods
1363 * `get(key)`: returns a value
1364 * `get_bool(key)`: returns a boolean
1365 * `set(key, value)`
1366 * `remove(key)`: returns a boolean (`true` for success)
1367 * `get_names()`: returns `{key1,...}`
1368 * `write()`: returns a boolean (`true` for success)
1369     * write changes to file
1370 * `to_table()`: returns `{[key1]=value1,...}`
1371
1372 ### NodeMetaRef
1373 Node metadata: reference extra data and functionality stored in a node.
1374 Can be obtained via `minetest.get_meta(pos)`.
1375
1376 #### Methods
1377 * `get_string(name)`
1378 * `get_int(name)`
1379 * `get_float(name)`
1380 * `to_table()`: returns `nil` or a table with keys:
1381     * `fields`: key-value storage
1382     * `inventory`: `{list1 = {}, ...}}`
1383
1384 ### ClientObjectRef
1385
1386 Moving things in the game are generally these.
1387 This is basically a reference to a C++ `GenericCAO`.
1388
1389 #### Methods
1390
1391 * `get_pos()`: returns `{x=num, y=num, z=num}`
1392 * `get_velocity()`: returns the velocity, a vector
1393 * `get_acceleration()`: returns the acceleration, a vector
1394 * `get_rotation()`: returns the rotation, a vector (radians)
1395 * `is_player()`: returns true if the object is a player
1396 * `is_local_player()`: returns true if the object is the local player
1397 * `get_attach()`: returns parent or nil if it isn't attached.
1398 * `get_nametag()`: returns the nametag (string)
1399 * `get_item_textures()`: returns the textures
1400 * `get_max_hp()`: returns the maximum heath
1401 * `punch()`: punches the object
1402 * `rightclick()`: rightclicks the object
1403     
1404 ### `Raycast`
1405
1406 A raycast on the map. It works with selection boxes.
1407 Can be used as an iterator in a for loop as:
1408
1409     local ray = Raycast(...)
1410     for pointed_thing in ray do
1411         ...
1412     end
1413
1414 The map is loaded as the ray advances. If the map is modified after the
1415 `Raycast` is created, the changes may or may not have an effect on the object.
1416
1417 It can be created via `Raycast(pos1, pos2, objects, liquids)` or
1418 `minetest.raycast(pos1, pos2, objects, liquids)` where:
1419
1420 * `pos1`: start of the ray
1421 * `pos2`: end of the ray
1422 * `objects`: if false, only nodes will be returned. Default is true.
1423 * `liquids`: if false, liquid nodes won't be returned. Default is false.
1424
1425 #### Methods
1426
1427 * `next()`: returns a `pointed_thing` with exact pointing location
1428     * Returns the next thing pointed by the ray or nil.
1429
1430 -----------------
1431 ### Definitions
1432 * `minetest.get_node_def(nodename)`
1433         * Returns [node definition](#node-definition) table of `nodename`
1434 * `minetest.get_item_def(itemstring)`
1435         * Returns item definition table of `itemstring`
1436 * `minetest.override_item(itemstring, redefinition)`
1437     * Overrides fields of an item registered with register_node/tool/craftitem.
1438     * Note: Item must already be defined by the server
1439     * Example: `minetest.override_item("default:mese",
1440       {light_source=minetest.LIGHT_MAX})`
1441     * Doesnt really work yet an causes strange bugs, I'm working to make is better
1442
1443 #### Node Definition
1444
1445 ```lua
1446         {
1447                 has_on_construct = bool,        -- Whether the node has the on_construct callback defined
1448                 has_on_destruct = bool,         -- Whether the node has the on_destruct callback defined
1449                 has_after_destruct = bool,      -- Whether the node has the after_destruct callback defined
1450                 name = string,                  -- The name of the node e.g. "air", "default:dirt"
1451                 groups = table,                 -- The groups of the node
1452                 paramtype = string,             -- Paramtype of the node
1453                 paramtype2 = string,            -- ParamType2 of the node
1454                 drawtype = string,              -- Drawtype of the node
1455                 mesh = <string>,                -- Mesh name if existant
1456                 minimap_color = <Color>,        -- Color of node on minimap *May not exist*
1457                 visual_scale = number,          -- Visual scale of node
1458                 alpha = number,                 -- Alpha of the node. Only used for liquids
1459                 color = <Color>,                -- Color of node *May not exist*
1460                 palette_name = <string>,        -- Filename of palette *May not exist*
1461                 palette = <{                    -- List of colors
1462                         Color,
1463                         Color
1464                 }>,
1465                 waving = number,                -- 0 of not waving, 1 if waving
1466                 connect_sides = number,         -- Used for connected nodes
1467                 connects_to = {                 -- List of nodes to connect to
1468                         "node1",
1469                         "node2"
1470                 },
1471                 post_effect_color = Color,      -- Color overlayed on the screen when the player is in the node
1472                 leveled = number,               -- Max level for node
1473                 sunlight_propogates = bool,     -- Whether light passes through the block
1474                 light_source = number,          -- Light emitted by the block
1475                 is_ground_content = bool,       -- Whether caves should cut through the node
1476                 walkable = bool,                -- Whether the player collides with the node
1477                 pointable = bool,               -- Whether the player can select the node
1478                 diggable = bool,                -- Whether the player can dig the node
1479                 climbable = bool,               -- Whether the player can climb up the node
1480                 buildable_to = bool,            -- Whether the player can replace the node by placing a node on it
1481                 rightclickable = bool,          -- Whether the player can place nodes pointing at this node
1482                 damage_per_second = number,     -- HP of damage per second when the player is in the node
1483                 liquid_type = <string>,         -- A string containing "none", "flowing", or "source" *May not exist*
1484                 liquid_alternative_flowing = <string>, -- Alternative node for liquid *May not exist*
1485                 liquid_alternative_source = <string>, -- Alternative node for liquid *May not exist*
1486                 liquid_viscosity = <number>,    -- How fast the liquid flows *May not exist*
1487                 liquid_renewable = <boolean>,   -- Whether the liquid makes an infinite source *May not exist*
1488                 liquid_range = <number>,        -- How far the liquid flows *May not exist*
1489                 drowning = bool,                -- Whether the player will drown in the node
1490                 floodable = bool,               -- Whether nodes will be replaced by liquids (flooded)
1491                 node_box = table,               -- Nodebox to draw the node with
1492                 collision_box = table,          -- Nodebox to set the collision area
1493                 selection_box = table,          -- Nodebox to set the area selected by the player
1494                 sounds = {                      -- Table of sounds that the block makes
1495                         sound_footstep = SimpleSoundSpec,
1496                         sound_dig = SimpleSoundSpec,
1497                         sound_dug = SimpleSoundSpec
1498                 },
1499                 legacy_facedir_simple = bool,   -- Whether to use old facedir
1500                 legacy_wallmounted = bool       -- Whether to use old wallmounted
1501         }
1502 ```
1503
1504 #### Item Definition
1505
1506 ```lua
1507         {
1508                 name = string,                  -- Name of the item e.g. "default:stone"
1509                 description = string,           -- Description of the item e.g. "Stone"
1510                 type = string,                  -- Item type: "none", "node", "craftitem", "tool"
1511                 inventory_image = string,       -- Image in the inventory
1512                 wield_image = string,           -- Image in wieldmesh
1513                 palette_image = string,         -- Image for palette
1514                 color = Color,                  -- Color for item
1515                 wield_scale = Vector,           -- Wieldmesh scale
1516                 stack_max = number,             -- Number of items stackable together
1517                 usable = bool,                  -- Has on_use callback defined
1518                 liquids_pointable = bool,       -- Whether you can point at liquids with the item
1519                 tool_capabilities = <table>,    -- If the item is a tool, tool capabilities of the item
1520                 groups = table,                 -- Groups of the item
1521                 sound_place = SimpleSoundSpec,  -- Sound played when placed
1522                 sound_place_failed = SimpleSoundSpec, -- Sound played when placement failed
1523                 node_placement_prediction = string -- Node placed in client until server catches up
1524         }
1525 ```
1526 -----------------
1527
1528 ### Chat command definition (`register_chatcommand`)
1529
1530     {
1531         params = "<name> <privilege>", -- Short parameter description
1532         description = "Remove privilege from player", -- Full description
1533         func = function(param),        -- Called when command is run.
1534                                        -- Returns boolean success and text output.
1535     }
1536 ### Server info
1537 ```lua
1538 {
1539         address = "minetest.example.org", -- The domain name/IP address of a remote server or "" for a local server.
1540         ip = "203.0.113.156",             -- The IP address of the server.
1541         port = 30000,                     -- The port the client is connected to.
1542         protocol_version = 30             -- Will not be accurate at start up as the client might not be connected to the server yet, in that case it will be 0.
1543 }
1544 ```
1545
1546 ### HUD Definition (`hud_add`, `hud_get`)
1547 ```lua
1548     {
1549         hud_elem_type = "image", -- see HUD element types, default "text"
1550     --  ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
1551         position = {x=0.5, y=0.5},
1552     --  ^ Left corner position of element, default `{x=0,y=0}`.
1553         name = "<name>",    -- default ""
1554         scale = {x=2, y=2}, -- default {x=0,y=0}
1555         text = "<text>",    -- default ""
1556         number = 2,         -- default 0
1557         item = 3,           -- default 0
1558     --  ^ Selected item in inventory.  0 for no item selected.
1559         direction = 0,      -- default 0
1560     --  ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
1561         alignment = {x=0, y=0},   -- default {x=0, y=0}
1562     --  ^ See "HUD Element Types"
1563         offset = {x=0, y=0},      -- default {x=0, y=0}
1564     --  ^ See "HUD Element Types"
1565         size = { x=100, y=100 },  -- default {x=0, y=0}
1566     --  ^ Size of element in pixels
1567     }
1568 ```
1569
1570 Escape sequences
1571 ----------------
1572 Most text can contain escape sequences, that can for example color the text.
1573 There are a few exceptions: tab headers, dropdowns and vertical labels can't.
1574 The following functions provide escape sequences:
1575 * `minetest.get_color_escape_sequence(color)`:
1576     * `color` is a [ColorString](#colorstring)
1577     * The escape sequence sets the text color to `color`
1578 * `minetest.colorize(color, message)`:
1579     * Equivalent to:
1580       `minetest.get_color_escape_sequence(color) ..
1581        message ..
1582        minetest.get_color_escape_sequence("#ffffff")`
1583 * `minetest.rainbow(message)`:
1584     * Rainbow colorizes the message.
1585 * `minetest.get_background_escape_sequence(color)`
1586     * `color` is a [ColorString](#colorstring)
1587     * The escape sequence sets the background of the whole text element to
1588       `color`. Only defined for item descriptions and tooltips.
1589 * `minetest.strip_foreground_colors(str)`
1590     * Removes foreground colors added by `get_color_escape_sequence`.
1591 * `minetest.strip_background_colors(str)`
1592     * Removes background colors added by `get_background_escape_sequence`.
1593 * `minetest.strip_colors(str)`
1594     * Removes all color escape sequences.
1595
1596 `ColorString`
1597 -------------
1598 `#RGB` defines a color in hexadecimal format.
1599
1600 `#RGBA` defines a color in hexadecimal format and alpha channel.
1601
1602 `#RRGGBB` defines a color in hexadecimal format.
1603
1604 `#RRGGBBAA` defines a color in hexadecimal format and alpha channel.
1605
1606 Named colors are also supported and are equivalent to
1607 [CSS Color Module Level 4](http://dev.w3.org/csswg/css-color/#named-colors).
1608 To specify the value of the alpha channel, append `#AA` to the end of the color name
1609 (e.g. `colorname#08`). For named colors the hexadecimal string representing the alpha
1610 value must (always) be two hexadecimal digits.
1611
1612 `Color`
1613 -------------
1614 `{a = alpha, r = red, g = green, b = blue}` defines an ARGB8 color.
1615
1616 HUD element types
1617 -----------------
1618 The position field is used for all element types.
1619
1620 To account for differing resolutions, the position coordinates are the percentage
1621 of the screen, ranging in value from `0` to `1`.
1622
1623 The name field is not yet used, but should contain a description of what the
1624 HUD element represents. The direction field is the direction in which something
1625 is drawn.
1626
1627 `0` draws from left to right, `1` draws from right to left, `2` draws from
1628 top to bottom, and `3` draws from bottom to top.
1629
1630 The `alignment` field specifies how the item will be aligned. It ranges from `-1` to `1`,
1631 with `0` being the center, `-1` is moved to the left/up, and `1` is to the right/down.
1632 Fractional values can be used.
1633
1634 The `offset` field specifies a pixel offset from the position. Contrary to position,
1635 the offset is not scaled to screen size. This allows for some precisely-positioned
1636 items in the HUD.
1637
1638 **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling factor!
1639
1640 Below are the specific uses for fields in each type; fields not listed for that type are ignored.
1641
1642 **Note**: Future revisions to the HUD API may be incompatible; the HUD API is still
1643 in the experimental stages.
1644
1645 ### `image`
1646 Displays an image on the HUD.
1647
1648 * `scale`: The scale of the image, with 1 being the original texture size.
1649   Only the X coordinate scale is used (positive values).
1650   Negative values represent that percentage of the screen it
1651   should take; e.g. `x=-100` means 100% (width).
1652 * `text`: The name of the texture that is displayed.
1653 * `alignment`: The alignment of the image.
1654 * `offset`: offset in pixels from position.
1655
1656 ### `text`
1657 Displays text on the HUD.
1658
1659 * `scale`: Defines the bounding rectangle of the text.
1660   A value such as `{x=100, y=100}` should work.
1661 * `text`: The text to be displayed in the HUD element.
1662 * `number`: An integer containing the RGB value of the color used to draw the text.
1663   Specify `0xFFFFFF` for white text, `0xFF0000` for red, and so on.
1664 * `alignment`: The alignment of the text.
1665 * `offset`: offset in pixels from position.
1666
1667 ### `statbar`
1668 Displays a horizontal bar made up of half-images.
1669
1670 * `text`: The name of the texture that is used.
1671 * `number`: The number of half-textures that are displayed.
1672   If odd, will end with a vertically center-split texture.
1673 * `direction`
1674 * `offset`: offset in pixels from position.
1675 * `size`: If used, will force full-image size to this value (override texture pack image size)
1676
1677 ### `inventory`
1678 * `text`: The name of the inventory list to be displayed.
1679 * `number`: Number of items in the inventory to be displayed.
1680 * `item`: Position of item that is selected.
1681 * `direction`
1682 * `offset`: offset in pixels from position.
1683
1684 ### `waypoint`
1685
1686 Displays distance to selected world position.
1687
1688 * `name`: The name of the waypoint.
1689 * `text`: Distance suffix. Can be blank.
1690 * `precision`: Waypoint precision, integer >= 0. Defaults to 10.
1691   If set to 0, distance is not shown. Shown value is `floor(distance*precision)/precision`.
1692   When the precision is an integer multiple of 10, there will be `log_10(precision)` digits after the decimal point.
1693   `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
1694   `precision = 2` will show multiples of `0.5`; precision = 5 will show multiples of `0.2` and so on:
1695   `precision = n` will show multiples of `1/n`
1696 * `number:` An integer containing the RGB value of the color used to draw the
1697   text.
1698 * `world_pos`: World position of the waypoint.
1699 * `offset`: offset in pixels from position.
1700 * `alignment`: The alignment of the waypoint.
1701
1702 ### `image_waypoint`
1703
1704 Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint.
1705
1706 * `scale`: The scale of the image, with 1 being the original texture size.
1707   Only the X coordinate scale is used (positive values).
1708   Negative values represent that percentage of the screen it
1709   should take; e.g. `x=-100` means 100% (width).
1710 * `text`: The name of the texture that is displayed.
1711 * `alignment`: The alignment of the image.
1712 * `world_pos`: World position of the waypoint.
1713 * `offset`: offset in pixels from position.
1714
1715 ### Particle definition (`add_particle`)
1716
1717     {
1718         pos = {x=0, y=0, z=0},
1719         velocity = {x=0, y=0, z=0},
1720         acceleration = {x=0, y=0, z=0},
1721     --  ^ Spawn particle at pos with velocity and acceleration
1722         expirationtime = 1,
1723     --  ^ Disappears after expirationtime seconds
1724         size = 1,
1725         collisiondetection = false,
1726     --  ^ collisiondetection: if true collides with physical objects
1727         collision_removal = false,
1728     --  ^ collision_removal: if true then particle is removed when it collides,
1729     --  ^ requires collisiondetection = true to have any effect
1730         vertical = false,
1731     --  ^ vertical: if true faces player using y axis only
1732         texture = "image.png",
1733     --  ^ Uses texture (string)
1734         animation = {Tile Animation definition},
1735     --  ^ optional, specifies how to animate the particle texture
1736         glow = 0
1737     --  ^ optional, specify particle self-luminescence in darkness
1738     }
1739
1740 ### `ParticleSpawner` definition (`add_particlespawner`)
1741
1742     {
1743         amount = 1,
1744         time = 1,
1745     --  ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
1746         minpos = {x=0, y=0, z=0},
1747         maxpos = {x=0, y=0, z=0},
1748         minvel = {x=0, y=0, z=0},
1749         maxvel = {x=0, y=0, z=0},
1750         minacc = {x=0, y=0, z=0},
1751         maxacc = {x=0, y=0, z=0},
1752         minexptime = 1,
1753         maxexptime = 1,
1754         minsize = 1,
1755         maxsize = 1,
1756     --  ^ The particle's properties are random values in between the bounds:
1757     --  ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
1758     --  ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
1759         collisiondetection = false,
1760     --  ^ collisiondetection: if true uses collision detection
1761         collision_removal = false,
1762     --  ^ collision_removal: if true then particle is removed when it collides,
1763     --  ^ requires collisiondetection = true to have any effect
1764         vertical = false,
1765     --  ^ vertical: if true faces player using y axis only
1766         texture = "image.png",
1767     --  ^ Uses texture (string)
1768     }
1769
1770 ### InventoryAction
1771 A reference to a C++ InventoryAction. You can move, drop and craft items in all accessible inventories using InventoryActions.
1772
1773 #### methods
1774
1775 * `InventoryAction(type)`:
1776     * creates a new InventoryAction
1777     * type is on of "move", "drop", or "craft", else returns nil
1778     * indexing starts at 1
1779 * `apply()`:
1780     * applies the InventoryAction (InventoryActions can be applied multible times)
1781 * `from(inventorylocation, listname, stack)`
1782     * this is valid for move or drop actions
1783     * when `apply()` is called items are moved / dropped from `listname` `inventorylocation` in` at `stack`
1784 * `to(inventorylocation, listname, stack)`
1785     * this is valid for move actions
1786     * when `apply()` is called items are moved to `listname` in`inventorylocation` at `stack`
1787 * `craft(inventoryaction)`
1788     * this is valid for craft actions
1789     * when `apply()` is called a craft event for this inventory will be triggered
1790 * `set_count(count)`
1791     * this is valid for all actions
1792     * it specifies how many items to drop / craft / move
1793     * `0` means move all items
1794     * default count: `0`
1795     
1796 #### example
1797     `local move_act = InventoryAction("move")
1798     move_act:from("current_player", "main", 1)
1799     move_act:to("current_player", "craft", 1)
1800     move_act:set_count(1)
1801     local craft_act = InventoryAction("craft")
1802     craft_act:craft("current_player")
1803     local drop_act = InventoryAction("drop")
1804     drop_act:from("current_player", "craft_result",10)
1805     move_act:apply()
1806     craft_act:apply()
1807     drop_act:apply()
1808     `
1809     * e.g. In first hotbar slot there are tree logs: Move one to craft field, then craft wood out of it and immediately drop it
1810     
1811
1812     
1813