summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2018-03-31 12:30:43 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-04-02 17:18:48 +0200
commitf6eff57f7cf504c715f9b58147667f2ae77732c0 (patch)
tree0c6c9abd6fb663e042bc16e63ad484df423d77a2 /doc
parent12edb200eb0b61972418a95c704fc1c3dd6357cf (diff)
downloadminetest-f6eff57f7cf504c715f9b58147667f2ae77732c0.tar.gz
minetest-f6eff57f7cf504c715f9b58147667f2ae77732c0.tar.bz2
minetest-f6eff57f7cf504c715f9b58147667f2ae77732c0.zip
Add player inventory callbacks
Diffstat (limited to 'doc')
-rw-r--r--doc/lua_api.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 00f5e3f71..0c995b54e 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -2880,6 +2880,22 @@ Call these functions only at load time!
* `minetest.register_craft_predict(func(itemstack, player, old_craft_grid, craft_inv))`
* The same as before, except that it is called before the player crafts, to
make craft prediction, and it should not change anything.
+* `minetest.register_allow_player_inventory_action(func(player, inventory, action, inventory_info))`
+ * Determinates how much of a stack may be taken, put or moved to a
+ player inventory.
+ * `player` (type `ObjectRef`) is the player who modified the inventory
+ `inventory` (type `InvRef`).
+ * List of possible `action` (string) values and their
+ `inventory_info` (table) contents:
+ * `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`
+ * `put`: `{listname=string, index=number, stack=ItemStack}`
+ * `take`: Same as `put`
+ * Return a numeric value to limit the amount of items to be taken, put or
+ moved. A value of `-1` for `take` will make the source stack infinite.
+* `minetest.register_on_player_inventory_action(func(player, inventory, action, inventory_info))`
+ * Called after a take, put or move event from/to/in a player inventory
+ * Function arguments: see `minetest.register_allow_player_inventory_action`
+ * Does not accept or handle any return value.
* `minetest.register_on_protection_violation(func(pos, name))`
* Called by `builtin` and mods when a player violates protection at a
position (eg, digs a node or punches a protected entity).