X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=75ad07cadeb9d7f517ea277970c47076a85cbd6e;hb=6be7150cd5c18869911bcba8e5833155521d2780;hp=5640be73c37d329e5bbb84a60e61d8bc8bfbdd46;hpb=69a2099c04527404f2d0942f2088b3d22dd75b5a;p=minetest.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 5640be73c..75ad07cad 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -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,34 +839,58 @@ 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,`. +one player using `to_player = name`. 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` ----------------- -* 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}` +Specifies a sound name, gain (=volume) and pitch. +This is either a string or a table. + +In string form, you just specify the sound name or +the empty string for no sound. + +Table form has the following fields: + +* `name`: Sound name +* `gain`: Volume (`1.0` = 100%) +* `pitch`: Pitch (`1.0` = 100%) +`gain` and `pitch` are optional and default to `1.0`. + +Examples: + +* `""`: 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 Special sound files ------------------- These sound files are played back by the engine if provided. - * `main_menu`: Looped sound in the main menu (gain = 1.0) * `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) Registered definitions ====================== @@ -924,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 @@ -941,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 @@ -972,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) @@ -1010,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]. @@ -1260,6 +1296,11 @@ 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. @@ -1476,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} @@ -1923,6 +1965,9 @@ 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`. +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! @@ -2088,15 +2133,32 @@ 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`, a fullscreen background is drawn and the color is ignored - (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[,;,;]` @@ -2189,8 +2251,13 @@ Elements half a coordinate. With the old system, newlines are spaced 2/5 of an inventory slot. -### `vertlabel[,;