summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2020-09-04 20:49:07 +0200
committerGitHub <noreply@github.com>2020-09-04 20:49:07 +0200
commit050964bed6005f8d816ddf362b9fc8675581d190 (patch)
tree3229276c2c989597da4a052aa67373c8b887accb /doc
parent4ba5046308d6bdf7b38394770c6f82b6927393f2 (diff)
downloadminetest-050964bed6005f8d816ddf362b9fc8675581d190.tar.gz
minetest-050964bed6005f8d816ddf362b9fc8675581d190.tar.bz2
minetest-050964bed6005f8d816ddf362b9fc8675581d190.zip
Fix inventory swapping not calling all callbacks (#9923)
"Predicts" whether something will be swapped for allow callbacks, then calls callbacks a second time with swapped properties. Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/lua_api.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index cc4af970c..86627c19e 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -5888,6 +5888,31 @@ An `InvRef` is a reference to an inventory.
`minetest.get_inventory(location)`.
* returns `{type="undefined"}` in case location is not known
+### Callbacks
+
+Detached & nodemeta inventories provide the following callbacks for move actions:
+
+#### Before
+
+The `allow_*` callbacks return how many items can be moved.
+
+* `allow_move`/`allow_metadata_inventory_move`: Moving items in the inventory
+* `allow_take`/`allow_metadata_inventory_take`: Taking items from the inventory
+* `allow_put`/`allow_metadata_inventory_put`: Putting items to the inventory
+
+#### After
+
+The `on_*` callbacks are called after the items have been placed in the inventories.
+
+* `on_move`/`on_metadata_inventory_move`: Moving items in the inventory
+* `on_take`/`on_metadata_inventory_take`: Taking items from the inventory
+* `on_put`/`on_metadata_inventory_put`: Putting items to the inventory
+
+#### Swapping
+
+When a player tries to put an item to a place where another item is, the items are *swapped*.
+This means that all callbacks will be called twice (once for each action).
+
`ItemStack`
-----------