From c5303de0176efb1d34622a620a0937592d5c356b Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 31 Jan 2017 14:21:12 +0000 Subject: [PATCH] Update lua_api.html --- lua_api.html | 143 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 117 insertions(+), 26 deletions(-) diff --git a/lua_api.html b/lua_api.html index caeeefd..8986bb9 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 28/December/2016.
See doc/lua_api.txt for the latest version (in plaintext).
Generated using a Python script.
+This page was last updated 31/January/2017.
See doc/lua_api.txt for the latest version (in plaintext).
Generated using a Python script.

Table of Contents

@@ -370,7 +372,7 @@ source code patches to celeron55@gmail.com< This page was last updated 28/December/2016.
See doc/lua_api.txt for the latest version (in plaintext).
Generated using a Python script.

Programming in Lua

+This page was last updated 31/January/2017.
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

@@ -680,6 +682,9 @@ Rotations are counter-clockwise.

[mask:<file>

Apply a mask to the base image.

The mask is applied using binary AND.

+

[sheet:<w>x<h>:<x>,<y>

+

Retrieves a tile at position x,y from the base image +which it assumes to be a tilesheet with dimensions w,h.

[colorize:<color>:<ratio>

Colorize the textures with the given color. <color> is specified as a ColorString. @@ -690,6 +695,12 @@ omitted, the alpha of <color> will be used as the ratio. If the word "alpha", then each texture pixel will contain the RGB of <color> and the alpha of <color> multiplied by the alpha of the texture pixel.

+

[multiply:<color>

+

Multiplies texture colors with the given color. +<color> is specified as a ColorString. +Result is more like what you'd expect if you put a color on top of another +color. Meaning white surfaces get a lot of your new color while black parts don't +change very much.

Sounds

Only Ogg Vorbis files are supported.

For positional playing of sounds, only single-channel (mono) files are @@ -930,6 +941,19 @@ paramtype2 == "meshoptions" bit 4 (0x10) - Makes the plant mesh 1.4x larger bit 5 (0x20) - Moves each face randomly a small bit down (1/8 max) bits 6-7 are reserved for future use. +paramtype2 == "color" +^ `param2` tells which color is picked from the palette. + The palette should have 256 pixels. +paramtype2 == "colorfacedir" +^ Same as `facedir`, but with colors. + The first three bits of `param2` tells which color + is picked from the palette. + The palette should have 8 pixels. +paramtype2 == "colorwallmounted" +^ Same as `wallmounted`, but with colors. + The first five bits of `param2` tells which color + is picked from the palette. + The palette should have 32 pixels. collision_box = { type = "fixed", fixed = { @@ -1545,7 +1569,7 @@ Currently a smoke puff will appear when an entity dies.

group disables the regular damage mechanism for players punching it by hand or a non-tool item, so that it can do something else than take damage.

On the Lua side, every punch calls:

-
entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
+
entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction, damage)
 

This should never be called directly, because damage is usually not handled by the entity itself.

@@ -1556,6 +1580,9 @@ the entity itself.

  • #tool_capabilities can be nil.
  • #direction is a unit vector, pointing from the source of the punch to the punched object.
  • +
  • #damage damage that will be done to entity +Return value of this function will determin if damage is done by this function +(retval true) or shall be done by engine (retval false)
  • To punch an entity/object in Lua, call:

    object:punch(puncher, time_from_last_punch, tool_capabilities, direction)
    @@ -2056,6 +2083,7 @@ The following functions provide escape sequences:
     
  • #vector.round(v): returns a vector, each dimension rounded to nearest int
  • #vector.apply(v, func): returns a vector
  • #vector.equals(v1, v2): returns a boolean
  • +
  • #vector.sort(v1, v2): returns minp, maxp vectors of the cuboid defined by v1 and v2
  • For the following functions x can be either a vector or a number:

      @@ -2298,7 +2326,7 @@ The following functions provide escape sequences:
    • #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
    • +
    • #damage - number that represents the damage calculated by the engine
    • #should return true to prevent the default damage mechanism
    @@ -2386,7 +2414,18 @@ The following functions provide escape sequences:

    Other registration functions

      -
    • #minetest.register_chatcommand(cmd, chatcommand definition)
    • +
    • #minetest.register_chatcommand(cmd, chatcommand definition)
        +
      • Adds definition to minetest.registered_chatcommands
      • +
      +
    • +
    • #minetest.override_chatcommand(name, redefinition)
        +
      • Overrides fields of a chatcommand registered with register_chatcommand.
      • +
      +
    • +
    • #minetest.unregister_chatcommand(name)
        +
      • Unregisters a chatcommands registered with register_chatcommand.
      • +
      +
    • #minetest.register_privilege(name, definition)
      • #definition: "description text"
      • #definition: { description = "description text", give_to_singleplayer = boolean} @@ -2532,8 +2571,8 @@ and minetest.auth_reload call the authetification handler.

      • #Get NodeTimerRef
    • -
    • # -

      minetest.add_entity(pos, name): Spawn Lua-defined entity at position

      +
    • # +

      minetest.add_entity(pos, name, [staticdata]): Spawn Lua-defined entity at position

      • #Returns ObjectRef, or nil if failed
      @@ -2868,6 +2907,14 @@ and minetest.auth_reload call the authetification handler.

    • Convert a wallmounted value back into a vector aimed directly out the "back" of a node
    +
  • #minetest.dir_to_yaw(dir)
      +
    • Convert a vector into a yaw (angle)
    • +
    +
  • +
  • #minetest.yaw_to_dir(yaw)
      +
    • Convert yaw (angle) to a vector
    • +
    +
  • #minetest.get_node_drops(nodename, toolname)
    • Returns list of item names.
    • Note: This will be removed or modified in a future version.
    • @@ -3143,6 +3190,7 @@ and minetest.auth_reload call the authetification handler.

      Misc.

      • #minetest.get_connected_players(): returns list of ObjectRefs
      • +
      • #minetest.player_exists(name): boolean, whether player exists (regardless of online status)
      • #minetest.hud_replace_builtin(name, hud_definition)
        • Replaces definition of a builtin hud element
        • #name: "breath" or "health"
        • @@ -3367,6 +3415,10 @@ end
        • Map of Lua entities, indexed by active object id
      • +
      • #minetest.registered_chatcommands
          +
        • Map of registered chat command definitions, indexed by name
        • +
        +
      • #minetest.registered_ores
        • List of registered ore definitions.
        @@ -3395,8 +3447,9 @@ Can be gotten via minetest.get_meta(pos).

      • #get_inventory(): returns InvRef
      • #to_table(): returns nil or {fields = {...}, inventory = {list1 = {}, ...}}
      • #from_table(nil or {})
          -
        • to clear metadata, use from_table(nil)
        • +
        • Any non-table value will clear the metadata
        • See "Node Metadata"
        • +
        • #returns true on success
      @@ -3430,7 +3483,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
  • @@ -3443,9 +3496,9 @@ Can be gotten via minetest.get_node_timer(pos).

  • Note: Doesn't work on players, use minetest.kick_player instead
  • -
  • #getpos(): returns {x=num, y=num, z=num}
  • -
  • #setpos(pos); pos={x=num, y=num, z=num}
  • -
  • #moveto(pos, continuous=false): interpolated move
  • +
  • #get_pos(): returns {x=num, y=num, z=num}
  • +
  • #set_pos(pos); pos={x=num, y=num, z=num}
  • +
  • #move_to(pos, continuous=false): interpolated move
  • #punch(puncher, time_from_last_punch, tool_capabilities, direction)
    • #puncher = another ObjectRef,
    • #time_from_last_punch = time since last punch action of the puncher
    • @@ -3502,14 +3555,15 @@ Can be gotten via minetest.get_node_timer(pos).

    LuaEntitySAO-only (no-op for other objects)
      -
    • #setvelocity({x=num, y=num, z=num})
    • -
    • #getvelocity(): returns {x=num, y=num, z=num}
    • -
    • #setacceleration({x=num, y=num, z=num})
    • -
    • #getacceleration(): returns {x=num, y=num, z=num}
    • -
    • #setyaw(radians)
    • -
    • #getyaw(): returns number in radians
    • -
    • #settexturemod(mod)
    • -
    • #setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2, +
    • #set_velocity({x=num, y=num, z=num})
    • +
    • #get_velocity(): returns {x=num, y=num, z=num}
    • +
    • #set_acceleration({x=num, y=num, z=num})
    • +
    • #get_acceleration(): returns {x=num, y=num, z=num}
    • +
    • #set_yaw(radians)
    • +
    • #get_yaw(): returns number in radians
    • +
    • #set_texture_mod(mod)
    • +
    • #get_texture_mod() returns current texture modifier
    • +
    • #set_sprite(p={x=0,y=0}, num_frames=1, framelength=0.2, select_horiz_by_yawpitch=false)
      • Select sprite from spritesheet with optional animation and DM-style texture selection based on yaw relative to camera
      • @@ -3560,6 +3614,8 @@ Can be gotten via minetest.get_node_timer(pos).

    • +
    • #set_attribute(attribute, value): sets an extra attribute with value on player
    • +
    • #get_attribute(attribute): returns value for extra attribute. Returns nil if no attribute found.
    • #set_inventory_formspec(formspec)
      • Redefine player's inventory form
      • Should usually be called in on_joinplayer
      • @@ -3596,7 +3652,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
        • @@ -4409,15 +4465,37 @@ minetest.spawn_tree(pos,apple_tree) not the node it's on
      • +
      • #{name="image.png", color=ColorSpec}
          +
        • the texture's color will be multiplied with this color.
        • +
        • the tile's color overrides the owning node's color in all cases.
        • +
        +
      • #deprecated, yet still supported field names:
        • #image (name)

      Tile animation definition

      -
        -
      • #{type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}
      • -
      +
      {
      +    type = "vertical_frames",
      +    aspect_w = 16,
      +    -- ^ specify width of a frame in pixels
      +    aspect_h = 16,
      +    -- ^ specify height of a frame in pixels
      +    length = 3.0,
      +    -- ^ specify full loop length
      +}
      +
      +{
      +    type = "sheet_2d",
      +    frames_w = 5,
      +    -- ^ specify width in number of frames
      +    frames_h = 3,
      +    -- ^ specify height in number of frames
      +    frame_length = 0.5,
      +    -- ^ specify length of a single frame
      +}
      +

      Node definition (register_node)

      {
           -- <all fields allowed in item definitions>,
      @@ -4434,8 +4512,17 @@ minetest.spawn_tree(pos,apple_tree)
           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 ]]
      -    alpha = 255,
      +    color = ColorSpec, --[[
      +    ^ The node's original color will be multiplied with this color.
      +    ^ If the node has a palette, then this setting only has an effect
      +    ^ in the inventory and on the wield item. ]]
           use_texture_alpha = false, -- Use texture's alpha channel
      +    palette = "palette.png", --[[
      +    ^ The node's `param2` is used to select a pixel from the image
      +    ^ (pixels are arranged from left to right and from top to bottom).
      +    ^ The node's color will be multiplied with the selected pixel's
      +    ^ color. Tiles can override this behavior.
      +    ^ Only when `paramtype2` supports palettes. ]]
           post_effect_color = "green#0F", -- If player is inside node, see "ColorSpec"
           paramtype = "none", -- See "Nodes" --[[
           ^ paramtype = "light" allows light to propagate from or through the node with light value
      @@ -4857,8 +4944,12 @@ The Biome API is still in an experimental phase and subject to change.

      -- ^ vertical: if true faces player using y axis only texture = "image.png", -- ^ Uses texture (string) - playername = "singleplayer" + playername = "singleplayer", -- ^ optional, if specified spawns particle only on the player's client + animation = {Tile Animation definition}, +-- ^ optional, specifies how to animate the particle texture + glow = 0 +-- ^ optional, specify particle self-luminescence in darkness }

      ParticleSpawner definition (add_particlespawner)