]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - doc/lua_api.txt
Merge pull request #243 from xyzz/liquid_renewable
[dragonfireclient.git] / doc / lua_api.txt
index c9fafd65fbc072076ea38118a226cdb745b1b4b9..3018326189f3d9c9f07f37e60853cd974927c19c 100644 (file)
@@ -423,7 +423,7 @@ effective towards.
 
 Groups in crafting recipes
 ---------------------------
-An example:
+An example: Make meat soup from any meat, any water and any bowl
 {
     output = 'food:meat_soup_raw',
     recipe = {
@@ -431,7 +431,13 @@ An example:
         {'group:water'},
         {'group:bowl'},
     },
-    preserve = {'group:bowl'}, -- Not implemented yet (TODO)
+    -- preserve = {'group:bowl'}, -- Not implemented yet (TODO)
+}
+An another example: Make red wool from white wool and red dye
+{
+       type = 'shapeless',
+    output = 'wool:red',
+    recipe = {'wool:white', 'group:dye,basecolor_red'},
 }
 
 Special groups
@@ -447,6 +453,10 @@ Special groups
   - 2: node is removed without tool wear after 0.5 seconds or so
        (rail, sign)
   - 3: node is removed without tool wear immediately (torch)
+- disable_jump: Player (and possibly other things) cannot jump from node
+- fall_damage_add_percent: damage speed = speed * (1 + value/100)
+- bouncy: value is bounce speed in percent
+- falling_node: if there is no walkable block under the node it will fall
 
 Known damage and digging time defining groups
 ----------------------------------------------
@@ -851,7 +861,8 @@ minetest.get_inventory(location) -> InvRef
 ^ location = eg. {type="player", name="celeron55"}
                  {type="node", pos={x=, y=, z=}}
                  {type="detached", name="creative"}
-minetest.create_detached_inventory(name) -> InvRef
+minetest.create_detached_inventory(name, callbacks) -> InvRef
+^ callbacks: See "Detached inventory callbacks"
 ^ Creates a detached inventory. If it already exists, it is cleared.
 
 Item handling:
@@ -881,6 +892,20 @@ minetest.get_craft_recipe(output) -> input
 ^ input.items = for example { stack 1, stack 2, stack 3, stack 4,
                               stack 5, stack 6, stack 7, stack 8, stack 9 }
 ^ input.items = nil if no recipe found
+minetest.handle_node_drops(pos, drops, digger)
+^ drops: list of itemstrings
+^ Handles drops from nodes after digging: Default action is to put them into
+  digger's inventory
+^ Can be overridden to get different functionality (eg. dropping items on
+  ground)
+
+Rollbacks:
+minetest.rollback_get_last_node_actor(p, range, seconds) -> actor, p, seconds
+^ Find who has done something to a node, or near a node
+^ actor: "player:<name>", also "liquid".
+minetest.rollback_revert_actions_by(actor, seconds) -> bool, log messages
+^ Revert latest actions of someone
+^ actor: "player:<name>", also "liquid".
 
 Defaults for the on_* item definition functions:
 (These return the leftover itemstack)
@@ -913,6 +938,16 @@ minetest.after(time, func, param)
 ^ Call function after time seconds
 ^ param is optional; to pass multiple parameters, pass a table.
 
+Server:
+minetest.request_shutdown() -> request for server shutdown
+minetest.get_server_status() -> server status string
+
+Bans:
+minetest.get_ban_list() -> ban list (same as minetest.get_ban_description(""))
+minetest.get_ban_description(ip_or_name) -> ban description (string)
+minetest.ban_player(name) -> ban a player
+minetest.unban_player_or_ip(name) -> unban player or IP address
+
 Random:
 minetest.get_connected_players() -> list of ObjectRefs
 minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer
@@ -1002,6 +1037,8 @@ methods:
   ^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
 - get_perlin(seeddiff, octaves, persistence, scale)
   ^ Return world-specific perlin noise (int(worldseed)+seeddiff)
+- clear_objects()
+  ^ clear all objects in the environments 
 Deprecated:
 - add_rat(pos): Add C++ rat object (no-op)
 - add_firefly(pos): Add C++ firefly object (no-op)
@@ -1051,6 +1088,7 @@ methods:
 - punch(puncher, time_from_last_punch, tool_capabilities, direction)
   ^ puncher = an another ObjectRef,
   ^ time_from_last_punch = time since last punch action of the puncher
+  ^ direction: can be nil
 - right_click(clicker); clicker = an another ObjectRef
 - get_hp(): returns number of hitpoints (2 * number of hearts)
 - set_hp(hp): set number of hitpoints (2 * number of hearts)
@@ -1091,6 +1129,8 @@ methods:
 - 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
+- get_width(listname): get width of a list
+- set_width(listname, width): set width of list; currently used for crafting
 - get_stack(listname, i): get a copy of stack index i in list
 - set_stack(listname, i, stack): copy stack to index i in list
 - get_list(listname): return full list
