]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - doc/lua_api.txt
Document which formspec fields are sent (#7717)
[dragonfireclient.git] / doc / lua_api.txt
index a8e843878a65a55511f70dccd76724fb14e65eec..ca9133b1a3ba3eeabb931707d2517b78283bd02b 100644 (file)
@@ -279,7 +279,7 @@ of the game's nodes are to be used by the core mapgens. For example:
 
     minetest.register_alias("mapgen_stone", "default:stone")
 
-### Aliases needed for all mapgens except Mapgen v6
+### Aliases needed for all mapgens except Mapgen V6
 
 #### Base terrain
 
@@ -289,28 +289,24 @@ of the game's nodes are to be used by the core mapgens. For example:
 
 #### Caves
 
+Not required if cave liquid nodes are set in biome definitions.
+
 * mapgen_lava_source
 
 #### Dungeons
 
-Only needed for registered biomes where 'node_stone' is stone:
+Not required if dungeon nodes are set in biome definitions.
 
 * mapgen_cobble
 * mapgen_stair_cobble
 * mapgen_mossycobble
-
-Only needed for registered biomes where 'node_stone' is desert stone:
-
 * mapgen_desert_stone
 * mapgen_stair_desert_stone
-
-Only needed for registered biomes where 'node_stone' is sandstone:
-
 * mapgen_sandstone
 * mapgen_sandstonebrick
 * mapgen_stair_sandstone_block
 
-### Aliases needed for Mapgen v6
+### Aliases needed for Mapgen V6
 
 #### Terrain and biomes
 
@@ -346,6 +342,13 @@ Only needed for registered biomes where 'node_stone' is sandstone:
 * mapgen_mossycobble
 * mapgen_stair_desert_stone
 
+### Setting the node used in Mapgen Singlenode
+
+By default the world is filled with air nodes. To set a different node use, for
+example:
+
+    minetest.register_alias("mapgen_singlenode", "default:stone")
+
 
 
 
@@ -1074,7 +1077,7 @@ Look for examples in `games/minimal` or `games/minetest_game`.
 * `glasslike_framed`
     * All face-connected nodes are drawn as one volume within a surrounding
       frame.
-    * The frame appearence is generated from the edges of the first texture
+    * The frame appearance is generated from the edges of the first texture
       specified in `tiles`. The width of the edges used are 1/16th of texture
       size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
     * The glass 'shine' (or other desired detail) on each node face is supplied
@@ -1317,6 +1320,17 @@ For helper functions see [Spatial Vectors].
 * `{type="node", under=pos, above=pos}`
 * `{type="object", ref=ObjectRef}`
 
+Exact pointing location (currently only `Raycast` supports these fields):
+* `pointed_thing.intersection_point`: The absolute world coordinates of the
+  point on the selection box which is pointed at. May be in the selection box
+  if the pointer is in the box too.
+* `pointed_thing.box_id`: The ID of the pointed selection box (counting starts
+  from 1).
+* `pointed_thing.intersection_normal`: Unit vector, points outwards of the
+  selected selection box. This specifies which face is pointed at.
+  Is a null vector `{x = 0, y = 0, z = 0}` when the pointer is inside the
+  selection box.
+
 
 
 
@@ -1365,16 +1379,15 @@ Item types
 
 There are three kinds of items: nodes, tools and craftitems.
 
-* Node: An item that can be placed in the world as a node.
-* Tool: An item that can be worn out and repaired, cannot be stacked, and often
-  digs or deals damage.
-* Craftitem: A general purpose item that can be used in crafting recipes, eaten,
-  dropped, or used on things in the world.
+* Node: Can be placed in the world's voxel grid
+* Tool: Has a wear property but cannot be stacked. The default use action is to
+  dig nodes or hit objects according to its tool capabilities.
+* Craftitem: Cannot dig nodes or be placed
 
 Amount and wear
 ---------------
 
-All item stacks have an amount between 0 to 65535. It is 1 by
+All item stacks have an amount between 0 and 65535. It is 1 by
 default. Tool item stacks can not have an amount greater than 1.
 
 Tools use a wear (damage) value ranging from 0 to 65535. The
@@ -1538,6 +1551,8 @@ Special groups
   connect to each other
 * `slippery`: Players and items will slide on the node.
   Slipperiness rises steadily with `slippery` value, starting at 1.
+* `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
+  `"toolrepair"` crafting recipe
 
 
 Known damage and digging time defining groups
@@ -2244,8 +2259,10 @@ Player Inventory lists
 
 * `main`: list containing the default inventory
 * `craft`: list containing the craft input
-* `craftpreview`: list containing the craft output
+* `craftpreview`: list containing the craft prediction
+* `craftresult`: list containing the crafted output
 * `hand`: list containing an override for the empty hand
+    * Is not created automatically, use `InvRef:set_size`
 
 
 
@@ -3538,7 +3555,7 @@ Call these functions only at load time!
       ignored. For input use the same recipe table syntax as for
       `minetest.register_craft(recipe)`. For output specify only the item,
       without a quantity.
-    * If no erase candidate could be found, Lua exception will be thrown.
+    * Returns false if no erase candidate could be found, otherwise returns true.
     * **Warning**! The type field ("shaped", "cooking" or any other) will be
       ignored if the recipe contains output. Erasing is then done independently
       from the crafting method.
@@ -3650,7 +3667,11 @@ Call these functions only at load time!
     * Return `true` to mark the message as handled, which means that it will
       not be sent to other players.
 * `minetest.register_on_player_receive_fields(func(player, formname, fields))`
-    * Called when a button is pressed in player's inventory form
+    * Called when a button is pressed in player's inventory form, when form
+      values are submitted or when the form is actively closed by the player.
+    * Fields are sent for formspec elements which define a field, and the "quit"
+      field is sent when actively closing the form by mouse click, keypress or
+      through a button_exit[] element.
     * Newest functions are called first
     * If function returns `true`, remaining functions are not called
 * `minetest.register_on_craft(func(itemstack, player, old_craft_grid, craft_inv))`
@@ -4126,6 +4147,8 @@ Inventory
       Note that this parameter is mostly just a workaround and will be removed
       in future releases.
     * Creates a detached inventory. If it already exists, it is cleared.
+* `minetest.remove_detached_inventory(name)`
+    * Returns a `boolean` indicating whether the removal succeeded.
 * `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
   returns left over ItemStack.
     * See `minetest.item_eat` and `minetest.register_on_item_eat`
@@ -5051,6 +5074,9 @@ This is basically a reference to a C++ `ServerActiveObject`
 * `set_acceleration(acc)`
     * `acc` is a vector
 * `get_acceleration()`: returns the acceleration, a vector
+* `set_rotation(rot)`
+    * `rot` is a vector (radians)
+* `get_rotation()` : returns the rotation, a vector (radians)
 * `set_yaw(radians)`
 * `get_yaw()`: returns number in radians
 * `set_texture_mod(mod)`
@@ -5324,7 +5350,12 @@ It can be created via `PseudoRandom(seed)`.
 ---------
 
 A raycast on the map. It works with selection boxes.
-Can be used as an iterator in a for loop.
+Can be used as an iterator in a for loop as:
+
+    local ray = Raycast(...)
+    for pointed_thing in ray do
+        ...
+    end
 
 The map is loaded as the ray advances. If the map is modified after the
 `Raycast` is created, the changes may or may not have an effect on the object.
@@ -5339,7 +5370,7 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
 
 ### Methods
 
-* `next()`: returns a `pointed_thing`
+* `next()`: returns a `pointed_thing` with exact pointing location
     * Returns the next thing pointed by the ray or nil.
 
 `SecureRandom`
@@ -6134,6 +6165,8 @@ Used by `minetest.register_craft`.
         additional_wear = -0.02,
     }
 
