Merging Chests

by Atria

Enables merging of multiple chests into one entity. Supports merging of arbitrary number of chests (configurable in mod settings).

Content
17 days ago
0.13 - 2.0
117K
Storage

i About saving memory & minor things

5 years ago
(updated 5 years ago)

Hi! I love using Merging Chests mod a lot.
But I realized that I could reduce the startup loading time by 40-60 s, by disabling this mod...
So I have to cut down the settings (width/height/area = 16) to speed up loading (still take like 10 s), but also limiting my uses.

Maybe let me explain my uses of your mod first, I uses merged chests in two places:
A) Train station cargo load/unload. Now I use 1×6 chest for each wagon, to ensure all inserters are working for max load/unload speed, by avoiding the "old" unbalanced / complicated circuit problem. (I wanted to use one single long chest 1×55 for my 8 wagon ore trains. But that makes the loading hopelessly long... I gave up.)
B) Belt/lane balancer, together with loaders. This setup is naturally output balanced. I typically use 1×4, 1×8, 1×16.
As you can see, I only use the "linear subset" of merged chests. But I have both vertical and horizontal placement of them, so I am using setting width/height/area = 16. (Tried to use width/height/area = 55, but this was very slow...)

So my requests are:
1) Is it possible to restrict the dimensions? For example, I do not need the 2×2 or 2×8 chests. Skipping can save some memory and a lot of loading time.
2) Or go even further, can I just specify the desired dimensions? It may take as a "string-setting" in options, like "1×4; 1×6; 1×8; 1×16; 1×27; 1×55". Then at "data.lua" stage, this string is parsed, and generate only these specific chests in both vertical and horizontal form. This way I can save even more memory and loading time. (By skipping dimensions like 1×2, 1×3, 1×5, 1×7, 1×9, ...)
3) Or... I am a modder too. So if you do not want to do the above for any reasons (e.g., making your code too complicated to handle different setups, no time to do that, do not want these in a single mod, etc...), then can you grant me the permission to make a fork based on this mod? It is supposed to be a subset of your mod, so not trying to replacing / stealing your work or whatever.

Lastly is about the upgrade planner.
When using the upgrade planner, I found a new tab "Merged chests", which is filled with ALL possible dimensions of merged chests. They are not supposed to be upgradable, right? Can they be hidden?

Regards,
Schall

5 years ago

Hello,
both requests seems to be easy to implement but both of them require additional setting. I could probably merge them and allow players to give ranges instead of simple list. I recently worked with cron expressions and I can imagine using config like 1x2/2 (every even size chest) or 1x2-20 (chests with length up to 20). Multiple configs separated by some character. But maybe I'll just stick with simple list and ranges because the slash notation could be confusing.

About the upgrade planner. I'll check if there is a flag to hide from upgrade planner.

I'm going on vacation this week so I'll implement the changes then.

Thank you for suggestions.

5 years ago

Thank you for your prompt reply. Looking forward to see that included.

PS:
"Train station chests" are 1×6, 1×13, 1×20, 1×27, ..., 1×55, 1×(7n-1).
"Belt/lane balancer chests" are 1×4, 1×8, 1×16, ..., 1×2^n. But I probably do not need 64 belt balancer. :D

5 years ago

I'm not thinking of implementing some predefined filters.

I wasn't thinking of giving the algorithm a formula containing "n" and let it figure out all possible sizes. But when I think about it it could be a good idea, if I'm able to parse it into a annonymous function. That is a big if because I'm not that agile with lua. If you have idea on how to parse string like "(7n-1)" to function with numeric input and output I'll be glad to hear them.

5 years ago
(updated 5 years ago)

Lua functions string.match or string.gmatch can be used to parse the whole string and recognize the different numbers and variables. But still some additional code to handle the logic.
So yes, it is much more complicated than handling a direct list of sizes, using pattern "(%d+){×xX}(%d+)". So if it were for me to do it, I would simply just accept list of number pairs (e.g., "1×4; 1×6; 1×8; 1×13; 1×16; 1×27; 1×55"), as suggested by my first post point 2. If such string is empty or no valid number pairs are found, then return to your original behaviour to implement all possible dimensions.

EDIT: The markdown syntax is messing with my pattern string above, because of the square brackets. Please replace the curly brackets with square brackets.

5 years ago

Aaaaaand done.

5 years ago
(updated 5 years ago)

Thanks for the work, but may I ask what else settings needed to get the whitelist feature working?
I currently apply Whitelist of merged chests with '1×4 1×6 1×8 1×13 1×16 1×20 1×27 1×32 1×55', with Maximum chest width/height/area = 16. I still get chests like 1×2 or 1×15 which I don't want to have.
When I changed Maximum chest width/height/area = 2, I do not get chest like 1×4 or 1×16.

5 years ago

You are probably using unexpected "x" character. Use normal "x" letter.

5 years ago

Alright, the English alphabet "x" works. Thought it would accept the unicode multiplication sign "×".
BTW, it is a bit inconvenient that using '1x4 1x6 1x8 1x13 1x16 1x20 1x27 1x32 1x55' only apply to vertical spanning chests. I expected the symmetry/rotatable that the horizontal spanning chests would be applied as well. Anyway, not a big issue.

5 years ago

It should accept these characters: "×xX*", and multiplication should be there, maybe just different variant.
Adding symetry would be easy but I wanted to let people have more control. In your case you could whitelist "1xN and Nx1" and limit width/height/area to 55. 108 entities should load fast.

5 years ago

I used the exact previous string '1×4 1×6 1×8 1×13 1×16 1×20 1×27 1×32 1×55' having Unicode multiplication sign "×", which is how I drawn my conclusion last reply. You may copy and paste it to see how it does not work.
Replacing it with English alphabet '1x4 1x6 1x8 1x13 1x16 1x20 1x27 1x32 1x55' made it work.

I understand your point about symmetry, it is fine to keep it.
Anyway, the latest version let me reduce the number of entities greatly, which is what the most important to me. My request is fulfilled. Thanks and keep up the good work!

5 years ago

Yes I also tried it with string you sent and it also didn't work, I'll add additional multiplication signs in next update. No problem and thank you for suggestion.

5 years ago

Nice to see the multiplication sign added in the update.
Will test it when I have time to start the game, but I assume it works if not "complain" afterwards. Thank you! :D

5 years ago

I used wrong encoding when saving the previous version. This one is in UTF-8 so it should work.

New response