Page 1 of 1

Add a condition "one car empty" to trains

Posted: Sat Aug 27, 2016 8:36 am
by Hannu
Is it possible to add a condition "at least one of the cars is empty" to train stops?

I have 4, 6 and 8 car trains to haul the most common resources. I have also standard belt balancers between unload stations and consumer devices. But they do not balance perfectly in that direction and typically there is one or two wagons (always the same) which are emptied more slowly than others. I have tried to solve the problem with circuit conditions. It works somehow in most cases but results are not perfect. They can not always keep lines compressed. It would balance things very easily if there was a condition which leaves the train when first of the cars is empty.

Re: Add a condition "one car empty" to trains

Posted: Sat Aug 27, 2016 12:07 pm
by ssilk
Hm. I think no. :) The next comes and wants the same with two wagons. And so on. :)

There must be a limit of train-stop-conditions, otherwise the game becomes too complex. This new condition is in my eyes too specialized to have it as general case in the vanilla; especially cause you will have (at some time) an alternative: to implement such a "specialized" condition would be to built a circuit network and set the train to wait for that circuit condition.

Re: Add a condition "one car empty" to trains

Posted: Sat Aug 27, 2016 1:34 pm
by Hannu
ssilk wrote:This new condition is in my eyes too specialized to have it as general case in the vanilla; especially cause you will have (at some time) an alternative: to implement such a "specialized" condition would be to built a circuit network and set the train to wait for that circuit condition.
It is OK for me that is moddable. But I think it is hard coded.

What do you mean with circuit conditions? I think that there will not be a way to get the circuit data from the single wagon. I know that I can make some kind of crazy computer to count changes of item counts in chests but it is far too laborious and impractical (large number of combinators would make unload platforms ugly mess and be potential source of lag and problems in updates if devs make even minor changes to the combinators).

Re: Add a condition "one car empty" to trains

Posted: Sat Aug 27, 2016 2:00 pm
by HL65536
just hook unloading inserters together, set them to output their holded item(s), select "hold" mode and then you only need a circuit that outputs something as soon as the inserters output 0 for longer than one second
or use inactivity if you only touch one of the cargo wagons at this station
or use the cargo of type x < N option if that one specific cargo wagon has different items from the others

Re: Add a condition "one car empty" to trains

Posted: Sat Aug 27, 2016 4:20 pm
by MeduSalem
ssilk wrote:Hm. I think no. :) The next comes and wants the same with two wagons. And so on. :)
Well... not that I need that particular feature... but what about if the trainstop could map a signal to a circuit network channel (much like in Roboports) that reports the total amount of wagons attached to the train and another one of how many of them are full/empty?

That would be a more general solution and probably also allow some interesting things to be done with it like detecting what kind of train it is by checking its length. Just some food for thought though.

Then it wouldn't really need to be a special condition within the train... rather map the signal to a circuit network channel in the trainstop, run it through a combinator (to do whatever you want with it) and then back into the trainstop and use the "wait on circuit network" condition in the train.

The mapping of signals to special circuit network channels would actually be an interesting feature altogether... Made a thread about it here: viewtopic.php?f=6&t=31705

Re: Add a condition "one car empty" to trains

Posted: Sat Aug 27, 2016 5:05 pm
by Ranakastrasz
Well... One way to do it would be to have a sensor that you place close to a car, while you can wire up to the station, and use it to decide.

Re: Add a condition "one car empty" to trains

Posted: Sat Aug 27, 2016 5:32 pm
by Hannu
HL65536 wrote:just hook unloading inserters together, set them to output their holded item(s), select "hold" mode and then you only need a circuit that outputs something as soon as the inserters output 0 for longer than one second
or use inactivity if you only touch one of the cargo wagons at this station
or use the cargo of type x < N option if that one specific cargo wagon has different items from the others
I have all 8 cars filled with the same thing and loaded and unloaded always simultaneously. I have large outposts and my new iron and copper smelters are specified to process at least million ores per hour. I load trains until they are full and unload every car to one input line of 8 x 8 balancer. However, balancers do not seem to work perfectly to backward direction.

Thanks for the tip. I have to study timing circuits. Maybe it could be some kind of counter which is zeroed if inserters are idle. There will be problem when the chests are filled but the car has stuff left, but I think that it can be solved by controlling signals.

Re: Add a condition "one car empty" to trains

Posted: Sat Aug 27, 2016 10:20 pm
by siggboy
Rails should be made circuit-connectable (as proposed before by others and myself).

Then you could simply read the contents of individual wagons. It would also be ridiculously easy to implement.

Re: Add a condition "one car empty" to trains

Posted: Sun Aug 28, 2016 9:43 am
by Hannu
siggboy wrote:Rails should be made circuit-connectable (as proposed before by others and myself).

Then you could simply read the contents of individual wagons. It would also be ridiculously easy to implement.
I agree. This would be better solution than additional conditions in train stops. It would keep train stop interface simple and give more general options to control trains or material flows.

Re: Add a condition "one car empty" to trains

Posted: Sun Aug 28, 2016 9:56 am
by siggboy
Hannu wrote:I agree. This would be better solution than additional conditions in train stops. It would keep train stop interface simple and give more general options to control trains or material flows.
You could make a great deal of things possible with only a few very simple additions to the circuit network:

1. Make rails connectable. Should be really easy to implement, and would work like with belts.
2. Have a connected rail output the following: "W=1" when a regular wagon is on the rail; "T=1" when a tanker wagon is on the rail (they will be added to Vanilla); "L=1" when a locomotive is on the rail.
3. The rail will also output the cargo content of the wagon on top of it in pulse or hold mode, if that is configured; would work like with belts. Pulse mode would transmit cargo changes, hold mode would work as in SmartTrains (simply outputting the cargo content, ideally tick-perfect so you can make loading contraptions that rely on low latency).
4. Locomotives could output their fuel storage instead of the cargo. They could output a "P" signal that shows how many passengers are on the train.
5. The wagons could output "F=1" if they are filled to capacity (as this is very difficult to determine from the numbers alone, but often very useful in a circuit).

Nothing about this is complicated or would confuse players who are not interested in the functionality.
No new virtual signals would be necessary.
All the information above is already processed by the game anyway, I suppose it would be really easy to add it to the circuit network.

You could then make nice train counters and all sorts of smart loaders and unloaders, and the train station UI would not even have to be touched.

You could also add this to the modding API, and then rather simple mods could add additional signals if that is desired.

Re: Add a condition "one car empty" to trains

Posted: Mon Aug 29, 2016 3:48 am
by HL65536
A method I often use to unload smaller trains is a balancer on the other side of the rails that works like this:
unloading.png
unloading.png (539.74 KiB) Viewed 7288 times
This works by setting the inserters on the balancer side to put items onto the belt if all chests on the other side of the rails are full and pulling them in if not. No combinators needed. The bandwidth is however limited.

For faster balance, robots could actually do the job:
unloading2.png
unloading2.png (1.39 MiB) Viewed 7288 times
The inserters only put stuff into the provider chests if their total item count is less than x (the combinator in the picture is not really needed). They are either all on or all off so the train is unloaded perfectly equalized. The robots do the actual equalizing job. I did not test this for longer trains (the robots could maybe be stupid enough to transport items from one end to the other while having a filled chest next to the requester). If distances are small, robots have incredible throughput.

Otherwise, circuit-connectable rails would be great to have.

Re: Add a condition "one car empty" to trains

Posted: Mon Sep 12, 2016 8:14 pm
by ssilk
See viewtopic.php?f=6&t=32557 Cargo Wagon Condition Idea