diff --git a/lua_api.html b/lua_api.html index eb767d4..62ff994 100644 --- a/lua_api.html +++ b/lua_api.html @@ -4,7 +4,7 @@ layout: default ---

This is lua_api.txt nicely formated: I did not write this

-This page was last updated 19/February/2017.
See doc/lua_api.txt for the latest version (in plaintext).
Generated using a Python script.
+This page was last updated 23/April/2017.
See doc/lua_api.txt for the latest version (in plaintext).
Generated using a Python script.

Table of Contents

  • #dig_immediate: (player can always pick up node without tool wear)
  • #disable_jump: Player (and possibly other things) cannot jump from node
  • @@ -1654,6 +1659,9 @@ meta:from_table({

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

    Example stuff:

    local meta = stack:get_meta()
    @@ -1692,6 +1700,18 @@ list[current_player;craftpreview;7,1;1,1;]
     
  • #fixed_size: true/false (optional)
  • #deprecated: invsize[<W>,<H>;]
  • +

    position[<X>,<Y>]

    +
      +
    • Define the position of the formspec
    • +
    • A value between 0.0 and 1.0 represents a position inside the screen
    • +
    • The default value is the center of the screen (0.5, 0.5)
    • +
    +

    anchor[<X>,<Y>]

    +
      +
    • Define the anchor of the formspec
    • +
    • A value between 0.0 and 1.0 represents an anchor inside the formspec
    • +
    • The default value is the center of the formspec (0.5, 0.5)
    • +

    container[<X>,<Y>]

    • Start of a container block, moves all physical elements in the container by (X, Y)
    • @@ -1924,7 +1944,7 @@ list[current_player;craftpreview;7,1;1,1;]
    • Simple colored semitransparent box
    • #x and y position the box relative to the top left of the menu
    • #w and h are the size of box
    • -
    • #color is color specified as a ColorString
    • +
    • #color is color specified as a ColorString
      @@ -2009,7 +2029,7 @@ list[current_player;craftpreview;7,1;1,1;]
    • #Types: text, image, color, indent, tree
      • #text: show cell contents as text
      • #image: cell contents are an image index, use column options to define images
      • -
      • #color: cell contents are a ColorString and define color of following cell
      • +
      • #color: cell contents are a ColorString and define color of following cell
      • #indent: cell contents are a number and define indentation of following cell
      • #tree: same as indent, but user can open and close subtrees (treeview-like)
      @@ -2036,7 +2056,7 @@ list[current_player;craftpreview;7,1;1,1;] non-numeric cells are treated as 0.
    -
  • #color column options:
      +
    • #color column options:
      • #span=<value>: number of following columns to affect (default: infinite)
    • @@ -2090,10 +2110,16 @@ The following functions provide escape sequences: core.get_color_escape_sequence(color) .. message .. core.get_color_escape_sequence("#ffffff") -* color.get_background_escape_sequence(color) + color.get_background_escape_sequence(color) * color is a ColorString * The escape sequence sets the background of the whole text element to - color. Only defined for item descriptions and tooltips.

      + color. Only defined for item descriptions and tooltips. +
      color.strip_foreground_colors(str) + * Removes foreground colors added by get_color_escape_sequence. + color.strip_background_colors(str) + * Removes background colors added by get_background_escape_sequence. + color.strip_colors(str) + * Removes all color escape sequences.

      Spatial Vectors

      • #vector.new(a[, b, c]): returns a vector:
          @@ -2167,7 +2193,7 @@ The following functions provide escape sequences:
      • #minetest.is_yes(arg)
          -
        • #returns whether arg can be interpreted as yes
        • +
        • returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
      • #minetest.get_us_time()
          @@ -2178,6 +2204,10 @@ The following functions provide escape sequences:
        • #returns a deep copy of table
      • +
      • #minetest.pointed_thing_to_face_pos(placer, pointed_thing): returns a position
          +
        • returns the exact position on the surface of a pointed node
        • +
        +

      minetest namespace reference

      Utilities

      @@ -2196,57 +2226,73 @@ The following functions provide escape sequences:
  • #minetest.is_singleplayer()
  • -
  • #minetest.features
      -
    • #Table containing API feature flags: {foo=true, bar=true}
    • -
    -
  • +
  • #minetest.features: Table containing API feature flags + { + glasslike_framed = true, + nodebox_as_selectionbox = true, + chat_send_player_param3 = true, + get_all_craft_recipes_works = true, + use_texture_alpha = true, + -- ^ The transparency channel of textures can be used optionally + no_legacy_abms = true, + -- ^ Tree and grass ABMs are no longer done from C++ + texture_names_parens = true, + -- ^ Texture grouping is possible using parentheses + area_store_custom_ids = true, + -- ^ Unique Area ID for AreaStore:insert_area + add_entity_with_staticdata = true, + -- ^ add_entity supports passing initial staticdata to on_activate + no_chat_message_prediction = true, + -- ^ Chat messages are no longer predicted + }
  • #minetest.has_feature(arg): returns boolean, missing_features
      -
    • #arg: string or table in format {foo=true, bar=true}
    • +
    • #arg: string or table in format {foo=true, bar=true}
    • #missing_features: {foo=true, bar=true}
  • -
  • #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
    -    --major = 0,                 -- major version number
    -    --minor = 4,                 -- minor version number
    -    --patch = 10,                -- patch version number
    -    --vers_string = "0.4.9-git", -- full version string
    -    --state = "Active"           -- current client state
    -}
    +
  • #minetest.get_player_information(player_name):
      +
    • #Returns a table containing information about a 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
      +--major = 0,                 -- major version number
      +--minor = 4,                 -- minor version number
      +--patch = 10,                -- patch version number
      +--vers_string = "0.4.9-git", -- full version string
      +--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.
      • -
      • #minetest.get_version(): returns a table containing components of the - engine version. Components:
      • -
      • #project: Name of the project, eg, "Minetest"
      • -
      • #string: Simple version, eg, "1.2.3-dev"
      • -
      • #hash: Full git version (only set if available), eg, "1.2.3-dev-01234567-dirty" +

        } + 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. +* minetest.get_version(): returns a table containing components of the + engine version. Components: + * project: Name of the project, eg, "Minetest" + * string: Simple version, eg, "1.2.3-dev" + * hash: Full git version (only set if available), eg, "1.2.3-dev-01234567-dirty" Use this for informational purposes only. The information in the returned table does not represent the capabilities of the engine, nor is it reliable or verifyable. Compatible forks will have a different name and version entirely. To check for the presence of engine features, test whether the functions exported by the wanted features exist. For example: - if core.nodeupdate then ... end.

      • + if core.nodeupdate then ... end.

        +
    @@ -2575,12 +2621,17 @@ and minetest.auth_reload call the authetification handler.

  • #Returns true if successful, false on failure (e.g. protected location)
  • -
  • # -

    minetest.punch_node(pos)

    -
      +
    • #minetest.punch_node(pos)
      • Punch node with the same effects that a player would cause
    • +
    • # +

      minetest.spawn_falling_node(pos)

      +
        +
      • Change node into falling node
      • +
      • #Returns true if successful, false on failure
      • +
      +
    • #

      minetest.find_nodes_with_meta(pos1, pos2)

        @@ -2815,6 +2866,24 @@ and minetest.auth_reload call the authetification handler.

      • can be negative for decreasing
    • +
    • #minetest.fix_light(pos1, pos2): returns true/false
        +
      • resets the light in a cuboid-shaped part of + the map and removes lighting bugs.
      • +
      • Loads the area if it is not loaded.
      • +
      • #pos1 is the corner of the cuboid with the least coordinates + (in node coordinates), inclusive.
      • +
      • #pos2 is the opposite corner of the cuboid, inclusive.
      • +
      • The actual updated cuboid might be larger than the specified one, + because only whole map blocks can be updated. + The actual updated area consists of those map blocks that intersect + with the given cuboid.
      • +
      • However, the neighborhood of the updated area might change + as well, as light can spread out of the cuboid, also light + might be removed.
      • +
      • #returns false if the area is not fully generated, + true otherwise
      • +
      +
    • #core.check_single_for_falling(pos)
      • #causes an unsupported group:falling_node node to fall and causes an unattached group:attached_node node to fall.
      • @@ -3075,10 +3144,18 @@ and minetest.auth_reload call the authetification handler.

      Server

        -
      • #minetest.request_shutdown([message],[reconnect]): request for server shutdown. Will display message to clients, - and reconnect == true displays a reconnect button.
      • +
      • #minetest.request_shutdown([message],[reconnect],[delay]): request for server shutdown. Will display message to clients, + reconnect == true displays a reconnect button, + delay adds an optional delay (in seconds) before shutdown + negative delay cancels the current active shutdown + zero delay triggers an immediate shutdown.
      • +
      • #minetest.cancel_shutdown_requests(): cancel current delayed shutdown
      • #minetest.get_server_status(): returns server status string
      • #minetest.get_server_uptime(): returns the server uptime in seconds
      • +
      • #minetest.remove_player(name): remove player from database (if he is not connected).
          +
        • Returns a code (0: successful, 1: no such player, 2: player is connected)
        • +
        +

      Bans

        @@ -3272,7 +3349,7 @@ and minetest.auth_reload call the authetification handler.

      • #minetest.write_json(data[, styled]): returns a string or nil and an error message
        • Convert a Lua table into a JSON string
        • styled: Outputs in a human-readable format if this is set, defaults to false
        • -
        • Unserializable things like functions and userdata are saved as null.
        • +
        • Unserializable things like functions and userdata will cause an error.
        • 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. @@ -3290,7 +3367,7 @@ and minetest.auth_reload call the authetification handler.

          3. #minetest.deserialize(string): returns a table
            • #Convert a string returned by minetest.deserialize into a table
            • -
            • #string is loaded in an empty sandbox environment.
            • +
            • #string is loaded in an empty sandbox environment.
            • Will load functions, but they cannot access the global environment.
            • #Example: deserialize('return { ["foo"] = "bar" }'), returns {foo='bar'}
            • #Example: deserialize('print("foo")'), returns nil (function call fails)
                @@ -3378,7 +3455,7 @@ end

                minetest.forceload_block(pos[, transient])

                • #forceloads the position pos.
                • -
                • #returns true if area could be forceloaded
                • +
                • #returns true if area could be forceloaded
                • #If transient is false or absent, the forceload will be persistent (saved between server runs). If true, the forceload will be transient (not saved between server runs).
                • @@ -3485,7 +3562,11 @@ end
                • #from_table(nil or {})
                  • Any non-table value will clear the metadata
                  • See "Node Metadata" for an example
                  • -
                  • #returns true on success
                  • +
                  • #returns true on success
                  • +
                  +
                • +
                • #equals(other)
                    +
                  • #returns true if this metadata has the same key-value pairs as other
                @@ -3541,7 +3622,7 @@ Can be gotten via minetest.get_node_timer(pos).

            • #is_started(): returns boolean state of timer
                -
              • #returns true if timer is started, otherwise false
              • +
              • #returns true if timer is started, otherwise false
            @@ -3694,7 +3775,11 @@ Can be gotten via minetest.get_node_timer(pos).

          4. #jump: multiplier to default jump value (default: 1)
          5. #gravity: multiplier to default gravity value (default: 1)
          6. #sneak: whether player can sneak (default: true)
          7. -
          8. #sneak_glitch: whether player can use the sneak glitch (default: true)
          9. +
          10. #sneak_glitch: whether player can use the new move code replications + of the old sneak side-effects: sneak ladders and 2 node sneak jump + (default: false)
          11. +
          12. #new_move: use new move/sneak code. When false the exact old code + is used for the specific old sneak behaviour (default: true)
      @@ -3710,7 +3795,7 @@ Can be gotten via minetest.get_node_timer(pos).

    • #hud_get(id): gets the HUD element definition structure of the specified ID
    • #hud_set_flags(flags): sets specified HUD flags to true/false
      • #flags: (is visible) hotbar, healthbar, crosshair, wielditem, minimap
      • -
      • #pass a table containing a true/false value of each flag to be set or unset
      • +
      • #pass a table containing a true/false value of each flag to be set or unset
      • #if a flag equals nil, the flag is not modified
      • #note that setting minimap modifies the client's permission to view the minimap -
      • the client may locally elect to not view the minimap
      • @@ -3777,7 +3862,7 @@ Can be gotten via minetest.get_node_timer(pos).

      • #is_empty(listname): return true if list is empty
      • #get_size(listname): get size of a list
      • #set_size(listname, size): set size of a list
          -
        • #returns false on error (e.g. invalid listname or size)
        • +
        • #returns false on error (e.g. invalid listname or size)
      • #get_width(listname): get width of a list
      • @@ -4009,8 +4094,6 @@ otherwise explicitly stated.

        format as produced by get_data() et al. and is not required to be a table retrieved from get_data().

        Once the internal VoxelManip state has been modified to your liking, the changes can be committed back to the map by calling VoxelManip:write_to_map().

        -

        Finally, a call to VoxelManip:update_map() is required to re-calculate lighting and set the blocks -as being modified so that connected clients are sent the updated parts of map.

        Flat array format

        Let Nx = p2.X - p1.X + 1, @@ -4062,8 +4145,6 @@ but with a few differences:

        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 @@ -4098,8 +4179,14 @@ will place the schematic inside of the VoxelManip.

    • #returns actual emerged pmin, actual emerged pmax
  • -
  • #write_to_map(): Writes the data loaded from the VoxelManip back to the map.
      +
    • #write_to_map([light]): Writes the data loaded from the VoxelManip back to the map.
      • #important: data must be set using VoxelManip:set_data() before calling this
      • +
      • #if light is true, then lighting is automatically recalculated. + The default value is true. + If light is false, no light calculations happen, and you should correct + all modified blocks with minetest.fix_light() as soon as possible. + Keep in mind that modifying the map where light is incorrect can cause + more lighting bugs.
    • #get_node_at(pos): Returns a MapNode table of the node currently loaded in @@ -4111,14 +4198,10 @@ will place the schematic inside of the VoxelManip.

  • #set_data(data): Sets the data contents of the VoxelManip object
  • -
  • #update_map(): Update map after writing chunk back to map.
      -
    • #To be used only by VoxelManip objects created by the mod itself; - not a VoxelManip that was retrieved from minetest.get_mapgen_object
    • -
    -
  • +
  • #update_map(): Does nothing, kept for compatibility.
  • #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
    • +
    • #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; defaults to the whole area if left out
    @@ -4141,7 +4224,7 @@ will place the schematic inside of the VoxelManip.

  • #set_param2_data(param2_data): Sets the param2 contents of each node in 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
    • +
    • #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 or nil
    • #propagate_shadow is an optional boolean deciding whether shadows in a generated @@ -4164,7 +4247,7 @@ The coordinates are inclusive, like most other things in Minetest.

      MinEdge and MaxEdge
    • #getVolume(): returns the volume of the area formed by MinEdge and MaxEdge
    • #index(x, y, z): returns the index of an absolute position in a flat array starting at 1
        -
      • #useful for things like VoxelManip, raw Schematic specifiers, +
      • #useful for things like VoxelManip, raw Schematic specifiers, PerlinNoiseMap:get2d/3dMap, and so on
    • @@ -4438,6 +4521,19 @@ minetest.spawn_tree(pos,apple_tree) {hard = 1, metal = 1, spikes = 1} inventory_image = "default_tool_steelaxe.png", wield_image = "", + palette = "", + --[[ + ^ An image file containing the palette of a node. + ^ You can set the currently used color as the + ^ "palette_index" field of the item stack metadata. + ^ The palette is always stretched to fit indices + ^ between 0 and 255, to ensure compatibility with + ^ "colorfacedir" and "colorwallmounted" nodes. + ]] + color = "0xFFFFFFFF", + --[[ + ^ The color of the item. The palette overrides this. + ]] wield_scale = {x = 1, y = 1, z = 1}, stack_max = 99, range = 4.0, @@ -4561,13 +4657,20 @@ minetest.spawn_tree(pos,apple_tree) drawtype = "normal", -- See "Node drawtypes" visual_scale = 1.0, --[[ - ^ Supported for drawtypes "plantlike", "signlike", "torchlike", "mesh". - ^ For plantlike, the image will start at the bottom of the node; for the - ^ other drawtypes, the image will be centered on the node. + ^ Supported for drawtypes "plantlike", "signlike", "torchlike", + ^ "firelike", "mesh". + ^ For plantlike and firelike, the image will start at the bottom of the + ^ node, for the other drawtypes the image will be centered on the node. ^ Note that positioning for "torchlike" may still change. ]] tiles = {tile definition 1, def2, def3, def4, def5, def6}, --[[ ^ Textures of node; +Y, -Y, +X, -X, +Z, -Z (old field name: tile_images) ^ List can be shortened to needed length ]] + overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6}, --[[ + ^ Same as `tiles`, but these textures are drawn on top of the + ^ base tiles. You can use this to colorize only specific parts of + ^ your texture. If the texture name is an empty string, that + ^ overlay is not drawn. Since such tiles are drawn twice, it + ^ is not recommended to use overlays on very common nodes. special_tiles = {tile definition 1, Tile definition 2}, --[[ ^ Special textures of node; used rarely (old field name: special_materials) ^ List can be shortened to needed length ]] @@ -4656,6 +4759,13 @@ minetest.spawn_tree(pos,apple_tree) ^ Node destructor; called after removing node ^ Not called for bulk node placement (i.e. schematics and VoxelManip) ^ default: nil ]] + on_flood = func(pos, oldnode, newnode), --[[ + ^ Called when a liquid (newnode) is about to flood oldnode, if + ^ it has `floodable = true` in the nodedef. Not called for bulk + ^ node placement (i.e. schematics and VoxelManip) or air nodes. If + ^ return true the node is not flooded, but on_flood callback will + ^ most likely be called over and over again every liquid update + ^ interval. Default: nil ]] after_place_node = func(pos, placer, itemstack, pointed_thing) --[[ ^ Called after constructing node when node was placed using diff --git a/static/flow_leftclick.mermaid b/static/flow_leftclick.mermaid new file mode 100644 index 0000000..b70f727 --- /dev/null +++ b/static/flow_leftclick.mermaid @@ -0,0 +1,2 @@ +graph LR +user_lc[User left clicks] diff --git a/static/flow_rightclick.mermaid b/static/flow_rightclick.mermaid new file mode 100644 index 0000000..99915cf --- /dev/null +++ b/static/flow_rightclick.mermaid @@ -0,0 +1,22 @@ +graph LR +user_rc[User right clicks] + +user_rc --> run_on_place + +run_on_place{Is def.on_place specified?} +run_on_place -->|Yes| run[Run custom on_place] +run --> done +run_on_place -->|No, defaults to minetest.item_place| is_rightclickable + +is_rightclickable{Is pointing at right clickable node?} +is_rightclickable -->|Yes| is_sneaking +is_rightclickable -->|No| is_node +is_sneaking{Is sneaking?} +is_sneaking -->|Yes| is_node +is_sneaking -->|No| rightclick[Call Rightclick of pointed at node] +rightclick --> done + +is_node{def.type is node?} +is_node -->|yes| place_node[Place Node] +is_node -->|no| done +place_node --> done