]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - doc/lua_api.txt
is_player() is no player-only function
[dragonfireclient.git] / doc / lua_api.txt
index a7fcaeab1857e6ef77ca843eb37ba4b88d930c93..8fda137ae89abc9c6506355f5a56ee9bb56eb231 100644 (file)
@@ -782,30 +782,27 @@ Schematic specifier
 --------------------
 A schematic specifier identifies a schematic by either a filename to a
 Minetest Schematic file (`.mts`) 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 probability of that node appearing in the structure.
-
-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
+in the form of a table.  This table specifies the following fields:
+
+* The `size` field is a 3D vector containing the dimensions of the provided schematic. (required)
+* The `yslice_prob` field is a table of {ypos, prob} which sets the `ypos`th vertical slice
+  of the schematic to have a `prob / 256 * 100` chance of occuring. (default: 255)
+* The `data` field is a flat table of MapNode tables making up the schematic,
+  in the order of `[z [y [x]]]`. (required)
+  Each MapNode table contains:
+  * `name`: the name of the map node to place (required)
+  * `prob` (alias `param1`): the probability of this node being placed (default: 255)
+  * `param2`: the raw param2 value of the node being placed onto the map (default: 0)
+  * `force_place`: boolean representing if the node should forcibly overwrite any
+     previous contents (default: false)
+
+About probability values:
+* A probability value of `0` or `1` means that node will never appear (0% chance).
+* A probability value of `254` or `255` means the node will always appear (100% chance).
+* If the probability value `p` is greater than `1`, then there is a
+  `(p / 256 * 100)` percent chance that node will appear when the schematic is
   placed on the map.
 
-**Important note**: Node aliases cannot be used for a raw schematic provided
-  when registering as a decoration.
-
 
 Schematic attributes
 --------------------
@@ -1871,6 +1868,8 @@ and `minetest.auth_reload` call the authetification handler.
 * `minetest.punch_node(pos)`
     * Punch node with the same effects that a player would cause
 
+* `minetest.find_nodes_with_meta(pos1, pos2)`
+    * Get a table of positions of nodes that have metadata within a region {pos1, pos2}
 * `minetest.get_meta(pos)`
     * Get a `NodeMetaRef` at that position
 * `minetest.get_node_timer(pos)`
@@ -2176,17 +2175,10 @@ These functions return the leftover itemstack.
     * "mts" - a string containing the binary MTS data used in the MTS file format
     * "lua" - a string containing Lua code representing the schematic in table format
     * `options` is a table containing the following optional parameters:
-    * If `use_comments` is true and `format` is "lua", the Lua code generated will have (X, Z)
+    * If `lua_use_comments` is true and `format` is "lua", the Lua code generated will have (X, Z)
     * position comments for every X row generated in the schematic data for easier reading.
-    * If `register_after_load` is true, then `schematic`, if not yet loaded, will be registered
-    * after loading and persist in memory.
-    * node_resolve_method can be one of either "none", "direct", or "deferred" (default: "none")
-    * This sets the way method by with node names are mapped to their content IDs, if loaded:
-    * "none" performs no node resolution and preserves all node names from the schematic definition
-    * "direct" performs an immediate lookup of content ID, given all the nodes that have been
-    * registered up to this point in script execution
-    * "deferred" pends node resolution until after the script registration phase has ended
-    * In practice, it is recommended to use "none" in nearly all use cases.
+    * If `lua_num_indent_spaces` is a nonzero number and `format` is "lua", the Lua code generated
+    * will use that number of spaces as indentation instead of a tab character.
 
 ### Misc.
 * `minetest.get_connected_players()`: returns list of `ObjectRefs`
@@ -2289,6 +2281,9 @@ These functions return the leftover itemstack.
 
 Please note that forceloaded areas are saved when the server restarts.
 
+minetest.global_exists(name)
+^ Checks if a global variable has been set, without triggering a warning.
+
 ### Global objects
 * `minetest.env`: `EnvRef` of the server environment and world.
     * Any function in the minetest namespace can be called using the syntax
@@ -2392,6 +2387,7 @@ This is basically a reference to a C++ `ServerActiveObject`
     * `position`: `{x=num, y=num, z=num}` (relative)
     * `rotation`: `{x=num, y=num, z=num}`
 * `set_properties(object property table)`
+* `is_player()`: returns true for players, false otherwise
 
 ##### LuaEntitySAO-only (no-op for other objects)
 * `setvelocity({x=num, y=num, z=num})`
@@ -2409,7 +2405,6 @@ This is basically a reference to a C++ `ServerActiveObject`
 * `get_luaentity()`
 
 ##### Player-only (no-op for other objects)
-* `is_player()`: true for players, false for others
 * `get_player_name()`: returns `""` if is not a player
 * `get_look_dir()`: get camera direction as a unit vector
 * `get_look_pitch()`: pitch in radians
@@ -2479,7 +2474,7 @@ This is basically a reference to a C++ `ServerActiveObject`
             {x=189, y=198}, -- <  dig animation key frames
             {x=200, y=219}, -- <  walk+dig animation key frames
             frame_speed=30): -- <  animation frame speed
-            
+
 * `set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})`: defines offset value for camera per player
     * in first person view
     * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
@@ -3195,6 +3190,10 @@ Definition tables
     --  ^ Multiplier of the randomness contribution to the noise value at any
     --   given point to decide if ore should be placed.  Set to 0 for solid veins.
     --  ^ This parameter is only valid for ore_type == "vein".
+        biomes = {"desert", "rainforest"}
+    --  ^ List of biomes in which this decoration occurs.  Occurs in all biomes if this is omitted,
+    --  ^ and ignored if the Mapgen being used does not support biomes.
+    --  ^ Can be a list of (or a single) biome names, IDs, or definitions.
     }
 
 ### Decoration definition (`register_decoration`)