How to import a map from civ5

Gedemon

Modder
Super Moderator
Joined
Oct 4, 2004
Messages
11,603
Location
France
First you need to learn a bit about the modinfo file to setup the mod, something like that (with your own GUID)
HTML:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="any_GUID" version="23">
  <Properties>
    <Name>Your Mod Name</Name>
    <Stability>Alpha</Stability>
    <Teaser>ttt</Teaser>
    <Description>ddd</Description>
    <Authors>xxx</Authors>
  </Properties>
  <Dependencies />
  <References />
  <Blocks />
    <Settings>
        <Custom>
            <Items>
                <File>Config.xml</File>
            </Items>
        </Custom>
    </Settings>
    <Components>
        <ImportFiles>
            <Items>
                <File>YourMap.lua</File>
            </Items>
        </ImportFiles>
    </Components>
    <Files>
        <File>YourMap.lua</File>
        <File>Config.xml</File>
    </Files>
</Mod>

Then in Config.xml
HTML:
<GameInfo>
    <Maps>
        <Row File="YourMap.lua" Name="Your Map" Description="The map description" SortIndex="1"/>
    </Maps>
</GameInfo>

and in YourMap.lua
PHP:
------------------------------------------------------------------------------
--    FILE:     YourMap.Lua
--
------------------------------------------------------------------------------



include "MapEnums"
include "MapUtilities"
include "MountainsCliffs"
include "RiversLakes"
include "FeatureGenerator"
include "TerrainGenerator"
include "NaturalWonderGenerator"
include "ResourceGenerator"
include "AssignStartingPlots"

print("LoadingYour map")

local g_iW, g_iH;
local g_iFlags = {};
local g_continentsFrac = nil;

------------------------------------------------------------------------------
-- The application side will call GetMapScriptInfo directly to request
-- information about the map script.
-------------------------------------------------------------------------------
function GetMapInitData(worldSize)
    return {
        Width = 180,
        Height = 94,
        WrapX = true,
        WrapY = false,
    };   
end

-------------------------------------------------------------------------------
function GenerateMap()
    print("Generating Your Map");
    local pPlot;

    -- Set globals
    g_iW, g_iH = 180, 94;
    g_iFlags = TerrainBuilder.GetFractalFlags();

    ImportMap()

    -- Temp
    AreaBuilder.Recalculate();
    local biggest_area = Areas.FindBiggestArea(false);
    print("After Adding Hills: ", biggest_area:GetPlotCount());
  
    -- River generation is affected by plot types, originating from highlands and preferring to traverse lowlands.
    --AddRivers();
  
    --AddFeatures(); 

    local args = {
        numberToPlace = GameInfo.Maps[Map.GetMapSize()].NumNaturalWonders,
    };
    --local nwGen = NaturalWonderGenerator.Create(args);

    AreaBuilder.Recalculate();
    TerrainBuilder.AnalyzeChokepoints();
    TerrainBuilder.StampContinents();
  
    resourcesConfig = MapConfiguration.GetValue("resources");
    local args = {
        resources = resourcesConfig,
    };
    --ResourceGenerator.Create(args);

    print("Creating start plot database.");
    local startConfig = MapConfiguration.GetValue("start");-- Get the start config
    -- START_MIN_Y and START_MAX_Y is the percent of the map ignored for major civs' starting positions.
    local args = {
        MIN_MAJOR_CIV_FERTILITY = 150,
        MIN_MINOR_CIV_FERTILITY = 50,
        MIN_BARBARIAN_FERTILITY = 1,
        START_MIN_Y = 15,
        START_MAX_Y = 15,
        START_CONFIG = startConfig,
    };
    local start_plot_database = AssignStartingPlots.Create(args)

    local GoodyGen = AddGoodies(g_iW, g_iH);
end

function AddFeatures()
    print("Adding Features");

    -- Get Rainfall setting input by user.
    local rainfall = MapConfiguration.GetValue("rainfall");
    if rainfall == 4 then
        rainfall = 1 + TerrainBuilder.GetRandomNumber(3, "Random Rainfall - Lua");
    end
  
    local args = {rainfall = rainfall}
    local featuregen = FeatureGenerator.Create(args);

    featuregen:AddFeatures();
