Auto-Refill Chests

Post Reply
Grogak
New member
Posts: 4
Joined: Sun Oct 18, 2020 15:15

Auto-Refill Chests

by Grogak » Post

Hello,

I'm curious if there exists a mod or a function which allows me to place a chest, that has an infinite amount of certain items (or that the chest refills itself after some time).

It has to be possible, for example the "Castrum" Mod has chests that refill automaticly. But I was not able to find the code snippets which do this.

I would be happy if someone could help me out!

Dragonop
Member
Posts: 1194
Joined: Tue Oct 23, 2012 12:59
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop
Location: Argentina

Re: Auto-Refill Chests

by Dragonop » Post

An example of asnippet of code in Castrum that refills chests is contained in globalstep.lua, it uses inv:add_item, to, well, add items to an inventory when a timer exceeds a certain threshold.

I've found that this thread: "add_item to inventory - Unexpected behavior?" has some explaining of the function.

minetest.add_item on the Minetest Developer Wiki

What you ask for could probably be easily done in a simple mod, hope you find these links useful.

User avatar
LibraSubtilis
Member
Posts: 17
Joined: Fri Jul 17, 2020 18:57
GitHub: LibraSubtilis

Re: Auto-Refill Chests

by LibraSubtilis » Post

devtest has a "chest of everything" that contains every item.

User avatar
AiTechEye
Member
Posts: 861
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: ¯\_(ツ)_/¯

Re: Auto-Refill Chests

by AiTechEye » Post

i can make one to you, but the items, should those be able to be removed, and what should happen when you whant to remove the chest?

Dragonop
Member
Posts: 1194
Joined: Tue Oct 23, 2012 12:59
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop
Location: Argentina

Re: Auto-Refill Chests

by Dragonop » Post

I liked the concept, made something that I think resembles what you want. Haven't implemented priv checks or anything of the like

https://github.com/Dragonop/infchest
Download
AiTechEye wrote:
Wed Nov 18, 2020 21:17
i can make one to you, but the items, should those be able to be removed, and what should happen when you whant to remove the chest?
I think all players should be able to take items from it, but only a player with the give priv should be able to decide whatever item is to be replicated.

Grogak
New member
Posts: 4
Joined: Sun Oct 18, 2020 15:15

Re: Auto-Refill Chests

by Grogak » Post

Wow Guys thanks!

I was busy with other tasks the last days so I haven't checked this forum but I'm really surprised with the help I got already!

In fact it's like Dragonop said:
I want that all players are able to take items out of the chest but only I (or someone with the corresponding privs) is able to define what's in the chest.

The idea why I want/need this is:

I'm making a "break-server" for my workplace with different challenges (labyrinths, jump puzzles etc..) and I want to provide them with a build-area where they can get creative. But I don't want to simply give them the privs to generate infinite amounts of every block. I want to provide them only with some blocks to build with and my idea to do this was with an infinite chest.


I will look at your answers/mods in detail the next day and give feedback.

Thank you!!

User avatar
cx384
Member
Posts: 502
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Auto-Refill Chests

by cx384 » Post

This is very easy to achieve.
viewtopic.php?t=23178
viewtopic.php?t=18546
viewtopic.php?t=13719
viewtopic.php?t=13375
These mods may be sufficient for your needs and if not try to make your own mod or simply use the command block from mesecons with the give (and teleport) command.
Can your read this?

User avatar
sorcerykid
Member
Posts: 1462
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: Auto-Refill Chests

by sorcerykid » Post

It sounds like what you really want is a chest where the inventory slots are actually buttons. When the button for the corresponding item is clicked, then it will be added to the player's inventory. This way you don't have to keep refilling the chest inventory every single time an item is taken, which is kind of hacky.

Of course, if an admin opens the chest, then it would show the inventory slots as normal so that the item selection could be changed. I would probably make it so that only one item could be placed in each slot, since it doesn't make sense to have a stack count when the items are unlimited anyway.

Just some thoughts.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests