[0.15.4][Twinsen] Read train contents sends 0 briefly?

This subforum contains all the issues which we already resolved.
Aeternus
Filter Inserter
Filter Inserter
Posts: 835
Joined: Wed Mar 29, 2017 2:10 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Aeternus »

Deadly-Bagel wrote:Inserter starts working the moment the train stops, the train opening is just an animation. Twinsen said he could delay the Inserter but would impact performance, probably only a little but these things add up.
No, it is not just an animation. If you stop a train at a station, then tell it to start moving but manually block it with a red signal, the wagons stay closed and the inserters can't touch the contents, even if the train isn't moving at all. Being stopped at a station in automatic mode is a state a train can be in - transitioning to that state just needs to be synced with the circuit network.

And unless you need to test for empty trains, "Anything > 0" is a signal you can use to check if a train is at the station.
What'd be REALLY useful would be to output the number of locomotives and wagons/tankers as inventory, that way you could even dynamically configure a station to service the type and length of train using it... and "Locomotives > 0" becomes the check signal to see if a train is present.
maniak1349
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Mon Nov 03, 2014 12:28 pm
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by maniak1349 »

Twinsen wrote:I will add a new mode of operation to the station that outputs a number to a specified signal when a train stops there. That number will be a unique id for the train.
While you at it, can you add an optional player-configurable signal to trains that will be transmitted alongside with the train id? If it's not too much of trouble that is.

This will be really helpful for cases where multiple empty trains of different types may arrive at a single station. Currently the common approach for such a case is to carry around an ID item (fish, it's always a fish!). It works, but you will lose a slot in the wagon and outbound inserters on every station serving the train should have filters. Train IDs can be used to set up such multipurpose stations too, but you will need to list every train ID of the same type in the circuit network and will need to be reconfigurated when train will be destroyed/rebuilt.

I'm not apposed to the train IDs idea though. It will be a fun feature to have too.
Tekky
Smart Inserter
Smart Inserter
Posts: 1040
Joined: Sun Jul 31, 2016 10:53 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Tekky »

maniak1349 wrote:While you at it, can you add an optional player-configurable signal to trains that will be transmitted alongside with the train id?
I don't like the idea of sending both a unique Train-ID (probably generated from some internal game entity ID) and a player-defined signal. In my opinion, it should be only one signal, either one or the other. Otherwise it would get too complicated.

In my opinion, the best solution would be to allow the user to specify an ID value for the train to send in the train orders window. That way, it would also be also possible for several trains to share an ID value if, for example, you want them to be treated the same way by the circuit network. However, if you want all trains to have a unique ID, you can do that too.

This would also allow grouping and assigning properties to trains. For example, I could assign all my iron ore trains an ID between 1000 and 1999 and all my copper trains an ID between 2000 and 2999. In other words, the first digit would define the type of train. Also, I could, for example, assign the length of the train to the second digit. That way, a train with an ID of 2348 would be a copper train with a length of 3. All of this information could easily be extracted by the circuit network simply by reading the ID of the train. The possibilities would be endless.

If the player is too lazy to assign a Train-ID to every one of his trains, the value sent by the train could default to either the number 1 (just a simple signal) or the internal Train-ID of the game. This ID would of course have to always be nonzero, because the circuit network is unable to distinguish between an empty station and a station with a train with an ID of 0.

EDIT: In this post, I proposed that the player should be able to specify the custom Train-ID in the train orders window. However, in this suggestion thread, it has been proposed that the Locomotives can be set to act as a constant combinator, whose signal is then sent to the circuit network when the train stops at a station. I believe that this suggestion may be more in the spirit of Factorio than my suggestion.
Last edited by Tekky on Thu May 11, 2017 3:01 pm, edited 2 times in total.
User avatar
Deadly-Bagel
Smart Inserter
Smart Inserter
Posts: 1498
Joined: Wed Jul 13, 2016 10:12 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Deadly-Bagel »

Tekky wrote:If the player is too lazy to assign a Train-ID to every one of his trains...
Then a signal isn't set and nothing gets sent? This is only to cater for advanced designs, most train stations won't use or need this feature.
Money might be the root of all evil, but ignorance is the heart.
Tekky
Smart Inserter
Smart Inserter
Posts: 1040
Joined: Sun Jul 31, 2016 10:53 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Tekky »

Deadly-Bagel wrote:
Tekky wrote:If the player is too lazy to assign a Train-ID to every one of his trains...
Then a signal isn't set and nothing gets sent? This is only to cater for advanced designs, most train stations won't use or need this feature.
Maybe you are right. After thinking about this problem for a long time, the solution described in the following suggestion thread seems most appealing to me:

viewtopic.php?f=6&t=46969 Constant Combinator for Locomotive

In that thread, it has been proposed that the Locomotives can be set to act as a constant combinator, whose signal is then sent to the circuit network when the train stops at a station. That way, you could set the ID of the train using the same interface as a constant combinator.

I believe that this solution fits best with the spirit of Factorio.
Twinsen
Factorio Staff
Factorio Staff
Posts: 1348
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Twinsen »

Implemented in Version: 0.15.11.

Just a unique number is sent when a train is stopped at the station. The unique number is equivalent to luaTrain::id
Tekky
Smart Inserter
Smart Inserter
Posts: 1040
Joined: Sun Jul 31, 2016 10:53 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Tekky »

Thank you very much. That will certainly give us something to play with, at least until version 0.16.

Is luaTrain::id guaranteed to always be nonzero? If not, then the circuit network will be unable to distinguish an empty station from a station with a train with an ID of 0 in it.
Twinsen
Factorio Staff
Factorio Staff
Posts: 1348
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Twinsen »

Tekky wrote:Is luaTrain::id guaranteed to always be nonzero?
yes
Tekky
Smart Inserter
Smart Inserter
Posts: 1040
Joined: Sun Jul 31, 2016 10:53 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Tekky »

Very nice. Thanks again.
BenSeidel
Filter Inserter
Filter Inserter
Posts: 590
Joined: Tue Jun 28, 2016 1:44 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by BenSeidel »

Twinsen wrote:Implemented in Version: 0.15.11.
OMG!!!
GIMME!!!

Seriously though, 0.15+ is becoming a very well-rounded game. You guys & gals ROCK!!!
Vegemeister
Long Handed Inserter
Long Handed Inserter
Posts: 85
Joined: Sun Dec 04, 2016 9:18 pm
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Vegemeister »

Twinsen wrote:I will add a new mode of operation to the station that outputs a number to a specified signal when a train stops there. That number will be a unique id for the train.

Not only will this be a way to fix this problem, but it seems like a nice feature to have :)
Thanks for the suggestions.
Train ID should be a hash of the train's schedule. That'd make it easy to work with for multiple trains on the same route.
Inari
Burner Inserter
Burner Inserter
Posts: 13
Joined: Fri Apr 14, 2017 9:16 pm
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Inari »

