LuaRendering scale_with_zoom and combining objects

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
SupplyDepoo
Filter Inserter
Filter Inserter
Posts: 286
Joined: Sat Oct 29, 2016 8:42 pm
Contact:

LuaRendering scale_with_zoom and combining objects

Post by SupplyDepoo »

I have encountered a show-stopper for a mod which requires the ability to draw multiple lines of text on the screen, anchored to an entity, and with scale_with_zoom enabled.

Since text objects ignore line breaks, the only way to do multi-line text (anchored to an entity) is to create multiple objects with different y-offsets. The problem is that if scale_with_zoom is enabled, two text objects will overlap at distant zoom levels. Since there's no way to read the player's zoom level and adjust the offsets accordingly, I have to choose between having the lines overlap when the camera is far away, or something like a ridiculous 10x line spacing when the camera is close up, or not using scale_with_zoom in which case the text will also be either illegible at a distance or humungous close up.

Using LuaGUI instead of LuaRendering is not an option because there is no API to anchor a LuaGUIElement to an entity or to convert between screen and world coordinates.

Two solutions come to mind, in the form of additions to the LuaRendering API:
  1. A draw_textbox function, similar to the existing draw_text, but with extra parameters to control line wrapping, line height, and probably also a way to specify which side/corner to use as the origin. This would be ideal for multi-line text, especially with automatic line wrapping, but nothing else (and how many use cases are there for multi-line text attached to entities that really needs automatic line wrapping?).
  2. The ability to offset an object relative to an existing object, specifically one of the sides/edges/points/whatever of that object, and in a way that automatically adjusts with scale_with_zoom (offsetting relative to an object's origin would not fix the scaling issue). This solution would be sufficient for my mod, and it could be more broadly useful for composing different objects where scale_with_zoom is also needed.

Post Reply

Return to “Modding interface requests”