Skip to content

Files

Latest commit

11e0502 · Nov 20, 2024

History

History
38 lines (24 loc) · 2.35 KB

README.md

File metadata and controls

38 lines (24 loc) · 2.35 KB

Factorio to Leaflet Maps

A Python script to convert Factorio screenshots into Leaflet map tiles.

Getting Factorio Screenshots

  1. In Factorio, open the console. The default hotkey for the console is `.
  2. 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.

  1. A set of screenshots is taken and saved to %APPDATA%\Factorio\script-output\factoriomaps

Getting Leaflet Tiles

Script Requirements

  1. 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.

  1. The screenshots are converted to Leaflet tiles.

Creating a Leaflet Map

  1. 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.

  2. For further customation, see the Leaflet documentation.