Lua access to map view's base-layer data (the 1 pixel per tile stuff, e.g. belts = 1 yellow pixel)

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
jeff.s
Burner Inserter
Burner Inserter
Posts: 16
Joined: Thu Jan 10, 2019 10:49 pm
Contact:

Lua access to map view's base-layer data (the 1 pixel per tile stuff, e.g. belts = 1 yellow pixel)

Post by jeff.s »

I'm looking to build a mod that can export the map view representation of a base for a feature similar to https://factoriomaps.com

I'm not looking to replicate exactly what is on a user's screen - instead, I'm looking for the underlying chunk-level imagery upon which the rest of map view's features are drawn. I would do things like showing vehicle locations, train stations, map markers, etc with the equivalent functionality where I'm presenting the map (for example, via leaflet.js in a browser)

In a best case scenario, this would work on a headless Factorio instance too.

My understanding of map view:

It appears that there's two parts to map view. First, there's a "base layer", which is a 32x32 pixel image per chunk, scaled via (it seems) nearest-neighbor to the current zoom level. Second, there's a UI-scale-dependent set of layers drawn on top which includes all the rest of the map view things, such as vehicle markers, character markers+names, station markers+names, etc.

The base layer imagery is updated a couple times per second, and when a chunk is no longer "visible" to a force (e.g. falls out of radar/player coverage), the last available imagery is retained and displayed faded-out on map view.

I also understand from other threads that not all aspects of map view are deterministic or shared across clients, such as where on the map any given player is looking/pointing their cursor, and I'm not looking to access any of these.


The mod interface request:

The mod feature I'm looking for is access to what I called the "base layer" of map view data above. Hopefully, this would be available for any chunk, whether or not it's currently in radar coverage. If possible, this image data wouldn't come pre-faded in chunks which are outside radar coverage - instead, mods can consult LuaForce:is_chunk_visible and make their own decisions about rendering.

To put it in terms of an API call, what I'm thinking of would look something like:

Code: Select all

LuaForce::get_chunk_chart_pixels(surface, chunk)
, which would return a 32x32 array of Color tables (e.g. an array, containing 32 arrays, each subarray containing 32 Colors). Alternatively it could take an arbitrary BoundingBox instead of a chunk, or output in some other format if either of those makes it easier, but something tells me you already are storing it per chunk.

Is such a thing feasible and something you'd be willing to consider adding at some point? Thanks so much!

Post Reply

Return to “Modding interface requests”