X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=6ed5608694d95e0318c3555f48933b0374b46030;hb=2625323f25ebb4e9ab1079ff60a77b40f58c5bf9;hp=5920b97a0909d33a423c4fd3299cd6f15d84db1f;hpb=9e100bc42b5275299020ea8619e64f2e4aa76192;p=dragonfireclient.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 5920b97a0..6ed560869 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1,4 +1,4 @@ -Minetest Lua Modding API Reference 0.4.7 +Minetest Lua Modding API Reference 0.4.9 ======================================== More information at http://www.minetest.net/ Developer Wiki: http://dev.minetest.net/ @@ -100,6 +100,8 @@ Mod directory structure mods |-- modname | |-- depends.txt +| |-- screenshot.png +| |-- description.txt | |-- init.lua | |-- textures | | |-- modname_stuff.png @@ -121,12 +123,11 @@ depends.txt: to a single modname. Their meaning is that if the specified mod is missing, that does not prevent this mod from being loaded. -optdepends.txt: - An alternative way of specifying optional dependencies. - Like depends.txt, a single line contains a single modname. +screenshot.png: + A screenshot shown in modmanager within mainmenu. - NOTE: This file exists for compatibility purposes only and - support for it will be removed from the engine by the end of 2013. +description.txt: + File containing desctiption to be shown within mainmenu. init.lua: The main Lua script. Running this script should register everything it @@ -322,6 +323,8 @@ param2 is reserved for the engine when any of these are used: facedir modulo 4 = axisdir 0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y- facedir's two less significant bits are rotation around the axis + paramtype2 == "leveled" + ^ The drawn node level is read from param2, like flowingliquid Nodes can also contain extra data. See "Node Metadata". @@ -353,7 +356,7 @@ 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" box type is supported for these. +"fixed" and "leveled" box type is supported for these. ^ Please note that this is still experimental, and may be incompatibly changed in the future. @@ -381,6 +384,8 @@ A box is defined as: 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 "fixed", but y2 will be automaticaly setted to level from param2 + Ore types --------------- These tell in what manner the ore is generated. @@ -388,7 +393,7 @@ All default ores are of the uniformly-distributed scatter type. - scatter Randomly chooses a location and generates a cluster of ore. - If noise_params is specified, the ore will be placed if the 3d perlin noise at + If noise_params is specified, the ore will be placed if the 3d perlin noise at that point is greater than the noise_threshhold, giving the ability to create a non-equal distribution of ore. - sheet @@ -405,6 +410,7 @@ All default ores are of the uniformly-distributed scatter type. Ore attributes ------------------- +See section Flag Specifier Format. Currently supported flags: absheight - absheight Also produce this same ore between the height range of -height_max and -height_min. @@ -432,22 +438,21 @@ Schematic specifier or through raw data supplied through Lua, in the form of a table. This table must specify two fields: - The 'size' field is a 3d vector containing the dimensions of the provided schematic. - The 'data' field is a flat table of MapNodes making up the schematic, in the order of [z [y [x]]]. +Important: The default value for param1 in MapNodes here is 255, which represents "always place". -In the bulk MapNode data, param1, instead of the typical light values, instead represents the +In the bulk MapNode data, param1, instead of the typical light values, instead represents the probability of that node appearing in the structure. -When passed to minetest.create_schematic, probability is an integer value ranging from -1 to 255: - - A probability value of 0 means that node will always appear. - - A probability value of -1 means the node will never appear. +When passed to minetest.create_schematic, probability is an integer value ranging from 0 to 255: + - A probability value of 0 means that node will never appear (0% chance). + - A probability value of 255 means the node will always appear (100% chance). - If the probability value p is greater than 0, then there is a (p / 256 * 100)% chance that node will appear when the schematic is placed on the map. -If registering a structure in the raw format, however, -1 is not a valid probability value; in order to -have a node that is not placed, it must be CONTENT_IGNORE (the name for which is "ignore"). - Important note: Node aliases cannot be used for a raw schematic provided when registering as a decoration. Schematic attributes --------------------- +See section Flag Specifier Format. Currently supported flags: place_center_x, place_center_y, place_center_z - place_center_x Placement of this decoration is centered along the X axis. @@ -470,14 +475,17 @@ 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 precisely-positioned items in the HUD. +Note offset WILL adapt to screen dpi as well as user defined scaling factor! Below are the specific uses for fields in each type; fields not listed for that type are ignored. Note: Future revisions to the HUD API may be incompatible; the HUD API is still in the experimental stages. - image Displays an image on the HUD. - - scale: The scale of the image, with 1 being the original texture size. - Only the X coordinate scale is used. + - scale: The scale of the image, with 1 being the original texture size. + Only the X coordinate scale is used (positive values) + Negative values represent that percentage of the screen it + should take; e.g. x=-100 means 100% (width) - text: The name of the texture that is displayed. - alignment: The alignment of the image. - offset: offset in pixels from position. @@ -497,24 +505,50 @@ Note: Future revisions to the HUD API may be incompatible; the HUD API is still If odd, will end with a vertically center-split texture. - direction - offset: offset in pixels from position. + - size: If used will force full-image size to this value (override texture 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. - direction +- waypoint + Displays distance to selected world position. + - name: The name of the waypoint. + - text: Distance suffix. Can be blank. + - number: An integer containing the RGB value of the color used to draw the text. + - world_pos: World position of the waypoint. Representations of simple things -------------------------------- Position/vector: {x=num, y=num, z=num} -Currently the API does not provide any helper functions for addition, -subtraction and whatever; you can define those that you need yourself. +For helper functions see "Vector helpers". pointed_thing: {type="nothing"} {type="node", under=pos, above=pos} {type="object", ref=ObjectRef} +Flag Specifier Format +----------------------- +Flags using the standardized flag specifier format can be specified in either of two ways, by string or table. +The string format is a comma-delimited set of flag names; whitespace and unrecognized flag fields are ignored. +Specifying a flag in the string sets the flag, and specifying a flag prefixed by the string "no" explicitly +clears the flag from whatever the default may be. +In addition to the standard string flag format, the schematic flags field can also be a table of flag names +to boolean values representing whether or not the flag is set. Additionally, if a field with the flag name +prefixed with "no" is present, mapped to a boolean of any value, the specified flag is unset. + +e.g. A flag field of value + {place_center_x = true, place_center_y=false, place_center_z=true} +is equivalent to + {place_center_x = true, noplace_center_y=true, place_center_z=true} +which is equivalent to + "place_center_x, noplace_center_y, place_center_z" +or even + "place_center_x, place_center_z" +since, by default, no schematic attributes are set. + Items ------ Node (register_node): @@ -532,7 +566,7 @@ eg. 'default:pick_wood 21323' eg. 'default:apple' Table format: -eg. {name="default:dirt", count=5, wear=0, metadata=""} +eg. {name="default:dirt", count=5, wear=0, metadata=""} ^ 5 dirt nodes eg. {name="default:pick_wood", count=1, wear=21323, metadata=""} ^ a wooden pick about 1/3 weared out @@ -817,7 +851,7 @@ Example stuff: local meta = minetest.get_meta(pos) meta:set_string("formspec", - "invsize[8,9;]".. + "size[8,9]".. "list[context;main;0,0;8,4;]".. "list[current_player;main;0,5;8,4;]") meta:set_string("infotext", "Chest"); @@ -829,7 +863,7 @@ meta:from_table({ main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "", [5] = "", [6] = "", [7] = "", [8] = "", [9] = "", [10] = "", [11] = "", [12] = "", [13] = "", [14] = "default:cobble", [15] = "", [16] = "", [17] = "", [18] = "", [19] = "", [20] = "default:cobble", [21] = "", [22] = "", [23] = "", [24] = "", [25] = "", [26] = "", [27] = "", [28] = "", [29] = "", [30] = "", [31] = "", [32] = ""} }, fields = { - formspec = "invsize[8,9;]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]", + formspec = "size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]", infotext = "Chest" } }) @@ -844,17 +878,17 @@ examples. Examples: - Chest: - invsize[8,9;] + size[8,9] list[context;main;0,0;8,4;] list[current_player;main;0,5;8,4;] - Furnace: - invsize[8,9;] + size[8,9] list[context;fuel;2,3;1,1;] list[context;src;2,1;1,1;] list[context;dst;5,1;2,2;] list[current_player;main;0,5;8,4;] - Minecraft-like player inventory - invsize[8,7.5;] + size[8,7.5] image[1,0.6;1,2;player.png] list[current_player;main;0,3.5;8,4;] list[current_player;craft;3,0;3,3;] @@ -862,14 +896,31 @@ Examples: Elements: -size[,] +size[,,] ^ Define the size of the menu in inventory slots +^ fixed_size true/false (optional) ^ deprecated: invsize[,;] list[;;,;,;] list[;;,;,;] ^ Show an inventory list +listcolors[;] +^ Sets background color of slots in HEX-Color format +^ Sets background color of slots on mouse hovering + +listcolors[;;] +^ Sets background color of slots in HEX-Color format +^ Sets background color of slots on mouse hovering +^ Sets color of slots border + +listcolors[;;;;] +^ Sets background color of slots in HEX-Color format +^ Sets background color of slots on mouse hovering +^ Sets color of slots border +^ Sets background color of tooltips +^ Sets font color of tooltips + image[,;,;] ^ Show an image ^ Position and size units are inventory slots @@ -878,11 +929,30 @@ item_image[,;,;] ^ Show an inventory image of registered item/node ^ Position and size units are inventory slots +bgcolor[;] +^ Sets background color of formspec in HEX-Color format +^ If true the background color is drawn fullscreen (does not effect the size of the formspec) + 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*16px x 4*16px +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*16px x 4*16px +^ If true the background is clipped to formspec size (x and y are used as offset values, w and h are ignored) + +pwdfield[,;,;;