LuaPlayer :: create_local_flying_text speed depends on zoom level

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
TarrynPellimar
Manual Inserter
Manual Inserter
Posts: 1
Joined: Thu Jul 06, 2023 3:45 am
Contact:

LuaPlayer :: create_local_flying_text speed depends on zoom level

Post by TarrynPellimar »

LuaPlayer.create_local_flying_text speed is a double given in tiles/second. This means it is dependent on zoom level. Specifically, it rises further (and thus faster) when zoomed in (zoom level greater than 1) because tiles are larger, and it rises less (and thus slower) when zoomed out (zoom level less than 1) because tiles are smaller. However, when using create_at_cursor, all other parameters are ignored, and thus the speed of the text is constant regardless of zoom level.

Request: Since accessing the zoom level from a mod directly isn't tenable, can we have a flag on this function that scales speed by (inverse) zoom level?

Use case: I've created a simple mod that allows the player to interact with an object using a keyboard control hotkey. If the player is too far away to interact, I display a cant-reach error, which is the same text that the player gets when attempting to interact with the entity with the mouse. I noticed that the mouse button interaction actually displays the flying text at the position of the entity. I can mimic this behavior exactly by passing position = entity.position. However, the mouse interaction text speed does not depend on the zoom level.

Through trial and error, I've discovered that the built-in speed for this particular error is 2.4 when game.player.zoom is 1.0. I would like to scale my own speed by zoom level, like 2.4 / game.player.zoom, but zoom level isn't readable.

As it currently exists, the speed parameter isn't particularly useful except as a boolean: zero or non-zero, because there's no way for a mod to actually control the effective speed.

This is a follow-up to LuaPlayer :: create_local_flying_text at cursor position.

Post Reply

Return to “Modding interface requests”