X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=a07356d00ad8a3012f8e4be45b72346991069c1a;hb=faa358e797128ab07bb5644ce305a832d59e5596;hp=d7f45fb1b42a1a34f7b524fb54382462e102c11f;hpb=6f22d14206824911b620ecec450689f84e6d278b;p=oweals%2Fminetest.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index d7f45fb1b..a07356d00 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1,10 +1,13 @@ Minetest Lua Modding API Reference ================================== + * More information at * Developer Wiki: + Introduction ------------- +============ + Content and functionality can be added to Minetest using Lua scripting in run-time loaded mods. @@ -19,45 +22,48 @@ functionality in the engine and API, and to document it here. Programming in Lua ------------------ + If you have any difficulty in understanding this, please read [Programming in Lua](http://www.lua.org/pil/). Startup ------- + Mods are loaded during server startup from the mod load paths by running the `init.lua` scripts in a shared environment. Paths ----- + * `RUN_IN_PLACE=1` (Windows release, local build) - * `$path_user`: - * Linux: `` - * Windows: `` - * `$path_share` - * Linux: `` - * Windows: `` + * `$path_user`: `` + * `$path_share`: `` * `RUN_IN_PLACE=0`: (Linux release) - * `$path_share` + * `$path_share`: * Linux: `/usr/share/minetest` * Windows: `/minetest-0.4.x` * `$path_user`: * Linux: `$HOME/.minetest` * Windows: `C:/users//AppData/minetest` (maybe) + + + Games ------ +===== + Games are looked up from: -* `$path_share/games/gameid/` -* `$path_user/games/gameid/` +* `$path_share/games//` +* `$path_user/games//` -Where `gameid` is unique to each game. +Where `` is unique to each game. The game directory can contain the following files: * `game.conf`, with the following keys: - * `name` - required, human readable name e.g. `name = Minetest` - * `description` - Short description to be shown in the content tab + * `name`: Required, human readable name e.g. `name = Minetest` + * `description`: Short description to be shown in the content tab * `disallowed_mapgens = ` e.g. `disallowed_mapgens = v5,v6,flat` These mapgens are removed from the list of mapgens for the game. @@ -71,7 +77,8 @@ The game directory can contain the following files: texturepack, overriding mod textures. Any server texturepack will override mod textures and the game texturepack. -### Menu images +Menu images +----------- Games can provide custom main menu images. They are put inside a `menu` directory inside the game directory. @@ -82,90 +89,85 @@ If you want to specify multiple images for one identifier, add additional images named like `$identifier.$n.png`, with an ascending number $n starting with 1, and a random image will be chosen from the provided ones. -Mod load path -------------- -Generic: -* `$path_share/games/gameid/mods/` -* `$path_share/mods/` -* `$path_user/games/gameid/mods/` -* `$path_user/mods/` (User-installed mods) -* `$worldpath/worldmods/` -In a run-in-place version (e.g. the distributed windows version): -* `minetest-0.4.x/games/gameid/mods/` -* `minetest-0.4.x/mods/` (User-installed mods) -* `minetest-0.4.x/worlds/worldname/worldmods/` +Mods +==== + +Mod load path +------------- -On an installed version on Linux: +Paths are relative to the directories listed in the [Paths] section above. -* `/usr/share/minetest/games/gameid/mods/` -* `$HOME/.minetest/mods/` (User-installed mods) -* `$HOME/.minetest/worlds/worldname/worldmods` +* `games//mods/` +* `mods/` +* `worlds//worldmods/` + +World-specific games +-------------------- -Mod load path for world-specific games --------------------------------------- It is possible to include a game in a world; in this case, no mods or games are loaded or checked from anywhere else. -This is useful for e.g. adventure worlds. - -This happens if the following directory exists: +This is useful for e.g. adventure worlds and happens if the `/game/` +directory exists. - $world/game/ +Mods should then be placed in `/game/mods/`. -Mods should be then be placed in: - - $world/game/mods/ +Modpacks +-------- -Modpack support ----------------- Mods can be put in a subdirectory, if the parent directory, which otherwise should be a mod, contains a file named `modpack.txt`. This file shall be empty, except for lines starting with `#`, which are comments. Mod directory structure ------------------------- +----------------------- mods - |-- modname - | |-- mod.conf - | |-- screenshot.png - | |-- settingtypes.txt - | |-- init.lua - | |-- models - | |-- textures - | | |-- modname_stuff.png - | | `-- modname_something_else.png - | |-- sounds - | |-- media - | |-- locale - | `-- - `-- another + ├── modname + │   ├── mod.conf + │   ├── screenshot.png + │   ├── settingtypes.txt + │   ├── init.lua + │   ├── models + │   ├── textures + │   │   ├── modname_stuff.png + │   │   └── modname_something_else.png + │   ├── sounds + │   ├── media + │   ├── locale + │   └── + └── another ### modname + The location of this directory can be fetched by using `minetest.get_modpath(modname)`. ### mod.conf + A key-value store of mod details. -* `name` - the mod name. Allows Minetest to determine the mod name even if the - folder is wrongly named. -* `description` - Description of mod to be shown in the Mods tab of the mainmenu. -* `depends` - A comma separated list of dependencies. These are mods that must - be loaded before this mod. -* `optional_depends` - A comma separated list of optional dependencies. - Like a dependency, but no error if the mod doesn't exist. +* `name`: The mod name. Allows Minetest to determine the mod name even if the + folder is wrongly named. +* `description`: Description of mod to be shown in the Mods tab of the main + menu. +* `depends`: A comma separated list of dependencies. These are mods that must be + loaded before this mod. +* `optional_depends`: A comma separated list of optional dependencies. + Like a dependency, but no error if the mod doesn't exist. Note: to support 0.4.x, please also provide depends.txt. ### `screenshot.png` + A screenshot shown in the mod manager within the main menu. It should have an aspect ratio of 3:2 and a minimum size of 300×200 pixels. ### `depends.txt` + **Deprecated:** you should use mod.conf instead. This file is used if there are no dependencies in mod.conf. @@ -179,39 +181,46 @@ to a single modname. This means that if the specified mod is missing, it does not prevent this mod from being loaded. ### `description.txt` + **Deprecated:** you should use mod.conf instead. This file is used if there is no description in mod.conf. -A file containing a description to be shown in the Mods tab of the mainmenu. +A file containing a description to be shown in the Mods tab of the main menu. ### `settingtypes.txt` + A file in the same format as the one in builtin. It will be parsed by the settings menu and the settings will be displayed in the "Mods" category. ### `init.lua` + The main Lua script. Running this script should register everything it wants to register. Subsequent execution depends on minetest calling the registered callbacks. `minetest.settings` can be used to read custom or existing settings at load -time, if necessary. (See `Settings`) +time, if necessary. (See [`Settings`]) ### `models` + Models for entities or meshnodes. ### `textures`, `sounds`, `media` + Media files (textures, sounds, whatever) that will be transferred to the client and will be available for use by the mod. ### `locale` -Translation files for the clients. (See `Translations`) -Naming convention for registered textual names ----------------------------------------------- +Translation files for the clients. (See [Translations]) + +Naming conventions +------------------ + Registered names should generally be in this format: - `modname:` + modname: `` can have these characters: @@ -220,24 +229,29 @@ Registered names should generally be in this format: This is to prevent conflicting names from corrupting maps and is enforced by the mod loader. +Registered names can be overridden by prefixing the name with `:`. This can +be used for overriding the registrations of some other mod. + +The `:` prefix can also be used for maintaining backwards compatibility. + ### Example + In the mod `experimental`, there is the ideal item/node/entity name `tnt`. So the name should be `experimental:tnt`. -Enforcement can be overridden by prefixing the name with `:`. This can -be used for overriding the registrations of some other mod. - -Example: Any mod can redefine `experimental:tnt` by using the name +Any mod can redefine `experimental:tnt` by using the name :experimental:tnt -when registering it. -(also that mod is required to have `experimental` as a dependency) +when registering it. That mod is required to have `experimental` as a +dependency. + + -The `:` prefix can also be used for maintaining backwards compatibility. Aliases -------- +======= + Aliases can be added by using `minetest.register_alias(name, convert_to)` or `minetest.register_alias_force(name, convert_to)`. @@ -259,75 +273,88 @@ and be able to use `/giveme stuff`. Mapgen aliases -------------- + In a game, a certain number of these must be set to tell core mapgens which of the game's nodes are to be used by the core mapgens. For example: minetest.register_alias("mapgen_stone", "default:stone") -### Aliases needed for all mapgens except Mapgen v6 +### Aliases needed for all mapgens except Mapgen V6 + +#### Base terrain + +* mapgen_stone +* mapgen_water_source +* mapgen_river_water_source + +#### Caves + +Not required if cave liquid nodes are set in biome definitions. -Base terrain: +* mapgen_lava_source -"mapgen_stone" -"mapgen_water_source" -"mapgen_river_water_source" +#### Dungeons -Caves: +Not required if dungeon nodes are set in biome definitions. -"mapgen_lava_source" +* mapgen_cobble +* mapgen_stair_cobble +* mapgen_mossycobble +* mapgen_desert_stone +* mapgen_stair_desert_stone +* mapgen_sandstone +* mapgen_sandstonebrick +* mapgen_stair_sandstone_block -Dungeons: +### Aliases needed for Mapgen V6 -Only needed for registered biomes where 'node_stone' is stone: -"mapgen_cobble" -"mapgen_stair_cobble" -"mapgen_mossycobble" -Only needed for registered biomes where 'node_stone' is desert stone: -"mapgen_desert_stone" -"mapgen_stair_desert_stone" -Only needed for registered biomes where 'node_stone' is sandstone: -"mapgen_sandstone" -"mapgen_sandstonebrick" -"mapgen_stair_sandstone_block" +#### Terrain and biomes -### Aliases needed for Mapgen v6 +* mapgen_stone +* mapgen_water_source +* mapgen_lava_source +* mapgen_dirt +* mapgen_dirt_with_grass +* mapgen_sand +* mapgen_gravel +* mapgen_desert_stone +* mapgen_desert_sand +* mapgen_dirt_with_snow +* mapgen_snowblock +* mapgen_snow +* mapgen_ice -Terrain and biomes: +#### Flora -"mapgen_stone" -"mapgen_water_source" -"mapgen_lava_source" -"mapgen_dirt" -"mapgen_dirt_with_grass" -"mapgen_sand" -"mapgen_gravel" -"mapgen_desert_stone" -"mapgen_desert_sand" -"mapgen_dirt_with_snow" -"mapgen_snowblock" -"mapgen_snow" -"mapgen_ice" +* mapgen_tree +* mapgen_leaves +* mapgen_apple +* mapgen_jungletree +* mapgen_jungleleaves +* mapgen_junglegrass +* mapgen_pine_tree +* mapgen_pine_needles -Flora: +#### Dungeons + +* mapgen_cobble +* mapgen_stair_cobble +* mapgen_mossycobble +* mapgen_stair_desert_stone + +### Setting the node used in Mapgen Singlenode + +By default the world is filled with air nodes. To set a different node use, for +example: + + minetest.register_alias("mapgen_singlenode", "default:stone") -"mapgen_tree" -"mapgen_leaves" -"mapgen_apple" -"mapgen_jungletree" -"mapgen_jungleleaves" -"mapgen_junglegrass" -"mapgen_pine_tree" -"mapgen_pine_needles" -Dungeons: -"mapgen_cobble" -"mapgen_stair_cobble" -"mapgen_mossycobble" -"mapgen_stair_desert_stone" Textures --------- +======== + Mods should generally prefix their textures with `modname_`, e.g. given the mod name `foomod`, a texture could be called: @@ -341,10 +368,12 @@ stripping out the file extension: Texture modifiers ----------------- + There are various texture modifiers that can be used to generate textures on-the-fly. ### Texture overlaying + Textures can be overlaid by putting a `^` between them. Example: @@ -356,6 +385,7 @@ The texture with the lower resolution will be automatically upscaled to the higher resolution texture. ### Texture grouping + Textures can be grouped together by enclosing them in `(` and `)`. Example: `cobble.png^(thing1.png^thing2.png)` @@ -364,6 +394,7 @@ A texture for `thing1.png^thing2.png` is created and the resulting texture is overlaid on top of `cobble.png`. ### Escaping + Modifiers that accept texture names (e.g. `[combine`) accept escaping to allow passing complex texture names as arguments. Escaping is done with backslash and is required for `^` and `:`. @@ -376,15 +407,17 @@ on top of `cobble.png`. ### Advanced texture modifiers #### Crack + * `[crack::

` * `[cracko::

` * `[crack:::

` * `[cracko:::

` Parameters: -* `` = tile count (in each direction) -* `` = animation frame count -* `

` = current animation frame + +* ``: tile count (in each direction) +* ``: animation frame count +* `

`: current animation frame Draw a step of the crack animation on the texture. `crack` draws it normally, while `cracko` lays it over, keeping transparent @@ -395,11 +428,12 @@ Example: default_cobble.png^[crack:10:1 #### `[combine:x:,=:,=:...` -* `` = width -* `` = height -* `` = x position -* `` = y position -* `` = texture to combine + +* ``: width +* ``: height +* ``: x position +* ``: y position +* ``: texture to combine Creates a texture of size `` times `` and blits the listed files to their specified coordinates. @@ -409,6 +443,7 @@ Example: [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png #### `[resize:x` + Resizes the texture to the given dimensions. Example: @@ -416,16 +451,17 @@ Example: default_sandstone.png^[resize:16x16 #### `[opacity:` + Makes the base image transparent according to the given ratio. -`r` must be between 0 and 255. -0 means totally transparent. 255 means totally opaque. +`r` must be between 0 (transparent) and 255 (opaque). Example: default_sandstone.png^[opacity:127 #### `[invert:` + Inverts the given channels of the base image. Mode may contain the characters "r", "g", "b", "a". Only the channels that are mentioned in the mode string will be inverted. @@ -435,6 +471,7 @@ Example: default_apple.png^[invert:rgb #### `[brighten` + Brightens the texture. Example: @@ -442,6 +479,7 @@ Example: tnt_tnt_side.png^[brighten #### `[noalpha` + Makes the texture completely opaque. Example: @@ -449,6 +487,7 @@ Example: default_leaves.png^[noalpha #### `[makealpha:,,` + Convert one color to transparency. Example: @@ -456,7 +495,8 @@ Example: default_cobble.png^[makealpha:128,128,128 #### `[transform` -* `` = transformation(s) to apply + +* ``: transformation(s) to apply Rotates and/or flips the image. @@ -477,6 +517,7 @@ Example: default_stone.png^[transformFXR90 #### `[inventorycube{{{` + Escaping does not apply here and `^` is replaced by `&` in texture names instead. @@ -490,6 +531,7 @@ Creates an inventorycube with `grass.png`, `dirt.png^grass_side.png` and `dirt.png^grass_side.png` textures #### `[lowpart::` + Blit the lower ``% part of `` on the texture. Example: @@ -497,8 +539,9 @@ Example: base.png^[lowpart:25:overlay.png #### `[verticalframe::` -* `` = animation frame count -* `` = current animation frame + +* ``: animation frame count +* ``: current animation frame Crops the texture to a frame of a vertical animation. @@ -507,16 +550,18 @@ Example: default_torch_animated.png^[verticalframe:16:8 #### `[mask:` + Apply a mask to the base image. The mask is applied using binary AND. #### `[sheet:x:,` + Retrieves a tile at position x,y from the base image which it assumes to be a tilesheet with dimensions w,h. - #### `[colorize::` + Colorize the textures with the given color. `` is specified as a `ColorString`. `` is an int ranging from 0 to 255 or the word "`alpha`". If @@ -528,14 +573,16 @@ the word "`alpha`", then each texture pixel will contain the RGB of texture pixel. #### `[multiply:` + Multiplies texture colors with the given color. `` is specified as a `ColorString`. Result is more like what you'd expect if you put a color on top of another -color. Meaning white surfaces get a lot of your new color while black parts +color, meaning white surfaces get a lot of your new color while black parts don't change very much. Hardware coloring ----------------- + The goal of hardware coloring is to simplify the creation of colorful nodes. If your textures use the same pattern, and they only differ in their color (like colored wool blocks), you can use hardware @@ -544,30 +591,35 @@ All of these methods use color multiplication (so a white-black texture with red coloring will result in red-black color). ### Static coloring + This method is useful if you wish to create nodes/items with the same texture, in different colors, each in a new node/item definition. #### Global color + When you register an item or node, set its `color` field (which accepts a `ColorSpec`) to the desired color. -An `ItemStack`s static color can be overwritten by the `color` metadata +An `ItemStack`'s static color can be overwritten by the `color` metadata field. If you set that field to a `ColorString`, that color will be used. #### Tile color + Each tile may have an individual static color, which overwrites every -other coloring methods. To disable the coloring of a face, +other coloring method. To disable the coloring of a face, set its color to white (because multiplying with white does nothing). You can set the `color` property of the tiles in the node's definition if the tile is in table format. ### Palettes + For nodes and items which can have many colors, a palette is more suitable. A palette is a texture, which can contain up to 256 pixels. Each pixel is one possible color for the node/item. You can register one node/item, which can have up to 256 colors. #### Palette indexing + When using palettes, you always provide a pixel index for the given node or `ItemStack`. The palette is read from left to right and from top to bottom. If the palette has less than 256 pixels, then it is @@ -580,14 +632,15 @@ Examples: * 16x16 palette, index = 4: the fifth pixel in the first row * 16x16 palette, index = 16: the pixel below the top left corner * 16x16 palette, index = 255: the bottom right corner -* 2 (width)x4 (height) palette, index=31: the top left corner. +* 2 (width) x 4 (height) palette, index = 31: the top left corner. The palette has 8 pixels, so each pixel is stretched to 32 pixels, to ensure the total 256 pixels. -* 2x4 palette, index=32: the top right corner -* 2x4 palette, index=63: the top right corner -* 2x4 palette, index=64: the pixel below the top left corner +* 2x4 palette, index = 32: the top right corner +* 2x4 palette, index = 63: the top right corner +* 2x4 palette, index = 64: the pixel below the top left corner #### Using palettes with items + When registering an item, set the item definition's `palette` field to a texture. You can also use texture modifiers. @@ -596,6 +649,7 @@ stack's metadata. `palette_index` is an integer, which specifies the index of the pixel to use. #### Linking palettes with nodes + When registering a node, set the item definition's `palette` field to a texture. You can also use texture modifiers. The node's color depends on its `param2`, so you also must set an @@ -630,7 +684,8 @@ appropriate `paramtype2`: To colorize a node on the map, set its `param2` value (according to the node's paramtype2). -### Conversion between nodes in the inventory and the on the map +### Conversion between nodes in the inventory and on the map + Static coloring is the same for both cases, there is no need for conversion. @@ -660,6 +715,7 @@ Example: }) ### Colored items in craft recipes + Craft recipes only support item strings, but fortunately item strings can also contain metadata. Example craft recipe registration: @@ -679,6 +735,7 @@ so the craft output is independent of the color of the ingredients. Soft texture overlay -------------------- + Sometimes hardware coloring is not enough, because it affects the whole tile. Soft texture overlays were added to Minetest to allow the dynamic coloring of only specific parts of the node's texture. @@ -719,8 +776,12 @@ Example (colored grass block): palette = "default_foilage.png", }) + + + Sounds ------- +====== + Only Ogg Vorbis files are supported. For positional playing of sounds, only single-channel (mono) files are @@ -748,41 +809,43 @@ Examples of sound parameter tables: -- Play locationless on all clients { - gain = 1.0, -- default - fade = 0.0, -- default, change to a value > 0 to fade the sound in - pitch = 1.0, -- default + gain = 1.0, -- default + fade = 0.0, -- default, change to a value > 0 to fade the sound in + pitch = 1.0, -- default } -- Play locationless to one player { to_player = name, - gain = 1.0, -- default - fade = 0.0, -- default, change to a value > 0 to fade the sound in - pitch = 1.0, -- default + gain = 1.0, -- default + fade = 0.0, -- default, change to a value > 0 to fade the sound in + pitch = 1.0, -- default } -- Play locationless to one player, looped { to_player = name, - gain = 1.0, -- default + gain = 1.0, -- default loop = true, } -- Play in a location { pos = {x = 1, y = 2, z = 3}, - gain = 1.0, -- default - max_hear_distance = 32, -- default, uses an euclidean metric + gain = 1.0, -- default + max_hear_distance = 32, -- default, uses an euclidean metric } -- Play connected to an object, looped { object = , - gain = 1.0, -- default - max_hear_distance = 32, -- default, uses an euclidean metric + gain = 1.0, -- default + max_hear_distance = 32, -- default, uses an euclidean metric loop = true, } Looped sounds must either be connected to an object or played locationless to one player using `to_player = name,` -### `SimpleSoundSpec` +`SimpleSoundSpec` +----------------- + * e.g. `""` * e.g. `"default_place_node"` * e.g. `{}` @@ -790,12 +853,16 @@ one player using `to_player = name,` * e.g. `{name = "default_place_node", gain = 1.0}` * e.g. `{name = "default_place_node", gain = 1.0, pitch = 1.0}` -Registered definitions of stuff -------------------------------- -Anything added using certain `minetest.register_*` functions get added to + + + +Registered definitions +====================== + +Anything added using certain `minetest.register_*` functions gets added to the global `minetest.registered_*` tables. -* `minetest.register_entity(name, prototype table)` +* `minetest.register_entity(name, entity definition)` * added to `minetest.registered_entities[name]` * `minetest.register_node(name, node definition)` @@ -810,8 +877,8 @@ the global `minetest.registered_*` tables. * `minetest.unregister_item(name)` * Unregisters the item name from engine, and deletes the entry with key - * `name` from `minetest.registered_items` and from the associated item - * table according to its nature: `minetest.registered_nodes[]` etc + `name` from `minetest.registered_items` and from the associated item + table according to its nature: `minetest.registered_nodes[]` etc * `minetest.register_biome(biome definition)` * returns an integer uniquely identifying the registered biome @@ -820,7 +887,7 @@ the global `minetest.registered_*` tables. * `minetest.unregister_biome(name)` * Unregisters the biome name from engine, and deletes the entry with key - * `name` from `minetest.registered_biome` + `name` from `minetest.registered_biome` * `minetest.register_ore(ore definition)` * returns an integer uniquely identifying the registered ore @@ -869,27 +936,21 @@ Example: If you want to check the drawtype of a node, you could do: end local drawtype = get_nodedef_field(nodename, "drawtype") -Example: `minetest.get_item_group(name, group)` has been implemented as: - function minetest.get_item_group(name, group) - if not minetest.registered_items[name] or not - minetest.registered_items[name].groups[group] then - return 0 - end - return minetest.registered_items[name].groups[group] - end + Nodes ------ +===== + Nodes are the bulk data of the world: cubes and other things that take the space of a cube. Huge amounts of them are handled efficiently, but they are quite static. -The definition of a node is stored and can be accessed by name in +The definition of a node is stored and can be accessed by using minetest.registered_nodes[node.name] -See "Registered definitions of stuff". +See [Registered definitions]. Nodes are passed by value between Lua and the engine. They are represented by a table: @@ -900,101 +961,104 @@ They are represented by a table: them for certain automated functions. If you don't use these functions, you can use them to store arbitrary values. +Node paramtypes +--------------- + The functions of `param1` and `param2` are determined by certain fields in the -node definition: +node definition. `param1` is reserved for the engine when `paramtype != "none"`: - paramtype = "light" - ^ The value stores light with and without sun in its upper and lower 4 bits +* `paramtype = "light"` + * The value stores light with and without sun in its upper and lower 4 bits respectively. - Required by a light source node to enable spreading its light. - Required by the following drawtypes as they determine their visual + * Required by a light source node to enable spreading its light. + * Required by the following drawtypes as they determine their visual brightness from their internal light value: - torchlike, - signlike, - firelike, - fencelike, - raillike, - nodebox, - mesh, - plantlike, - plantlike_rooted. + * torchlike + * signlike + * firelike + * fencelike + * raillike + * nodebox + * mesh + * plantlike + * plantlike_rooted `param2` is reserved for the engine when any of these are used: - liquidtype == "flowing" - ^ The level and some flags of the liquid is stored in param2 - drawtype == "flowingliquid" - ^ The drawn liquid level is read from param2 - drawtype == "torchlike" - drawtype == "signlike" - paramtype2 == "wallmounted" - ^ The rotation of the node is stored in param2. You can make this value - by using minetest.dir_to_wallmounted(). - paramtype2 == "facedir" - ^ The rotation of the node is stored in param2. Furnaces and chests are - rotated this way. Can be made by using minetest.dir_to_facedir(). - Values range 0 - 23 - facedir / 4 = axis direction: - 0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y- - facedir modulo 4 = rotation around that axis - paramtype2 == "leveled" - ^ Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted". - Leveled nodebox: - The level of the top face of the nodebox is stored in param2. - The other faces are defined by 'fixed = {}' like 'type = "fixed"' - nodeboxes. - The nodebox height is (param2 / 64) nodes. - The maximum accepted value of param2 is 127. - Rooted plantlike: - The height of the 'plantlike' section is stored in param2. - The height is (param2 / 16) nodes. - paramtype2 == "degrotate" - ^ Only valid for "plantlike". The rotation of the node is stored in param2. - Values range 0 - 179. The value stored in param2 is multiplied by two to +* `liquidtype = "flowing"` + * The level and some flags of the liquid is stored in `param2` +* `drawtype = "flowingliquid"` + * The drawn liquid level is read from `param2` +* `drawtype = "torchlike"` +* `drawtype = "signlike"` +* `paramtype2 = "wallmounted"` + * The rotation of the node is stored in `param2`. You can make this value + by using `minetest.dir_to_wallmounted()`. +* `paramtype2 = "facedir"` + * The rotation of the node is stored in `param2`. Furnaces and chests are + rotated this way. Can be made by using `minetest.dir_to_facedir()`. + * Values range 0 - 23 + * facedir / 4 = axis direction: + 0 = y+, 1 = z+, 2 = z-, 3 = x+, 4 = x-, 5 = y- + * facedir modulo 4 = rotation around that axis +* `paramtype2 = "leveled"` + * Only valid for "nodebox" with 'type = "leveled"', and "plantlike_rooted". + * Leveled nodebox: + * The level of the top face of the nodebox is stored in `param2`. + * The other faces are defined by 'fixed = {}' like 'type = "fixed"' + nodeboxes. + * The nodebox height is (`param2` / 64) nodes. + * The maximum accepted value of `param2` is 127. + * Rooted plantlike: + * The height of the 'plantlike' section is stored in `param2`. + * The height is (`param2` / 16) nodes. +* `paramtype2 = "degrotate"` + * Only valid for "plantlike". The rotation of the node is stored in + `param2`. + * Values range 0 - 179. The value stored in `param2` is multiplied by two to get the actual rotation in degrees of the node. - paramtype2 == "meshoptions" - ^ Only valid for "plantlike". The value of param2 becomes a bitfield which +* `paramtype2 = "meshoptions"` + * Only valid for "plantlike". The value of `param2` becomes a bitfield which can be used to change how the client draws plantlike nodes. - Bits 0, 1 and 2 form a mesh selector. + * Bits 0, 1 and 2 form a mesh selector. Currently the following meshes are choosable: - 0 = a "x" shaped plant (ordinary plant) - 1 = a "+" shaped plant (just rotated 45 degrees) - 2 = a "*" shaped plant with 3 faces instead of 2 - 3 = a "#" shaped plant with 4 faces instead of 2 - 4 = a "#" shaped plant with 4 faces that lean outwards - 5-7 are unused and reserved for future meshes. - Bits 3 through 7 are optional flags that can be combined and give these + * 0 = a "x" shaped plant (ordinary plant) + * 1 = a "+" shaped plant (just rotated 45 degrees) + * 2 = a "*" shaped plant with 3 faces instead of 2 + * 3 = a "#" shaped plant with 4 faces instead of 2 + * 4 = a "#" shaped plant with 4 faces that lean outwards + * 5-7 are unused and reserved for future meshes. + * Bits 3 through 7 are optional flags that can be combined and give these effects: - bit 3 (0x08) - Makes the plant slightly vary placement horizontally - bit 4 (0x10) - Makes the plant mesh 1.4x larger - bit 5 (0x20) - Moves each face randomly a small bit down (1/8 max) - bits 6-7 are reserved for future use. - paramtype2 == "color" - ^ `param2` tells which color is picked from the palette. + * bit 3 (0x08) - Makes the plant slightly vary placement horizontally + * bit 4 (0x10) - Makes the plant mesh 1.4x larger + * bit 5 (0x20) - Moves each face randomly a small bit down (1/8 max) + * bits 6-7 are reserved for future use. +* `paramtype2 = "color"` + * `param2` tells which color is picked from the palette. The palette should have 256 pixels. - paramtype2 == "colorfacedir" - ^ Same as `facedir`, but with colors. - The first three bits of `param2` tells which color - is picked from the palette. - The palette should have 8 pixels. - paramtype2 == "colorwallmounted" - ^ Same as `wallmounted`, but with colors. - The first five bits of `param2` tells which color - is picked from the palette. - The palette should have 32 pixels. - paramtype2 == "glasslikeliquidlevel" - ^ Only valid for "glasslike_framed" or "glasslike_framed_optional" +* `paramtype2 = "colorfacedir"` + * Same as `facedir`, but with colors. + * The first three bits of `param2` tells which color is picked from the + palette. The palette should have 8 pixels. +* `paramtype2 = "colorwallmounted"` + * Same as `wallmounted`, but with colors. + * The first five bits of `param2` tells which color is picked from the + palette. The palette should have 32 pixels. +* `paramtype2 = "glasslikeliquidlevel"` + * Only valid for "glasslike_framed" or "glasslike_framed_optional" drawtypes. - param2 values 0-63 define 64 levels of internal liquid, 0 being empty and - 63 being full. - Liquid texture is defined using `special_tiles = {"modname_tilename.png"},` + * `param2` values 0-63 define 64 levels of internal liquid, 0 being empty + and 63 being full. + * Liquid texture is defined using `special_tiles = {"modname_tilename.png"}` -Nodes can also contain extra data. See "Node Metadata". +Nodes can also contain extra data. See [Node Metadata]. Node drawtypes -------------- + There are a bunch of different looking node types. Look for examples in `games/minimal` or `games/minetest_game`. @@ -1013,7 +1077,7 @@ Look for examples in `games/minimal` or `games/minetest_game`. * `glasslike_framed` * All face-connected nodes are drawn as one volume within a surrounding frame. - * The frame appearence is generated from the edges of the first texture + * The frame appearance is generated from the edges of the first texture specified in `tiles`. The width of the edges used are 1/16th of texture size: 1 pixel for 16x16, 2 pixels for 32x32 etc. * The glass 'shine' (or other desired detail) on each node face is supplied @@ -1043,7 +1107,7 @@ Look for examples in `games/minimal` or `games/minetest_game`. side of a node. * `plantlike` * Two vertical and diagonal textures at right-angles to each other. - * See `paramtype2 == "meshoptions"` above for other options. + * See `paramtype2 = "meshoptions"` above for other options. * `firelike` * When above a flat surface, appears as 6 textures, the central 2 as `plantlike` plus 4 more surrounding those. @@ -1064,7 +1128,7 @@ Look for examples in `games/minimal` or `games/minetest_game`. * `nodebox` * Often used for stairs and slabs. * Allows defining nodes consisting of an arbitrary number of boxes. - * See 'Node boxes' below for more information. + * See [Node boxes] below for more information. * `mesh` * Uses models for nodes. * Tiles should hold model materials textures. @@ -1085,6 +1149,7 @@ Look for examples in `games/minimal` or `games/minetest_game`. Node boxes ---------- + Node selection boxes are defined using "node boxes". A nodebox is defined as any of: @@ -1136,7 +1201,7 @@ A nodebox is defined as any of: disconnected_right = box OR {box1, box2, ...} disconnected = box OR {box1, box2, ...} -- when there is *no* neighbour disconnected_sides = box OR {box1, box2, ...} -- when there are *no* - neighbours to the sides + -- neighbours to the sides } A `box` is defined as: @@ -1149,8 +1214,13 @@ A box of a regular node would look like: + +HUD +=== + HUD element types ----------------- + The position field is used for all element types. To account for differing resolutions, the position coordinates are the @@ -1189,6 +1259,7 @@ Displays an image on the HUD. * `offset`: offset in pixels from position. ### `text` + Displays text on the HUD. * `scale`: Defines the bounding rectangle of the text. @@ -1200,6 +1271,7 @@ Displays text on the HUD. * `offset`: offset in pixels from position. ### `statbar` + Displays a horizontal bar made up of half-images. * `text`: The name of the texture that is used. @@ -1211,6 +1283,7 @@ Displays a horizontal bar made up of half-images. pack image size) ### `inventory` + * `text`: The name of the inventory list to be displayed. * `number`: Number of items in the inventory to be displayed. * `item`: Position of item that is selected. @@ -1218,6 +1291,7 @@ Displays a horizontal bar made up of half-images. * `offset`: offset in pixels from position. ### `waypoint` + Displays distance to selected world position. * `name`: The name of the waypoint. @@ -1226,22 +1300,43 @@ Displays distance to selected world position. text. * `world_pos`: World position of the waypoint. + + + Representations of simple things --------------------------------- +================================ -### Position/vector +Position/vector +--------------- {x=num, y=num, z=num} -For helper functions see "Spatial Vectors". +For helper functions see [Spatial Vectors]. + +`pointed_thing` +--------------- -### `pointed_thing` * `{type="nothing"}` * `{type="node", under=pos, above=pos}` * `{type="object", ref=ObjectRef}` +Exact pointing location (currently only `Raycast` supports these fields): +* `pointed_thing.intersection_point`: The absolute world coordinates of the + point on the selection box which is pointed at. May be in the selection box + if the pointer is in the box too. +* `pointed_thing.box_id`: The ID of the pointed selection box (counting starts + from 1). +* `pointed_thing.intersection_normal`: Unit vector, points outwards of the + selected selection box. This specifies which face is pointed at. + Is a null vector `{x = 0, y = 0, z = 0}` when the pointer is inside the + selection box. + + + + Flag Specifier Format ---------------------- +===================== + Flags using the standardized flag specifier format can be specified in either of two ways, by string or table. @@ -1273,31 +1368,44 @@ or even since, by default, no schematic attributes are set. + + + Items ------ +===== + +Item types +---------- -### Item types There are three kinds of items: nodes, tools and craftitems. -* Node (`register_node`): A node from the world. -* Tool (`register_tool`): A tool/weapon that can dig and damage - things according to `tool_capabilities`. -* Craftitem (`register_craftitem`): A miscellaneous item. +* Node: Can be placed in the world's voxel grid +* Tool: Has a wear property but cannot be stacked. The default use action is to + dig nodes or hit objects according to its tool capabilities. +* Craftitem: Cannot dig nodes or be placed + +Amount and wear +--------------- -### Amount and wear -All item stacks have an amount between 0 to 65535. It is 1 by +All item stacks have an amount between 0 and 65535. It is 1 by default. Tool item stacks can not have an amount greater than 1. -Tools use a wear (=damage) value ranging from 0 to 65535. The -value 0 is the default and used is for unworn tools. The values +Tools use a wear (damage) value ranging from 0 to 65535. The +value 0 is the default and is used for unworn tools. The values 1 to 65535 are used for worn tools, where a higher value stands for a higher wear. Non-tools always have a wear value of 0. -### Item formats +Item formats +------------ + Items and item stacks can exist in three formats: Serializes, table format and `ItemStack`. -#### Serialized +When an item must be passed to a function, it can usually be in any of +these formats. + +### Serialized + This is called "stackstring" or "itemstring". It is a simple string with 1-3 components: the full item identifier, an optional amount and an optional wear value. Syntax: @@ -1311,7 +1419,8 @@ Examples: * `'default:pick_stone'`: a new stone pickaxe * `'default:pick_wood 1 21323'`: a wooden pickaxe, ca. 1/3 worn out -#### Table format +### Table format + Examples: 5 dirt nodes: @@ -1326,30 +1435,33 @@ An apple: {name="default:apple", count=1, wear=0, metadata=""} -#### `ItemStack` +### `ItemStack` + A native C++ format with many helper methods. Useful for converting -between formats. See the Class reference section for details. +between formats. See the [Class reference] section for details. + -When an item must be passed to a function, it can usually be in any of -these formats. Groups ------- +====== + In a number of places, there is a group table. Groups define the properties of a thing (item, node, armor of entity, capabilities of tool) in such a way that the engine and other mods can can interact with the thing without actually knowing what the thing is. -### Usage +Usage +----- + Groups are stored in a table, having the group names with keys and the group ratings as values. For example: + -- Default dirt groups = {crumbly=3, soil=1} - -- ^ Default dirt + -- A more special dirt-kind of thing groups = {crumbly=2, soil=1, level=2, outerspace=1} - -- ^ A more special dirt-kind of thing Groups always have a rating associated with them. If there is no useful meaning for a rating for an enabled group, it shall be `1`. @@ -1361,26 +1473,36 @@ You can read the rating of a group for an item or a node by using minetest.get_item_group(itemname, groupname) -### Groups of items +Groups of items +--------------- + Groups of items can define what kind of an item it is (e.g. wool). -### Groups of nodes +Groups of nodes +--------------- + In addition to the general item things, groups are used to define whether a node is destroyable and how long it takes to destroy by a tool. -### Groups of entities +Groups of entities +------------------ + For entities, groups are, as of now, used only for calculating damage. The rating is the percentage of damage caused by tools with this damage group. -See "Entity damage mechanism". +See [Entity damage mechanism]. object.get_armor_groups() --> a group-rating table (e.g. {fleshy=100}) object.set_armor_groups({fleshy=30, cracky=80}) -### Groups of tools +Groups of tools +--------------- + Groups in tools define which groups of nodes and entities they are effective towards. -### Groups in crafting recipes +Groups in crafting recipes +-------------------------- + An example: Make meat soup from any meat, any water and any bowl: { @@ -1401,7 +1523,9 @@ Another example: Make red wool from white wool and red dye: recipe = {'wool:white', 'group:dye,basecolor_red'}, } -### Special groups +Special groups +-------------- + * `immortal`: Disables the group damage system for an entity * `punch_operable`: For entities; disables the regular damage mechanism for players punching it by hand or a non-tool item, so that it can do something @@ -1412,7 +1536,7 @@ Another example: Make red wool from white wool and red dye: from destroyed nodes. * `0` is something that is directly accessible at the start of gameplay * There is no upper limit -* `dig_immediate`: (player can always pick up node without reducing tool wear) +* `dig_immediate`: Player can always pick up node without reducing tool wear * `2`: the node always gets the digging time 0.5 seconds (rail, sign) * `3`: the node always gets the digging time 0 seconds (torch) * `disable_jump`: Player (and possibly other things) cannot jump from node @@ -1427,9 +1551,13 @@ Another example: Make red wool from white wool and red dye: connect to each other * `slippery`: Players and items will slide on the node. Slipperiness rises steadily with `slippery` value, starting at 1. +* `disable_repair`: If set to 1 for a tool, it cannot be repaired using the + `"toolrepair"` crafting recipe -### Known damage and digging time defining groups +Known damage and digging time defining groups +--------------------------------------------- + * `crumbly`: dirt, sand * `cracky`: tough but crackable stuff like stone. * `snappy`: something that can be cut using fine tools; e.g. leaves, small @@ -1445,7 +1573,9 @@ Another example: Make red wool from white wool and red dye: speed of a tool if the tool can dig at a faster speed than this suggests for the hand. -### Examples of custom groups +Examples of custom groups +------------------------- + Item groups are often used for defining, well, _groups of items_. * `meat`: any meat-kind of a thing (rating might define the size or healing @@ -1459,7 +1589,9 @@ Item groups are often used for defining, well, _groups of items_. * `weapon`: any weapon * `heavy`: anything considerably heavy -### Digging time calculation specifics +Digging time calculation specifics +---------------------------------- + Groups such as `crumbly`, `cracky` and `snappy` are used for this purpose. Rating is `1`, `2` or `3`. A higher rating for such a group implies faster digging time. @@ -1474,7 +1606,15 @@ Tools define their properties by a list of parameters for groups. They cannot dig other groups; thus it is important to use a standard bunch of groups to enable interaction with tools. -#### Tools definition + + + +Tools +===== + +Tools definition +---------------- + Tools define: * Full punch interval @@ -1485,19 +1625,22 @@ Tools define: * Digging times * Damage groups -#### Full punch interval +### Full punch interval + When used as a weapon, the tool will do full damage if this time is spent between punches. If e.g. half the time is spent, the tool will do half damage. -#### Maximum drop level +### Maximum drop level + Suggests the maximum level of node, when dug with the tool, that will drop it's useful item. (e.g. iron ore to drop a lump of iron). This is not automated; it is the responsibility of the node definition to implement this. -#### Uses +### Uses + Determines how many uses the tool has when it is used for digging a node, of this group, of the maximum level. For lower leveled nodes, the use count is multiplied by `3^leveldiff`. @@ -1506,11 +1649,13 @@ is multiplied by `3^leveldiff`. * `uses=10, leveldiff=1`: actual uses: 30 * `uses=10, leveldiff=2`: actual uses: 90 -#### Maximum level +### Maximum level + Tells what is the maximum level of a node of this group that the tool will be able to dig. -#### Digging times +### Digging times + List of digging times for different ratings of the group, for nodes of the maximum level. @@ -1523,10 +1668,12 @@ If the result digging time is 0, a delay of 0.15 seconds is added between digging nodes; If the player releases LMB after digging, this delay is set to 0, i.e. players can more quickly click the nodes away instead of holding LMB. -#### Damage groups -List of damage for groups of entities. See "Entity damage mechanism". +### Damage groups -#### Example definition of the capabilities of a tool +List of damage for groups of entities. See [Entity damage mechanism]. + +Example definition of the capabilities of a tool +------------------------------------------------ tool_capabilities = { full_punch_interval=1.5, @@ -1566,14 +1713,18 @@ Table of resulting tool uses: easy nodes to be quickly breakable. * At `level > 2`, the node is not diggable, because it's `level > maxlevel` + + + Entity damage mechanism ------------------------ +======================= + Damage calculation: damage = 0 foreach group in cap.damage_groups: - damage += cap.damage_groups[group] * limit(actual_interval / - cap.full_punch_interval, 0.0, 1.0) + damage += cap.damage_groups[group] + * limit(actual_interval / cap.full_punch_interval, 0.0, 1.0) * (object.armor_groups[group] / 100.0) -- Where object.armor_groups[group] is 0 for inexistent values return damage @@ -1592,7 +1743,8 @@ a non-tool item, so that it can do something else than take damage. On the Lua side, every punch calls: - entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, damage) + entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, + damage) This should never be called directly, because damage is usually not handled by the entity itself. @@ -1616,11 +1768,18 @@ To punch an entity/object in Lua, call: * If `direction` equals `nil` and `puncher` does not equal `nil`, `direction` will be automatically filled in based on the location of `puncher`. + + + +Metadata +======== + Node Metadata ------------- + The instance of a node in the world normally only contains the three values -mentioned in "Nodes". However, it is possible to insert extra data into a -node. It is called "node metadata"; See `NodeMetaRef`. +mentioned in [Nodes]. However, it is possible to insert extra data into a node. +It is called "node metadata"; See `NodeMetaRef`. Node metadata contains two things: @@ -1629,10 +1788,10 @@ Node metadata contains two things: Some of the values in the key-value store are handled specially: -* `formspec`: Defines a right-click inventory menu. See "Formspec". +* `formspec`: Defines a right-click inventory menu. See [Formspec]. * `infotext`: Text shown on the screen when the node is pointed at -Example stuff: +Example: local meta = minetest.get_meta(pos) meta:set_string("formspec", @@ -1662,7 +1821,8 @@ Example stuff: Item Metadata ------------- -Item stacks can store metadata too. See `ItemStackMetaRef`. + +Item stacks can store metadata too. See [`ItemStackMetaRef`]. Item metadata only contains a key-value store. @@ -1674,33 +1834,45 @@ Some of the values in the key-value store are handled specially: * `palette_index`: If the item has a palette, this is used to get the current color from the palette. -Example stuff: +Example: local meta = stack:get_meta() meta:set_string("key", "value") print(dump(meta:to_table())) + + + Formspec --------- +======== + Formspec defines a menu. Currently not much else than inventories are supported. It is a string, with a somewhat strange format. Spaces and newlines can be inserted between the blocks, as is used in the examples. +Position and size units are inventory slots, `X` and `Y` position the formspec +element relative to the top left of the menu or container. `W` and `H` are its +width and height values. +When displaying text which can contain formspec code, e.g. text set by a player, +use `minetest.formspec_escape`. +For coloured text you can use `minetest.colorize`. + WARNING: Minetest allows you to add elements to every single formspec instance -using player:set_formspec_prepend(), which may be the reason backgrounds are -appearing when you don't expect them to. See `no_prepend[]` +using `player:set_formspec_prepend()`, which may be the reason backgrounds are +appearing when you don't expect them to. See [`no_prepend[]`]. -### Examples +Examples +-------- -#### Chest +### Chest size[8,9] list[context;main;0,0;8,4;] list[current_player;main;0,5;8,4;] -#### Furnace +### Furnace size[8,9] list[context;fuel;2,3;1,1;] @@ -1708,7 +1880,7 @@ appearing when you don't expect them to. See `no_prepend[]` list[context;dst;5,1;2,2;] list[current_player;main;0,5;8,4;] -#### Minecraft-like player inventory +### Minecraft-like player inventory size[8,7.5] image[1,0.6;1,2;player.png] @@ -1716,14 +1888,17 @@ appearing when you don't expect them to. See `no_prepend[]` list[current_player;craft;3,0;3,3;] list[current_player;craftpreview;7,1;1,1;] -### Elements +Elements +-------- + +### `size[,,]` -#### `size[,,]` * Define the size of the menu in inventory slots * `fixed_size`: `true`/`false` (optional) * deprecated: `invsize[,;]` -#### `position[,]` +### `position[,]` + * Must be used after `size` element. * Defines the position on the game window of the formspec's `anchor` point. * For X and Y, 0.0 and 1.0 represent opposite edges of the game window, @@ -1732,7 +1907,8 @@ appearing when you don't expect them to. See `no_prepend[]` * [1.0, 1.0] sets the position to the bottom right of the game window. * Defaults to the center of the game window [0.5, 0.5]. -#### `anchor[,]` +### `anchor[,]` + * Must be used after both `size` and `position` (if present) elements. * Defines the location of the anchor point within the formspec. * For X and Y, 0.0 and 1.0 represent opposite edges of the formspec, @@ -1744,115 +1920,129 @@ appearing when you don't expect them to. See `no_prepend[]` * `position` and `anchor` elements need suitable values to avoid a formspec extending off the game window due to particular game window sizes. -#### `no_prepend[]` +### `no_prepend[]` + * Must be used after the `size`, `position`, and `anchor` elements (if present). * Disables player:set_formspec_prepend() from applying to this formspec. -#### `container[,]` +### `container[,]` + * Start of a container block, moves all physical elements in the container by (X, Y). * Must have matching `container_end` * Containers can be nested, in which case the offsets are added (child containers are relative to parent containers) -#### `container_end[]` +### `container_end[]` + * End of a container, following elements are no longer relative to this container. -#### `list[;;,;,;]` +### `list[;;,;,;]` + * Show an inventory list -#### `list[;;,;,;]` +### `list[;;,;,;]` + * Show an inventory list -#### `listring[;]` +### `listring[;]` + * Allows to create a ring of inventory lists * Shift-clicking on items in one element of the ring will send them to the next inventory list inside the ring * The first occurrence of an element inside the ring will determine the inventory where items will be sent to -#### `listring[]` +### `listring[]` + * Shorthand for doing `listring[;]` for the last two inventory lists added by list[...] -#### `listcolors[;]` +### `listcolors[;]` + * Sets background color of slots as `ColorString` * Sets background color of slots on mouse hovering -#### `listcolors[;;]` +### `listcolors[;;]` + * Sets background color of slots as `ColorString` * Sets background color of slots on mouse hovering * Sets color of slots border -#### `listcolors[;;;;]` +### `listcolors[;;;;]` + * Sets background color of slots as `ColorString` * Sets background color of slots on mouse hovering * Sets color of slots border * Sets default background color of tooltips * Sets default font color of tooltips -#### `tooltip[;;;]` +### `tooltip[;;;]` + * Adds tooltip for an element * `` tooltip background color as `ColorString` (optional) * `` tooltip font color as `ColorString` (optional) -#### `image[,;,;]` +### `tooltip[,;,;;;]` +* Adds tooltip for an area. Other tooltips will take priority when present. +* `` tooltip background color as `ColorString` (optional) +* `` tooltip font color as `ColorString` (optional) + +### `image[,;,;]` + * Show an image -* Position and size units are inventory slots -#### `item_image[,;,;]` +### `item_image[,;,;]` + * Show an inventory image of registered item/node -* Position and size units are inventory slots -#### `bgcolor[;]` +### `bgcolor[;]` + * Sets background color of formspec as `ColorString` -* If `true`, the background color is drawn fullscreen (does not effect the size +* If `true`, the background color is drawn fullscreen (does not affect the size of the formspec). -#### `background[,;,;]` +### `background[,;,;]` + * Use a background. Inventory rectangles are not drawn then. -* Position and size units are inventory slots * Example for formspec 8x4 in 16x resolution: image shall be sized 8 times 16px times 4 times 16px. -#### `background[,;,;;]` +### `background[,;,;;]` + * Use a background. Inventory rectangles are not drawn then. -* Position and size units are inventory slots * Example for formspec 8x4 in 16x resolution: image shall be sized 8 times 16px times 4 times 16px -* If `true` the background is clipped to formspec size +* If `auto_clip` is `true`, the background is clipped to the formspec size (`x` and `y` are used as offset values, `w` and `h` are ignored) -#### `pwdfield[,;,;;