character_running_speed inaccuracy

Place to get help with not working mods / modding interface.
proicop
Inserter
Inserter
Posts: 20
Joined: Wed Jul 22, 2020 9:27 am
Contact:

character_running_speed inaccuracy

Post by proicop »

Hi!

I am trying to precisely predict how long it will take for a character to walk from a point a to a point b on a straight/diagonal line. I found the `character_running_speed` property of the character which is equal to `0.15`. This leads me to believe that the character will move exactly `0.15` tiles per tick.

I am setting the character's moving state every tick and printing its position and from my testing it seems like the character is actually moving exactly `0.1484375` tiles per tick instead when moving along a straight line. Are there any other modifiers that I should account for?
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: character_running_speed inaccuracy

Post by PFQNiet »

Many positions are in multiples of 1/256, and the closest multiple of that to 0.15 is the number you have found, which is 38/256.

I'm not sure how this will affect diagonal speed, but if it's preserving speed then you would travel 27/256 of a tile in each axis.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5304
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: character_running_speed inaccuracy

Post by Klonan »

The game only stores positions as 1/256 of a tile,
So then it moves the 0.15, it rounds to the nearest valid position

0.15 = 38.4 / 256
0.1484375 = 38 / 256
proicop
Inserter
Inserter
Posts: 20
Joined: Wed Jul 22, 2020 9:27 am
Contact:

Re: character_running_speed inaccuracy

Post by proicop »

Ok that makes sense. Thanks!
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: character_running_speed inaccuracy

Post by darkfrei »

What if the speed is less than 1/256 tiles per tick? No movement at all or the movement will be accordingly accumulated?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3724
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: character_running_speed inaccuracy

Post by DaveMcW »

There is no accumulation, all rounding errors are discarded.
Post Reply

Return to “Modding help”