Page 1 of 1

on_put/allow_put/etc. for non-detached inventories

PostPosted: Mon Mar 09, 2015 20:10
by Wuzzy
I know there are functions called “on_put”, “allow_put”, “on_move”, “on_take”, etc. available for detached definitions; they are defined when calling minetest.create_detached_inventory.

I wonder if such functions are available for non-detached inventories as well. Especially player inventories.
I want to achieve that some slots of a player's inventory behave differently by only allow them to hold a particular item type, but no other item type.
I know this can be achieved for detached inventories by defining the allow_put function.

Re: on_put/allow_put/etc. for non-detached inventories

PostPosted: Wed Mar 11, 2015 17:58
by Krock
That's a good question. I haven't seen any of those functions for player inventories yet.
Open an issue on GitHub or code those functions because I see no other soulation.

Re: on_put/allow_put/etc. for non-detached inventories

PostPosted: Wed Apr 01, 2015 20:31
by prestidigitator
This is possible for node inventories and for detached inventories, but not for player inventories. It would be nice.

For now your best bet is probably to create a detached inventory for each player or something. You'll probably have to be careful about persisting contents as I don't think they're kept in the world database (not completely sure of that one though). Unfortunately it'll also require changing player inventory formspecs. There's no built-in way to do that such that the change doesn't trample other mods' changes, so you'll either have to be incompatible with all other such mods or depend on a mod that provides a framework to coordinate changes.