end
--[[

    ENUM from Civ5
  
    ResourceType
  
    [0]     = RESOURCE_IRON
    [1]     = RESOURCE_HORSE
    [2]     = RESOURCE_COAL
    [3]     = RESOURCE_OIL
    [4]     = RESOURCE_ALUMINUM
    [5]     = RESOURCE_URANIUM
    [6]     = RESOURCE_WHEAT
    [7]     = RESOURCE_COW
    [8]     = RESOURCE_SHEEP
    [9]     = RESOURCE_DEER
    [10] = RESOURCE_BANANA
    [11] = RESOURCE_FISH
    [12] = RESOURCE_STONE
    [13] = RESOURCE_WHALE
    [14] = RESOURCE_PEARLS
    [15] = RESOURCE_GOLD
    [16] = RESOURCE_SILVER
    [17] = RESOURCE_GEMS
    [18] = RESOURCE_MARBLE
    [19] = RESOURCE_IVORY
    [20] = RESOURCE_FUR
    [21] = RESOURCE_DYE
    [22] = RESOURCE_SPICES
    [23] = RESOURCE_SILK
    [24] = RESOURCE_SUGAR
    [25] = RESOURCE_COTTON
    [26] = RESOURCE_WINE
    [27] = RESOURCE_INCENSE
    [28] = RESOURCE_JEWELRY
    [29] = RESOURCE_PORCELAIN
    [30] = RESOURCE_COPPER
    [31] = RESOURCE_SALT
    [32] = RESOURCE_CRAB
    [33] = RESOURCE_TRUFFLES
    [34] = RESOURCE_CITRUS
    [40] = RESOURCE_BISON
    [41] = RESOURCE_COCOA
  
    civ6
    [0]     = RESOURCE_BANANAS
    [1]     = RESOURCE_CATTLE
    [2]     = RESOURCE_COPPER
    [3]     = RESOURCE_CRABS
    [4]     = RESOURCE_DEER
    [5]     = RESOURCE_FISH
    [6]     = RESOURCE_RICE
    [7]     = RESOURCE_SHEEP
    [8]     = RESOURCE_STONE
    [9]     = RESOURCE_WHEAT
    [10] = RESOURCE_CITRUS
    [11] = RESOURCE_COCOA
    [12] = RESOURCE_COFFEE
    [13] = RESOURCE_COTTON
    [14] = RESOURCE_DIAMONDS
    [15] = RESOURCE_DYES
    [16] = RESOURCE_FURS
    [17] = RESOURCE_GYPSUM
    [18] = RESOURCE_INCENSE
    [19] = RESOURCE_IVORY
    [20] = RESOURCE_JADE
    [21] = RESOURCE_MARBLE
    [22] = RESOURCE_MERCURY
    [23] = RESOURCE_PEARLS
    [24] = RESOURCE_SALT
    [25] = RESOURCE_SILK
    [26] = RESOURCE_SILVER
    [27] = RESOURCE_SPICES
    [28] = RESOURCE_SUGAR
    [29] = RESOURCE_TEA
    [30] = RESOURCE_TOBACCO
    [31] = RESOURCE_TRUFFLES
    [32] = RESOURCE_WHALES
    [33] = RESOURCE_WINE
    [40] = RESOURCE_ALUMINUM
    [41] = RESOURCE_COAL
    [42] = RESOURCE_HORSES
    [43] = RESOURCE_IRON
    [44] = RESOURCE_NITER
    [45] = RESOURCE_OIL
    [46] = RESOURCE_URANIUM
  
    FeaturesType
    [0]  = FEATURE_ICE            ----> 1
    [1]  = FEATURE_JUNGLE        ----> 2
    [2]  = FEATURE_MARSH        ----> 5
    [3]  = FEATURE_OASIS        ----> 4
    [4]  = FEATURE_FLOOD_PLAINS    ----> 0
    [5]  = FEATURE_FOREST        ----> 3
    [6]  = FEATURE_FALLOUT
    [7]  = FEATURE_CRATER
    [8]  = FEATURE_FUJI
    [9]  = FEATURE_MESA
    [10] = FEATURE_REEF            ----> 6
    [11] = FEATURE_VOLCANO
    [12] = FEATURE_GIBRALTAR
    [13] = FEATURE_GEYSER
    [14] = FEATURE_FOUNTAIN_YOUTH
    [15] = FEATURE_POTOSI
    [16] = FEATURE_EL_DORADO
    [17] = FEATURE_ATOLL
    [18] = FEATURE_SRI_PADA
    [19] = FEATURE_MT_SINAI
    [20] = FEATURE_MT_KAILASH
    [21] = FEATURE_ULURU
    [22] = FEATURE_LAKE_VICTORIA
    [23] = FEATURE_KILIMANJARO    ----> 12
    [24] = FEATURE_SOLOMONS_MINES 
  
    PlotType
    [0] =    PLOT_MOUNTAIN     
    [1] =    PLOT_HILLS     
    [2] =    PLOT_LAND     
    [3] =    PLOT_OCEAN     

    TerrainTypes
    [0] = TERRAIN_GRASS,
    [1] = TERRAIN_PLAINS,
    [2] = TERRAIN_DESERT,
    [3] = TERRAIN_TUNDRA,
    [4] = TERRAIN_SNOW,
    [5] = TERRAIN_COAST,
    [6] = TERRAIN_OCEAN,
  
    FeatureTypes
    [0] = FEATURE_ICE,
    [1] = FEATURE_JUNGLE,
    [2] = FEATURE_MARSH,
    [3] = FEATURE_OASIS,
    [4] = FEATURE_FLOOD_PLAINS,
    [5] = FEATURE_FOREST,
    [6] = FEATURE_FALLOUT,
    [7] = FEATURE_ATOLL,
  
    Continental Art Set
    [0] = Ocean
    [1] = America
    [2] = Asia
    [3] = Africa
    [4] = Europe
  
    Rivers (same for civ6)
    [0] = FLOWDIRECTION_NORTH
    [1] = FLOWDIRECTION_NORTHEAST
    [2] = FLOWDIRECTION_SOUTHEAST
    [3] = FLOWDIRECTION_SOUTH
    [4] = FLOWDIRECTION_SOUTHWEST
    [5] = FLOWDIRECTION_NORTHWEST
  
    Directions (same for civ6)
    [0] = DIRECTION_NORTHEAST 
    [1] = DIRECTION_EAST
    [2] = DIRECTION_SOUTHEAST
    [3] = DIRECTION_SOUTHWEST
    [4] = DIRECTION_WEST     
    [5] = DIRECTION_NORTHWEST
  
  
    -- Code to export the civ5 map
    for iPlotLoop = 0, Map.GetNumPlots()-1, 1 do
        local plot = Map.GetPlotByIndex(iPlotLoop)
        local NEOfRiver = 0
        local WOfRiver = 0
        local NWOfRiver = 0
        if plot:IsNEOfRiver() then NEOfRiver = 1 end -- GetRiverSWFlowDirection()
        if plot:IsWOfRiver() then WOfRiver = 1 end -- GetRiverEFlowDirection()
        if plot:IsNWOfRiver() then NWOfRiver = 1 end -- GetRiverSEFlowDirection()
        print("MapToConvert["..plot:GetX().."]["..plot:GetY().."]={"..plot:GetTerrainType()..","..plot:GetPlotType()..","..plot:GetFeatureType()..","..plot:GetContinentArtType()..",{{"..NEOfRiver..","..plot:GetRiverSWFlowDirection().. "},{"..WOfRiver..","..plot:GetRiverEFlowDirection().."},{"..NWOfRiver..","..plot:GetRiverSEFlowDirection().."}},{"..plot:GetResourceType(-1)..","..plot:GetNumResource().."}}")
    end

--]]

