X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=07ed27cdfcb2274650b82acc4efb92216bbcb336;hb=1137f469e2cec17708756d5263c3ffdbf6174099;hp=1e6cf0b71eeb4f38abdef16938dff40f3a9600de;hpb=4edf08709010f721b099dfae3cab011acbdfb3ff;p=minetest.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 1e6cf0b71..07ed27cdf 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -51,33 +51,36 @@ Games are looked up from: * `$path_share/games/gameid/` * `$path_user/games/gameid/` -where `gameid` is unique to each game. - -The game directory contains the file `game.conf`, which contains these fields: - - name = - -e.g. - - name = Minetest - -The game directory can contain the file minetest.conf, which will be used -to set default settings when running the particular game. -It can also contain a settingtypes.txt in the same format as the one in builtin. -This settingtypes.txt will be parsed by the menu and the settings will be displayed -in the "Games" category in the settings tab. +Where `gameid` is unique to each game. + +The game directory can contain the following files: + +* `game.conf`, which contains: + * `name = ` e.g. `name = Minetest` + * Optionally, game.conf can also contain + `disallowed_mapgens = ` + e.g. `disallowed_mapgens = v5,v6,flat` + These mapgens are removed from the list of mapgens for the game. +* `minetest.conf`: + Used to set default settings when running this game. +* `settingtypes.txt`: + In the same format as the one in builtin. + This settingtypes.txt will be parsed by the menu and the settings will be + displayed in the "Games" category in the advanced settings tab. +* If the subgame contains a folder called `textures` the server will load it + as a texturepack, overriding mod textures. + Any server texturepack will override mod textures and the game texturepack. ### Menu images -Games can provide custom main menu images. They are put inside a `menu` directory -inside the game directory. - -The images are named `$identifier.png`, where `$identifier` is -one of `overlay,background,footer,header`. -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. +Games can provide custom main menu images. They are put inside a `menu` +directory inside the game directory. +The images are named `$identifier.png`, where `$identifier` is one of +`overlay`, `background`, `footer`, `header`. +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 ------------- @@ -551,6 +554,7 @@ stretched to contain exactly 256 pixels (after arranging the pixels to one line). The indexing starts from 0. Examples: + * 16x16 palette, index = 0: the top left corner * 16x16 palette, index = 4: the fifth pixel in the first row * 16x16 palette, index = 16: the pixel below the top left corner @@ -575,6 +579,7 @@ 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 appropriate `drawtype`: + * `drawtype = "color"` for nodes which use their full `param2` for palette indexing. These nodes can have 256 different colors. The palette should contain 256 pixels. @@ -585,10 +590,10 @@ appropriate `drawtype`: palette). These nodes can have 32 different colors, and the palette should contain 32 pixels. Examples: - * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1) - pixel will be picked from the palette. - * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1) - pixel will be picked from the palette. + * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1) + pixel will be picked from the palette. + * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1) + pixel will be picked from the palette. * `drawtype = "colorfacedir"` for nodes which use the first three bits of `param2` for palette indexing. The remaining five bits are describing rotation, as in `facedir` draw type. @@ -596,10 +601,10 @@ appropriate `drawtype`: palette). These nodes can have 8 different colors, and the palette should contain 8 pixels. Examples: - * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the - first (= 0 + 1) pixel will be picked from the palette. - * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the - second (= 1 + 1) pixel will be picked from the palette. + * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the + first (= 0 + 1) pixel will be picked from the palette. + * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the + second (= 1 + 1) pixel will be picked from the palette. To colorize a node on the map, set its `param2` value (according to the node's draw type). @@ -617,6 +622,7 @@ when a player digs or places a colored node. You can disable this feature by setting the `drop` field of the node to itself (without metadata). To transfer the color to a special drop, you need a drop table. + Example: minetest.register_node("mod:stone", { @@ -1022,6 +1028,17 @@ A nodebox is defined as any of: connect_left = box OR {box1, box2, ...} connect_back = box OR {box1, box2, ...} connect_right = box OR {box1, box2, ...} + -- The following `disconnected_*` boxes are the opposites of the + -- `connect_*` ones above, i.e. when a node has no suitable neighbour + -- on the respective side, the corresponding disconnected box is drawn. + disconnected_top = box OR {box1, box2, ...} + disconnected_bottom = box OR {box1, box2, ...} + disconnected_front = box OR {box1, box2, ...} + disconnected_left = box OR {box1, box2, ...} + disconnected_back = box OR {box1, box2, ...} + 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 } A `box` is defined as: @@ -1279,11 +1296,11 @@ in the form of a table. This table specifies the following fields: * The `data` field is a flat table of MapNode tables making up the schematic, in the order of `[z [y [x]]]`. (required) Each MapNode table contains: - * `name`: the name of the map node to place (required) - * `prob` (alias `param1`): the probability of this node being placed (default: 255) - * `param2`: the raw param2 value of the node being placed onto the map (default: 0) - * `force_place`: boolean representing if the node should forcibly overwrite any - previous contents (default: false) + * `name`: the name of the map node to place (required) + * `prob` (alias `param1`): the probability of this node being placed (default: 255) + * `param2`: the raw param2 value of the node being placed onto the map (default: 0) + * `force_place`: boolean representing if the node should forcibly overwrite any + previous contents (default: false) About probability values: @@ -1828,7 +1845,7 @@ Some of the values in the key-value store are handled specially: * `description`: Set the item stack's description. Defaults to `idef.description` * `color`: A `ColorString`, which sets the stack's color. * `palette_index`: If the item has a palette, this is used to get the - current color from the palette. + current color from the palette. Example stuff: @@ -1876,14 +1893,23 @@ examples. * deprecated: `invsize[,;]` #### `position[,]` -* Define the position of the formspec -* A value between 0.0 and 1.0 represents a position inside the screen -* The default value is the center of the screen (0.5, 0.5) +* 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, for example: + * [0.0, 0.0] sets the position to the top left corner of the game window. + * [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[,]` -* Define the anchor of the formspec -* A value between 0.0 and 1.0 represents an anchor inside the formspec -* The default value is the center of the formspec (0.5, 0.5) +* 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, for example: + * [0.0, 1.0] sets the anchor to the bottom left corner of the formspec. + * [1.0, 0.0] sets the anchor to the top right of the formspec. +* Defaults to the center of the formspec [0.5, 0.5]. + +* `position` and `anchor` elements need suitable values to avoid a formspec + extending off the game window due to particular game window sizes. #### `container[,]` * Start of a container block, moves all physical elements in the container by (X, Y) @@ -2040,8 +2066,8 @@ examples. #### `item_image_button[,;,;;;