becreswell wrote: Wed Nov 01, 2023 6:11 am
The only way i've found to work around it is to override the stack size and set it to 1, which is obviously not a good way to load trains.
The way you found is going in the right direction though, because if an inserter get stuck with the wrong material, it's already problematic, but it will also cause it to drop that extra item in the next train coming by which is another problem that your solution doesn't cause.
Now what you want is going faster, or use more than 1 inserter i suppose, but then reducing stack size to 1 would not work, because if there is 1 room left for 1 iron plate and 6 inserter grab 1 at the same time, 5 will get stuck.
You could use 2 filter inserters one for steel one for iron plate, that's another way you may want to look for. But beware of cargo wagon without filter in the next train if you have some filter inserter left holding some item
It depends what you want to do, or if you were just toying with trains to see how it works, there are others ways , like using circuits networks, in particular, the ability to connect the train stop and the inserters, this allow to "read the content" of the train if you tick that option in the connected-with-wire train station. Inserters can have their stack size set with circuit network. So one another way would be to use arithmetic combinators to turn the train content into negative, so instead of 450 iron plate, the signal would be -450 iron plate if the train has 450 plate in its wagon. 450 input , the operation is multiplication between "each" and "-1" so it will also turn the steel quantity or any quantity into negative. Then if you connect with the same wire color a constant combinator to the output of the arithemtic, it will automatically addition the value in the constant, and the negative value. So if you want 500 plate in the train, you set the constant with "500" in the signal "iron plate". At any point you can read the value in the wires when they are connected to a power pole, if you connect such wire to an inserter, it will read "50 iron plate", and you can use that as stack size when the inserter is connected to a wire, you can tick the option "set stack size" and the signal "iron plate".
When it's above the max stack size allowed, it will choose the max instead, but if you have 497 iron plate, the output of the arithmetic would be -497 +500 in the constant combinator, the result would be 3 so the stack size would be 3. And maybe it will take 3, if 2 is the max, then it will be 499 plate in the train, 500 in the constant, so stack size would automatically change to 1 and it will prevent the inserter to grab too many plate for the last swing.
Yes that only works with 1 inserter but that's also only using 2 combinators, not sure if that is your thing but there are ways to investigate there.
Again depending on what you have in mind, there may be different solutions. Filtering wagons and using filter inserters is quite robust and simple , it prevent 1) wrong material in wagon 2) inserter stuck with wrong material (*most of the time)
*The risk is you have a train you want loaded full iron, and then a train loaded full copper and you plan to change the filter of the inserter in between, but they have already some iron grabbed leftover, so some of them won't load the copper train, but would resume their work once a iron train need to be loaded. As such it's not always a good idea to change filter, it also depend on the larger picture.