mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Add player inventory callbacks
This commit is contained in:
parent
12edb200eb
commit
f6eff57f7c
5 changed files with 259 additions and 1 deletions
|
@ -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).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue