Add the ability to read distance along a space route via scripting

bunshaman
Burner Inserter
Burner Inserter
Posts: 12
Joined: Fri May 24, 2024 3:14 am
Contact:

Add the ability to read distance along a space route via scripting

Post by bunshaman »

Hello, I think this would be fantastic because as of right now, the only way of obtaining the distance a platform has traveled is by summing up a platforms speed over an interval of time. This works alright at best, and can only be very general. There is no way of telling whether a platform is traveling from A to B, or B to A. All the platform knows is it is traveling and has been at A or B last, and is aiming to get to C. This was a rough analogy, but there is stuff left to be desired for scripting here.

For an in game example, I am trying to run some scripts when a platform is traveling from the solar system edge (SSE) to the shattered planet (SP). I can detect when the last space location was SSE, and if the next station is the SP. However, when the platform turns around, it still believes the last space location was SSE, and now the next station may or may not be SSE, so its return trip is not entirely clear where it ends.
curiosity
Filter Inserter
Filter Inserter
Posts: 597
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by curiosity »

Writing distance would also be useful.
User avatar
Khazul
Fast Inserter
Fast Inserter
Posts: 200
Joined: Fri Sep 03, 2021 4:47 am
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by Khazul »

bunshaman wrote: Fri Dec 20, 2024 6:08 am Hello, I think this would be fantastic because as of right now, the only way of obtaining the distance a platform has traveled is by summing up a platforms speed over an interval of time. This works alright at best, and can only be very general. There is no way of telling whether a platform is traveling from A to B, or B to A. All the platform knows is it is traveling and has been at A or B last, and is aiming to get to C. This was a rough analogy, but there is stuff left to be desired for scripting here.

For an in game example, I am trying to run some scripts when a platform is traveling from the solar system edge (SSE) to the shattered planet (SP). I can detect when the last space location was SSE, and if the next station is the SP. However, when the platform turns around, it still believes the last space location was SSE, and now the next station may or may not be SSE, so its return trip is not entirely clear where it ends.
I cannot say I have noticed any issue with planet signals, but then I have not been staring at them while a ship does an auto-turn around between system edge and shattered planet. What you describe sounds like a bug if true and assuming that your planet checking circuit is correct which it may not be.

What circuit are you using to check your location? I assume it is basically:
12-20-2024, 15-34-34.png
12-20-2024, 15-34-34.png (20.23 KiB) Viewed 897 times
Which will be true if travelling to/from Shattered Planet or stopped at Shattered Planet (latter unlikely).
bunshaman
Burner Inserter
Burner Inserter
Posts: 12
Joined: Fri May 24, 2024 3:14 am
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by bunshaman »

Khazul wrote: Fri Dec 20, 2024 3:29 pm
bunshaman wrote: Fri Dec 20, 2024 6:08 am Hello, I think this would be fantastic because as of right now, the only way of obtaining the distance a platform has traveled is by summing up a platforms speed over an interval of time. This works alright at best, and can only be very general. There is no way of telling whether a platform is traveling from A to B, or B to A. All the platform knows is it is traveling and has been at A or B last, and is aiming to get to C. This was a rough analogy, but there is stuff left to be desired for scripting here.

For an in game example, I am trying to run some scripts when a platform is traveling from the solar system edge (SSE) to the shattered planet (SP). I can detect when the last space location was SSE, and if the next station is the SP. However, when the platform turns around, it still believes the last space location was SSE, and now the next station may or may not be SSE, so its return trip is not entirely clear where it ends.
I cannot say I have noticed any issue with planet signals, but then I have not been staring at them while a ship does an auto-turn around between system edge and shattered planet. What you describe sounds like a bug if true and assuming that your planet checking circuit is correct which it may not be.

What circuit are you using to check your location? I assume it is basically:
12-20-2024, 15-34-34.png
Which will be true if travelling to/from Shattered Planet or stopped at Shattered Planet (latter unlikely).
Ah, I am talking about scripting with Lua, not in game circuit conditions :D
User avatar
Khazul
Fast Inserter
Fast Inserter
Posts: 200
Joined: Fri Sep 03, 2021 4:47 am
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by Khazul »

bunshaman wrote: Sat Dec 21, 2024 4:10 pm
Khazul wrote: Fri Dec 20, 2024 3:29 pm
bunshaman wrote: Fri Dec 20, 2024 6:08 am Hello, I think this would be fantastic because as of right now, the only way of obtaining the distance a platform has traveled is by summing up a platforms speed over an interval of time. This works alright at best, and can only be very general. There is no way of telling whether a platform is traveling from A to B, or B to A. All the platform knows is it is traveling and has been at A or B last, and is aiming to get to C. This was a rough analogy, but there is stuff left to be desired for scripting here.

For an in game example, I am trying to run some scripts when a platform is traveling from the solar system edge (SSE) to the shattered planet (SP). I can detect when the last space location was SSE, and if the next station is the SP. However, when the platform turns around, it still believes the last space location was SSE, and now the next station may or may not be SSE, so its return trip is not entirely clear where it ends.
I cannot say I have noticed any issue with planet signals, but then I have not been staring at them while a ship does an auto-turn around between system edge and shattered planet. What you describe sounds like a bug if true and assuming that your planet checking circuit is correct which it may not be.

