Page 1 of 4

[MOD 0.12.x] Equalizer chests v1.4.0

Posted: Fri Nov 07, 2014 11:52 am
by Boogieman14
*NOTE* Version for Factorio 0.13 and up can be found in the mod portal!


So I made my first mod :)



This mod will provide 48-slot chests that will 'connect' with their direct neighbours and balance ("equalize") the contents of these chests (think Communicating vessels). My personal use case for this will be with train unloaders, where the chests furthest from the middle of the wagon don't receive nearly as much materials as the center chest.

This mod only deals with itemcounts, so no effort is made to balance individual items. There's also a lower threshold of 10 items below which no items will be transfer (this to avoid ping-ponging stuff back and forth).

I haven't tested it extensively yet, but some basic testing showed no obvious problems. I think it should be MP-safe.

As of 0.11.2, the scripting now also works when the chest was placed by a robot.

Of course, I welcome any tips and suggestions for improvement :)

You're welcome to include this mod in any modpacks, provided you include a link to this forum post whenever you publish the pack.

Updated for 0.12.0
The update for 0.12.0 has only been tested briefly, no extensive playthroughs have been done with it yet (but all the basic functionality appears to work: placing, balacing, removing, destroying). I have not tested this at all in MP and no provisions have been made yet for different forces.
acknowledgement
version history
Blue coloured icons provided by Turtle.


0.12.11+:
Equalizer_Chests_1.1.4.zip
For 0.12.11 and later
(17.56 KiB) Downloaded 1428 times
for older versions of Factorio

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri Nov 07, 2014 12:53 pm
by bobingabout
Sounds useful, but for barely more than that one specific purpose that you mentioned. But for that purpose, it could be quite invaluble.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri Nov 07, 2014 1:10 pm
by Boogieman14
Yeah, that's probably true for many specific mods like this. I'm pretty sure I'll enjoy the benefits though, and if nothing else, it's been a nice learning experience :)

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri Nov 07, 2014 3:26 pm
by TheSAguy
Hey Boogieman14,

I was very exited to see this!

This sounds a lot like the mod I suggested/requested here: https://forums.factorio.com/forum/vie ... =33&t=6251

I'm not sure why you're "equalize" the content over the different chests, all that's needed is that two adjacent chests become one container.

I'm glad for this though and will definitely give it a try.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri Nov 07, 2014 3:37 pm
by atehxx
I didn't use this yet but checked source and is this ok?:

Code: Select all

--game.onevent(defines.events.onpreplayermineditem, removedEntity)
--game.onevent(defines.events.onrobotpremined, removedEntity)
--game.onevent(defines.events.onentitydied, removedEntity)
You don't seem to check for removed chests atm.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri Nov 07, 2014 3:38 pm
by Boogieman14
TheSAguy wrote: all that's needed is that two adjacent chests become one container.
I suspect your "all that's needed" may actually be a lot more complicated than it sounds :) Especially when you want the flexibility you're describing of being able to add (and presumably removed) containers at will. This mod will leave each container as a standalone unit that interfaces with its neighbours. So it doesn't become one big inventory.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri Nov 07, 2014 3:40 pm
by Boogieman14
atehxx wrote:I didn't use this yet but checked source and is this ok?:

Code: Select all

--game.onevent(defines.events.onpreplayermineditem, removedEntity)
--game.onevent(defines.events.onrobotpremined, removedEntity)
--game.onevent(defines.events.onentitydied, removedEntity)
You don't seem to check for removed chests atm.
Yes, that's actually ok :) I guess i might as well remove that bit, because it isn't needed. Removal makes the entity invalid (entity.valid = false), all the code that interacts with chests checks for that valid flag, and in the tick-loop, if the entity is invalid, it gets removed at that moment. As far as I can think of, nothing else is needed for removal.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri Nov 07, 2014 7:57 pm
by Rseding91
Looks nice. I downloaded the mod to see how you where handling the detection of new chests (and ticking of the chests) only to read the first two lines of the control.lua file and get a giant grin across my face :D

