Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: DFHack scripts: exportmap.lua/tweakmap.lua  (Read 3625 times)

PatrikLundell

  • Bay Watcher
    • View Profile
DFHack scripts: exportmap.lua/tweakmap.lua
« on: October 22, 2016, 10:49:34 am »

Purpose: Generate a world map in DF, export it as parameters+PSV data, tweak the PSV data, and then regenerate a tweaked world resembling the original one. The functionality of tweakmap has grown to allow it to act as a replacement for World Painter, if desired.

https://www.dropbox.com/s/mlhcs3ik1wdnkgw/exportmap.lua?dl=0 version 0.1 2016-10-22
https://www.dropbox.com/s/60kmfv55ctnmebc/tweakmap.lua?dl=0 version 0.8 2017-11-23
Both can be found here:https://github.com/PatrikLundell/scripts/tree/own_scripts

exportmap.lua:
This script exports a world as parameters + PSV data to <DF directory>\data\init\exported_map.txt. The data isn't exported exactly as is, but rather adjusted to generate approximately the same world when DF's advanced world generation uses it (when the file contents has been pasted into world_gen.txt).
- Elevation is converted from the ranges used in the world to those used by the PSV set.
- Temperatures are attempted to be adjusted to compensate for elevation and latitude adjustments performed by DF. "Attempted" means the formulae used are not known, and so measured translation tables are used.
- Most of the world gen parameters are exported as they exist in DF, but some are changed to attempt to increase the chances that DF will actually generate the same thing world map tiles. Variances are modified, for instance, and if the pole was specified to one of the "chose one" alternatives it's locked to the one actually used.

tweakmap.lua:
This script reads the contents of the file exportmap.lua produced and presents it using DF as a display engine, without actually using any data within DF itself. The script displays world map tiles according to the biomes the PSV values would result in.
- You can change any if the PSV values for the currently selected tile to any value within the legal range.
- You can select the biome of the currently selected tile from a list of ones legal at that latitude. That will change PSV values to values that generate the selected biome. These parameters can be manually tuned after biome selection by the function above.
- Temperatures are WYSIWYG, i.e. the temperatures displayed differ from what was/will be in the PSV set and displays what they correspond to in a DF world.
- You can save the modified parameter + PSV set back to <DF directory>\data\init\exported_map.txt for manual copy into world_gen.txt.
- PSV parameter sets can be ignored, i.e. not saved. This is probably useful only to let DF randomize Volcanism.

Caveats, known deficiencies, rambling, etc:
- Temperature conversion is measured table based, rather than using the actual formulae DF used, since those are unknown to the author. Differences seem to be limited to 1 degree.
- World generation does not generate exactly the same elevations as the PSV set specifies, but they are generally close.
- Volcanism can spread out one tile from volcanoes, and volcanoes do not necessarily appear in the same location in a regenerated world.
- Biomes are determined using 6 parameters: Elevation, Temperature, Rainfall, Drainage, Vegetation, and Salinity. It can be noted that Vegetation and Salinity are not available as PSV parameters. Vegetation seems to always match Rainfall, so that's used as a proxy. Salinity, however, is problematic. Tweakmap uses a salinity value of 100 for wetlands as that allows for Mangrove Swamps, but the users should be aware that they may end up with freshwater marshers/swamps instead.
- The author has tried to set the parameters to get DF's world to match the PSV data as closely as possible, but the author is not confident the selections are the best ones possible, so there may very well be room for improvement.
- Tweakmap does not change the parameter part of the data read, but rather prints it out unchanged: all modifications are done by exportmap.
- Since Evilness is not available as PSV data, the data is displayed without consideration to any possible evilness values.

The author intends to modify this first post to reflect any changes in the scripts or associated knowledge without explicit change markings. Usually a new post at the end of the thread would indicate this post has changed, though.

Change log:
tweakmap 0.8 2017-11-23: Fixed bug in grid widget for maps wider than they are high.
  Changed ESCAPE behavior to escape out of help to the main display, rather than out of the tool completely.
  Blocked the editing and movement command keys from having any effect while the help is displayed (save and exit still work).
tweakmap 0.7 2017-08-05: Fixed screwed up addressing of 'r' and 'b' for frames essentially replacing them with 'w' and 'h'. Affected screen resizing handling, but had no effects on actual functionality.
tweakmap 0.6 2017-07-23:
- Fixed bug in determination of possible biomes on smaller maps for the "maybe" zone.
- Fixed incorrect key function descriptions referring to the wrong name of the save file.
tweakmap 0.5 2017-06-27:
- Replaced the crummy movement scheme of separate movement and panning with a single set of keys that pans automatically to keep the cursor as close to the center as possible (incidentally the same way DF does it...).
tweakmap 0.4 2017-06-22:
- Restored the functionality for the "map" to resize when the DF window size is changed.
tweakmap 0.3 2017-06-21:
- No functionality changes. Updated help text slightly.
- Replaced internal mechanism for map panning using a new widget.
tweakmap 0.2 2017-02-21:
- Tweaked maps are now saved back into exported_map.txt rather than to a separate file.
- Missing PSV values are replaced by defaults, allowing tweakmap to be used as a replacement for World Painter. In that case you would start with the world generation parameters only in the exported_map.txt file.
- It's possible to suppress the saving of one or more PSV parameters, allowing DF to generate those on its own.
« Last Edit: January 12, 2020, 05:41:43 am by PatrikLundell »
Logged