X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=75ad07cadeb9d7f517ea277970c47076a85cbd6e;hb=6be7150cd5c18869911bcba8e5833155521d2780;hp=2b05cff8c1db90ec8289f85ca560d86163b497f4;hpb=34a5960671d2bae76b3ad2080397ffae694a4209;p=minetest.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 2b05cff8c..75ad07cad 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -3,10 +3,10 @@ Minetest Lua Modding API Reference * More information at * Developer Wiki: - +* (Unofficial) Minetest Modding Book by rubenwardy: Introduction -============ +------------ Content and functionality can be added to Minetest using Lua scripting in run-time loaded mods. @@ -119,8 +119,14 @@ Modpacks -------- 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. +should be a mod, contains a file named `modpack.conf`. +The file is a key-value store of modpack details. + +* `name`: The modpack name. +* `description`: Description of mod to be shown in the Mods tab of the main + menu. + +Note: to support 0.4.x, please also create an empty modpack.txt file. Mod directory structure ----------------------- @@ -148,7 +154,7 @@ The location of this directory can be fetched by using ### mod.conf -A key-value store of mod details. +A `Settings` file that provides meta information about the mod. * `name`: The mod name. Allows Minetest to determine the mod name even if the folder is wrongly named. @@ -190,8 +196,9 @@ 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. +The format is documented in `builtin/settingtypes.txt`. +It is parsed by the main menu settings dialogue to list mod-specific +settings in the "Mods" category. ### `init.lua` @@ -252,13 +259,15 @@ dependency. Aliases ======= -Aliases can be added by using `minetest.register_alias(name, convert_to)` or -`minetest.register_alias_force(name, convert_to)`. +Aliases of itemnames can be added by using +`minetest.register_alias(alias, original_name)` or +`minetest.register_alias_force(alias, original_name)`. -This converts anything called `name` to `convert_to`. +This adds an alias `alias` for the item called `original_name`. +From now on, you can use `alias` to refer to the item `original_name`. The only difference between `minetest.register_alias` and -`minetest.register_alias_force` is that if an item called `name` exists, +`minetest.register_alias_force` is that if an item named `alias` already exists, `minetest.register_alias` will do nothing while `minetest.register_alias_force` will unregister it. @@ -275,40 +284,35 @@ 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: +of the game's nodes are to be used for core mapgen generation. For example: minetest.register_alias("mapgen_stone", "default:stone") -### Aliases needed for all mapgens except Mapgen V6 +### Aliases for non-V6 mapgens -#### Base terrain +#### Essential aliases * mapgen_stone * mapgen_water_source * mapgen_river_water_source -#### Caves +`mapgen_river_water_source` is required for mapgens with sloping rivers where +it is necessary to have a river liquid node with a short `liquid_range` and +`liquid_renewable = false` to avoid flooding. -Not required if cave liquid nodes are set in biome definitions. +#### Optional aliases * mapgen_lava_source -#### Dungeons - -Not required if dungeon nodes are set in biome definitions. +Fallback lava node used if cave liquids are not defined in biome definitions. +Deprecated for non-V6 mapgens, define cave liquids in biome definitions instead. * mapgen_cobble -* mapgen_stair_cobble -* mapgen_mossycobble -* mapgen_desert_stone -* mapgen_stair_desert_stone -* mapgen_sandstone -* mapgen_sandstonebrick -* mapgen_stair_sandstone_block -### Aliases needed for Mapgen V6 +Fallback node used if dungeon nodes are not defined in biome definitions. +Deprecated for non-V6 mapgens, define dungeon nodes in biome definitions instead. -#### Terrain and biomes +### Aliases needed for Mapgen V6 * mapgen_stone * mapgen_water_source @@ -324,8 +328,6 @@ Not required if dungeon nodes are set in biome definitions. * mapgen_snow * mapgen_ice -#### Flora - * mapgen_tree * mapgen_leaves * mapgen_apple @@ -335,8 +337,6 @@ Not required if dungeon nodes are set in biome definitions. * mapgen_pine_tree * mapgen_pine_needles -#### Dungeons - * mapgen_cobble * mapgen_stair_cobble * mapgen_mossycobble @@ -826,7 +826,7 @@ Examples of sound parameter tables: gain = 1.0, -- default loop = true, } - -- Play in a location + -- Play at a location { pos = {x = 1, y = 2, z = 3}, gain = 1.0, -- default @@ -839,94 +839,75 @@ Examples of sound parameter tables: max_hear_distance = 32, -- default, uses an euclidean metric loop = true, } + -- Play at a location, heard by anyone *but* the given player + { + pos = {x = 32, y = 0, z = 100}, + max_hear_distance = 40, + exclude_player = name, + } Looped sounds must either be connected to an object or played locationless to -one player using `to_player = name,` - -`SimpleSoundSpec` ------------------ +one player using `to_player = name`. -* e.g. `""` -* e.g. `"default_place_node"` -* e.g. `{}` -* e.g. `{name = "default_place_node"}` -* e.g. `{name = "default_place_node", gain = 1.0}` -* e.g. `{name = "default_place_node", gain = 1.0, pitch = 1.0}` +A positional sound will only be heard by players that are within +`max_hear_distance` of the sound position, at the start of the sound. +`exclude_player = name` can be applied to locationless, positional and object- +bound sounds to exclude a single player from hearing them. +`SimpleSoundSpec` +----------------- +Specifies a sound name, gain (=volume) and pitch. +This is either a string or a table. -Registered definitions -====================== +In string form, you just specify the sound name or +the empty string for no sound. -Anything added using certain `minetest.register_*` functions gets added to -the global `minetest.registered_*` tables. +Table form has the following fields: -* `minetest.register_entity(name, entity definition)` - * added to `minetest.registered_entities[name]` +* `name`: Sound name +* `gain`: Volume (`1.0` = 100%) +* `pitch`: Pitch (`1.0` = 100%) -* `minetest.register_node(name, node definition)` - * added to `minetest.registered_items[name]` - * added to `minetest.registered_nodes[name]` +`gain` and `pitch` are optional and default to `1.0`. -* `minetest.register_tool(name, item definition)` - * added to `minetest.registered_items[name]` - -* `minetest.register_craftitem(name, item definition)` - * added to `minetest.registered_items[name]` - -* `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 - -* `minetest.register_biome(biome definition)` - * returns an integer uniquely identifying the registered biome - * added to `minetest.registered_biome` with the key of `biome.name` - * if `biome.name` is nil, the key is the returned ID - -* `minetest.unregister_biome(name)` - * Unregisters the biome name from engine, and deletes the entry with key - `name` from `minetest.registered_biome` - -* `minetest.register_ore(ore definition)` - * returns an integer uniquely identifying the registered ore - * added to `minetest.registered_ores` with the key of `ore.name` - * if `ore.name` is nil, the key is the returned ID +Examples: -* `minetest.register_decoration(decoration definition)` - * returns an integer uniquely identifying the registered decoration - * added to `minetest.registered_decorations` with the key of - `decoration.name`. - * if `decoration.name` is nil, the key is the returned ID +* `""`: No sound +* `{}`: No sound +* `"default_place_node"`: Play e.g. `default_place_node.ogg` +* `{name = "default_place_node"}`: Same as above +* `{name = "default_place_node", gain = 0.5}`: 50% volume +* `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch -* `minetest.register_schematic(schematic definition)` - * returns an integer uniquely identifying the registered schematic - * added to `minetest.registered_schematic` with the key of `schematic.name` - * if `schematic.name` is nil, the key is the returned ID - * if the schematic is loaded from a file, schematic.name is set to the - filename. - * if the function is called when loading the mod, and schematic.name is a - relative path, then the current mod path will be prepended to the - schematic filename. +Special sound files +------------------- -* `minetest.clear_registered_biomes()` - * clears all biomes currently registered +These sound files are played back by the engine if provided. -* `minetest.clear_registered_ores()` - * clears all ores currently registered + * `player_damage`: Played when the local player takes damage (gain = 0.5) + * `player_falling_damage`: Played when the local player takes + damage by falling (gain = 0.5) + * `default_dig_`: Default node digging sound + (see node sound definition for details) -* `minetest.clear_registered_decorations()` - * clears all decorations currently registered +Registered definitions +====================== -* `minetest.clear_registered_schematics()` - * clears all schematics currently registered +Anything added using certain [Registration functions] gets added to one or more +of the global [Registered definition tables]. Note that in some cases you will stumble upon things that are not contained in these tables (e.g. when a mod has been removed). Always check for existence before trying to access the fields. -Example: If you want to check the drawtype of a node, you could do: +Example: + +All nodes register with `minetest.register_node` get added to the table +`minetest.registered_nodes`. + +If you want to check the drawtype of a node, you could do: local function get_nodedef_field(nodename, fieldname) if not minetest.registered_nodes[nodename] then @@ -967,7 +948,8 @@ Node paramtypes The functions of `param1` and `param2` are determined by certain fields in the node definition. -`param1` is reserved for the engine when `paramtype != "none"`: +The function of `param1` is determined by `paramtype` in 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 @@ -984,19 +966,27 @@ node definition. * 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"` +* `paramtype = "none"` + * `param1` will not be used by the engine and can be used to store + an arbitrary value + +The function of `param2` is determined by `paramtype2` in node definition. +`param2` is reserved for the engine when `paramtype2 != "none"`. + +* `paramtype2 = "flowingliquid"` + * Used by `drawtype = "flowingliquid"` and `liquidtype = "flowing"` + * The liquid level and a flag of the liquid are stored in `param2` + * Bits 0-2: Liquid level (0-7). The higher, the more liquid is in this node + * Bit 3: If set, liquid is flowing downwards (no graphical effect) * `paramtype2 = "wallmounted"` - * The rotation of the node is stored in `param2`. You can make this value - by using `minetest.dir_to_wallmounted()`. + * Supported drawtypes: "torchlike", "signlike", "normal", "nodebox", "mesh" + * The rotation of the node is stored in `param2` + * You can make this value by using `minetest.dir_to_wallmounted()` + * Values range 0 - 5 + * The value denotes at which direction the node is "mounted": + 0 = y+, 1 = y-, 2 = x+, 3 = x-, 4 = z+, 5 = z- * `paramtype2 = "facedir"` + * Supported drawtypes: "normal", "nodebox", "mesh" * 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 @@ -1015,13 +1005,13 @@ node definition. * 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 + * Only valid for "plantlike" drawtype. 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 - can be used to change how the client draws plantlike nodes. + * Only valid for "plantlike" drawtype. 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. Currently the following meshes are choosable: * 0 = a "x" shaped plant (ordinary plant) @@ -1053,6 +1043,9 @@ node definition. * `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"}` +* `paramtype2 = "none"` + * `param2` will not be used by the engine and can be used to store + an arbitrary value Nodes can also contain extra data. See [Node Metadata]. @@ -1077,16 +1070,11 @@ 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 by the second texture specified in `tiles`. - * If a third texture is specified in `tiles` it will be used for the top and - base of the glass volume. - * If third and fourth textures are specified in `tiles`, the third will be - used for the top of the glass volume and the fourth will be used for the - base of the glass volume. * `glasslike_framed_optional` * This switches between the above 2 drawtypes according to the menu setting 'Connected Glass'. @@ -1220,6 +1208,64 @@ A box of a regular node would look like: +Map terminology and coordinates +=============================== + +Nodes, mapblocks, mapchunks +--------------------------- + +A 'node' is the fundamental cubic unit of a world and appears to a player as +roughly 1x1x1 meters in size. + +A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the +fundamental region of a world that is stored in the world database, sent to +clients and handled by many parts of the engine. +'mapblock' is preferred terminology to 'block' to help avoid confusion with +'node', however 'block' often appears in the API. + +A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks +(80x80x80 nodes) and is the volume of world generated in one operation by +the map generator. +The size in mapblocks has been chosen to optimise map generation. + +Coordinates +----------- + +### Orientation of axes + +For node and mapblock coordinates, +X is East, +Y is up, +Z is North. + +### Node coordinates + +Almost all positions used in the API use node coordinates. + +### Mapblock coordinates + +Occasionally the API uses 'blockpos' which refers to mapblock coordinates that +specify a particular mapblock. +For example blockpos (0,0,0) specifies the mapblock that extends from +node position (0,0,0) to node position (15,15,15). + +#### Converting node position to the containing blockpos + +To calculate the blockpos of the mapblock that contains the node at 'nodepos', +for each axis: + +* blockpos = math.floor(nodepos / 16) + +#### Converting blockpos to min/max node positions + +To calculate the min/max node positions contained in the mapblock at 'blockpos', +for each axis: + +* Minimum: + nodepos = blockpos * 16 +* Maximum: + nodepos = blockpos * 16 + 15 + + + + HUD === @@ -1238,9 +1284,10 @@ is drawn. `0` draws from left to right, `1` draws from right to left, `2` draws from top to bottom, and `3` draws from bottom to top. -The `alignment` field specifies how the item will be aligned. It ranges from -`-1` to `1`, with `0` being the center. `-1` is moved to the left/up, and `1` -is to the right/down. Fractional values can be used. +The `alignment` field specifies how the item will be aligned. It is a table +where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is +moved to the left/up, and `1` is to the right/down. Fractional values can be +used. The `offset` field specifies a pixel offset from the position. Contrary to position, the offset is not scaled to screen size. This allows for some @@ -1249,10 +1296,16 @@ precisely positioned items in the HUD. **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling factor! +The `z_index` field specifies the order of HUD elements from back to front. +Lower z-index elements are displayed behind higher z-index elements. Elements +with same z-index are displayed in an arbitrary order. Default 0. +Supports negative values. + Below are the specific uses for fields in each type; fields not listed for that type are ignored. ### `image` + Displays an image on the HUD. * `scale`: The scale of the image, with 1 being the original texture size. @@ -1323,9 +1376,13 @@ For helper functions see [Spatial Vectors]. * `{type="nothing"}` * `{type="node", under=pos, above=pos}` + * Indicates a pointed node selection box. + * `under` refers to the node position behind the pointed face. + * `above` refers to the node position in front of the pointed face. * `{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. @@ -1460,7 +1517,8 @@ Usage ----- Groups are stored in a table, having the group names with keys and the -group ratings as values. For example: +group ratings as values. Group ratings are integer values within the +range [-32767, 32767]. For example: -- Default dirt groups = {crumbly=3, soil=1} @@ -1531,35 +1589,59 @@ Another example: Make red wool from white wool and red dye: 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 - else than take damage. -* `level`: Can be used to give an additional sense of progression in the game. - * A larger level will cause e.g. a weapon of a lower level make much less - damage, and get worn out much faster, or not be able to get drops - from destroyed nodes. - * `0` is something that is directly accessible at the start of gameplay - * There is no upper limit +The asterisk `(*)` after a group name describes that there is no engine +functionality bound to it, and implementation is left up as a suggestion +to games. + +### Node, item and tool groups + +* `not_in_creative_inventory`: (*) Special group for inventory mods to indicate + that the item should be hidden in item lists. + + +### Node-only groups + +* `attached_node`: if the node under it is not a walkable block the node will be + dropped as an item. If the node is wallmounted the wallmounted direction is + checked. +* `bouncy`: value is bounce speed in percent +* `connect_to_raillike`: makes nodes of raillike drawtype with same group value + connect to each other * `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 * `fall_damage_add_percent`: damage speed = `speed * (1 + value/100)` -* `bouncy`: value is bounce speed in percent * `falling_node`: if there is no walkable block under the node it will fall -* `attached_node`: if the node under it is not a walkable block the node will be - dropped as an item. If the node is wallmounted the wallmounted direction is - checked. -* `soil`: saplings will grow on nodes in this group -* `connect_to_raillike`: makes nodes of raillike drawtype with same group value - connect to each other +* `float`: the node will not fall through liquids +* `level`: Can be used to give an additional sense of progression in the game. + * A larger level will cause e.g. a weapon of a lower level make much less + damage, and get worn out much faster, or not be able to get drops + from destroyed nodes. + * `0` is something that is directly accessible at the start of gameplay + * There is no upper limit + * See also: `leveldiff` in [Tools] * `slippery`: Players and items will slide on the node. Slipperiness rises steadily with `slippery` value, starting at 1. + + +### Tool-only groups + * `disable_repair`: If set to 1 for a tool, it cannot be repaired using the `"toolrepair"` crafting recipe +### `ObjectRef` groups + +* `immortal`: Skips all damage and breath handling for an object. This group + will also hide the integrated HUD status bars for players, and is + automatically set to all players when damage is disabled on the server. +* `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 + else than take damage. + + + Known damage and digging time defining groups --------------------------------------------- @@ -1649,6 +1731,8 @@ to implement this. 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`. +`leveldiff` is the difference of the tool's `maxlevel` `groupcaps` and the +node's `level` group. The node cannot be dug if `leveldiff` is less than zero. * `uses=10, leveldiff=0`: actual uses: 10 * `uses=10, leveldiff=1`: actual uses: 30 @@ -1851,22 +1935,46 @@ Example: Formspec ======== -Formspec defines a menu. Currently not much else than inventories are -supported. It is a string, with a somewhat strange format. +Formspec defines a menu. This supports inventories and some of the +typical widgets like buttons, checkboxes, text input fields, etc. +It is a string, with a somewhat strange format. + +A formspec is made out of formspec elements, which includes widgets +like buttons but also can be used to set stuff like background color. + +Many formspec elements have a `name`, which is a unique identifier which +is used when the server receives user input. You must not use the name +"quit" for formspec elements. 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. +Position and size units are inventory slots unless the new coordinate system +is enabled. `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. + +If the new system is enabled, all elements have unified coordinates for all +elements with no padding or spacing in between. This is highly recommended +for new forms. See `real_coordinates[]` and `Migrating to Real +Coordinates`. + +Inventories with a `player:` inventory location are only sent to the +player named ``. + 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 +Since formspec version 3, elements drawn in the order they are defined. All +background elements are drawn before all other elements. + +**WARNING**: do _not_ use a element name starting with `key_`; those names are +reserved to pass key press events to formspec! + +**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[]`]. +appearing when you don't expect them to, or why things are styled differently +to normal. See [`no_prepend[]`] and [Styling Formspecs]. Examples -------- @@ -1896,6 +2004,15 @@ Examples Elements -------- +### `formspec_version[]` + +* Set the formspec version to a certain number. If not specified, + version 1 is assumed. +* Must be specified before `size` element. +* Clients older than this version can neither show newer elements nor display + elements with new arguments correctly. +* Available since feature `formspec_version_element`. + ### `size[,,]` * Define the size of the menu in inventory slots @@ -1930,6 +2047,17 @@ Elements * Must be used after the `size`, `position`, and `anchor` elements (if present). * Disables player:set_formspec_prepend() from applying to this formspec. +### `real_coordinates[]` + +* INFORMATION: Enable it automatically using `formspec_version` version 2 or newer. +* When set to true, all following formspec elements will use the new coordinate system. +* If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements + (if present), the form size will use the new coordinate system. +* **Note**: Formspec prepends are not affected by the coordinates in the main form. + They must enable it explicitly. +* For information on converting forms to the new coordinate system, see `Migrating + to Real Coordinates`. + ### `container[,]` * Start of a container block, moves all physical elements in the container by @@ -1945,11 +2073,17 @@ Elements ### `list[;;,;,;]` -* Show an inventory list +* Show an inventory list if it has been sent to the client. Nothing will + be shown if the inventory list is of size 0. +* **Note**: With the new coordinate system, the spacing between inventory + slots is one-fourth the size of an inventory slot. ### `list[;;,;,;]` -* Show an inventory list +* Show an inventory list if it has been sent to the client. Nothing will + be shown if the inventory list is of size 0. +* **Note**: With the new coordinate system, the spacing between inventory + slots is one-fourth the size of an inventory slot. ### `listring[;]` @@ -1990,6 +2124,7 @@ Elements * `` tooltip font color as `ColorString` (optional) ### `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) @@ -1998,36 +2133,68 @@ Elements * Show an image +### `animated_image[,;,;:,]` + +* Show an animated image. The image is drawn like a "vertical_frames" tile + animation (See Tile animation definition), but uses a frame count/duration + for simplicity +* `` is the image to use +* `` is the number of frames animating the image +* `` is in milliseconds + ### `item_image[,;,;]` * Show an inventory image of registered item/node -### `bgcolor[;]` +### `bgcolor[;;]` -* Sets background color of formspec as `ColorString` -* If `true`, the background color is drawn fullscreen (does not affect the size - of the formspec). +* Sets background color of formspec. +* `bgcolor` and `fbgcolor` (optional) are `ColorString`s, they define the color + of the non-fullscreen and the fullscreen background. +* `fullscreen` (optional) can be one of the following: + * `false`: Only the non-fullscreen background color is drawn. (default) + * `true`: Only the fullscreen background color is drawn. + * `both`: The non-fullscreen and the fullscreen background color are drawn. + * `neither`: No background color is drawn. +* Note: Leave a parameter empty to not modify the value. +* Note: `fbgcolor`, leaving parameters empty and values for `fullscreen` that + are not bools are only available since formspec version 3. ### `background[,;,;]` -* Use a background. Inventory rectangles are not drawn then. * Example for formspec 8x4 in 16x resolution: image shall be sized 8 times 16px times 4 times 16px. ### `background[,;,;;]` -* Use a background. Inventory rectangles are not drawn then. * Example for formspec 8x4 in 16x resolution: image shall be sized 8 times 16px times 4 times 16px * 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) +### `background9[,;,;;;]` + +* 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling +* Middle is a rect which defines the middle of the 9-slice. + * `x` - The middle will be x pixels from all sides. + * `x,y` - The middle will be x pixels from the horizontal and y from the vertical. + * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values + will be added to the width and height of the texture, allowing it to be used as the + distance from the far end. + * All numbers in middle are integers. +* Example for formspec 8x4 in 16x resolution: + image shall be sized 8 times 16px times 4 times 16px +* 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) +* Available since formspec version 2 + ### `pwdfield[,;,;;