I don't see any issues with the logic you've got setup - nice mod :)

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri Nov 07, 2014 9:11 pm
by atehxx
Boogieman14 wrote: Yes, that's actually ok :) I guess i might as well remove that bit, because it isn't needed. Removal makes the entity invalid (entity.valid = false), all the code that interacts with chests checks for that valid flag, and in the tick-loop, if the entity is invalid, it gets removed at that moment. As far as I can think of, nothing else is needed for removal.
Right... I got to that part of code later... :) I guess I no longer need to create my tiny mod with long&narrow boxes anymore :P

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Sun Nov 09, 2014 1:51 pm
by SHiRKiT
Let's come up with a possible scenario:
I have line setup of 10 chests.
I only input to 8 of them.
Only pull from 4 of them.

Let's say that after inputting some items, I stop doing so, and items are only being pulled out of 4 chests at random. What would happen in that case?

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Sun Nov 09, 2014 2:14 pm
by Boogieman14
Test it and let me know ;)

You'd probably end up with 4 empty chests (well, that one's for sure) and 6 chests with a number of items in it. The exact numbers depend on the distribution of the extraction inserters. If they're all at one end of the line, the other chests will contain between 1 and 60 items. If they're evenly distributed, the leftovers will all be in the 1-10 range, I think.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Thu Feb 19, 2015 6:47 pm
by KrzysD
Bug report; if you put blueprints in they will be cleared.

Would it be to much to ask for Equalizing Passive Provider Chest? 8-)

Thanks for the useful mod :D

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Sun Feb 22, 2015 2:42 pm
by Kane
Seems to work well. Any chance of seeing future logistic versions of these chests?

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Mon Feb 23, 2015 2:20 pm
by Boogieman14
KrzysD wrote:Bug report; if you put blueprints in they will be cleared.
That's interesting. Blueprints probably have some special properties that the code doesn't take into account. I'll have to look into it, although not sure I'll spend too much time trying to fix this as it seems such a fringe case :)
Would it be to much to ask for Equalizing Passive Provider Chest? 8-)
That should be possible, although not sure if/when I'll get around to it as I've been taking a break from Factorio (so much to do, so little time :lol: )
Thanks for the useful mod :D
Glad you like it :)

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Fri May 15, 2015 7:43 pm
by Turtle
Thanks for this mod. I find it invaluable at train stations. I got sick of accidentally making these chests instead of regular steel chests though, so I tinted some steel chests with a blue-ish tint:
equalizer-chest.png
equalizer-chest.png (5.74 KiB) Viewed 20577 times
Equalizer_Chests_1.0.0.zip
Download
(16.48 KiB) Downloaded 371 times
The only part of the code changed is the pathing for the images.
@Booggieman14 - Please let me know if you don't approve and I'll take it down, otherwise feel free to update your first post.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Thu May 21, 2015 1:42 pm
by Boogieman14
Awesome, I never got around to doing that myself, even though I ran into the problem myself a few times in my latest game :oops: I've added it to the first post, thanks :)

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Tue May 26, 2015 4:48 pm
by TheSAguy
I use your chest as a buffer at my Iron and Copper smelting stations.
I haul in great volumes of ore and store them in the chests.

The ore goes in tat the top as fast as I can get it. (Normally the belts are full, I just had an alien attack take down my power)

Image

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Wed May 27, 2015 3:49 pm
by TheSAguy
Hey Boogieman14,

I thought of an upgrade to your chests. Quantum Chests!
They will work like underground belts. You build them in pairs and they stay connected, but can span a distance underground. The distance can be increased by upgrading, like underground belts.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Thu May 28, 2015 9:45 am
by Boogieman14
Cool layout, hadn't thought of using them like that ;)

As for the quantum chests, I seem to remember I've seen something like that already. Or maybe those were remote inserters or something like that. I probably won't make something like that, as I feel this kind of "teleportation" doesn't really fit in the setting of the game. Equalizer chests work by physically handing stuff over to adjecent chests.

Re: [Mod 0.11.x] Equalizer chests v1.0.0

Posted: Mon Jul 20, 2015 3:26 pm
by buder5
any plan for factorio 0.12 ?