A Python script to convert Factorio screenshots into Leaflet map tiles.
- In Factorio, open the console. The default hotkey for the console is `.
- Paste the following command and press Enter.
/c json=''; for _, surface in pairs(game.surfaces) do if (json ~= '') then json=json..', '; end; surface_name = surface.name; if surface.planet then surface_name = surface.planet.name; elseif surface.platform then surface_name = surface.platform.name; end; json=json..'"'..surface.index..'": "'..surface_name..'"'; for x=-1000,1000 do for y=-1000,1000 do if game.forces["player"].is_chunk_charted(surface, {x, y}) then game.take_screenshot{surface=surface, show_entity_info=true, daytime=0, water_tick=0, hide_clouds=true, hide_fog=true, zoom=1, resolution={1024,1024}, position={x=32*x+16,y=32*y+16}, path="factoriomaps/"..surface.index.."/chunk_"..x.."_"..y..".jpg"}; end; end; end; end; helpers.write_file("factoriomaps/surfaces.json", "{"..json.."}");
NOTE: Using console commands disables achievements in your current game. To retain achievements, reload your save after running the command.
- A set of screenshots is taken and saved to
%APPDATA%\Factorio\script-output\factoriomaps
- Execute the script:
python3 factoriomap.py [source] [destination]
- Source: The path to the directory containing the screenshots, or the path to a tar file containing the screenshots.
- Destination: The path to a directory to hold the Leaflet tiles.
NOTE: Depending on your system configuration, the command to run a Python 3 script (
python3
above) may differ. Use the appropriate command for your system. NOTE: The tar file option is useful if the screenshots need to be uploaded to a remote server before running the script.
- The screenshots are converted to Leaflet tiles.
-
Create an HTML page to launch Leaflet. A simple example page is included in the repository. Change
PATH_TO_TILE_DIRECTORY
to the actual path of the tile directory. -
For further customation, see the Leaflet documentation.