Hm I would have found it reading the train's colour as an option make more sense. Theres red/green/blue signals fro that too. But as long as it works.
Tekky
Smart Inserter
Smart Inserter
Posts: 1040
Joined: Sun Jul 31, 2016 10:53 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Tekky »

It may have been better if Twinsen had simply implemented a constant signal instead of a unique Train-ID signal, because then he wouldn't be overwhelmed now with all of these additional feature requests regarding Train-IDs. But I guess it is too late now, he has already opened Pandora's Box. :)
User avatar
Deadly-Bagel
Smart Inserter
Smart Inserter
Posts: 1498
Joined: Wed Jul 13, 2016 10:12 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Deadly-Bagel »

Going to be a real pain if this signal is used in 5+ train stops and the train gets destroyed or needs deconstructing for some reason =/

Also does that mean you don't know the ID of the train until you read it from the network?
Money might be the root of all evil, but ignorance is the heart.
Inari
Burner Inserter
Burner Inserter
Posts: 13
Joined: Fri Apr 14, 2017 9:16 pm
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Inari »

Deadly-Bagel wrote:Going to be a real pain if this signal is used in 5+ train stops and the train gets destroyed or needs deconstructing for some reason =/

Also does that mean you don't know the ID of the train until you read it from the network?
Thats whyI think the colour thing would be better. That way you can have the same "ID" for multiple trains, as well as replace a train.
Tekky
Smart Inserter
Smart Inserter
Posts: 1040
Joined: Sun Jul 31, 2016 10:53 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Tekky »

Deadly-Bagel wrote:Going to be a real pain if this signal is used in 5+ train stops and the train gets destroyed or needs deconstructing for some reason =/
Yes, that is one reason why I believe it would be nice to also be able to define a user-defined value as the Train-ID. This has been suggested in the following thread:
viewtopic.php?f=6&t=46969 Constant Combinator for Locomotive
Deadly-Bagel wrote:Also does that mean you don't know the ID of the train until you read it from the network?
As far as I know, yes. It has already been suggested (for example in this post) that the train ID should also be visible in the train window.
Hermitude
Burner Inserter
Burner Inserter
Posts: 11
Joined: Wed Jul 05, 2017 8:13 am
Contact:

Re: [0.15.4][Twinsen] Read train contents sends 0 briefly?

Post by Hermitude »

There is a neat (and fairly intuitive) solution to this problem that uses a small number of combinators.

I don't want to give it away entirely since I think part of the joy of this game is in using your own spatial reasoning to solve these logistical problems. However, I will say that you can solve it using a single decider combinator wired to the train stop along with a single constant combinator to determine your maximum item limit. You can also repeat this pattern if you have several different maximums for your inserters to obey..
Post Reply

Return to “Resolved Problems and Bugs”