+Note: Tools with group `disable_repair=1` will not repairable by this recipe.
+
 ### Cooking
 
     {
@@ -6601,14 +6634,21 @@ Used by `minetest.add_particle`.
         -- Disappears after expirationtime seconds
 
         size = 1,
+        -- Scales the visual size of the particle texture.
 
         collisiondetection = false,
-        -- If true collides with physical objects
+        -- If true collides with `walkable` nodes and, depending on the
+        -- `object_collision` field, objects too.
 
         collision_removal = false,
         -- If true particle is removed when it collides.
         -- Requires collisiondetection = true to have any effect.
 
+        object_collision = false,
+        -- If true particle collides with objects that are defined as
+        -- `physical = true,` and `collide_with_objects = true,`.
+        -- Requires collisiondetection = true to have any effect.
+
         vertical = false,
         -- If true faces player using y axis only
 
@@ -6633,10 +6673,12 @@ Used by `minetest.add_particlespawner`.
 
     {
         amount = 1,
+        -- Number of particles spawned over the time period `time`.
 
         time = 1,
-        -- If time is 0 has infinite lifespan and spawns the amount on a
-        -- per-second basis.
+        -- Lifespan of spawner in seconds.
+        -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
+        -- a per-second basis.
 
         minpos = {x=0, y=0, z=0},
         maxpos = {x=0, y=0, z=0},
@@ -6648,14 +6690,21 @@ Used by `minetest.add_particlespawner`.
         maxexptime = 1,
         minsize = 1,
         maxsize = 1,
-        -- The particle's properties are random values in between the bounds
+        -- The particles' properties are random values between the min and max
+        -- values.
         -- pos, velocity, acceleration, expirationtime, size
 
         collisiondetection = false,
-        -- If true collides with physical objects
+        -- If true collide with `walkable` nodes and, depending on the
+        -- `object_collision` field, objects too.
 
         collision_removal = false,
-        -- If true particle is removed when it collides.
+        -- If true particles are removed when they collide.
+        -- Requires collisiondetection = true to have any effect.
+
+        object_collision = false,
+        -- If true particles collide with objects that are defined as
+        -- `physical = true,` and `collide_with_objects = true,`.
         -- Requires collisiondetection = true to have any effect.
 
         attached = ObjectRef,
@@ -6663,15 +6712,15 @@ Used by `minetest.add_particlespawner`.
         -- relative to this object's position and yaw
 
         vertical = false,
-        -- If true faces player using y axis only
+        -- If true face player using y axis only
 
         texture = "image.png",
 
         playername = "singleplayer",
-        -- Optional, if specified spawns particle only on the player's client
+        -- Optional, if specified spawns particles only on the player's client
 
         animation = {Tile Animation definition},
-        -- Optional, specifies how to animate the particle texture
+        -- Optional, specifies how to animate the particles' texture
 
         glow = 0
         -- Optional, specify particle self-luminescence in darkness.