Help with creating another inventory (modding)

Post Reply
LC Creations
Member
Posts: 159
Joined: Mon Feb 18, 2019 02:53
GitHub: LandonAConway

Help with creating another inventory (modding)

by LC Creations » Post

Hello, I'm working on a mod that allows players to put a single item from their inventory in a formspec list (for one item only). I dont know how to create another inventory that is attached to the player. How do I do this. I know to to create formspecs and show the original inventory but how to I create a secondary inventory for the player?
cdb_ac3a146dcafb

Eran
Member
Posts: 123
Joined: Fri May 03, 2019 16:46

Re: Help with creating another inventory (modding)

by Eran » Post

You'll want to use detached inventories. You can use their callbacks to make it so a player can only put in a single item. Keep in mind you'll have to save these manually in player meta, mod storage or a file. You can save using detached inventory callbacks aswell.
To get a detached inventory to show up in a formspec see here.

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Help with creating another inventory (modding)

by rubenwardy » Post

Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
CBugDCoder
Member
Posts: 32
Joined: Tue Jul 31, 2018 12:13
GitHub: CBugDCoder
IRC: CBugDCoder
In-game: CalebDavis
Location: Home

Re: Help with creating another inventory (modding)

by CBugDCoder » Post

This might be the completely wrong way of doing it but I have been able to create a custom inventory bound to the player simply by setting the size of a new list in the player inventory on join e.g.
minetest.register_on_joinplayer(player)
local inv = player:get_player_inventory()
inv:set_size("antimater_chest", 8*4)
end
This creates a inventory that I use for a enderchest like node.
My Mods: Mob AI Glider

Eran
Member
Posts: 123
Joined: Fri May 03, 2019 16:46

Re: Help with creating another inventory (modding)

by Eran » Post

CBugDCoder wrote:This might be the completely wrong way of doing it but I have been able to create a custom inventory bound to the player simply by setting the size of a new list in the player inventory on join e.g.
minetest.register_on_joinplayer(player)
local inv = player:get_player_inventory()
inv:set_size("antimater_chest", 8*4)
end
This creates a inventory that I use for a enderchest like node.
Huh, neat, I didn't know that was possible.

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 25 guests