Help with creating another inventory (modding)
-
- Member
- Posts: 159
- Joined: Mon Feb 18, 2019 02:53
- GitHub: LandonAConway
Help with creating another inventory (modding)
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
Re: Help with creating another inventory (modding)
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.
To get a detached inventory to show up in a formspec see here.
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
- 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)
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.
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.
Re: Help with creating another inventory (modding)
Huh, neat, I didn't know that was possible.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.
Who is online
Users browsing this forum: Semrush [Bot] and 25 guests