Page 1 of 1

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

Posted: Fri Dec 20, 2024 6:08 am
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.

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

Posted: Fri Dec 20, 2024 11:59 am
by curiosity
Writing distance would also be useful.

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

Posted: Fri Dec 20, 2024 3:29 pm
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 895 times
Which will be true if travelling to/from Shattered Planet or stopped at Shattered Planet (latter unlikely).

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

Posted: Sat Dec 21, 2024 4:10 pm
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

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

Posted: Sat Dec 21, 2024 4:54 pm
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'.

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

Posted: Mon Dec 30, 2024 10:03 pm
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.

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

Posted: Wed Jan 01, 2025 1:34 am
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.

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

Posted: Wed Jan 01, 2025 1:45 am
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.

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

Posted: Thu Feb 06, 2025 1:36 pm
by Genhis
Implemented for 2.0.34.

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

Posted: Fri Mar 14, 2025 11:37 pm
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 70 times

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

Posted: Sat Mar 15, 2025 12:03 am
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.

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

Posted: Sat Mar 15, 2025 12:10 am
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.