X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=c29abdf9c60d07873abc574bc4746ff5c31b5c78;hb=9b8fa99fe30728c1fcfa73cdf74211841bdae9fb;hp=3fc815272adbcf13c3e8b767d5c10e26de41c8fc;hpb=ef285b2815962a7a01791059ed984cb12fdba4dd;p=oweals%2Fminetest.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 3fc815272..c29abdf9c 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1,4 +1,4 @@ -Minetest Lua Modding API Reference 0.4.16 +Minetest Lua Modding API Reference 0.5.0 ========================================= * More information at * Developer Wiki: @@ -15,8 +15,7 @@ Mods are contained and ran solely on the server side. Definitions and media files are automatically transferred to the client. If you see a deficiency in the API, feel free to attempt to add the -functionality in the engine and API. You can send such improvements as -source code patches to . +functionality in the engine and API. Programming in Lua ------------------ @@ -139,6 +138,7 @@ Mod directory structure | | `-- modname_something_else.png | |-- sounds | |-- media + | |-- locale | `-- `-- another @@ -182,6 +182,9 @@ Models for entities or meshnodes. 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 ---------------------------------------------- Registered names should generally be in this format: @@ -536,6 +539,21 @@ automatically transferred between node and item forms by the engine, 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", { + description = "Stone", + tiles = {"default_stone.png"}, + paramtype2 = "color", + palette = "palette.png", + drop = { + items = { + -- assume that mod:cobblestone also has the same palette + {items = {"mod:cobblestone"}, inherit_color = true }, + } + } + }) ### Colored items in craft recipes Craft recipes only support item strings, but fortunately item strings @@ -569,7 +587,11 @@ other. This allows different hardware coloring, but also means that tiles with overlays are drawn slower. Using too much overlays might cause FPS loss. -To define an overlay, simply set the `overlay_tiles` field of the node +For inventory and wield images you can specify overlays which +hardware coloring does not modify. You have to set `inventory_overlay` +and `wield_overlay` fields to an image name. + +To define a node overlay, simply set the `overlay_tiles` field of the node definition. These tiles are defined in the same way as plain tiles: they can have a texture name, color etc. To skip one face, set that overlay tile to an empty string. @@ -692,6 +714,10 @@ the global `minetest.registered_*` tables. * 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` @@ -797,6 +823,15 @@ node definition: 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" ^ The rotation of this node is stored in param2. Plants are rotated this way. Values range 0 - 179. The value stored in param2 is multiplied by two to @@ -832,13 +867,14 @@ node definition: The palette should have 32 pixels. paramtype2 == "glasslikeliquidlevel" ^ Only valid for "glasslike_framed" or "glasslike_framed_optional" drawtypes. - param2 defines 64 levels of internal liquid. + 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". Node drawtypes ---------------- +-------------- There are a bunch of different looking node types. Look for examples in `games/minimal` or `games/minetest_game`. @@ -858,22 +894,18 @@ Look for examples in `games/minimal` or `games/minetest_game`. * `firelike` * `fencelike` * `raillike` -* `nodebox` -- See below. (**Experimental!**) -* `mesh` -- use models for nodes -* `plantlike_rooted` +* `nodebox` -- See below +* `mesh` -- Use models for nodes, see below +* `plantlike_rooted` -- See below `*_optional` drawtypes need less rendering time if deactivated (always client side). Node boxes ------------ +---------- Node selection boxes are defined using "node boxes" -The `nodebox` node drawtype allows defining visual of nodes consisting of -arbitrary number of boxes. It allows defining stuff like stairs. Only the -`fixed` and `leveled` box type is supported for these. - -Please note that this is still experimental, and may be incompatibly -changed in the future. +The `nodebox` node drawtype allows defining nodes consisting of an arbitrary +number of boxes. It allows defining stuff like stairs and slabs. A nodebox is defined as any of: @@ -882,10 +914,18 @@ A nodebox is defined as any of: type = "regular" } { - -- A fixed box (facedir param2 is used, if applicable) + -- A fixed box (or boxes) (facedir param2 is used, if applicable) type = "fixed", fixed = box OR {box1, box2, ...} } + { + -- A variable height box (or boxes) with the top face position defined by + -- the node parameter 'leveled = ', or if 'paramtype2 == "leveled"' by + -- param2. + -- Other faces are defined by 'fixed = {}' as with 'type = "fixed"'. + type = "leveled", + fixed = box OR {box1, box2, ...} + } { -- A box like the selection box for torches -- (wallmounted param2 is used, if applicable) @@ -915,16 +955,24 @@ A box of a regular node would look like: {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -`type = "leveled"` is same as `type = "fixed"`, but `y2` will be automatically -set to level from `param2`. - - Meshes ------ If drawtype `mesh` is used, tiles should hold model materials textures. Only static meshes are implemented. For supported model formats see Irrlicht engine documentation. +Rooted plantlike drawtype +------------------------- +The `plantlike_rooted` drawtype was developed to enable underwater plants +without air bubbles around the plants. +It consists of a base cube at the co-ordinates of the node (the seabed / +lakebed / riverbed node) plus a 'plantlike' extension above with a height +defined by param2 (maximum height 16 nodes). This extension visually passes +through any nodes above the base cube without affecting them. +The node is dug by digging the base cube. +The base cube texture tiles are defined as normal, the plantlike extension +uses the defined 'special tile', for example: +`special_tiles = {{name = "default_papyrus.png", tileable_vertical = true}},` Noise Parameters ---------------- @@ -1042,7 +1090,6 @@ within the currently generated chunk. The vertical top and bottom displacement of each puff are determined by the noise parameters `np_puff_top` and `np_puff_bottom`, respectively. - ### `blob` Creates a deformed sphere of ore according to 3d perlin noise described by `noise_params`. The maximum size of the blob is `clust_size`, and @@ -1051,12 +1098,17 @@ Creates a deformed sphere of ore according to 3d perlin noise described by ### `vein` Creates veins of ore varying in density by according to the intersection of two instances of 3d perlin noise with diffferent seeds, both described by -`noise_params`. `random_factor` varies the influence random chance has on -placement of an ore inside the vein, which is `1` by default. Note that -modifying this parameter may require adjusting `noise_threshold`. +`noise_params`. + +`random_factor` varies the influence random chance has on placement of an ore +inside the vein, which is `1` by default. Note that modifying this parameter may +require adjusting `noise_threshold`. + The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored -by this ore type. This ore type is difficult to control since it is sensitive -to small changes. The following is a decent set of parameters to work from: +by this ore type. + +This ore type is difficult to control since it is sensitive to small changes. +The following is a decent set of parameters to work from: noise_params = { offset = 0, @@ -1072,6 +1124,30 @@ to small changes. The following is a decent set of parameters to work from: **WARNING**: Use this ore type *very* sparingly since it is ~200x more computationally expensive than any other ore. +### `stratum` +Creates a single undulating ore stratum that is continuous across mapchunk +borders and horizontally spans the world. + +The 2D perlin noise described by `noise_params` varies the Y co-ordinate of the +stratum midpoint. The 2D perlin noise described by `np_stratum_thickness` +varies the stratum's vertical thickness (in units of nodes). Due to being +continuous across mapchunk borders the stratum's vertical thickness is +unlimited. + +`y_min` and `y_max` define the limits of the ore generation and for performance +reasons should be set as close together as possible but without clipping the +stratum's Y variation. + +If either of the 2 noise parameters are omitted the ore will occur from y_min +to y_max in a simple horizontal stratum. As this does not compute noise +performance improves, and is ideal for placing many layers. + +Each node in the stratum has a 1-in-`clust_scarcity` chance of being ore, so a +solid-ore stratum would require a `clust_scarcity` of 1. + +The parameters `clust_num_ores`, `clust_size`, `noise_threshold` and +`random_factor` are ignored by this ore type. + Ore attributes -------------- See section "Flag Specifier Format". @@ -1424,6 +1500,9 @@ Another example: Make red wool from white wool and red dye: * `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 +* `slippery`: Players and items will slide on the node. + Slipperiness rises steadily with `slippery` value, starting at 1. + ### Known damage and digging time defining groups * `crumbly`: dirt, sand @@ -1839,8 +1918,9 @@ examples. * if is false, pressing enter in the field will submit the form but not close it * defaults to true when not specified (ie: no tag for a field) -#### `textarea[,;,;;