LuaPlayer::analog_walking_state: a field containing direction and magnitude of player's walking state

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
MeteorSwarm
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Thu Sep 25, 2025 10:49 pm
Contact:

LuaPlayer::analog_walking_state: a field containing direction and magnitude of player's walking state

Post by MeteorSwarm »

Alternative name: LuaPlayer::vector_walking_state

This field makes it possible to determine the character's direction and magnitude of walking state. When using a keyboard, magnitude is always 1, but on a gamepad, magnitude is proprotional to the magnitude of the character's stick pitch from [0,0]. This field would help mods read the state of the player's analog walking state so that scripts that change based on the character's running speed and direction look correct when players use a gamepad.

This field would improve the experience of playing Muluna with a gamepad. Currently, walking at partial speed with an analog stick on Muluna results in walking particles being produced at the incorrect frequency. The walking particle frequency is currently based on LuaPlayer::character_running_speed, which prints the character's speed when using the maximum analog stick pitch, or when holding down a movement key.
MeteorSwarm
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Thu Sep 25, 2025 10:49 pm
Contact:

Re: LuaPlayer::analog_walking_state: a field containing direction and magnitude of player's walking state

Post by MeteorSwarm »

I've gotten around this issue by calculating the player's actual velocity by subtracting the player's current position from their previous tick's position. This results in an increase of about 50% in the cost of the walking particle script, from around 0.1 ms/player/tick to 0.15 ms/player/tick. Because this code only fires when players are actively walking, this is a minor issue.

https://github.com/nicholasgower/planet ... 8df9481147
Post Reply

Return to “Modding interface requests”