@@ -1198,7 +1238,7 @@ Entity definition (register_entity)
     
     initial_properties = <initial object properties>,
 
-    on_activate = function(self, staticdata),
+    on_activate = function(self, staticdata, dtime_s),
     on_step = function(self, dtime),
     on_punch = function(self, hitter),
     on_rightclick = function(self, clicker),
@@ -1307,6 +1347,8 @@ Node definition (register_node)
     liquid_alternative_flowing = "", -- Flowing version of source liquid
     liquid_alternative_source = "", -- Source version of flowing liquid
     liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
+    liquid_renewable = true, -- Can new liquid source be created by placing
+    two or more sources nearly?
     light_source = 0, -- Amount of light emitted by node
     damage_per_second = 0, -- If player is inside node, this damage is caused
     node_box = {type="regular"}, -- See "Node boxes"
@@ -1361,35 +1403,32 @@ Node definition (register_node)
     ^ Called when an UI form (eg. sign text input) returns data
     ^ default: nil
 
-    on_metadata_inventory_move = func(pos, from_list, from_index,
-                                      to_list, to_index, count, player),
-    ^ Called when a player wants to move items inside the metadata
-    ^ Should move items, or some items, if permitted. If not, should do
-      nothing.
-    ^ The engine ensures the action is valid, i.e. the stack fits at the
-      given position
-    ^ default: minetest.node_metadata_inventory_move_allow_all
-
-    on_metadata_inventory_offer = func(pos, listname, index, stack, player),
-    ^ Called when a player wants to put something into the metadata
-      inventory
-    ^ Should check if the action is permitted (the engine ensures the
-      action is valid, i.e. the stack fits at the given position)
-      ^ If permitted, modify the metadata inventory and return the
-        "leftover" stack (normally nil).
-      ^ If not permitted, return itemstack.
-    ^ default: minetest.node_metadata_inventory_offer_allow_all
-
-    on_metadata_inventory_take = func(pos, listname, index, count, player),
-    ^ Called when a player wants to take something out of the metadata
-      inventory
-    ^ Should check if the action is permitted (the engine ensures the
-      action is valid, i.e. there's a stack of at least “count” items at
-      that position)
-      ^ If permitted, modify the metadata inventory and return the
-        stack of items
-      ^ If not permitted, return nil.
-    ^ default: minetest.node_metadata_inventory_take_allow_all
+       allow_metadata_inventory_move = func(pos, from_list, from_index,
+                       to_list, to_index, count, player),
+       ^ Called when a player wants to move items inside the inventory
+       ^ Return value: number of items allowed to move
+       
+       allow_metadata_inventory_put = func(pos, listname, index, stack, player),
+       ^ Called when a player wants to put something into the inventory
+       ^ Return value: number of items allowed to put
+       ^ Return value: -1: Allow and don't modify item count in inventory
+  
+       allow_metadata_inventory_take = func(pos, listname, index, stack, player),
+       ^ Called when a player wants to take something out of the inventory
+       ^ Return value: number of items allowed to take
+       ^ Return value: -1: Allow and don't modify item count in inventory
+
+       on_metadata_inventory_move = func(pos, from_list, from_index,
+                       to_list, to_index, count, player),
+       on_metadata_inventory_put = func(pos, listname, index, stack, player),
+       on_metadata_inventory_take = func(pos, listname, index, stack, player),
+       ^ Called after the actual action has happened, according to what was allowed.
+       ^ No return value
+    
+       on_blast = func(pos, intensity),
+       ^ intensity: 1.0 = mid range of regular TNT
+       ^ If defined, called when an explosion touches the node, instead of
+         removing the node
 }
 
 Recipe for register_craft: (shaped)
@@ -1446,3 +1485,26 @@ Chatcommand definition (register_chatcommand)
     func = function(name, param), -- called when command is run
 }
 
+Detached inventory callbacks
+{
+       allow_move = func(inv, from_list, from_index, to_list, to_index, count, player),
+    ^ Called when a player wants to move items inside the inventory
+       ^ Return value: number of items allowed to move
+       
+    allow_put = func(inv, listname, index, stack, player),
+    ^ Called when a player wants to put something into the inventory
+       ^ Return value: number of items allowed to put
+       ^ Return value: -1: Allow and don't modify item count in inventory
+   
+    allow_take = func(inv, listname, index, stack, player),
+    ^ Called when a player wants to take something out of the inventory
+       ^ Return value: number of items allowed to take
+       ^ Return value: -1: Allow and don't modify item count in inventory
+       
+       on_move = func(inv, from_list, from_index, to_list, to_index, count, player),
+    on_put = func(inv, listname, index, stack, player),
+    on_take = func(inv, listname, index, stack, player),
+       ^ Called after the actual action has happened, according to what was allowed.
+       ^ No return value
+}
+