How to differentiate between different station types so that I can send the correct train to it

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Afroman
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri Jan 06, 2017 3:28 am
Contact:

How to differentiate between different station types so that I can send the correct train to it

Post by Afroman »

I begin with Sorry.
This seems as a dilemma that must have come up before, but I wasn't able to find question about it.

The Problem:
How to differentiate between different station types so that I can send the correct train to it.

Summary:
I want my provider stations to send a signal for their resource with a value that indicates the type of train it wants (1-4,1-8-1 or fluid).
The problem being that several p-stations of the same resource will multiply that value thus confusing the trains interrupts.
There may be a need for more types later on.

Context:
So I have my own version of LTN.

- Requester Stations (R-Stations) send a green wire signal to a radar stating resource and how many trains of that resource it needs("iron plate 15" mean it needs 15 trains loaded with iron plates to be satisfied). And only if the following conditions are met:
- There is enough space for at least one full train worth of the resource.

- Provider Stations (P-Stations) send a red wire signal to a radar stating the resource. The value is always one("iron ore 1"). And only if the following conditions are met:
- There is a green wire signal for that resource larger than zero(meaning there is a request for it.)
- There is enough resource in this stations to fill at least one train worth of the resource.

- Train Depot
- Trains are dispatched from here whenever they get a red resource signal(meaning there is both demand and supply available for that resource)

So far so good.
Furthermore I have three types of trains(so far):
- 1-8-1 trains(8-trains) for mining resources(ores)
- 1-4 trains(4-trains) for other solids
- 1-8-1 trains(f-trains) for fluids

The problem is I need to know what kind of train can take what kind of resource.
My first solution was multiply all the resources signals sent by p-stations for 4-trains with 1000 and have their loading interrupt look for signals >= 1000.
It worked for a while until I wanted to incorporate fluids. My genius idea to multiply fluid signals with 2000 failed quickly since several p4-stations for the same resources would send multiples of thousands thus sending f-trains to them.

So I feel I should be able to use prime numbers and mod somehow, but so far don't have a good solution.

I hope this makes sense :)
Let me know if it needs clarifying somewhere.

Anyway thanks for reading this far :).
Last edited by Afroman on Fri Feb 21, 2025 11:33 am, edited 1 time in total.
mmmPI
Smart Inserter
Smart Inserter
Posts: 4581
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by mmmPI »

Afroman wrote: Wed Feb 12, 2025 9:15 am - Provider Stations (P-Stations) send a red signal to a radar stating the resource. The value is allways one("iron ore 1"). And only if the following conditions are met:
- There is a green signal for that resource larger than zero(meaning there is a request for it.)
- There is enough resource in this stations to fill at least one train worth of the resource.
I don't understand this part, maybe you can post a blueprint ?

For the more general question, it doesn't seem possible to me to differentiate between stations that have the same name unfortunatly. I don't understand well enough the system you describe to propose anything, but i expect it would be easier for me if you stated the goals of the system when it works, the idea you were pursuing when you started added things that some may need to be altered or removed to achieve the idea, or maybe the idea is not achievable in game which is a different case but i suspect unlikely if one is willing to modify enough the original system. The case of using several train size that can also use several ressources , i'm not sure i understand which trains are expected to carry which ressources to which stations.
adam_bise
Filter Inserter
Filter Inserter
Posts: 581
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by adam_bise »

Encode your resource signal and add 100k codes to it with a const comb so like, iron ore =101000, copper ore = 102000. Add them with an arith each + 0 out each
1.png
1.png (545.09 KiB) Viewed 1498 times
Decode with same const comb but with negative values iron ore = -101000, copper ore = -102000 - Again combine with arith each + 0
2.png
2.png (467.97 KiB) Viewed 1498 times
For your condition use >101000 and < 102000
3.png
3.png (39.41 KiB) Viewed 1498 times
In this way 101005 101 becomes code for iron and 005 becomes original signal.

But it seems to me that you already know what type can deliver what, so I would just exclude wrong types stations from the schedules.

Or you could do p=101000 f=102000 4=103000 - kind of unclear on what's what
Afroman
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri Jan 06, 2017 3:28 am
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by Afroman »

mmmPI wrote: Wed Feb 12, 2025 1:15 pm
Afroman wrote: Wed Feb 12, 2025 9:15 am - Provider Stations (P-Stations) send a red signal to a radar stating the resource. The value is allways one("iron ore 1"). And only if the following conditions are met:
- There is a green signal for that resource larger than zero(meaning there is a request for it.)
- There is enough resource in this stations to fill at least one train worth of the resource.
I don't understand this part, maybe you can post a blueprint ?

For the more general question, it doesn't seem possible to me to differentiate between stations that have the same name unfortunatly. I don't understand well enough the system you describe to propose anything, but i expect it would be easier for me if you stated the goals of the system when it works, the idea you were pursuing when you started added things that some may need to be altered or removed to achieve the idea, or maybe the idea is not achievable in game which is a different case but i suspect unlikely if one is willing to modify enough the original system. The case of using several train size that can also use several ressources , i'm not sure i understand which trains are expected to carry which ressources to which stations.
Basically, the Requesters tell the Providers when they want some stuff. And the Providers tell the trains when they have stuff AND a Requester wants stuff.
The Communication happen by radar. Requesters send green signals.
Provider send red.
Trains listen only to red signals.
Afroman
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri Jan 06, 2017 3:28 am
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by Afroman »

Thanks for the asnwers!

After some time in the sandbox I think I was overthinking it.

