API access to player's current speed with all modifiers

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Maoman
Inserter
Inserter
Posts: 22
Joined: Sat Nov 12, 2016 10:55 am
Contact:

API access to player's current speed with all modifiers

Post by Maoman »

Title pretty much sums it up. Currently there is no way (as far as I can tell) to read the actual speed of the player after all modifiers from both in-game and mods have been applied--i.e. the actual velocity the player will literally move on screen after all calculations have been done. There is already player.character.prototype.running_speed but that's just the base run speed before any modifiers. As far as I can tell, the only way to currently get this value is to manually take the base running_speed, iterate over the equipment and check for exoskeletons, calculate the total bonus from them and add to base, check what tile you're standing on and what it's speed modifier is and calculate that in, try to check for any mods that might be adjusting the speed as well, and then finally apply my own mod's speed calculations. And this would need to be recalculated with every tick (or at least every few ticks to save performance) because the player may have crossed from, say, concrete onto grass, and now their speed is totally different.
Bilka
Factorio Staff
Factorio Staff
Posts: 3415
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: API access to player's current speed with all modifiers

Post by Bilka »

I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Modding interface requests”