Allow_take inventory

Post Reply
User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Allow_take inventory

by runs » Post

Code: Select all

 
 -- Called when a player wants to take items out of the inventory
 allow_take = function(inv, listname, index, stack, player) end,
 
I would like to check the take process from a node inventory to a player inventory. The problem is that it is not the default "main" list. How could I know the target list of the player's inventory? This info is only get when move between lists within the same inventory (to_list).

I guess that those callbacks are only for the same inventory lists.

:-)

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Allow_take inventory

by Nathan.S » Post

I'm slightly confused as to what exactly you are trying to do. Allow_take doesn't need the name of the inventory that you are moving the item too, it only needs the inventory the item is being taken from. If you are trying to keep a player from putting something into their inventory you could do that with an allow_put, and put that code in the inventory you are trying to keep the player from putting the item in.

Not sure if that helps at all. I think we have a little language barrier. :)
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Allow_take inventory

by runs » Post

Nathan.S wrote:
Sun Nov 22, 2020 19:17
I'm slightly confused as to what exactly you are trying to do. Allow_take doesn't need the name of the inventory that you are moving the item too, it only needs the inventory the item is being taken from. If you are trying to keep a player from putting something into their inventory you could do that with an allow_put, and put that code in the inventory you are trying to keep the player from putting the item in.

Not sure if that helps at all. I think we have a little language barrier. :)
Yes, cos it is difficult to explain it, even in my native language. I have 3 inventories: "main" (player inv), "cloths" (player inv) and "closet" (node inv) in the same form.

I want to check the item put in the cloths (player) inv. The problem is that the item can come from "main" (player) or "closet" (node).

There is not an "allow_put" function for a player inventory, but 'minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))'

https://dev.minetest.net/minetest.regis ... ory_action

The problem is that the item from the "main" is get and procesed by that function (I suppose because are lists from the player inventory), but the item from the closet not, the 'inventory_info.listname' is nil in this case, I cannot capture the event.

vibes81
Member
Posts: 11
Joined: Sun Sep 20, 2020 18:42
In-game: Vibes81

Re: Allow_take inventory

by vibes81 » Post

Hi im new to minetest modding but would

Code: Select all

  allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
        -- Called when a player wants to move items inside the inventory.
        -- Return value: number of items allowed to move.
not be what you want?
From what I understand this is called whenever you want to move something from one list to another

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Allow_take inventory

by runs » Post

vibes81 wrote:
Mon Nov 23, 2020 18:26
Hi im new to minetest modding but would

Code: Select all

  allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
        -- Called when a player wants to move items inside the inventory.
        -- Return value: number of items allowed to move.
not be what you want?
From what I understand this is called whenever you want to move something from one list to another
No, this is only for lists from the same inventory type. Inventory types are 3: player, node and detached.

I want interchange items between different inventory types / lists.

vibes81
Member
Posts: 11
Joined: Sun Sep 20, 2020 18:42
In-game: Vibes81

Re: Allow_take inventory

by vibes81 » Post

my bad I didn't read your first post that explains the fact its between inventories.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Allow_take inventory

by runs » Post

Please, I need a solution to make a real 2.0 mod all people wants from me.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Allow_take inventory

by runs » Post

Finally I solved with:

- "inventory_info.to_list" and then 'inventory_info.from_list & inventory_info.from_index' to get the stack in the case of moving inside lists of the player inventory.
- "action" and "inventory_info.listname" for the case of diferent inventory types.

It could be done, but very unintuitive to implement.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests