From f6eff57f7cf504c715f9b58147667f2ae77732c0 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 31 Mar 2018 12:30:43 +0200 Subject: Add player inventory callbacks --- doc/lua_api.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'doc') 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). -- cgit v1.2.3