You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

5439 lines
236 KiB

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