-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect if chest has content? #538
Comments
I agree. The "is full" state is tricky because a slot could hold more, but not more of another item. Instead of those three states, it could count slots that have at least one item, and have two text fields to enter the minimum and maximum number of slots, both inclusive. It could also support percentages in addition to exact slot counts, so the player doesn't have to count slots.
Those cover your initial goals. Use The exact slot count is needed to allow the "has items" mode because 1% might be more than one for a chest with more than 100 slots. It also gives precise control over the number of slots that a signal should be active for. And some might find it easier than figuring out percentages. |
There's also unstackable items too, right? Like batteries? But, maybe there's not so many of them so we could have a static list of unstackables to use when summing up how many items are required to "fill" an item stack. Another option could be to try to add a dummy node of the same kind to the item stack but that might be wasteful in terms of cpu cycles.. |
Working WIP here (based on switch for now) https://github.com/johalun/mesecons/compare/master..scanner |
There is no need to check for stack size, just count the number of slots that have an item, ignoring the quantity of each stack. A chest with 1 stick in each slot will register as full but that isn't really possible to do with automation. Unless those sticks are shrinking the chest so it only holds a few of the item you actually want to go into the chest, in which case this method still works as intended.
It would also be nice to have an inventory name field for inventories with names other than "main", or multiple inventories. It could default to "main" if blank. |
That's true. Usually with automation you have one or just a few different kinds of items in a chest so maybe that's not a big deal. Yeah, I've been thinking about inventory name as well and that's a good idea. I know for example Pipework's autocrafter has a temporary inventory for uncrafted items as well as the inventory for crafted items. I wonder, would it be possible to fetch a list of all inventories from the chest/node behind the scanner and populate a drop down list? Sounds like it should be... |
https://dev.minetest.net/InvRef -- inv:get_lists() returns a table of list names. As for percentages, it might be good to store the actual values in min/max fields and if value is a percentage, store in min_pct and max_pct or set them to zero if 0% or not a percentage. That way the code uses fast min/max values instead of checking and calculating percentage each tick. Opening formspec and saving could recalculate or use on_punch to do it. |
PR here #540 |
I would like to see some way to request items to a chest or container. Ideally, as Factorio handles it, the mesecons would handle different signals with "IDs" or "types", and the signal could be linked to the desired/missing content of the object in from of the inserter, and therefore on the other end a decision could be bade based on what signal was sent and what items were missing. But even if only one signal could be sent when something was missing in the chest, one could use several "inserters" to detect the status of several types items in a chest. This could be used in a lot of ways. One could detect whether there are sufficient solar panels in a chest and when not, send a signal to an autocrafter. Another "inserter" could check whether the autocrafter has what it needs to make a solar panel, and so forth. Another option is to make machine and chest inventories able to send a signal when they do not have a certain item. The "inserters" or "requesters" would then not be needed. Machines and chests could send a "request" signal when they do not have the configured amount of items (which could be multiple combinations of quantities and types). This is rather similar to Factorio, where huge manufacturing chains can easily be setup and automated, and is pretty much the only missing item in the puzzle for Minetest to allow for automated factories. Or is there any other way to do this, which I haven't found? |
Are there any plans to create a node that can sense the content of a chest (and possibly other kinds of containers). Either one node that is configured in its GUI or 3 different nodes that output signals on "has items", "is empty" and "is full". If not, I might start working on this, either as a PR to mesecons, or a stand alone mod.
I'm already looking into adding a digilines "get" command to the digiline chest to get how many items it contains but it would also be nice not having to use lua for this and instead build a physical circuit with mesecons. I'm actually quite surprised this functionality hasn't been implemented yet, or am I missing something (I'm new to MTG)? Detecting the amount of contents in a chest seems like the one of the first things you'd want for automation. At least, that's what my MC brain is telling me, maybe there are existing different solutions for MTG?
The text was updated successfully, but these errors were encountered: