aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-07-25 02:36:54 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-07-25 02:36:54 +0300
commit9eaf93d41d6745b877f8f52cf54b21050abefda1 (patch)
tree5ceebc9b208a415a01440f60605345f5c238cae2 /doc
parent2ac20982e0772b94b21d95b53519bd2164632d98 (diff)
downloadminetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.tar.gz
minetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.tar.bz2
minetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.zip
Detached inventory callbacks and reworked node metadata callbacks
Diffstat (limited to 'doc')
-rw-r--r--doc/lua_api.txt72
1 files changed, 42 insertions, 30 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index c9fafd65f..5fb2c34e3 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -851,7 +851,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:
@@ -1361,35 +1362,25 @@ 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
+
+ allow_metadata_inventory_take = func(pos, listname, index, count, player),
+ ^ Called when a player wants to take something out of the inventory
+ ^ Return value: number of items allowed to take
+
+ 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, count, player),
+ ^ Called after the actual action has happened, according to what was allowed.
+ ^ No return value
}
Recipe for register_craft: (shaped)
@@ -1446,3 +1437,24 @@ 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
+
+ allow_take = func(inv, listname, index, count, player),
+ ^ Called when a player wants to take something out of the inventory
+ ^ Return value: number of items allowed to take
+
+ 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, count, player),
+ ^ Called after the actual action has happened, according to what was allowed.
+ ^ No return value
+}
+