What circuit are you using to check your location? I assume it is basically:
12-20-2024, 15-34-34.png
Which will be true if travelling to/from Shattered Planet or stopped at Shattered Planet (latter unlikely).
Ah, I am talking about scripting with Lua, not in game circuit conditions :D
My bad - have you looked inside the schedule records indexed by current (IIRC) to get the target location?
Adding distance could be useful too.
I was thinking circuits because I did a similar thing in circuits to read the speed every second and sum it every second to get an approx distance travelled - it was done as a fallback trigger on shattered planet runs in case something else was wrong and the normal return trigger failed.

Looking at the space location it looked like that should have everything until words to effect of 'currently stopped at or nil'.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15137
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by Rseding91 »

This should be doable (read and write) however I'll need to talk to one of the other developers to make sure the state transitions are handled correctly. So, I'm not sure when it will be done.
If you want to get ahold of me I'm almost always on Discord.
bunshaman
Burner Inserter
Burner Inserter
Posts: 12
Joined: Fri May 24, 2024 3:14 am
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by bunshaman »

Rseding91 wrote: Mon Dec 30, 2024 10:03 pm This should be doable (read and write) however I'll need to talk to one of the other developers to make sure the state transitions are handled correctly. So, I'm not sure when it will be done.


:o :o :o :o This would be a life saver, no rush at all.
bunshaman
Burner Inserter
Burner Inserter
Posts: 12
Joined: Fri May 24, 2024 3:14 am
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by bunshaman »

Khazul wrote: Sat Dec 21, 2024 4:54 pm
bunshaman wrote: Sat Dec 21, 2024 4:10 pm
Khazul wrote: Fri Dec 20, 2024 3:29 pm
bunshaman wrote: Fri Dec 20, 2024 6:08 am Hello, I think this would be fantastic because as of right now, the only way of obtaining the distance a platform has traveled is by summing up a platforms speed over an interval of time. This works alright at best, and can only be very general. There is no way of telling whether a platform is traveling from A to B, or B to A. All the platform knows is it is traveling and has been at A or B last, and is aiming to get to C. This was a rough analogy, but there is stuff left to be desired for scripting here.

For an in game example, I am trying to run some scripts when a platform is traveling from the solar system edge (SSE) to the shattered planet (SP). I can detect when the last space location was SSE, and if the next station is the SP. However, when the platform turns around, it still believes the last space location was SSE, and now the next station may or may not be SSE, so its return trip is not entirely clear where it ends.
I cannot say I have noticed any issue with planet signals, but then I have not been staring at them while a ship does an auto-turn around between system edge and shattered planet. What you describe sounds like a bug if true and assuming that your planet checking circuit is correct which it may not be.

What circuit are you using to check your location? I assume it is basically:
12-20-2024, 15-34-34.png
Which will be true if travelling to/from Shattered Planet or stopped at Shattered Planet (latter unlikely).
Ah, I am talking about scripting with Lua, not in game circuit conditions :D
My bad - have you looked inside the schedule records indexed by current (IIRC) to get the target location?
Adding distance could be useful too.
I was thinking circuits because I did a similar thing in circuits to read the speed every second and sum it every second to get an approx distance travelled - it was done as a fallback trigger on shattered planet runs in case something else was wrong and the normal return trigger failed.

Looking at the space location it looked like that should have everything until words to effect of 'currently stopped at or nil'.
I have checked this way. The issue with checking the target location is a platform could be heading from A to D, but has to go through B and C along the way. By passing through B and C, it changes the last visited space location.
Genhis
Factorio Staff
Factorio Staff
Posts: 766
Joined: Wed Dec 24, 2014 8:19 am
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by Genhis »

Implemented for 2.0.34.
Chumfactor
Long Handed Inserter
Long Handed Inserter
Posts: 80
Joined: Thu Apr 07, 2016 9:17 pm
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by Chumfactor »

Genhis wrote: Thu Feb 06, 2025 1:36 pm Implemented for 2.0.34.
Hmmm, not seeing distance-travelled in 2.0.41. Where should I look instead? :)
Screenshot 2025-03-14 at 4.36.50 PM.png
Screenshot 2025-03-14 at 4.36.50 PM.png (100.33 KiB) Viewed 72 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 15137
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by Rseding91 »

Chumfactor wrote: Fri Mar 14, 2025 11:37 pm
Genhis wrote: Thu Feb 06, 2025 1:36 pm Implemented for 2.0.34.
Hmmm, not seeing distance-travelled in 2.0.41. Where should I look instead? :)
Scripting: https://lua-api.factorio.com/latest/cla ... l#distance

What you're showing is the game player circuit control interface.
If you want to get ahold of me I'm almost always on Discord.
Chumfactor
Long Handed Inserter
Long Handed Inserter
Posts: 80
Joined: Thu Apr 07, 2016 9:17 pm
Contact:

Re: Add the ability to read distance along a space route via scripting

Post by Chumfactor »

Ah yes, I misread the OP.

New request: that value (distance travelled) available to game-UI circuitry.

Similar reasons as OP (and more!), but for us non-scripting ("vanilla" ;) ) players.
Post Reply

Return to “Implemented mod requests”