]> git.lizzy.rs Git - minetest.git/blobdiff - doc/lua_api.txt
Add missing doc for minetest.get_us_time()
[minetest.git] / doc / lua_api.txt
index 0d42d8ef6ef416bf36b448f2480ed2308e96553a..37eb7e79685b4ceb7852e43ec1b1538d95d58068 100644 (file)
@@ -1,4 +1,4 @@
-Minetest Lua Modding API Reference 0.4.9
+Minetest Lua Modding API Reference 0.4.10
 ========================================
 More information at http://www.minetest.net/
 Developer Wiki: http://dev.minetest.net/
@@ -186,6 +186,82 @@ stripping out the file extension:
   e.g. foomod_foothing.png
   e.g. foomod_foothing
 
+Texture modifiers
+-----------------
+There are various texture modifiers that can be used
+to generate textures on-the-fly.
+
+Texture overlaying:
+  Textures can be overlaid by putting a ^ between them.
+  Example: default_dirt.png^default_grass_side.png
+    default_grass_side.png is overlayed over default_dirt.png
+
+Texture grouping:
+  Textures can be grouped together by enclosing them in ( and ).
+  Example: cobble.png^(thing1.png^thing2.png)
+    A texture for 'thing1.png^thing2.png' is created and the resulting
+    texture is overlaid over cobble.png.
+
+Advanced texture modifiers:
+  [crack:<n>:<p>
+    n = animation frame count, p = current animation frame
+    Draw a step of the crack animation on the texture.
+    Example: default_cobble.png^[crack:10:1
+
+  [combine:<w>x<h>:<x1>,<y1>=<file1>:<x2>,<y2>=<file2>
+    w = width, h = height, x1/x2 = x position, y1/y1 = y position,
+    file1/file2 = texture to combine
+    Create a texture of size <w> x <h> and blit <file1> to (<x1>,<y1>)
+    and blit <file2> to (<x2>,<y2>).
+    Example: [combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
+
+  [brighten
+    Brightens the texture.
+    Example: tnt_tnt_side.png^[brighten
+
+  [noalpha
+    Makes the texture completely opaque.
+    Example: default_leaves.png^[noalpha
+
+  [makealpha:<r>,<g>,<b>
+    Convert one color to transparency.
+    Example: default_cobble.png^[makealpha:128,128,128
+
+  [transform<t>
+    t = transformation(s) to apply
+    Rotates and/or flips the image.
+    <t> can be a number (between 0 and 7) or a transform name.
+       Rotations are counter-clockwise.
+     0  I      identity
+     1  R90    rotate by 90 degrees
+     2  R180   rotate by 180 degrees
+     3  R270   rotate by 270 degrees
+     4  FX     flip X
+     5  FXR90  flip X then rotate by 90 degrees
+     6  FY     flip Y
+     7  FYR90  flip Y then rotate by 90 degrees
+    Example: default_stone.png^[transformFXR90
+
+  [inventorycube{<top>{<left>{<right>
+     '^' is replaced by '&' in texture names
+    Create an inventory cube texture using the side textures.
+    Example: [inventorycube{grass.png{dirt.png&grass_side.png{dirt.png&grass_side.png
+     Creates an inventorycube with 'grass.png', 'dirt.png^grass_side.png' and
+     'dirt.png^grass_side.png' textures
+
+  [lowpart:<percent>:<file>
+    Blit the lower <percent>% part of <file> on the texture:
+    Example: base.png^[lowpart:25:overlay.png
+
+  [verticalframe:<t>:<n>
+    t = animation frame count, n = current animation frame
+    Crops the texture to a frame of a vertical animation.
+    Example: default_torch_animated.png^[verticalframe:16:8
+
+  [mask:<file>
+    Apply a mask to the base image.
+    The mask is applied using binary AND.
+
 Sounds
 -------
 Only OGG Vorbis files are supported.
@@ -394,13 +470,13 @@ 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
-    that point is greater than the noise_threshhold, giving the ability to create a non-equal
+    that point is greater than the noise_threshold, giving the ability to create a non-equal
     distribution of ore.
 - sheet
     Creates a sheet of ore in a blob shape according to the 2d perlin noise described by noise_params.
     The relative height of the sheet can be controlled by the same perlin noise as well, by specifying
     a non-zero 'scale' parameter in noise_params.  IMPORTANT: The noise is not transformed by offset or
-    scale when comparing against the noise threshhold, but scale is used to determine relative height.
+    scale when comparing against the noise threshold, but scale is used to determine relative height.
     The height of the blob is randomly scattered, with a maximum height of clust_size.
     clust_scarcity and clust_num_ores are ignored.
     This is essentially an improved version of the so-called "stratus" ore seen in some unofficial mods.
@@ -769,7 +845,7 @@ tool_capabilities = {
     damage_groups = {fleshy=2},
 }
 
-This makes the tool be able to dig nodes that fulfill both of these:
+This makes the tool be able to dig nodes that fulfil both of these:
 - Have the **crumbly** group
 - Have a **level** group less or equal to 2
 
@@ -1047,7 +1123,7 @@ textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<sele
 tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]
 ^ show a tabHEADER at specific position (ignores formsize)
 ^ x and y position the itemlist relative to the top left of the menu
-^ name fieldname data is transfered to Lua
+^ name fieldname data is transferred to Lua
 ^ caption 1... name shown on top of tab
 ^ current_tab index of selected tab 1...
 ^ transparent (optional) show transparent
@@ -1061,20 +1137,35 @@ box[<X>,<Y>;<W>,<H>;<color>]
 
 dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]
 ^ show a dropdown field
+^ IMPORTANT NOTE: There are two different operation modes:
+^     1) handle directly on change (only changed dropdown is submitted)
+^     2) read the value on pressing a button (all dropdown values are available)
 ^ x and y position of dropdown
 ^ width of dropdown
-^ fieldname data is transfered to Lua
+^ fieldname data is transferred to Lua
 ^ items to be shown in dropdown
 ^ index of currently selected dropdown item
 
 checkbox[<X>,<Y>;<name>;<label>;<selected>;<tooltip>]
 ^ show a checkbox
 ^ x and y position of checkbox
-^ name fieldname data is transfered to Lua
+^ name fieldname data is transferred to Lua
 ^ label to be shown left of checkbox
 ^ selected (optional) true/false
 ^ tooltip (optional)
 
+scrollbar[<X>,<Y>;<W>,<H>;<orientation>;<name>;<value>]
+^ show a scrollbar
+^ there are two ways to use it:
+^     1) handle the changed event (only changed scrollbar is available)
+^     2) read the value on pressing a button (all scrollbars are available)
+^ x and y position of trackbar
+^ width and height
+^ orientation vertical/horizontal
+^ fieldname data is transferred to lua
+^ value this trackbar is set to (0-1000)
+^ see also minetest.explode_scrollbar_event (main menu: engine.explode_scrollbar_event)
+
 table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]
 ^ show scrollable table using options defined by the previous tableoptions[]
 ^ displays cells as defined by the previous tablecolumns[]
@@ -1185,6 +1276,8 @@ minetest.formspec_escape(string) -> string
 ^ escapes characters [ ] \ , ;  that can not be used in formspecs
 minetest.is_yes(arg)
 ^ returns whether arg can be interpreted as yes
+minetest.get_us_time()
+^ returns time with microsecond precision
 
 minetest namespace reference
 -----------------------------
@@ -1448,6 +1541,8 @@ minetest.set_node_level(pos, level)
 ^ set level of leveled node, default level = 1, if totallevel > maxlevel returns rest (total-max).
 minetest.add_node_level(pos, level)
 ^ increase level of leveled node by level, default level = 1, if totallevel > maxlevel returns rest (total-max). can be negative for decreasing
+minetest.get_time_us()
+^ get time in microseconds
 
 Inventory:
 minetest.get_inventory(location) -> InvRef
@@ -1472,6 +1567,9 @@ minetest.explode_table_event(string) -> table
 minetest.explode_textlist_event(string) -> table
 ^ returns e.g. {type="CHG", index=1}
 ^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
+minetest.explode_scrollbar_event(string) -> table
+^ returns e.g. {type="CHG", value=500}
+^ type: "INV" (something failed), "CHG" (has been changed) or "VAL" (not changed)
 
 Item handling:
 minetest.inventorycube(img1, img2, img3)
@@ -1650,7 +1748,7 @@ minetest.parse_json(string[, nullvalue]) -> something
 minetest.write_json(data[, styled]) -> string or nil and error message
 ^ Convert a Lua table into a JSON string
 ^ styled: Outputs in a human-readable format if this is set, defaults to false
-^ Un-serializable things like functions and userdata are saved as null.
+^ Unserializable things like functions and userdata are saved as null.
 ^ Warning: JSON is more strict than the Lua table format.
     1. You can only use strings and positive integers of at least one as keys.
     2. You can not mix string and integer keys.
@@ -1992,7 +2090,7 @@ methods:
   ^ To be used only by a VoxelManip object from minetest.get_mapgen_object
   ^ (p1, p2) is the area in which lighting is set; defaults to the whole area if left out
 - get_light_data(): Gets the light data read into the VoxelManip object
-  ^ Returns an array (indicies 1 to volume) of integers ranging from 0 to 255
+  ^ Returns an array (indices 1 to volume) of integers ranging from 0 to 255
   ^ Each value is the bitwise combination of day and night light values (0..15 each)
   ^ light = day + (night * 16)
 - set_light_data(light_data):  Sets the param1 (light) contents of each node in the VoxelManip
@@ -2112,7 +2210,7 @@ treedef={
   thin_branches, - boolean true -> use thin (1 node) branches
   fruit,         - string  fruit node name
   fruit_chance,  - num     chance (0-100) to replace leaves with fruit node
-  seed,          - num     random seed
+  seed,          - num     random seed; if no seed is provided, the engine will create one
   }
 
 Key for Special L-System Symbols used in Axioms
@@ -2474,7 +2572,7 @@ Ore definition (register_ore)
     flags = "",
     ^ Attributes for this ore generation
     noise_threshhold = 0.5,
-    ^ If noise is above this threshhold, ore is placed.  Not needed for a uniform distribution
+    ^ If noise is above this threshold, ore is placed.  Not needed for a uniform distribution
     noise_params = {offset=0, scale=1, spread={x=100, y=100, z=100}, seed=23, octaves=3, persist=0.70}
     ^ NoiseParams structure describing the perlin noise used for ore distribution.
     ^ Needed for sheet ore_type.  Omit from scatter ore_type for a uniform ore distribution