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?
Circuit Network Train ID #
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
-
- Smart Inserter
- Posts: 2530
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Circuit Network Train ID #
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
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
Re: Circuit Network Train ID #
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.
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.
Re: Circuit Network Train ID #
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.
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
Re: Circuit Network Train ID #
Great to know buddy .
-
- Smart Inserter
- Posts: 2530
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Circuit Network Train ID #
What I meant by that was that the actual composition of the train does not determine or affect the ID.ColonelSandersLite wrote: ↑Wed Aug 31, 2022 7:31 amYou 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.
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