From 706d74427ef1edeeac55f51d2174c5b33714ae16 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 7 Dec 2015 18:04:11 +0000 Subject: [PATCH] Update lua_api.html --- lua_api.html | 114 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 26 deletions(-) diff --git a/lua_api.html b/lua_api.html index 3f9c108..8f3b120 100644 --- a/lua_api.html +++ b/lua_api.html @@ -329,6 +329,7 @@ layout: default
  • Recipe for register_craft (cooking)
  • Recipe for register_craft (furnace fuel)
  • Ore definition (register_ore)
  • +
  • Biome definition (register_biome)
  • Decoration definition (register_decoration)
  • Chat command definition (register_chatcommand)
  • Detached inventory callbacks
  • @@ -353,7 +354,7 @@ source code patches to celeron55@gmail.com< This page was last updated 22/November/2015.
    See doc/lua_api.txt for the latest version (in plaintext).
    Generated using a Python script.

    Programming in Lua

    +This page was last updated 07/December/2015.
    See doc/lua_api.txt for the latest version (in plaintext).
    Generated using a Python script.

    Programming in Lua

    If you have any difficulty in understanding this, please read Programming in Lua.

    Startup

    @@ -998,7 +999,7 @@ parameters np_puff_top and np_puff_bottom, respectivel 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_threshhold. +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:

    @@ -1011,7 +1012,7 @@ to small changes. The following is a decent set of parameters to work from:

    persist = 0.5, flags = "eased", }, -noise_threshhold = 1.6 +noise_threshold = 1.6

    WARNING: Use this ore type very sparingly since it is ~200x more computationally expensive than any other ore.

    @@ -1463,12 +1464,16 @@ the entity itself.

    The instance of a node in the world normally only contains the three values mentioned in "Nodes". However, it is possible to insert extra data into a node. It is called "node metadata"; See "NodeMetaRef".

    -

    Metadata contains two things: - A key-value store - An inventory

    -

    Some of the values in the key-value store are handled specially: - formspec: Defines a right-click inventory menu. See "Formspec". - infotext: Text shown on the screen when the node is pointed at

    +

    Metadata contains two things:

    + +

    Some of the values in the key-value store are handled specially:

    +

    Example stuff:

    local meta = minetest.get_meta(pos)
     meta:set_string("formspec",
    @@ -2237,7 +2242,11 @@ or string form, a ColorString (defined above):
     
     
     
  • #minetest.get_password_hash(name, raw_password)
      -
    • Convert a name-password pair to a password hash that Minetest can use
    • +
    • Convert a name-password pair to a password hash that Minetest can use.
    • +
    • The returned value alone is not a good basis for password checks based
    • +
    • on comparing the password hash in the database with the password hash
    • +
    • from the function, with an externally provided password, as the hash
    • +
    • in the db might use the new SRP verifier format.
  • #minetest.string_to_privs(str): returns {priv1=true,...}
  • @@ -2537,7 +2546,7 @@ and minetest.auth_reload call the authetification handler.

  • #playername: name of player to show formspec
  • #formname: name passed to on_player_receive_fields callbacks. It should follow the "modname:<whatever>" naming convention
  • -
  • #formspec: formspec to display
  • +
  • #formspec: formspec to display
  • #minetest.formspec_escape(string): returns a string
      @@ -3572,20 +3581,22 @@ core.CONTENT_IGNORE (ID for "ignore" nodes)

      Mapgen VoxelManip objects

      Inside of on_generated() callbacks, it is possible to retrieve the same VoxelManip object used by the core's Map Generator (commonly abbreviated Mapgen). Most of the rules previously described still apply -but with a few differences: - The Mapgen VoxelManip object is retrieved using: minetest.get_mapgen_object("voxelmanip") - This VoxelManip object already has the region of map just generated loaded into it; it's not necessary - to call VoxelManip:read_from_map() before using a Mapgen VoxelManip. - The on_generated() callbacks of some mods may place individual nodes in the generated area using +but with a few differences:

      +
        +
      • #The Mapgen VoxelManip object is retrieved using: minetest.get_mapgen_object("voxelmanip")
      • +
      • #This VoxelManip object already has the region of map just generated loaded into it; it's not necessary + to call VoxelManip:read_from_map() before using a Mapgen VoxelManip.
      • +
      • #The on_generated() callbacks of some mods may place individual nodes in the generated area using non-VoxelManip map modification methods. Because the same Mapgen VoxelManip object is passed through each on_generated() callback, it becomes necessary for the Mapgen VoxelManip object to maintain consistency with the current map state. For this reason, calling any of the following functions: minetest.add_node(), minetest.set_node(), or minetest.swap_node() - will also update the Mapgen VoxelManip object's internal state active on the current thread. - After modifying the Mapgen VoxelManip object's internal buffer, it may be necessary to update lighting - information using either: VoxelManip:calc_lighting() or VoxelManip:set_lighting(). -* VoxelManip:update_map() does not need to be called after write_to_map(). The map update is performed - automatically after all on_generated callbacks have been run for that generated block.

        + will also update the Mapgen VoxelManip object's internal state active on the current thread.
      • +
      • #After modifying the Mapgen VoxelManip object's internal buffer, it may be necessary to update lighting + information using either: VoxelManip:calc_lighting() or VoxelManip:set_lighting().
      • +
      • #VoxelManip:update_map() does not need to be called after write_to_map(). The map update is performed + automatically after all on_generated callbacks have been run for that generated block.
      • +
      Other API functions operating on a VoxelManip

      If any VoxelManip contents were set to a liquid node, VoxelManip:update_liquids() must be called for these liquid nodes to begin flowing. It is recommended to call this function only after having @@ -3607,7 +3618,7 @@ will place the schematic inside of the VoxelManip.

      object. With the exception of Mapgen VoxelManips (see above section), the internal buffers are not updated. For this reason, it is strongly encouraged to complete the usage of a particular VoxelManip object in the same callback it had been created. -
    • #If a VoxelManip object will be used often, such as in an on_generated() callback, consider passing +
    • #If a VoxelManip object will be used often, such as in an on_generated() callback, consider passing a file-scoped table as the optional parameter to VoxelManip:get_data(), which serves as a static buffer the function can use to write map data to instead of returning a new table each call. This greatly enhances performance by avoiding unnecessary memory allocations.
    • @@ -3637,7 +3648,7 @@ will place the schematic inside of the VoxelManip.

      not a VoxelManip that was retrieved from minetest.get_mapgen_object
  • -
  • #set_lighting(light, p1, p2): Set the lighting within the VoxelManip to a uniform value
      +
    • #set_lighting(light, [p1, p2]): Set the lighting within the VoxelManip to a uniform value
      • #light is a table, {day=<0...15>, night=<0...15>}
      • #To be used only by a VoxelManip object from minetest.get_mapgen_object
      • #(p1, p2) is the area in which lighting is set; @@ -3657,10 +3668,12 @@ will place the schematic inside of the VoxelManip.

      • #get_param2_data(): Gets the raw param2 data read into the VoxelManip object
      • #set_param2_data(param2_data): Sets the param2 contents of each node in the VoxelManip
      • -
      • #calc_lighting(p1, p2): Calculate lighting within the VoxelManip
          +
        • #calc_lighting([p1, p2], [propagate_shadow]): Calculate lighting within the VoxelManip
          • #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
          • + if left out or nil +
          • #propagate_shadow is an optional boolean deciding whether shadows in a generated + mapchunk above are propagated down into the mapchunk; defaults to true if left out
        • #update_liquids(): Update liquid flow
        • @@ -3953,6 +3966,11 @@ minetest.spawn_tree(pos,apple_tree) --[[ ^ Shall place item and return the leftover itemstack ^ default: minetest.item_place ]] + on_secondary_use = func(itemstack, user, pointed_thing), + --[[ + ^ Same as on_place but called when pointing at nothing. + ^ pointed_thing : always { type = "nothing" } + ]] on_drop = func(itemstack, dropper, pos), --[[ ^ Shall drop item and return the leftover itemstack @@ -4212,7 +4230,7 @@ minetest.spawn_tree(pos,apple_tree) y_max = 64, flags = "", -- ^ Attributes for this ore generation - noise_threshhold = 0.5, + noise_threshold = 0.5, -- ^ 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. @@ -4227,6 +4245,50 @@ minetest.spawn_tree(pos,apple_tree) -- ^ Can be a list of (or a single) biome names, IDs, or definitions. }
  • +

    Biome definition (register_biome)

    +
    {
    +    name = "tundra",
    +    node_dust = "default:snow",
    +--  ^ Node dropped onto upper surface after all else is generated.
    +    node_top = "default:dirt_with_snow",
    +    depth_top = 1,
    +--  ^ Node forming surface layer of biome and thickness of this layer.
    +    node_filler = "default:permafrost",
    +    depth_filler = 3,
    +--  ^ Node forming lower layer of biome and thickness of this layer.
    +    node_stone = "default:bluestone",
    +--  ^ Node that replaces all stone nodes between roughly y_min and y_max.
    +    node_water_top = "default:ice",
    +    depth_water_top = 10,
    +--  ^ Node forming a surface layer in seawater with the defined thickness.
    +    node_water = "",
    +--  ^ Node that replaces all seawater nodes not in the defined surface layer.
    +    node_river_water = "default:ice",
    +--  ^ Node that replaces river water in mapgens that use default:river_water.
    +    y_min = 1,
    +    y_max = 31000,
    +--  ^ Lower and upper limits for biome.
    +--  ^ Because biome is not recalculated for every node in a node column
    +--  ^ some biome materials can exceed their limits, especially stone.
    +--  ^ For each node column in a mapchunk, biome is only recalculated at column
    +--  ^ top and at each of these surfaces:
    +--  ^ Ground below air, water below air, ground below water.
    +--  ^ The selected biome then stays in effect for all nodes below until
    +--  ^ column base or the next biome recalculation.
    +    heat_point = 0,
    +    humidity_point = 50,
    +--  ^ Characteristic average temperature and humidity for the biome.
    +--  ^ These values create 'biome points' on a voronoi diagram that has heat
    +--  ^ and humidity as axes. The resulting voronoi cells determine which
    +--  ^ heat/humidity points belong to which biome, and therefore determine
    +--  ^ the area and location of each biome in the world.
    +--  ^ The biome points need to be carefully and evenly spaced on the voronoi
    +--  ^ diagram to result in roughly equal size biomes.
    +--  ^ Heat and humidity have average values of 50, vary mostly between
    +--  ^ 0 and 100 but also often exceed these values.
    +--  ^ Heat is not in degrees celcius, both values are abstract.
    +}
    +

    Decoration definition (register_decoration)

    {
         deco_type = "simple", -- See "Decoration types"