mikerenfro / df-map-export

Dwarf Fortress Elevation to Map Tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dwarf Fortress Elevations to Map Tool

Reads a series of text files for each elevation of a Dwarf Fortress embark, and creates an Excel workbook showing the embark area's topography with one worksheet per elevation. The workbook formats cell contents to differentiate various tile types (currently, bodies of water, trees, grass, plants, boulders, rock walls/ramps, soil walls/ramps, pebbles, and subterranean tiles).

This is a much better method than my first attempt that did a lot of image processing of screenshots, but does require use of DFHack to create the text files.

Comparison of DF map elevation to Excel worksheet

Installation

Python script

pip install -r requirements.txt

Currently uses:

  • openpyxl

DFHack and Lua script

See Installing DFHack for instructions on how to install DFHack.

Copy export-map.lua to the DFHack scripts folder (in the Steam version, that's Dwarf Fortress/dfhack-config/scripts).

In Dwarf Fortress

Ideally, right after you start a new embark with DFHack enabled, pause the game and run export-map in DFHack. By default, export-map will not show any fully subterranean elevations to reduce spoilers. Run it as export-map spoilers to get exports from all elevations. This will write a set of map-exports/NAME_OF_FORTRESS/NAME_OF_FORTRESS-*.txt files under the main Dwarf Fortress folder.

elevations folder

Organize your text export files in this folder by world name, for example: elevations/Quakevaults/Quakevaults-*.txt for all text files from the Quakevaults embark.

Running

python df-map-export.py --help for help. Currently shows:

usage: df-map-export.py [-h] [--basedir BASEDIR] [--zoom ZOOM] [--embark-elevation EMBARK_ELEVATION] [--enable-macros]
                        world

positional arguments:
  world                 Folder in basedir containing minimap screenshots

options:
  -h, --help            show this help message and exit
  --basedir BASEDIR     Base directory containing folders with minimap elevations (defaults to
                        'elevations')
  --zoom ZOOM           Spreadsheet zoom level (in percent, defaults to 25)
  --embark-elevation EMBARK_ELEVATION
                        Elevation of embark site (if specified, will set active sheet in Excel workbook)
  --enable-macros       Create Excel workbook with macros to propagate zoom level and cell location across sheets

The --enable-macros parameter adds some VBA code to the workbook that will keep track of your zoom level and position in the active worksheet and set the zoom level and position of new worksheets to match. That lets you easily move through worksheets to get a feel for how your fortress works in a 3D sense.

For example, if you use the default text files in the examples/elevations/Quakevaults folder:

python .\df-map-export.py --basedir examples/elevations Quakevaults --embark-elevation 46

Or if you copy them to the elevations folder:

python .\df-map-export.py Quakevaults --embark-elevation 46

Examples

See the examples folder for some elevation files and resulting spreadsheets.

About

Dwarf Fortress Elevation to Map Tool

License:Apache License 2.0


Languages

Language:Lua 60.0%Language:Python 40.0%