I just need to multiply the different signal types with different factors of ten.
- Resources that uses long 8 trains multiply with one. 8-trains will trigger on signals that have the value 0>X>10
- Resources that uses long 4 trains multiply with 10. 4-trains will trigger on signals that have the value 10>X>100
- Resources that uses long fluids trains multiply with 100. F-trains will trigger on signals that have the value 100>X>1000

Since provider stations only send signals with value 1, this means several providers of the same resource will add up(If 3 Iron Ore Provider are available the signal will be iron ore 3) but the 8-trains will still pick them up.
3 Copper plates (that uses 4-trains) will be copper plates 30 and only the 4-trains picks them up.
and fluids will work the same but with 100.

The only problem would be if 10 of more provider station of the SAME resource will be available. And I dont see that ever happening.
Or if I ever decide I want to have different sizes on the same resource. Although I think I just burned that bridge with this system.
Gooberboi
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Feb 14, 2025 1:08 am
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by Gooberboi »

I solved this by only parking fluid trains in fluid-depot and item trains in item-depot.

So my entire base runs on two interrupts (one for items and one for fluids). The trains “know” what type of train it is by knowing the name of the depot it dispatched from.

All of the circuit work needed was letting the depots know a station is ready for a full train.

For example x item is added onto the network from x-item-in (because it’s running low on x). Train parked in item-depot (and meets all other requirements) is dispatched to x-item-out to bring x to x-item-in. After delivery the train goes back to item-depot waiting for a new circuit request.
Last edited by Gooberboi on Fri Feb 14, 2025 1:48 am, edited 2 times in total.
mmmPI
Smart Inserter
Smart Inserter
Posts: 4581
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by mmmPI »

Afroman wrote: Thu Feb 13, 2025 9:03 pm Requesters send green signals.
Trains listen only to red signals.
It appears that you don't mean "green signal" or "red signal" but instead you mean using a "green wire" and a "red wire", this is because a green signal is comonly used to talk about the signal for the color green.

Train stop are connected to red wire is what the meaning of your word imply, yet your wording suggest a different thing, that is : "train listen only to red signals" which would have nothing to do with the signal for the color red.

That's why i asked for a blueprint to clear any confusion that may come from the wording, but i'm glad the problem is now solved
Afroman
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri Jan 06, 2017 3:28 am
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by Afroman »

mmmPI wrote: Sun Feb 16, 2025 4:08 am
Afroman wrote: Thu Feb 13, 2025 9:03 pm Requesters send green signals.
Trains listen only to red signals.
It appears that you don't mean "green signal" or "red signal" but instead you mean using a "green wire" and a "red wire", this is because a green signal is comonly used to talk about the signal for the color green.

Train stop are connected to red wire is what the meaning of your word imply, yet your wording suggest a different thing, that is : "train listen only to red signals" which would have nothing to do with the signal for the color red.

That's why i asked for a blueprint to clear any confusion that may come from the wording, but i'm glad the problem is now solved
Ahh, make sense. You are correct. I mas referring to the color of the wire. Sorry about the confusion.
mmmPI
Smart Inserter
Smart Inserter
Posts: 4581
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by mmmPI »

Afroman wrote: Thu Feb 20, 2025 9:23 am Ahh, make sense. You are correct. I mas referring to the color of the wire. Sorry about the confusion.
no problem, i was thinking of this again
""
So I feel I should be able to use prime numbers and mod somehow, but so far don't have a good solution.
""

maybe what would work is using only power of 1, 2 4 8 16 32 64 ..... this way no matter how you add them up together, if only 1 number of each magnitude is added, it will be possible to decode at the end how many and which number were summed

the decoding algo would have to be a little smart x) if number is above a certain power of 2, remove it and continue from the largest power of 2 to the smallest


This is because the last number in serie 1 2 4 8 16 32 64 .... is bigger by 1 than the sum of all previous number
Nidan
Filter Inserter
Filter Inserter
Posts: 325
Joined: Sat Nov 21, 2015 1:40 am
Contact:

Re: How to differentiate between different station types so that I can send the correct train to it

Post by Nidan »

Afroman wrote: Thu Feb 13, 2025 9:18 pm I just need to multiply the different signal types with different factors of ten.
- Resources that uses long 8 trains multiply with one. 8-trains will trigger on signals that have the value 0>X>10
- Resources that uses long 4 trains multiply with 10. 4-trains will trigger on signals that have the value 10>X>100
- Resources that uses long fluids trains multiply with 100. F-trains will trigger on signals that have the value 100>X>1000

Since provider stations only send signals with value 1, this means several providers of the same resource will add up(If 3 Iron Ore Provider are available the signal will be iron ore 3) but the 8-trains will still pick them up.
3 Copper plates (that uses 4-trains) will be copper plates 30 and only the 4-trains picks them up.
and fluids will work the same but with 100.

The only problem would be if 10 of more provider station of the SAME resource will be available. And I dont see that ever happening.
I see you found the typical solution for packing multiple pieces of information into the same signal. You idea in the OP got close, but, as you realized, using 1000 and 2000 as multipliers only leaves room for exactly one train in the 1000 category.
Even if you think you'll never have more than 9 stations per type per resource, I recommend allocating more space. You have a signed 32 bit integer to work with (range -2147483648 to 2147483647).
Or if I ever decide I want to have different sizes on the same resource. Although I think I just burned that bridge with this system.
You've already prepared for that. If you want one station to handle multiple train types, things get tricky. But if not, you could e.g. just add the supported train type to the station name and have one set of interrupts per train type.
Post Reply

Return to “Gameplay Help”