Skip to content

Instantly share code, notes, and snippets.

@ennorehling
Created July 11, 2020 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ennorehling/80d7030303dc50680cf4bb883d6e158a to your computer and use it in GitHub Desktop.
Save ennorehling/80d7030303dc50680cf4bb883d6e158a to your computer and use it in GitHub Desktop.
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