Page 1 of 1

Configurable train loader

Posted: Fri Aug 13, 2021 9:31 am
by Khagan
So you want to dispatch a train load of assorted goodies to a distant building site, containing everything needed for a few hundred metres of defensive wall, a new science factory or a nuclear power station ('some assembly required'). How do you get the right mix of items loaded on the train? I'm sure everyone has their own favourite way of doing this, but here is what I have ended up with after a couple of iterations:
loader.png
loader.png (830.31 KiB) Viewed 3940 times


Here are half-a-dozen examples in real game use:
railDepot.png
railDepot.png (3.73 MiB) Viewed 3940 times
The main line of constant combinators is set up with the numbers of items requested; large requests can be split between multiple inserters feeding the same wagon, but balanced loading is not guaranteed if the same item is requested for two or more different wagons. There are two constant combinators at the front of the train that can be enabled or disabled to toggle requesting ('R') and loading ('L') respectively. For regular small jobs I keep them both on; for large or one-off jobs I keep the loading off until the request is complete, then turn requesting off and loading on. For large jobs this can be combined with requesting several train loads at once by changing the constant in the front right combinator from -1 to -n, where n is the number of train loads to spread the request over.

The way the controlling circuits are set up reminds me a little of enzymatic action in a cell: the central control doesn't tell the local machinery what to do, but instead dispatches inhibitors to stop it doing things. The train will only be loaded if it is 'officially' (i.e. automatically) at the station, since otherwise the contents of the train can't be read. The loading isn't count-perfect, but can trivially be made so at the cost of loading speed, by setting the stack size of all the filter inserters to 1.

Re: Configurable train loader

Posted: Tue Sep 28, 2021 12:16 am
by blazespinnaker
Cool, I'm trying to pack everything in one wagon.

For incoming, I use all 12 inserter spots, each pulling in 4 different items via underground belts and 2 red inserters each, for a total of 48.

However, a wagon can only filter 40 (1 for each spot), so I can't use all 48. Not a problem as setting up an arbitrary satellite base can be done within that subset of 40.

For outgoing, I use 40 different comparison combinators. It's a pain, but c'est la vie.

I wracked my brain but couldn't come up with any simpler that was as reliable. I thought about using an intermediate wagon on an orphan track, but such hackery didn't look like it would work. Too bad you can't set filters in the red logistics chests.

(Not researching logistic system makes things trickier, basically I'm re-inventing it with trains and decider combinators)

Re: Configurable train loader

Posted: Tue Sep 28, 2021 2:57 am
by foamy
Khagan wrote:
Fri Aug 13, 2021 9:31 am
The loading isn't count-perfect, but can trivially be made so at the cost of loading speed, by setting the stack size of all the filter inserters to 1.
You can add a removal inserter set to 1 to correct that, but it runs into difficulties if you're dealing with multiple stacks. If you're really fancy you can dynamically scale the inserter limits, but that only works if each inserter is moving a different item.

Re: Configurable train loader

Posted: Tue Sep 28, 2021 3:39 am
by Khagan
blazespinnaker wrote:
Tue Sep 28, 2021 12:16 am
For incoming, I use all 12 inserter spots, each pulling in 4 different items via underground belts and 2 red inserters each, for a total of 48.
I have done a belt-fed munitions train, but that didn't use combinators, just explicit stack limits inside the railway wagon.
For outgoing, I use 40 different comparison combinators. It's a pain, but c'est la vie.
At the destination I'm afraid I just dump everything higgledy-piggledy into storage chests and let the bots use it as they see fit.
(Not researching logistic system makes things trickier, basically I'm re-inventing it with trains and decider combinators)
I've never really been at the stage of building on the scale I'm talking about here (train loads of items) prior to having logistics available.

Re: Configurable train loader

Posted: Tue Sep 28, 2021 12:29 pm
by blazespinnaker
Yeah, logistic system would make everything trivial. Unfortunately, also rather boring, so I'm trying a game without ever researching it.

The downside though is that things are getting rather messy with all the belts.

Re: Configurable train loader

Posted: Wed Sep 29, 2021 4:16 pm
by disentius
If you want count perfect loading, here is a way to do it: https://www.youtube.com/watch?v=B8h5Aii1tts

Re: Configurable train loader

Posted: Wed Oct 06, 2021 9:08 pm
by blazespinnaker
I'm sure everyone has done some variant of this. One wagon is used to supply all the bases in case biters somehow make it in or I want to tweak things a bit.

The combinators have some limit on how many things I want to pull in so I don't waste too much. Get the right balance is important, as somethings you want more of, some less.

The roboport exports the number of bots so I can make sure I always have enough. The yellow chests return things to the train for other bases if I do some deconstructing.
stufrf.png
stufrf.png (307.66 KiB) Viewed 3467 times
filter.png
filter.png (69.99 KiB) Viewed 3467 times
Here's the loader. It sorta is not great because inserters can get stuck with items if a train is full of them. It doesn't pull like into an assembler with the right material. Even if you change it to pull size 1! Ideally I'd use two wagons each with 24 items. Just haven't got around to it.

load.png
load.png (37.33 KiB) Viewed 3462 times

Re: Configurable train loader

Posted: Wed Oct 06, 2021 11:44 pm
by mrvn
Setting it up so items get loaded count perfect with lots of inserters is tricky and takes a lot of combinators. It's easier to configure the train to load 1 item less than a full stack for each. Then have one inserter with stacksize 1 set to unload any items above the configured count.

PS: you can use a constant combinator to configure what to load and an arithmetic combinator to subtract the current content to get a count of what needs loading. No need to have one combinator per item.

Re: Configurable train loader

Posted: Thu Oct 07, 2021 3:24 am
by blazespinnaker
Hmm, loading count perfect isn't necessary. Just max the space in the wagon. Loading is pretty trivial for my use case. Unloading count perfect isn't really that important, just as long as its within 2 or 3 is fine.

The constant combinator, cool. Should have tried that.

Re: Configurable train loader

Posted: Thu Oct 07, 2021 6:02 pm
by mrvn
blazespinnaker wrote:
Thu Oct 07, 2021 3:24 am
Hmm, loading count perfect isn't necessary. Just max the space in the wagon. Loading is pretty trivial for my use case. Unloading count perfect isn't really that important, just as long as its within 2 or 3 is fine.

The constant combinator, cool. Should have tried that.
The problem is that a stack inserter will pick up 12 belts from the chest and try to load them. Then it reaches 192 belts in the wagon. Next swing it can only load 8 belts and is left with 4 in it's hand. The inserter is then blocked and can't switch over to loading underground belts or splitters. If you want to load more than one item from a chest, or more than 12 items total, you need to never block an inserter. So either you always leave at least 11 space for each item, you load count perfect or you unload excess.

Leaving 11 space for e.g. train stops means at least 2 slots reserved for train stops and loading only 9. 12 slots for artillery shells and only loading 1. Some items you want to have their own chests and the inserter to block.