Created
July 11, 2020 12:44
-
-
Save ennorehling/80d7030303dc50680cf4bb883d6e158a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local crs = require 'cr' | |
function log_error(str) | |
io.stderr:write(str) | |
end | |
local terrains = { | |
['Ozean'] = 'ocean', | |
['Gletscher'] = 'glacier', | |
['Eisberg'] = 'iceberg', | |
['Hochland'] = 'highland', | |
['Feuerwand'] = 'firewall', | |
['Sumpf'] = 'swamp', | |
['Aktiver Vulkan'] = 'volcano', | |
['Vulkan'] = 'volcano', | |
['Wüste'] = 'desert', | |
['Berge'] = 'mountain', | |
['Wald'] = 'plain', | |
['Ebene'] = 'plain', | |
} | |
function lua_export(cr) | |
local r | |
print('require "config"') | |
for _, r in ipairs(cr.REGION) do | |
if r.Terrain then | |
local terrain = terrains[r.Terrain] or 'desert' | |
print('region.create(' .. r.keys[1] .. ', ' .. r.keys[2] .. ', "' .. terrain .. '")') | |
end | |
end | |
print("eressea.write_game('export.dat')") | |
end | |
local name = arg[1] | |
local cr, err = crs.read(name) | |
if not cr then | |
log_error(name .. '\t' .. err .. '\n') | |
else | |
lua_export(cr) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment