You can clone the code from this branch: https://github.com/TurkeyMcMac/minetest/tree/dfimport
To use the code, you first have to get data from Dwarf Fortress. Go into Legends mode and export maps of elevation, temperature, and rainfall. Rename the bitmaps to el.bmp, tmp.bmp, and rain.bmp, respectively. Now run this Python script:
Code: Select all
#!/usr/bin/python3
from PIL import Image
el = Image.open("el.bmp")
def u16_bytes(value):
b1 = value // 256
b0 = value % 256
return (b1, b0)
def serialize_grid(img, f):
out = []
out += u16_bytes(img.width)
out += u16_bytes(img.height)
for z in range(img.height):
for x in range(img.width):
r, g, b = img.getpixel((x, z))
out += u16_bytes(f(r, g, b))
return out
with open("el.dat", "wb") as out:
el = Image.open("el.bmp")
def f(r, g, b):
if r > 0 and g == r and b == r:
return round(r * 99 / 74)
elif r == 0 and g == 0:
return b
out.write(bytearray(serialize_grid(el, f)))
with open("tmp.dat", "wb") as out:
tmp = Image.open("tmp.bmp")
def f(r, g, b):
return r
out.write(bytearray(serialize_grid(tmp, f)))
with open("rain.dat", "wb") as out:
rain = Image.open("rain.bmp")
def f(r, g, b):
return r
out.write(bytearray(serialize_grid(rain, f)))
If you don't want to go through the trouble of the above procedure, I have attached an archive "dfdata.zip" containing three files produced in this way.
For now, the output files need to be in the current working directory when you run Minetest. Open Minetest and create a world with the mapgen "dfimport".
Instead of using noise, terrain is generated by interpolating between the data points provided by Dwarf Fortress. One pixel in one of the source bitmaps corresponds to one Minetest mapchunk. The generated terrain is very large-scale. Mountains can rise over 400 nodes above sea level. Biomes are generated according to the set of registered biomes; they are not hard-coded. Besides fixing bugs, I still have to add cave and river generation (I plan on importing river information from Dwarf Fortress, but not cave information.)