on_put/allow_put/etc. for non-detached inventories

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

on_put/allow_put/etc. for non-detached inventories

by Wuzzy » Mon Mar 09, 2015 20:10

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.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

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

by Krock » Wed Mar 11, 2015 17:58

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.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

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

by prestidigitator » Wed Apr 01, 2015 20:31

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.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron