[MOD 0.17] VehicleSnap

Topics and discussion about specific mods
Zaflis
Filter Inserter
Filter Inserter
Posts: 529
Joined: Sun Apr 24, 2016 12:51 am
Contact:

Re: [MOD 0.17] VehicleSnap

Post by Zaflis »

I'm not sure how i feel about the patch as in including it in or not. It's true the angles between cardinals and diagonals are off, i took a little screenshot of current rails:
09-14-2025, 19-19-38.png
09-14-2025, 19-19-38.png (734.02 KiB) Viewed 1061 times
Your math is also something i don't follow :P
My thought after was to record those key angles into a table and then interpolate current angle to closest from the table. It'd just be a table of 16 numbers.

But i never considered this mod to actually use more than 8 rail directions, the extra angles between were just for immersion. I set it to 8 in mod settings myself.
Egor
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Aug 30, 2025 4:58 pm
Contact:

Re: [MOD 0.17] VehicleSnap

Post by Egor »

Zaflis wrote: Sun Sep 14, 2025 4:21 pm But i never considered this mod to actually use more than 8 rail directions, the extra angles between were just for immersion. I set it to 8 in mod settings myself.
Ok, you are using only 8 directions when playing the game.
Nevertheless the most popular user choice is 16, not 8.
So thank you for making your mod useful for all users, not only for users sharing your position.
"Snapping to Rail Angles" feature is just one more step to make your mod useful for everyone.
I believe it would be a valuable addition to VehicleSnap.

Do you remember your own description of the mod?
> Have you ever faced a problem when trying to drive exactly along a road, coastline or railroad, that car moves a tiny bit off to side?
You have mentioned "moving along a railroad" as what your mod was designed for.
So, it is quite natural for a mod user to expect that this feature will be in sync with Factorio rail system.

In my opinion, the angle (360°/16) does not have any practical value in the game.
All useful angles in Factorio equals to arctg(m/n) with some small integers m and n.
For example, the "half-diagonal rail" angle is not rail-specific: some of my defense structures have wall borders with the same angle (1 step north and 2 steps east, repeat).

Zaflis wrote: Sun Sep 14, 2025 4:21 pm Your math is also something i don't follow :P
I agree, my code is not a good code, it is not easy-to-understand.

My algo of calculating the snapping angle consists of three steps:
1. Calculate which 1/8 part of 360° the current orientation is inside. I used your own formula "multiply and round" here.
2. The current 1/8 consists of two UNEQUAL halves (1/16 each), so, direct angle comparison is used to determine which 1/16 is ours.
3. The current 1/16 consists of 2 equal 1/32 (or 3 equal 1/48, etc), so again using "multiply and round".
Zaflis wrote: Sun Sep 14, 2025 4:21 pm My thought after was to record those key angles into a table and then interpolate current angle to closest from the table. It'd just be a table of 16 numbers.
Yes, your approach would lead to a more-easy-to-understand code.
It looks like a good idea to write your own implementation instead of using my code as-is.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3256
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: [MOD 0.17] VehicleSnap

Post by BlueTemplar »

Egor wrote: Tue Oct 07, 2025 2:22 pm [...]
In my opinion, the angle (360°/16) does not have any practical value in the game.
All useful angles in Factorio equals to arctg(m/n) with some small integers m and n.
For example, the "half-diagonal rail" angle is not rail-specific: some of my defense structures have wall borders with the same angle (1 step north and 2 steps east, repeat).
[...]
Zaflis wrote: Sun Sep 14, 2025 4:21 pm [...]
i took a little screenshot of current rails:
09-14-2025, 19-19-38.png
[...]
Given the above, it would be amazing if you re-posted that picture, but with show-tile-grid on !
BobDiggity (mod-scenario-pack)
Post Reply

Return to “Mods”