diff --git a/lua_api.html b/lua_api.html index bea02a1..4f0a2f0 100644 --- a/lua_api.html +++ b/lua_api.html @@ -188,6 +188,7 @@ layout: default
  • Inventory locations
  • ColorString
  • +
  • ColorSpec
  • Vector helpers
  • Helper functions
  • minetest namespace referenceThis page was last updated 08/May/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 27/May/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

    @@ -986,27 +987,26 @@ structures, such as trees, cave spikes, rocks, and so on.

    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:

    +in the form of a table. This table specifies the following fields:

    -

    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:

    - -

    Important note: Node aliases cannot be used for a raw schematic provided - when registering as a decoration.

    +

    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.

    Schematic attributes

    See section "Flag Specifier Format".

    Currently supported flags: place_center_x, place_center_y, @@ -1801,6 +1801,14 @@ pass key press events to formspec!

    To specify the value of the alpha channel, append #AA to the end of the color name (e.g. colorname#08). For named colors the hexadecimal string representing the alpha value must (always) be two hexadecimal digits.

    +

    ColorSpec

    +

    A ColorSpec specifies a 32-bit color. It can be written in either: +table form, each element ranging from 0..255 (a, if absent, defaults to 255): + colorspec = {a=255, r=0, g=255, b=0} +numerical form, the raw integer value of an ARGB8 quad: + colorspec = 0xFF00FF00 +or string form, a ColorString (defined above): + colorspec = "green"

    Vector helpers

    -

    Example of minetest.get_player_information return value:

    -
    {
    -    address = "127.0.0.1",     -- IP address of client
    -    ip_version = 4,            -- IPv4 / IPv6
    -    min_rtt = 0.01,            -- minimum round trip time
    -    max_rtt = 0.2,             -- maximum round trip time
    -    avg_rtt = 0.02,            -- average round trip time
    -    min_jitter = 0.01,         -- minimum packet time jitter
    -    max_jitter = 0.5,          -- maximum packet time jitter
    -    avg_jitter = 0.03,         -- average packet time jitter
    -    connection_uptime = 200,   -- seconds since client connected
    -
    -    -- following information is available on debug build only!!!
    +
  • minetest.get_player_information(player_name): returns a table containing + information about player. Example return value: + { + address = "127.0.0.1", -- IP address of client + ip_version = 4, -- IPv4 / IPv6 + min_rtt = 0.01, -- minimum round trip time + max_rtt = 0.2, -- maximum round trip time + avg_rtt = 0.02, -- average round trip time + min_jitter = 0.01, -- minimum packet time jitter + max_jitter = 0.5, -- maximum packet time jitter + avg_jitter = 0.03, -- average packet time jitter + connection_uptime = 200, -- seconds since client connected
        -- following information is available on debug build only!!!
         -- DO NOT USE IN MODS
         --ser_vers = 26,             -- serialization version used by client
         --prot_vers = 23,            -- protocol version used by client
    @@ -1936,6 +1938,18 @@ value must (always) be two hexadecimal digits.

    --state = "Active" -- current client state }
    +
      +
    • minetest.mkdir(path): returns success.
    • +
    • Creates a directory specified by path, creating parent directories + if they don't exist.
    • +
    • minetest.get_dir_list(path, [is_dir]): returns list of entry names
    • +
    • is_dir is one of:
    • +
    • nil: return all entries,
    • +
    • true: return only subdirectory names, or
    • +
    • false: return only file names.
    • +
    +
  • +

    Logging

    • minetest.debug(line)
        @@ -2017,6 +2031,18 @@ value must (always) be two hexadecimal digits.

      • Called when a player dies
    • +
    • minetest.register_on_punchplayer(func(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))
        +
      • Called when a player is punched
      • +
      • player - ObjectRef - Player that was punched
      • +
      • hitter - ObjectRef - Player that hit
      • +
      • time_from_last_punch: Meant for disallowing spamming of clicks (can be nil)
      • +
      • tool_capabilities: capability table of used tool (can be nil)
      • +
      • dir: unit vector of direction of punch. Always defined. Points from + the puncher to the punched.
      • +
      • damage - number that represents the damage calculated by the engine
      • +
      • should return true to prevent the default damage mechanism
      • +
      +
    • minetest.register_on_respawnplayer(func(ObjectRef))
      • Called when player is to be respawned
      • Called before repositioning of player occurs
      • @@ -2101,9 +2127,17 @@ value must (always) be two hexadecimal digits.

        -
      • minetest.setting_set(name, value)
      • +
      • minetest.setting_set(name, value)
          +
        • Setting names can't contain whitespace or any of ="{}#.
        • +
        • Setting values can't contain the sequence \n""".
        • +
        • Setting names starting with "secure." can't be set.
        • +
        +
      • minetest.setting_get(name): returns string or nil
      • -
      • minetest.setting_setbool(name, value)
      • +
      • minetest.setting_setbool(name, value)
          +
        • See documentation on setting_set for restrictions.
        • +
        +
      • minetest.setting_getbool(name): returns boolean or nil
      • minetest.setting_get_pos(name): returns position or nil
      • minetest.setting_save(), returns nil, save all settings to config file
      • @@ -2677,6 +2711,12 @@ and minetest.auth_reload call the authetification handler.

      • Deprecated: An alias for the former.
    • +
    • minetest.raillike_group(name): returns a rating
        +
      • Returns rating of the connect_to_raillike group corresponding to name
      • +
      • If name is not yet the name of a connect_to_raillike group, a new group id
      • +
      • is created, with that name
      • +
      +
    • minetest.get_content_id(name): returns an integer
      • Gets the internal content ID of name
      @@ -2777,23 +2817,22 @@ end the floor or ceiling
    • The first four options are mutually-exclusive; the last in the list takes precedence over the first.
    • -
    -
  • - - -
  • -

    minetest.rotate_node(itemstack, placer, pointed_thing)

    - +
  • + +
  • minetest.forceload_block(pos)

  • @@ -2802,19 +2841,32 @@ end
  • stops forceloading the position pos
  • +
  • +

    minetest.request_insecure_environment(): returns an environment containing + insecure functions if the calling mod has been listed as trusted in the + secure.trusted_mods setting or security is disabled, otherwise returns nil.

    + +
  • +
  • +

    minetest.global_exists(name)

    + +
  • -

    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

    Global tables

  • set_properties(object property table)
  • +
  • is_player(): returns true for players, false otherwise
  • LuaEntitySAO-only (no-op for other objects)
    Player-only (no-op for other objects)
  • set_sky(bgcolor, type, {texture names})

    InvRef

    An InvRef is a reference to an inventory.

    @@ -3202,15 +3269,29 @@ or minetest.get_perlin(noiseparams).

    Format of size is {x=dimx, y=dimy, z=dimz}. The z conponent is ommitted for 2D noise, and it must be must be larger than 1 for 3D noise (otherwise nil is returned).

    +

    For each of the functions with an optional buffer parameter: If buffer is not +nil, this table will be used to store the result instead of creating a new table.

    Methods

    VoxelManip

    An interface to the MapVoxelManipulator for Lua.

    @@ -3231,8 +3312,9 @@ The map will be pre-loaded if two positions are passed to either.

    the VoxelManip at that position
  • set_node_at(pos, node): Sets a specific MapNode in the VoxelManip at that position
  • -
  • get_data(): Gets the data read into the VoxelManip object