API access to player's current speed with all modifiers

Things that already exist in the current mod API
User avatar
Maoman
Inserter
Inserter
Posts: 40
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: 3522
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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16051
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Looking at that value - it will give what's being asked for.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Already exists”