Circuit Network Train ID #

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
ColonelSandersLite
Fast Inserter
Fast Inserter
Posts: 208
Joined: Tue Apr 24, 2018 5:42 am
Contact:

Circuit Network Train ID #

Post by ColonelSandersLite »

So just a quick question -

When you read the train ID # from a train stop via the circuit network, is this value guaranteed to be non-zero?

I have been working under the assumption that it is without problems, but come to think of it, I honestly have no idea how the game decides a train's ID number.

And you know what they say about assumptions...


Anybody got any interesting insights into these numbers?

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Circuit Network Train ID #

Post by FuryoftheStars »

The number is simply that: a number. It doesn’t have any relation or pattern to it. Afaik, it starts at 1 (because 0 does not transmit), and every new train or modification to a train’s physical layout (add/remove wagons/locos) causes it to pick the next available number. I think the max is 2^32? Then it rolls over back to 1.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

ColonelSandersLite
Fast Inserter
Fast Inserter
Posts: 208
Joined: Tue Apr 24, 2018 5:42 am
Contact:

Re: Circuit Network Train ID #

Post by ColonelSandersLite »

Well see - you contradicted yourself there and, in the process you told me something interesting I didn't know and accidentally answered the actual question.

You said that "It doesn’t have any relation or pattern to it. " then you went on to describe how it's sequential. That's definitely a pattern and I had no idea that's how it worked. I figured it was just a random number.

My question was more is it "X = rand() % 1000000;" or "X = rand() % 1000000+ 1;" or even "X = rand() % 1000000 - 500000;" but the answer is none of the above!

I'm not sure how this bit of information is useful, but maybe I'll find a use for it someday.
Last edited by ColonelSandersLite on Wed Aug 31, 2022 11:15 pm, edited 1 time in total.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2244
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Circuit Network Train ID #

Post by boskid »

Train ID's are guaranteed to be non-zero. They are allocated starting from 1 and increasing for each new train. Even if an overflow would happen, a train ID will never be 0 as there is a special check that guards against this case.

ColonelSandersLite
Fast Inserter
Fast Inserter
Posts: 208
Joined: Tue Apr 24, 2018 5:42 am
Contact:

Re: Circuit Network Train ID #

Post by ColonelSandersLite »

Great to know buddy :D .

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Circuit Network Train ID #

Post by FuryoftheStars »

ColonelSandersLite wrote:
Wed Aug 31, 2022 7:31 am
You said that "It doesn’t have any relation or pattern to it. " then you went on to describe how it's sequential. That's definitely a pattern and I had no idea that's how it worked.
What I meant by that was that the actual composition of the train does not determine or affect the ID.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

Post Reply

Return to “Gameplay Help”