function ImportMap()
    local MapToConvert = GetMap()
    local count = 0
  
    -- Civ5 ENUM
    PLOT_MOUNTAIN = 0
    PLOT_HILLS = 1
  
    -- Civ5 to Civ6
    local FeaturesCiv5toCiv6 = {}
    for i = 0, 24 do FeaturesCiv5toCiv6[i] = g_FEATURE_NONE end
    FeaturesCiv5toCiv6[0]  = g_FEATURE_ICE
    FeaturesCiv5toCiv6[1]  = g_FEATURE_JUNGLE
    FeaturesCiv5toCiv6[2]  = g_FEATURE_MARSH
    FeaturesCiv5toCiv6[3]  = g_FEATURE_OASIS
    FeaturesCiv5toCiv6[4]  = g_FEATURE_FLOODPLAINS
    FeaturesCiv5toCiv6[5]  = g_FEATURE_FOREST
    -- Natural wonders may require a special coding
    FeaturesCiv5toCiv6[10] = g_FEATURE_BARRIER_REEF
    --FeaturesCiv5toCiv6[23] = g_FEATURE_KILIMANJARO
  
    local ResourceCiv5toCiv6 = {}
    for i = 0, 41 do ResourceCiv5toCiv6[i] = -1 end
    ResourceCiv5toCiv6[4]= 40 -- ALUMINUM
    ResourceCiv5toCiv6[10]= 0 -- BANANAS
    ResourceCiv5toCiv6[40]= 16 -- BISON to FURS
    ResourceCiv5toCiv6[7]= 1 -- CATTLE
    ResourceCiv5toCiv6[34]= 10 -- CITRUS
    ResourceCiv5toCiv6[2]= 41 -- COAL
    ResourceCiv5toCiv6[41]= 11 -- COCOA
    ResourceCiv5toCiv6[30]= 2 -- COPPER
    ResourceCiv5toCiv6[25]= 13 -- COTTON
    ResourceCiv5toCiv6[32]= 3 -- CRABS
    ResourceCiv5toCiv6[9]= 4 -- DEER
    ResourceCiv5toCiv6[17]= 14 -- DIAMONDS
    ResourceCiv5toCiv6[21]= 15 -- DYES
    ResourceCiv5toCiv6[11]= 5 -- FISH
    ResourceCiv5toCiv6[20]= 16 -- FURS
    ResourceCiv5toCiv6[15]= 44 -- GOLD to NITER
    ResourceCiv5toCiv6[1]= 42 -- HORSES
    ResourceCiv5toCiv6[27]= 18 -- INCENSE
    ResourceCiv5toCiv6[0]= 43 -- IRON
    ResourceCiv5toCiv6[19]= 19 -- IVORY
    ResourceCiv5toCiv6[28]= 20 -- JADE
    ResourceCiv5toCiv6[18]= 21 -- MARBLE
    ResourceCiv5toCiv6[3]= 45 -- OIL
    ResourceCiv5toCiv6[14]= 23 -- PEARLS
    ResourceCiv5toCiv6[31]= 24 -- SALT
    ResourceCiv5toCiv6[8]= 7 -- SHEEP
    ResourceCiv5toCiv6[23]= 25 -- SILK
    ResourceCiv5toCiv6[16]= 26 -- SILVER
    ResourceCiv5toCiv6[22]= 27 -- SPICES
    ResourceCiv5toCiv6[12]= 8 -- STONE
    ResourceCiv5toCiv6[24]= 28 -- SUGAR
    ResourceCiv5toCiv6[33]= 31 -- TRUFFLES
    ResourceCiv5toCiv6[5]= 46 -- URANIUM
    ResourceCiv5toCiv6[13]= 32 -- WHALES
    ResourceCiv5toCiv6[6]= 9 -- WHEAT
    ResourceCiv5toCiv6[26]= 33 -- WINE
  
    for i = 0, (g_iW * g_iH) - 1, 1 do
        plot = Map.GetPlotByIndex(i)
        print("----------")
        print("Convert plot at "..plot:GetX()..","..plot:GetY())
        -- Map Data
        -- MapToConvert[x][y] = {civ5TerrainType, civ5PlotTypes, civ5FeatureTypes, civ5ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ5ResourceType, num} }
        local civ5TerrainType = MapToConvert[plot:GetX()][plot:GetY()][1]
        local civ5PlotTypes = MapToConvert[plot:GetX()][plot:GetY()][2]
        local civ5FeatureTypes = MapToConvert[plot:GetX()][plot:GetY()][3]
        local civ5ContinentType = MapToConvert[plot:GetX()][plot:GetY()][4]
        local rivers = MapToConvert[plot:GetX()][plot:GetY()][5] -- = {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}
        local resource = MapToConvert[plot:GetX()][plot:GetY()][6] -- = {Civ5ResourceType, num}
      
        -- Set terrain type
        local civ6TerrainType = g_TERRAIN_TYPE_OCEAN     
        if civ5TerrainType == 5 then civ6TerrainType = g_TERRAIN_TYPE_COAST
        elseif civ5TerrainType ~= 6 then
            -- the code below won't work if the order is changed in the terrains table
            -- entrie for civ5 are: 0 = GRASS, 1= PLAINS, ...
            -- entries for civ6 are: 0 = GRASS, 1= GRASS_HILL, 2 = GRASS_MOUNTAIN, 3= PLAINS, 4 = PLAINS_HILL, ...
            civ6TerrainType = civ5TerrainType * 3 -- civ5TerrainType * 3  0-0 1-3 2-6 3-9 4-12
            if civ5PlotTypes == PLOT_HILLS then
                civ6TerrainType = civ6TerrainType + g_TERRAIN_BASE_TO_HILLS_DELTA
            elseif civ5PlotTypes == PLOT_MOUNTAIN then
                civ6TerrainType = civ6TerrainType + g_TERRAIN_BASE_TO_MOUNTAIN_DELTA
            end
        end
        print(" - Set Terrain Type = "..tostring(GameInfo.Terrains[civ6TerrainType].TerrainType))
        count = count + 1
        TerrainBuilder.SetTerrainType(plot, civ6TerrainType)
      
        -- Set rivers
        if rivers[1][1] == 1 then -- IsNEOfRiver
            TerrainBuilder.SetNEOfRiver(plot, true, rivers[1][2])
            print(" - Set is NE of river, flow = "..tostring(rivers[1][2]))
        end
        if rivers[2][1] == 1 then -- IsWOfRiver
            TerrainBuilder.SetWOfRiver(plot, true, rivers[2][2])
            print(" - Set is W of river, flow = "..tostring(rivers[2][2]))
        end
        if rivers[3][1] == 1 then -- IsNWOfRiver
            TerrainBuilder.SetNWOfRiver(plot, true, rivers[3][2])
            print(" - Set is NW of river, flow = "..tostring(rivers[3][2]))
        end
      
        -- Set Features
        if civ5FeatureTypes ~= -1 and FeaturesCiv5toCiv6[civ5FeatureTypes] ~= g_FEATURE_NONE then     
            print(" - Set Feature Type = "..tostring(GameInfo.Features[FeaturesCiv5toCiv6[civ5FeatureTypes]].FeatureType))
            TerrainBuilder.SetFeatureType(plot, FeaturesCiv5toCiv6[civ5FeatureTypes])
        end
      
        -- Set Resources
        if resource[1] ~= -1 and ResourceCiv5toCiv6[resource[1]] ~= -1 then     
            print(" - Set Resource Type = "..tostring(GameInfo.Resources[ResourceCiv5toCiv6[resource[1]]].ResourceType))
            ResourceBuilder.SetResourceType(plot, ResourceCiv5toCiv6[resource[1]], resource[2])
        end
      
    end
    print(" Placed terrain on "..tostring(count) .. " tiles")
end

