Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Making all world_region_details structures accessible in DFHack?  (Read 2879 times)

TurkeyMcMac

  • Escaped Lunatic
    • View Profile
Making all world_region_details structures accessible in DFHack?
« on: December 22, 2021, 02:17:42 pm »

Hi. I'm trying to export elevation data from a Dwarf Fortress world for use in another application. I have written a Lua script to do this, but I can't get data for all the region tiles. Some of the world_region_details structs are missing. Is there a way I can generate/access these missing structs?

Alternatively, maybe I could just use the elevation bitmap that can be exported from legends mode. Does this contain the same elevation information? If so, how can I convert from pixels to elevation data? The method of doing so eludes me.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Making all world_region_details structures accessible in DFHack?
« Reply #1 on: December 22, 2021, 04:10:12 pm »

Only the current world tile's region data is loaded into the game in the pre embark mode, which is why you can't access the data for the others. In Fortress mode it's a 3*3 world tile area centered on the current world tile (with the edges being obvious exceptions), and I believe the same goes for Adventure mode. This means you'll have to move around the world one world tile at a time to get the game to load all the tiles. There's more complications with "Feature Shells", i.e. 16*16 world tile blocks that take a significant time to load. This script https://github.com/PatrikLundell/scripts/blob/own_scripts/candy_corrector.lua (it's a HTML page with the script on it. To copy it you'd want to display it in raw mode) contains logic for iterating over the info, which can serve as a starting point for replacing the contents with your own payload.
Logged

TurkeyMcMac

  • Escaped Lunatic
    • View Profile
Re: Making all world_region_details structures accessible in DFHack?
« Reply #2 on: December 22, 2021, 05:08:29 pm »

Thanks, I'll take a look. With some experimentation, I may have figured out how to convert from bitmap pixels to elevation measurements, so I'll also try that approach.
Logged