function GetMap()

    local MapToConvert = {}
    for i = 0, g_iW - 1, 1 do
        MapToConvert[i] = {}
    end
  
    -- Map Data
    -- MapToConvert[x][y] = {civ5TerrainType, civ5PlotTypes, civ5FeatureTypes, civ5ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ5ResourceType, num} }
  
 MapToConvert[0][0]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[1][0]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[2][0]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[3][0]={4,1,-1,3,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[4][0]={5,3,0,0,{{0,-1},{0,-1},{0,-1}},{-1,0}}

 -- of course there will be a lot more lines here...

 MapToConvert[176][93]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[177][93]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[178][93]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[179][93]={4,0,-1,1,{{0,-1},{0,-1},{0,-1}},{-1,0}}
  

  
    return MapToConvert
end

Note that some line are commented out, like

PHP:
    --AddRivers();
  
    --AddFeatures();

You may reactivate them by removing the "--" at the beginning, it's
very important for resources:
PHP:
ResourceGenerator.Create(args)

because if your imported map doesn't have any, the game won't find starting positions for the civilizations.

There are also 3 mandatory things to change in this file:

The Width and Height here: (and maybe WrapX for an regional map)
PHP:
function GetMapInitData(worldSize)
    return {
        Width = 180,
        Height = 94,
        WrapX = true,
        WrapY = false,
    };   
end

and here
PHP:
    -- Set globals
    g_iW, g_iH = 180, 94;
    g_iFlags = TerrainBuilder.GetFractalFlags();

to match your map size.

and of course all the
PHP:
 MapToConvert[179][93]={4,0,-1,1,{{0,-1},{0,-1},{0,-1}},{-1,0}}

lines at the end of the file (but do not overwrite the 2 final lines !)

Now to get the MapToConvert data, use this code in civ5 (in firetuner for example)
PHP:
    for iPlotLoop = 0, Map.GetNumPlots()-1, 1 do
        local plot = Map.GetPlotByIndex(iPlotLoop)
        local NEOfRiver = 0
        local WOfRiver = 0
        local NWOfRiver = 0
        if plot:IsNEOfRiver() then NEOfRiver = 1 end -- GetRiverSWFlowDirection()
        if plot:IsWOfRiver() then WOfRiver = 1 end -- GetRiverEFlowDirection()
        if plot:IsNWOfRiver() then NWOfRiver = 1 end -- GetRiverSEFlowDirection()
        print("MapToConvert["..plot:GetX().."]["..plot:GetY().."]={"..plot:GetTerrainType()..","..plot:GetPlotType()..","..plot:GetFeatureType()..","..plot:GetContinentArtType()..",{{"..NEOfRiver..","..plot:GetRiverSWFlowDirection().. "},{"..WOfRiver..","..plot:GetRiverEFlowDirection().."},{"..NWOfRiver..","..plot:GetRiverSEFlowDirection().."}},{"..plot:GetResourceType(-1)..","..plot:GetNumResource().."}}")
    end
and then copy/paste in YourMap.Lua all the "MapToConvert" lines from the lua.log (removing the "[760818.859] InGame: " part, using a good file editor like Notepad++ because of the size of the text (use shift+alt to select the part to cut)
 
Last edited:
Actually WorldBuilder is already here. They just haven't made it accessible. But I have successfully added that option to the main menu. It simply opens the WorldBuilder.xml that is found in UI folder. The command line also accepts an argument to load a WorldBuilder map.
 
Yes, I'm just assuming that the external WB will allow to directly import maps from civ5, AFAIK the ingame WB can't do that.
 
Thanks for this!

I haven't tried yet and I will probably try at some point, I wonder if you can use this : http://forums.civfanatics.com/threads/civ5map-to-lua-script-tools.504715/

to convert civ 6 world builder maps (with only terrain/features placed) to lua by simply renaming the file type then doing what you provided. But that might just be wishful thinking I'm not sure how similar the content are if at all.

Also I was getting a bug earlier, delete autosaves after playing around/testing maps if your civ 6 breaks (crashs at loading screen even without mods). I think this may have come about from bad lua code.
 
Last edited:
Actually WorldBuilder is already here. They just haven't made it accessible. But I have successfully added that option to the main menu. It simply opens the WorldBuilder.xml that is found in UI folder. The command line also accepts an argument to load a WorldBuilder map.

How did you do that? Hidden 1 or Hidden 0. Or deleted all?
 
You load anything in civ5 (map, script, scenario, save) the code export just the terrain data (plot types, rivers) of what you have loaded into a mapscript for civ6
 
Thanks for this and all you do, Gedemon! Do you happen to know if there's a way to override the StampContinents method with our own continent logic? Maybe a SetContinent call that we can do per plot?
 
I was using the code in the OP to convert a map. It worked very well.... however, when I uncommented the naturalwonder generator and its arguments, my map would show up with no resources when it had previously worked.

I figured a work around... I moved the Natural Wonder generating code to after resources, and it seemed to work (at least as far as generating resources .... I cannot tell if it actually generates natural wonders as the world builder map is very unhelpful in that respect.

Anyhow, the functions were put in a differing order than the original code... below is the altered part. It was moved from its previous positions to after ResourceGenerator.... and now my map once more has resources.

Code:
 resourcesConfig = MapConfiguration.GetValue("resources");
    local args = {
        resources = resourcesConfig,
    };
    ResourceGenerator.Create(args);
    
    local args = {
       numberToPlace = GameInfo.Maps[Map.GetMapSize()].NumNaturalWonders,};
    local nwGen = NaturalWonderGenerator.Create(args);
 
I'm not a modder myself, but run Civplayers league. Can anyone port for me the skirmish map from Civ5 to Civ6? Maybe Lakes, and east vs west and north vs south? But skirmish is he most important as even with cloverleaf and snowflake there is still no duel map in Civ6. And all maps seem to be too large for any given player size, making building the only game for at least a couple hours on every map

CS
 
First you need to learn a bit about the modinfo file to setup the mod, something like that (with your own GUID)
HTML:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="any_GUID" version="23">
  <Properties>
    <Name>Your Mod Name</Name>
    <Stability>Alpha</Stability>
    <Teaser>ttt</Teaser>
    <Description>ddd</Description>
    <Authors>xxx</Authors>
  </Properties>
  <Dependencies />
  <References />
  <Blocks />
    <Settings>
        <Custom>
            <Items>
                <File>Config.xml</File>
            </Items>
        </Custom>
    </Settings>
    <Components>
        <ImportFiles>
            <Items>
                <File>YourMap.lua</File>
            </Items>
        </ImportFiles>
    </Components>
    <Files>
        <File>YourMap.lua</File>
        <File>Config.xml</File>
    </Files>
</Mod>

Then in Config.xml
HTML:
<GameInfo>
    <Maps>
        <Row File="YourMap.lua" Name="Your Map" Description="The map description" SortIndex="1"/>
    </Maps>
</GameInfo>

and in YourMap.lua
PHP:
------------------------------------------------------------------------------
--    FILE:     YourMap.Lua
--
------------------------------------------------------------------------------



include "MapEnums"
include "MapUtilities"
include "MountainsCliffs"
include "RiversLakes"
include "FeatureGenerator"
include "TerrainGenerator"
include "NaturalWonderGenerator"
include "ResourceGenerator"
include "AssignStartingPlots"

print("LoadingYour map")

local g_iW, g_iH;
local g_iFlags = {};
local g_continentsFrac = nil;

------------------------------------------------------------------------------
-- The application side will call GetMapScriptInfo directly to request
-- information about the map script.
-------------------------------------------------------------------------------
function GetMapInitData(worldSize)
    return {
        Width = 180,
        Height = 94,
        WrapX = true,
        WrapY = false,
    };  
end

-------------------------------------------------------------------------------
function GenerateMap()
    print("Generating Your Map");
    local pPlot;

    -- Set globals
    g_iW, g_iH = 180, 94;
    g_iFlags = TerrainBuilder.GetFractalFlags();

    ImportMap()

    -- Temp
    AreaBuilder.Recalculate();
    local biggest_area = Areas.FindBiggestArea(false);
    print("After Adding Hills: ", biggest_area:GetPlotCount());
 
    -- River generation is affected by plot types, originating from highlands and preferring to traverse lowlands.
    --AddRivers();
 
    --AddFeatures();

    local args = {
        numberToPlace = GameInfo.Maps[Map.GetMapSize()].NumNaturalWonders,
    };
    --local nwGen = NaturalWonderGenerator.Create(args);

    AreaBuilder.Recalculate();
    TerrainBuilder.AnalyzeChokepoints();
    TerrainBuilder.StampContinents();
 
    resourcesConfig = MapConfiguration.GetValue("resources");
    local args = {
        resources = resourcesConfig,
    };
    --ResourceGenerator.Create(args);

    print("Creating start plot database.");
    local startConfig = MapConfiguration.GetValue("start");-- Get the start config
    -- START_MIN_Y and START_MAX_Y is the percent of the map ignored for major civs' starting positions.
    local args = {
        MIN_MAJOR_CIV_FERTILITY = 150,
        MIN_MINOR_CIV_FERTILITY = 50,
        MIN_BARBARIAN_FERTILITY = 1,
        START_MIN_Y = 15,
        START_MAX_Y = 15,
        START_CONFIG = startConfig,
    };
    local start_plot_database = AssignStartingPlots.Create(args)

    local GoodyGen = AddGoodies(g_iW, g_iH);
end

function AddFeatures()
    print("Adding Features");

    -- Get Rainfall setting input by user.
    local rainfall = MapConfiguration.GetValue("rainfall");
    if rainfall == 4 then
        rainfall = 1 + TerrainBuilder.GetRandomNumber(3, "Random Rainfall - Lua");
    end
 
    local args = {rainfall = rainfall}
    local featuregen = FeatureGenerator.Create(args);

    featuregen:AddFeatures();
end
--[[

    ENUM from Civ5
 
    ResourceType
 
    [0]     = RESOURCE_IRON
    [1]     = RESOURCE_HORSE
    [2]     = RESOURCE_COAL
    [3]     = RESOURCE_OIL
    [4]     = RESOURCE_ALUMINUM
    [5]     = RESOURCE_URANIUM
    [6]     = RESOURCE_WHEAT
    [7]     = RESOURCE_COW
    [8]     = RESOURCE_SHEEP
    [9]     = RESOURCE_DEER
    [10] = RESOURCE_BANANA
    [11] = RESOURCE_FISH
    [12] = RESOURCE_STONE
    [13] = RESOURCE_WHALE
    [14] = RESOURCE_PEARLS
    [15] = RESOURCE_GOLD
    [16] = RESOURCE_SILVER
    [17] = RESOURCE_GEMS
    [18] = RESOURCE_MARBLE
    [19] = RESOURCE_IVORY
    [20] = RESOURCE_FUR
    [21] = RESOURCE_DYE
    [22] = RESOURCE_SPICES
    [23] = RESOURCE_SILK
    [24] = RESOURCE_SUGAR
    [25] = RESOURCE_COTTON
    [26] = RESOURCE_WINE
    [27] = RESOURCE_INCENSE
    [28] = RESOURCE_JEWELRY
    [29] = RESOURCE_PORCELAIN
    [30] = RESOURCE_COPPER
    [31] = RESOURCE_SALT
    [32] = RESOURCE_CRAB
    [33] = RESOURCE_TRUFFLES
    [34] = RESOURCE_CITRUS
    [40] = RESOURCE_BISON
    [41] = RESOURCE_COCOA
 
    civ6
    [0]     = RESOURCE_BANANAS
    [1]     = RESOURCE_CATTLE
    [2]     = RESOURCE_COPPER
    [3]     = RESOURCE_CRABS
    [4]     = RESOURCE_DEER
    [5]     = RESOURCE_FISH
    [6]     = RESOURCE_RICE
    [7]     = RESOURCE_SHEEP
    [8]     = RESOURCE_STONE
    [9]     = RESOURCE_WHEAT
    [10] = RESOURCE_CITRUS
    [11] = RESOURCE_COCOA
    [12] = RESOURCE_COFFEE
    [13] = RESOURCE_COTTON
    [14] = RESOURCE_DIAMONDS
    [15] = RESOURCE_DYES
    [16] = RESOURCE_FURS
    [17] = RESOURCE_GYPSUM
    [18] = RESOURCE_INCENSE
    [19] = RESOURCE_IVORY
    [20] = RESOURCE_JADE
    [21] = RESOURCE_MARBLE
    [22] = RESOURCE_MERCURY
    [23] = RESOURCE_PEARLS
    [24] = RESOURCE_SALT
    [25] = RESOURCE_SILK
    [26] = RESOURCE_SILVER
    [27] = RESOURCE_SPICES
    [28] = RESOURCE_SUGAR
    [29] = RESOURCE_TEA
    [30] = RESOURCE_TOBACCO
    [31] = RESOURCE_TRUFFLES
    [32] = RESOURCE_WHALES
    [33] = RESOURCE_WINE
    [40] = RESOURCE_ALUMINUM
    [41] = RESOURCE_COAL
    [42] = RESOURCE_HORSES
    [43] = RESOURCE_IRON
    [44] = RESOURCE_NITER
    [45] = RESOURCE_OIL
    [46] = RESOURCE_URANIUM
 
    FeaturesType
    [0]  = FEATURE_ICE            ----> 1
    [1]  = FEATURE_JUNGLE        ----> 2
    [2]  = FEATURE_MARSH        ----> 5
    [3]  = FEATURE_OASIS        ----> 4
    [4]  = FEATURE_FLOOD_PLAINS    ----> 0
    [5]  = FEATURE_FOREST        ----> 3
    [6]  = FEATURE_FALLOUT
    [7]  = FEATURE_CRATER
    [8]  = FEATURE_FUJI
    [9]  = FEATURE_MESA
    [10] = FEATURE_REEF            ----> 6
    [11] = FEATURE_VOLCANO
    [12] = FEATURE_GIBRALTAR
    [13] = FEATURE_GEYSER
    [14] = FEATURE_FOUNTAIN_YOUTH
    [15] = FEATURE_POTOSI
    [16] = FEATURE_EL_DORADO
    [17] = FEATURE_ATOLL
    [18] = FEATURE_SRI_PADA
    [19] = FEATURE_MT_SINAI
    [20] = FEATURE_MT_KAILASH
    [21] = FEATURE_ULURU
    [22] = FEATURE_LAKE_VICTORIA
    [23] = FEATURE_KILIMANJARO    ----> 12
    [24] = FEATURE_SOLOMONS_MINES
 
    PlotType
    [0] =    PLOT_MOUNTAIN    
    [1] =    PLOT_HILLS    
    [2] =    PLOT_LAND    
    [3] =    PLOT_OCEAN    

    TerrainTypes
    [0] = TERRAIN_GRASS,
    [1] = TERRAIN_PLAINS,
    [2] = TERRAIN_DESERT,
    [3] = TERRAIN_TUNDRA,
    [4] = TERRAIN_SNOW,
    [5] = TERRAIN_COAST,
    [6] = TERRAIN_OCEAN,
 
    FeatureTypes
    [0] = FEATURE_ICE,
    [1] = FEATURE_JUNGLE,
    [2] = FEATURE_MARSH,
    [3] = FEATURE_OASIS,
    [4] = FEATURE_FLOOD_PLAINS,
    [5] = FEATURE_FOREST,
    [6] = FEATURE_FALLOUT,
    [7] = FEATURE_ATOLL,
 
    Continental Art Set
    [0] = Ocean
    [1] = America
    [2] = Asia
    [3] = Africa
    [4] = Europe
 
    Rivers (same for civ6)
    [0] = FLOWDIRECTION_NORTH
    [1] = FLOWDIRECTION_NORTHEAST
    [2] = FLOWDIRECTION_SOUTHEAST
    [3] = FLOWDIRECTION_SOUTH
    [4] = FLOWDIRECTION_SOUTHWEST
    [5] = FLOWDIRECTION_NORTHWEST
 
    Directions (same for civ6)
    [0] = DIRECTION_NORTHEAST
    [1] = DIRECTION_EAST
    [2] = DIRECTION_SOUTHEAST
    [3] = DIRECTION_SOUTHWEST
    [4] = DIRECTION_WEST    
    [5] = DIRECTION_NORTHWEST
 
 
    -- Code to export the civ5 map
    for iPlotLoop = 0, Map.GetNumPlots()-1, 1 do
        local plot = Map.GetPlotByIndex(iPlotLoop)
        local NEOfRiver = 0
        local WOfRiver = 0
        local NWOfRiver = 0
        if plot:IsNEOfRiver() then NEOfRiver = 1 end -- GetRiverSWFlowDirection()
        if plot:IsWOfRiver() then WOfRiver = 1 end -- GetRiverEFlowDirection()
        if plot:IsNWOfRiver() then NWOfRiver = 1 end -- GetRiverSEFlowDirection()
        print("MapToConvert["..plot:GetX().."]["..plot:GetY().."]={"..plot:GetTerrainType()..","..plot:GetPlotType()..","..plot:GetFeatureType()..","..plot:GetContinentArtType()..",{{"..NEOfRiver..","..plot:GetRiverSWFlowDirection().. "},{"..WOfRiver..","..plot:GetRiverEFlowDirection().."},{"..NWOfRiver..","..plot:GetRiverSEFlowDirection().."}},{"..plot:GetResourceType(-1)..","..plot:GetNumResource().."}}")
    end

--]]

function ImportMap()
    local MapToConvert = GetMap()
    local count = 0
 
    -- Civ5 ENUM
    PLOT_MOUNTAIN = 0
    PLOT_HILLS = 1
 
    -- Civ5 to Civ6
    local FeaturesCiv5toCiv6 = {}
    for i = 0, 24 do FeaturesCiv5toCiv6[i] = g_FEATURE_NONE end
    FeaturesCiv5toCiv6[0]  = g_FEATURE_ICE
    FeaturesCiv5toCiv6[1]  = g_FEATURE_JUNGLE
    FeaturesCiv5toCiv6[2]  = g_FEATURE_MARSH
    FeaturesCiv5toCiv6[3]  = g_FEATURE_OASIS
    FeaturesCiv5toCiv6[4]  = g_FEATURE_FLOODPLAINS
    FeaturesCiv5toCiv6[5]  = g_FEATURE_FOREST
    -- Natural wonders may require a special coding
    FeaturesCiv5toCiv6[10] = g_FEATURE_BARRIER_REEF
    --FeaturesCiv5toCiv6[23] = g_FEATURE_KILIMANJARO
 
    local ResourceCiv5toCiv6 = {}
    for i = 0, 41 do ResourceCiv5toCiv6[i] = -1 end
    ResourceCiv5toCiv6[4]= 40 -- ALUMINUM
    ResourceCiv5toCiv6[10]= 0 -- BANANAS
    ResourceCiv5toCiv6[40]= 16 -- BISON to FURS
    ResourceCiv5toCiv6[7]= 1 -- CATTLE
    ResourceCiv5toCiv6[34]= 10 -- CITRUS
    ResourceCiv5toCiv6[2]= 41 -- COAL
    ResourceCiv5toCiv6[41]= 11 -- COCOA
    ResourceCiv5toCiv6[30]= 2 -- COPPER
    ResourceCiv5toCiv6[25]= 13 -- COTTON
    ResourceCiv5toCiv6[32]= 3 -- CRABS
    ResourceCiv5toCiv6[9]= 4 -- DEER
    ResourceCiv5toCiv6[17]= 14 -- DIAMONDS
    ResourceCiv5toCiv6[21]= 15 -- DYES
    ResourceCiv5toCiv6[11]= 5 -- FISH
    ResourceCiv5toCiv6[20]= 16 -- FURS
    ResourceCiv5toCiv6[15]= 44 -- GOLD to NITER
    ResourceCiv5toCiv6[1]= 42 -- HORSES
    ResourceCiv5toCiv6[27]= 18 -- INCENSE
    ResourceCiv5toCiv6[0]= 43 -- IRON
    ResourceCiv5toCiv6[19]= 19 -- IVORY
    ResourceCiv5toCiv6[28]= 20 -- JADE
    ResourceCiv5toCiv6[18]= 21 -- MARBLE
    ResourceCiv5toCiv6[3]= 45 -- OIL
    ResourceCiv5toCiv6[14]= 23 -- PEARLS
    ResourceCiv5toCiv6[31]= 24 -- SALT
    ResourceCiv5toCiv6[8]= 7 -- SHEEP
    ResourceCiv5toCiv6[23]= 25 -- SILK
    ResourceCiv5toCiv6[16]= 26 -- SILVER
    ResourceCiv5toCiv6[22]= 27 -- SPICES
    ResourceCiv5toCiv6[12]= 8 -- STONE
    ResourceCiv5toCiv6[24]= 28 -- SUGAR
    ResourceCiv5toCiv6[33]= 31 -- TRUFFLES
    ResourceCiv5toCiv6[5]= 46 -- URANIUM
    ResourceCiv5toCiv6[13]= 32 -- WHALES
    ResourceCiv5toCiv6[6]= 9 -- WHEAT
    ResourceCiv5toCiv6[26]= 33 -- WINE
 
    for i = 0, (g_iW * g_iH) - 1, 1 do
        plot = Map.GetPlotByIndex(i)
        print("----------")
        print("Convert plot at "..plot:GetX()..","..plot:GetY())
        -- Map Data
        -- MapToConvert[x][y] = {civ5TerrainType, civ5PlotTypes, civ5FeatureTypes, civ5ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ5ResourceType, num} }
        local civ5TerrainType = MapToConvert[plot:GetX()][plot:GetY()][1]
        local civ5PlotTypes = MapToConvert[plot:GetX()][plot:GetY()][2]
        local civ5FeatureTypes = MapToConvert[plot:GetX()][plot:GetY()][3]
        local civ5ContinentType = MapToConvert[plot:GetX()][plot:GetY()][4]
        local rivers = MapToConvert[plot:GetX()][plot:GetY()][5] -- = {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}
        local resource = MapToConvert[plot:GetX()][plot:GetY()][6] -- = {Civ5ResourceType, num}
     
        -- Set terrain type
        local civ6TerrainType = g_TERRAIN_TYPE_OCEAN    
        if civ5TerrainType == 5 then civ6TerrainType = g_TERRAIN_TYPE_COAST
        elseif civ5TerrainType ~= 6 then
            -- the code below won't work if the order is changed in the terrains table
            -- entrie for civ5 are: 0 = GRASS, 1= PLAINS, ...
            -- entries for civ6 are: 0 = GRASS, 1= GRASS_HILL, 2 = GRASS_MOUNTAIN, 3= PLAINS, 4 = PLAINS_HILL, ...
            civ6TerrainType = civ5TerrainType * 3 -- civ5TerrainType * 3  0-0 1-3 2-6 3-9 4-12
            if civ5PlotTypes == PLOT_HILLS then
                civ6TerrainType = civ6TerrainType + g_TERRAIN_BASE_TO_HILLS_DELTA
            elseif civ5PlotTypes == PLOT_MOUNTAIN then
                civ6TerrainType = civ6TerrainType + g_TERRAIN_BASE_TO_MOUNTAIN_DELTA
            end
        end
        print(" - Set Terrain Type = "..tostring(GameInfo.Terrains[civ6TerrainType].TerrainType))
        count = count + 1
        TerrainBuilder.SetTerrainType(plot, civ6TerrainType)
     
        -- Set rivers
        if rivers[1][1] == 1 then -- IsNEOfRiver
            TerrainBuilder.SetNEOfRiver(plot, true, rivers[1][2])
            print(" - Set is NE of river, flow = "..tostring(rivers[1][2]))
        end
        if rivers[2][1] == 1 then -- IsWOfRiver
            TerrainBuilder.SetWOfRiver(plot, true, rivers[2][2])
            print(" - Set is W of river, flow = "..tostring(rivers[2][2]))
        end
        if rivers[3][1] == 1 then -- IsNWOfRiver
            TerrainBuilder.SetNWOfRiver(plot, true, rivers[3][2])
            print(" - Set is NW of river, flow = "..tostring(rivers[3][2]))
        end
     
        -- Set Features
        if civ5FeatureTypes ~= -1 and FeaturesCiv5toCiv6[civ5FeatureTypes] ~= g_FEATURE_NONE then    
            print(" - Set Feature Type = "..tostring(GameInfo.Features[FeaturesCiv5toCiv6[civ5FeatureTypes]].FeatureType))
            TerrainBuilder.SetFeatureType(plot, FeaturesCiv5toCiv6[civ5FeatureTypes])
        end
     
        -- Set Resources
        if resource[1] ~= -1 and ResourceCiv5toCiv6[resource[1]] ~= -1 then    
            print(" - Set Resource Type = "..tostring(GameInfo.Resources[ResourceCiv5toCiv6[resource[1]]].ResourceType))
            ResourceBuilder.SetResourceType(plot, ResourceCiv5toCiv6[resource[1]], resource[2])
        end
     
    end
    print(" Placed terrain on "..tostring(count) .. " tiles")
end

function GetMap()

    local MapToConvert = {}
    for i = 0, g_iW - 1, 1 do
        MapToConvert[i] = {}
    end
 
    -- Map Data
    -- MapToConvert[x][y] = {civ5TerrainType, civ5PlotTypes, civ5FeatureTypes, civ5ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ5ResourceType, num} }
 
 MapToConvert[0][0]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[1][0]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[2][0]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[3][0]={4,1,-1,3,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[4][0]={5,3,0,0,{{0,-1},{0,-1},{0,-1}},{-1,0}}

 -- of course there will be a lot more lines here...

 MapToConvert[176][93]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[177][93]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[178][93]={5,3,0,4,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 MapToConvert[179][93]={4,0,-1,1,{{0,-1},{0,-1},{0,-1}},{-1,0}}
 

 
    return MapToConvert
end

Note that some line are commented out, like

PHP:
    --AddRivers();
 
    --AddFeatures();

You may reactivate them by removing the "--" at the beginning, it's
very important for resources:
PHP:
ResourceGenerator.Create(args)

because if your imported map doesn't have any, the game won't find starting positions for the civilizations.

There are also 3 mandatory things to change in this file:

The Width and Height here: (and maybe WrapX for an regional map)
PHP:
function GetMapInitData(worldSize)
    return {
        Width = 180,
        Height = 94,
        WrapX = true,
        WrapY = false,
    };  
end

and here
PHP:
    -- Set globals
    g_iW, g_iH = 180, 94;
    g_iFlags = TerrainBuilder.GetFractalFlags();

to match your map size.

and of course all the
PHP:
 MapToConvert[179][93]={4,0,-1,1,{{0,-1},{0,-1},{0,-1}},{-1,0}}

lines at the end of the file (but do not overwrite the 2 final lines !)

Now to get the MapToConvert data, use this code in civ5 (in firetuner for example)
PHP:
    for iPlotLoop = 0, Map.GetNumPlots()-1, 1 do
        local plot = Map.GetPlotByIndex(iPlotLoop)
        local NEOfRiver = 0
        local WOfRiver = 0
        local NWOfRiver = 0
        if plot:IsNEOfRiver() then NEOfRiver = 1 end -- GetRiverSWFlowDirection()
        if plot:IsWOfRiver() then WOfRiver = 1 end -- GetRiverEFlowDirection()
        if plot:IsNWOfRiver() then NWOfRiver = 1 end -- GetRiverSEFlowDirection()
        print("MapToConvert["..plot:GetX().."]["..plot:GetY().."]={"..plot:GetTerrainType()..","..plot:GetPlotType()..","..plot:GetFeatureType()..","..plot:GetContinentArtType()..",{{"..NEOfRiver..","..plot:GetRiverSWFlowDirection().. "},{"..WOfRiver..","..plot:GetRiverEFlowDirection().."},{"..NWOfRiver..","..plot:GetRiverSEFlowDirection().."}},{"..plot:GetResourceType(-1)..","..plot:GetNumResource().."}}")
    end
and then copy/paste in YourMap.Lua all the "MapToConvert" lines from the lua.log (removing the "[760818.859] InGame: " part, using a good file editor like Notepad++ because of the size of the text (use shift+alt to select the part to cut)




Hi, I've done a small map of earth, with TSL and resources...very little....my pc is not so cool :(...but it crash if I load that maps with TZmod....
you can see here https://www.dropbox.com/s/6b0rxad131q31km/74x46world_8_12_v16pippolo.Civ6Map?dl=0
So....I'll be very happy if I could obtain maptoconvert data...to try to run the map in lua mod (and no via TZ mod)...perhaps so it doesnt crash....
I'm not able to obtain with firetuner...nothing happens in lua.log.....
Can you help me and explain a little more how to use firetuner to obtain maptoconvert data maps from worldbuilder in civ6?
Thank you thank you thank you:)
 
I've been trying to figure out how to create custom maps on Civ 6, and trying to figure out how to convert Civ5maps into Lua map scripts. I too had the same problem you had, Pippolo, in trying to get Gedemon's LUA command to bring up the MapToConvert data. But I found out how. When you have the Firetuner LUA console open, and your map open in Civ5, go to the Maps tab in Firetuner. Right click in an open space, and add New Action Control. Once you have that open, Name it anything you want (it doesnt matter as far as I know), then Copy Gedemon's MapToConvert code. After that, you want to Paste the code in the Action Box. You do that by clicking in the Action text box, then press CTRL+V on your keyboard. The code should paste into the Action Text box. Press Okay, and go back to the tab labeled Lua Console, and there you should see all the MapToConvert data you need for your Civ6 Lua script. As of this moment, I haven't been able to get the Lua map to load in Civ6 without crashing, but being able to get the MapToConvert data is a big step in the right direction. If you need me to clarify anything just let me know and I'll try to help.
 
I've been trying to figure out how to create custom maps on Civ 6, and trying to figure out how to convert Civ5maps into Lua map scripts. I too had the same problem you had, Pippolo, in trying to get Gedemon's LUA command to bring up the MapToConvert data. But I found out how. When you have the Firetuner LUA console open, and your map open in Civ5, go to the Maps tab in Firetuner. Right click in an open space, and add New Action Control. Once you have that open, Name it anything you want (it doesnt matter as far as I know), then Copy Gedemon's MapToConvert code. After that, you want to Paste the code in the Action Box. You do that by clicking in the Action text box, then press CTRL+V on your keyboard. The code should paste into the Action Text box. Press Okay, and go back to the tab labeled Lua Console, and there you should see all the MapToConvert data you need for your Civ6 Lua script. As of this moment, I haven't been able to get the Lua map to load in Civ6 without crashing, but being able to get the MapToConvert data is a big step in the right direction. If you need me to clarify anything just let me know and I'll try to help.

Hallo P-Dubya,
Thanks a lot for your message and your help.
My problem is to extract FULL maptoconvert data from Civ6 world builder.
I launch Firetuner and Civ6WorldBuilder, then with Gedemon's script

local iPlotCount = Map.GetPlotCount();
for iPlotLoop = 0, iPlotCount-1, 1 do
local bData = false
local plot = Map.GetPlotByIndex(iPlotLoop)
local NEOfCliff = 0
local WOfCliff = 0
local NWOfCliff = 0
if plot:IsNEOfCliff() then NEOfCliff = 1 end
if plot:IsWOfCliff() then WOfCliff = 1 end
if plot:IsNWOfCliff() then NWOfCliff = 1 end
local NEOfRiver = 0
local WOfRiver = 0
local NWOfRiver = 0
if plot:IsNEOfRiver() then NEOfRiver = 1 end -- GetRiverSWFlowDirection()
if plot:IsWOfRiver() then WOfRiver = 1 end -- GetRiverEFlowDirection()
if plot:IsNWOfRiver() then NWOfRiver = 1 end -- GetRiverSEFlowDirection()
print("MapToConvert["..plot:GetX().."]["..plot:GetY().."]={"..plot:GetTerrainType()..","..plot:GetFeatureType()..","..plot:GetContinentType()..",{{"..NEOfRiver..","..plot:GetRiverSWFlowDirection().. "},{"..WOfRiver..","..plot:GetRiverEFlowDirection().."},{"..NWOfRiver..","..plot:GetRiverSEFlowDirection().."}},{"..plot:GetResourceType(-1)..","..tostring(1).."},{"..NEOfCliff..","..WOfCliff..","..NWOfCliff.."}}")
end


in Lua console I can extract datas but system don't output rivers' directions and cliffs.
Can you help me?

I see in your post that you extract from civ5.
Do you launch firetuner and then worldbuilder civ5?
In my case it seems firetuner doesn't link to civ5worldbuilder....so nothing outputs with gedemon's civ5script extract. Nothing runs in Firetuner.
Can you help me?

Merry xmas.... :)
pippolo
 
Hallo P-Dubya,
Thanks a lot for your message and your help.
My problem is to extract FULL maptoconvert data from Civ6 world builder.
I launch Firetuner and Civ6WorldBuilder, then with Gedemon's script

local iPlotCount = Map.GetPlotCount();
for iPlotLoop = 0, iPlotCount-1, 1 do
local bData = false
local plot = Map.GetPlotByIndex(iPlotLoop)
local NEOfCliff = 0
local WOfCliff = 0
local NWOfCliff = 0
if plot:IsNEOfCliff() then NEOfCliff = 1 end
if plot:IsWOfCliff() then WOfCliff = 1 end
if plot:IsNWOfCliff() then NWOfCliff = 1 end
local NEOfRiver = 0
local WOfRiver = 0
local NWOfRiver = 0
if plot:IsNEOfRiver() then NEOfRiver = 1 end -- GetRiverSWFlowDirection()
if plot:IsWOfRiver() then WOfRiver = 1 end -- GetRiverEFlowDirection()
if plot:IsNWOfRiver() then NWOfRiver = 1 end -- GetRiverSEFlowDirection()
print("MapToConvert["..plot:GetX().."]["..plot:GetY().."]={"..plot:GetTerrainType()..","..plot:GetFeatureType()..","..plot:GetContinentType()..",{{"..NEOfRiver..","..plot:GetRiverSWFlowDirection().. "},{"..WOfRiver..","..plot:GetRiverEFlowDirection().."},{"..NWOfRiver..","..plot:GetRiverSEFlowDirection().."}},{"..plot:GetResourceType(-1)..","..tostring(1).."},{"..NEOfCliff..","..WOfCliff..","..NWOfCliff.."}}")
end


in Lua console I can extract datas but system don't output rivers' directions and cliffs.
Can you help me?

I see in your post that you extract from civ5.
Do you launch firetuner and then worldbuilder civ5?
In my case it seems firetuner doesn't link to civ5worldbuilder....so nothing outputs with gedemon's civ5script extract. Nothing runs in Firetuner.
Can you help me?

Merry xmas.... :)
pippolo
From civ6 you must use the code from a script context (ie not any InGame context, add a panel with GameCore_Tuner checked), I use this code to export:
Code:
    local iPlotCount = Map.GetPlotCount();
    for iPlotLoop = 0, iPlotCount-1, 1 do
        local bData = false
        local plot = Map.GetPlotByIndex(iPlotLoop)
        local NEOfCliff = 0
        local WOfCliff = 0
        local NWOfCliff = 0
        if plot:IsNEOfCliff() then NEOfCliff = 1 end
        if plot:IsWOfCliff() then WOfCliff = 1 end
        if plot:IsNWOfCliff() then NWOfCliff = 1 end
        local NEOfRiver = 0
        local WOfRiver = 0
        local NWOfRiver = 0
        if plot:IsNEOfRiver() then NEOfRiver = 1 end -- GetRiverSWFlowDirection()
        if plot:IsWOfRiver() then WOfRiver = 1 end -- GetRiverEFlowDirection()
        if plot:IsNWOfRiver() then NWOfRiver = 1 end -- GetRiverSEFlowDirection()
        print("MapToConvert["..plot:GetX().."]["..plot:GetY().."]={"..plot:GetTerrainType()..","..plot:GetFeatureType()..","..plot:GetContinentType()..",{{"..NEOfRiver..","..plot:GetRiverSWFlowDirection().. "},{"..WOfRiver..","..plot:GetRiverEFlowDirection().."},{"..NWOfRiver..","..plot:GetRiverSEFlowDirection().."}},{"..plot:GetResourceType(-1)..","..tostring(1).."},{"..NEOfCliff..","..WOfCliff..","..NWOfCliff.."}}")
    end

and this code to import:
Code:
function ImportCiv6Map(MapToConvert, g_iW, g_iH, bDoTerrains, bImportRivers, bImportFeatures, bImportResources, bImportContinents)
    print("Importing Civ6 Map ( Terrain = "..tostring(bDoTerrains)..", Rivers = "..tostring(bImportRivers)..", Features = "..tostring(bImportFeatures)..", Resources = "..tostring(bImportResources)..", Continents = "..tostring(bImportContinents)..")")
    local count = 0
       
    bOutput = false
    for i = 0, (g_iW * g_iH) - 1, 1 do
        plot = Map.GetPlotByIndex(i)
        if bOutput then
            print("----------")
            print("Convert plot at "..plot:GetX()..","..plot:GetY())
        end
        -- Map Data
        -- MapToConvert[x][y] = {civ6TerrainType, civ6FeatureType, civ6ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ6ResourceType, num} }
        local civ6TerrainType = MapToConvert[plot:GetX()][plot:GetY()][1]
        local civ6FeatureType = MapToConvert[plot:GetX()][plot:GetY()][2]
        local civ6ContinentType = MapToConvert[plot:GetX()][plot:GetY()][3]
        local Rivers = MapToConvert[plot:GetX()][plot:GetY()][4] -- = {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}
        local resource = MapToConvert[plot:GetX()][plot:GetY()][5] -- = {Civ6ResourceType, num}
        local Cliffs =  MapToConvert[plot:GetX()][plot:GetY()][6] -- {IsNEOfCliff,IsWOfCliff,IsNWOfCliff}
       
        -- Set terrain type
        if bDoTerrains then
            if bOutput then print(" - Set Terrain Type = "..tostring(GameInfo.Terrains[civ6TerrainType].TerrainType)) end
            count = count + 1
            TerrainBuilder.SetTerrainType(plot, civ6TerrainType)
        end
       
        -- Set Rivers
        if bImportRivers then
            if Rivers[1][1] == 1 then -- IsNEOfRiver
                TerrainBuilder.SetNEOfRiver(plot, true, Rivers[1][2])
                if bOutput then print(" - Set is NE of River, flow = "..tostring(Rivers[1][2])) end
            end
            if Rivers[2][1] == 1 then -- IsWOfRiver
                TerrainBuilder.SetWOfRiver(plot, true, Rivers[2][2])
                if bOutput then print(" - Set is W of River, flow = "..tostring(Rivers[2][2])) end
            end
            if Rivers[3][1] == 1 then -- IsNWOfRiver
                TerrainBuilder.SetNWOfRiver(plot, true, Rivers[3][2])
                if bOutput then print(" - Set is NW of River, flow = "..tostring(Rivers[3][2])) end
            end
        end
       
        -- Set Features
        if bImportFeatures then
            if civ6FeatureType ~= g_FEATURE_NONE and civ6FeatureType < GameInfo.Features["FEATURE_BARRIER_REEF"].Index then -- Do not import Natural Wonder here !
                if bOutput then print(" - Set Feature Type = "..tostring(GameInfo.Features[civ6FeatureType].FeatureType)) end
                TerrainBuilder.SetFeatureType(plot, civ6FeatureType)
            end
        end
       
        -- Set Continent
        if bImportContinents then
            if civ6ContinentType ~= -1 then      
                if bOutput then print(" - Set Continent Type = "..tostring(GameInfo.Continents[civ6ContinentType].ContinentType)) end
                TerrainBuilder.SetContinentType(plot, civ6ContinentType)
            end
        end
       
        -- Set Resources
        if bImportResources and not plot:IsNaturalWonder() then
            if resource[1] ~= -1 then      
                if bOutput then print(" - Set Resource Type = "..tostring(GameInfo.Resources[resource[1]].ResourceType)) end
                --ResourceBuilder.SetResourceType(plot, ResourceCiv5toCiv6[resource[1]], resource[2]) -- maybe an option to import number of resources on one plot even if civ6 use 1 ?
                ResourceBuilder.SetResourceType(plot, resource[1], 1)
            end
        end
       
        -- Set Cliffs
        if Cliffs then
            if Cliffs[1] == 1 then -- IsNEOfCliff
                TerrainBuilder.SetNEOfCliff(plot, true)
                if bOutput then print(" - Set is NE of Cliff") end
            end
            if Cliffs[2] == 1 then -- IsWOfCliff
                TerrainBuilder.SetWOfCliff(plot, true)
                if bOutput then print(" - Set is W of Cliff") end
            end
            if Cliffs[3] == 1 then -- IsNWOfCliff
                TerrainBuilder.SetNWOfCliff(plot, true)
                if bOutput then print(" - Set is NW of Cliff") end
            end  
        end
       
    end  
   
    print("Placed terrain on "..tostring(count) .. " tiles")
end

See also the map file in YnAMP that call GenerateImportedMap (then do multiple pass with ImportCiv6Map as the order in important for placement of various things) in the override of AssignStartingPlots.lua

It's a bit complex, but I don't really have time to rewrite or document it. And to be honest I would have never thought that we'll still be without a real worldbuilder today...

Edit: but I'm trying to provide a mod to use as an example for external map script using YnAMP to load
 
Hello everyone

Anyone else bothered by the fact that sources of rivers DO NOT give fresh water bonus?

The river originating from a source DOES give the bonus, but ONLY to the 2 adjacent tiles.
The remaining third tile that's adjacent to the river's source, but not next to the actual river, DOES NOT receive fresh water.

Advice on how to fix this would be much appreciated!
 
Thanks for this. I hope to get this to load up the eastern united states map from civ4 which I have already ported to civ5 long time ago (it is in the downloads) wish me luck!
 
Top Bottom