Vilde321
Chieftain
- Joined
- Jul 15, 2015
- Messages
- 3
Hey! Firstly I'm sorry if this isnt supposed to be here, but I figured since it's LUA it propably should be here!!
I am completely new at map scripting, and I have done some sort of script (by copy pasting and looking at other people's scripts), where there are only basic settings enabled like "Tectonic islands", "Continent Grain" and so on..
What I really want is more islands, and I really cannot find a way to do that by myself (been looking for so long to find a solution but I just cannot understand anything and cannot find proper tutorials for this) ..
So basically, is there any way for making the map generator generate more islands for my map? (and possibly any tutorial that I've missed? Im willing to learn..) Or just making my continents have more coast? These are the major things I really wish to have in my script, since I love coastal maps with islands that still have enough ocean to make it interesting and make people isolated for the early game..
Also any info on Player starts? possible to make it so all players start on their own continent..?
I'm really sorry if someone didn't get my points or if I'm just being an idiot here, I just really wish someone could help me
My whole script is here, please don't laugh at it... atleast not too much ;__;
I am completely new at map scripting, and I have done some sort of script (by copy pasting and looking at other people's scripts), where there are only basic settings enabled like "Tectonic islands", "Continent Grain" and so on..
What I really want is more islands, and I really cannot find a way to do that by myself (been looking for so long to find a solution but I just cannot understand anything and cannot find proper tutorials for this) ..
So basically, is there any way for making the map generator generate more islands for my map? (and possibly any tutorial that I've missed? Im willing to learn..) Or just making my continents have more coast? These are the major things I really wish to have in my script, since I love coastal maps with islands that still have enough ocean to make it interesting and make people isolated for the early game..
Also any info on Player starts? possible to make it so all players start on their own continent..?
I'm really sorry if someone didn't get my points or if I'm just being an idiot here, I just really wish someone could help me

My whole script is here, please don't laugh at it... atleast not too much ;__;
Code:
-- Joojoo
-- Author: Vilde321
-- Original Author: Jamie McQueen (Skweetis) (thanks a lot for this it helped a lot!!)
-- DateCreated: 7/16/2016 3:33:39 AM
--------------------------------------------------------------
include("MapGenerator");
include("FractalWorld");
include("FeatureGenerator");
include("TerrainGenerator");
------------------------------------------------------------------------------
function GetMapScriptInfo()
local world_age, temperature, rainfall, sea_level, resources = GetCoreMapOptions()
return {
Name = "Joojoo",
Description = "Eetun seksiunelma.",
IsAdvancedMap = 0,
SupportsMultiplayer = true,
IconIndex = 1,
SortIndex = 1,
CustomOptions = {world_age, temperature, rainfall, sea_level, resources,
{
Name = "Continent Grain", -- Map.GetCustomOption(6) <<I do this only for reference to help remember what Option Pulldown information I am getting when putting in a variable (see next function)
Values = { -- play and see! basically smaller values make larger continents or a pangaea, larger will result in scattered islands.
"2,8", -- DefaultValue means this will be the first option displayed. Index (count) starts at 1 and counts up for each entry. Text is only used in pull down. Script takes index only.
"2,9", -- index value 2
"3",
"3,1",
"3,2",
"3,3",
"TXT_KEY_MAP_OPTION_RANDOM"
},
DefaultValue = 3, -- which index position will be displayed by default in pulldown.
SortPriority = 1, -- which order this option pulldown will be displayed.
},
{
Name = "Center Rift?", -- Map.GetCustomOption(7)
Values = { -- puts an ocean rift on the map to difinitively split continents apart. Essentially creates at least two separate land masses.
"No", -- Default
"Yes",
"TXT_KEY_MAP_OPTION_RANDOM"
},
DefaultValue = 2,
SortPriority = 2,
},
{
Name = "Rift Grain", -- Map.GetCustomOption(8)
Values = {-- -1 is Default no rifts. Set grain to between 1 and 3 to add rifts. - Bob(FractalWorld.lua)
"-1", -- Default
"1",
"2",
"4",
"6",
"TXT_KEY_MAP_OPTION_RANDOM"-- Default
},
DefaultValue = 1,
SortPriority = 3,
},
{
Name = "Has Tectonic Islands?", -- Map.GetCustomOption(9)
Values = {-- Build islands in oceans along tectonic ridge lines - Brian(FractalWorlds.lua)
"No", -- Default
"Yes",
"TXT_KEY_MAP_OPTION_RANDOM"
},
DefaultValue = 1,
SortPriority = 4,
},
{
Name = "Adjust Plates", -- Map.GetCustomOption(12)
Values = {
"0", -- Default
"1",
"1.5",
"3",
"TXT_KEY_MAP_OPTION_RANDOM"
},
DefaultValue = 1,
SortPriority = 7,
},
{
Name = "Player Distribution",-- Map.GetCustomOption(13)
Values = {
"Old World",
"Continental",
"Map Rectangle",
"TXT_KEY_MAP_OPTION_RANDOM"-- DefaultValue = 4,
},
DefaultValue = 4,
SortPriority = 8
},
};
};
end
function GeneratePlotTypes()
print("Generating Plot Types (Lua Worlds Unlimited) ..."); -- these statements only printout in the log. Useful for debugging, gives you a reference point when (and it will) your script blows up in the builder. Last print you see, gives you an idea where to look in your script.
-- collect user options and put them in a variable. I do it this way, there are many other methods, likely better coding practice, but
-- I found this way easier to follow while learning. The index of the option selected above is what we pass to the variable so we can do
-- stuff with it.
local sea_level = Map.GetCustomOption(4) -- my translation: "make me a container called sea_level and put the value the Map Option
local world_age = Map.GetCustomOption(1)
local continent_grain = Map.GetCustomOption(6) --this is the first custom option in the above function.
local rift_bool = Map.GetCustomOption(7) -- bool is short for boolean (true or false) Im in the habit of getting the numerical value, and turn it in to actual true or false after.
local rift_grain = Map.GetCustomOption(8)
local islands_bool = Map.GetCustomOption(9)
local adjust_plates = Map.GetCustomOption(12)
--default to false, I find it good practice to always 'initialise' your variables (ie, make sure they = something). I can't remember why though I'm sure there is a good reason! The pros always seem to do it!
local has_center_rift = false;
local tectonic_islands = false;
local polar = false;
-- calculate random selections, and modify any values
if sea_level == 4 then -- user selected random, so we are going to select from one of the other options in the list. Remember, we use the pulldown option index value, the text in quotes means nothing to the script.
sea_level = 1 + Map.Rand(3, "Random Sea Level - Lua"); -- this one is a bit longer to explain. try and take a good look at it and see if you can figure out and understand what is happening here (a good habit and skill to practice, imo) if not, make sure you take a peak at one of the tutorial's for Civ5 Map scripting out there.
end
print("DEBUG - Sea Level: ", sea_level); -- we want to see what was picked, this desplays it in the log. notice how it is written, recognise anything familiar?
if world_age == 4 then -- always always always try to remember to make sure you use two == when doing an 'if' evaluation. pain in the ass to find when you have a big script and cant find out why it isn't working!
world_age = 1 + Map.Rand(3, "Random World Age - Lua");
end
print("DEBUG - World Age: ", world_age);
if continent_grain == 7 then
continent_grain = 1 + Map.Rand(6, "Random Continent Grain - Lua");
end
print("DEBUG - Continent Grain: ", continent_grain);
if rift_bool == 3 then
rift_bool = 1 + Map.Rand(2, "Random Has Rift - Lua"); -- don't add 1, this is boolean.
end
if rift_bool == 2 then
has_center_rift = true; -- remember we initialised this to false above? well if it isn't random, and they didn't pick the first option (which would be false, and this variable is already set to false) the only option they have left is 2, which translates to true.
end
print("DEBUG - Has Center Rift: ", has_center_rift);
if rift_grain == 4 then
rift_grain = Map.Rand(3, "Random Continent Grain - Lua"); -- no need to add 1, because randomising resets the index start count to 0, and the value we need from this option is 0.
else
rift_grain = rift_grain - 1-- we still need that value to be 0, so if random was not selected, the index count would be 1 if the user selected the first value, and we need 0 for this option, so lets take one away from that value.
end
if rift_grain < 1 then -- only do this if the value is 0 or less
rift_grain = -1; -- we needed the 0, but it is not a valid option, and the first for this list is -1, so this here turns that 0 we can't use into a zero we can.
end
print("DEBUG - Rift Grain: ", rift_grain);
if islands_bool == 3 then
islands_bool = 1 + Map.Rand(2, "Random Tectonic Islands - Lua");
end
if islands_bool == 2 then
tectonic_islands = true;
end
print("DEBUG - Tectonic Islands: ", tectonic_islands);
if adjust_plates == 5 then
adjust_plates = 1 + Map.Rand(4, "Random Adjust Plates - Lua");
end
if adjust_plates == 1 then
adjust_plates = 0;
elseif adjust_plates == 2 then
adjust_plates = 1;
elseif adjust_plates == 3 then
adjust_plates = 1.5;
elseif adjust_plates == 4 then
adjust_plates = 3;
end
print("DEBUG - Adjust Plates: ", adjust_plates);
local fractal_world = FractalWorld.Create(); -- the way I undertand it, this gets the code from the Create() function in the file FractalWorld, the . is the separator, and it gets stored in our variable called fractal_world which we will use below. It may just be that its easier to type fractal_world than FractalWorld.Create() repeatedly... either way we are calling a function from another file we included at the top of our script.
fractal_world:InitFractal{ -- passing all the values between the braces, each variable separated by commas. the duplicate names may be redundant, but it makes it quicker to play change the value of any of those variables.
continent_grain = continent_grain,
rift_grain = rift_grain,
has_center_rift = has_center_rift,
};
local args = {
sea_level = sea_level,
world_age = world_age,
sea_level_low = 80,
sea_level_normal = 84,
sea_level_high = 87,
adjust_plates = adjust_plates,
has_center_rift = has_center_rift,
tectonic_islands = tectonic_islands,
};
local plotTypes = fractal_world:GeneratePlotTypes(args);
SetPlotTypes(plotTypes);
GenerateCoasts();
end
------------------------------------------------------------------------------
function GenerateTerrain()
print("Generating Terrain (Lua Worlds Unlimited) ...");
-- Get Temperature setting input by user.
local temp = Map.GetCustomOption(2)
if temp == 4 then
temp = 1 + Map.Rand(3, "Random Temperature");
end
local args = {temperature = temp};
local terraingen = TerrainGenerator.Create(args);
terrainTypes = terraingen:GenerateTerrain();
SetTerrainTypes(terrainTypes);
end
------------------------------------------------------------------------------
function AddFeatures()
print("Adding Features (Lua Worlds Unlimited) ...");
-- Get Rainfall setting input by user.
local rain = Map.GetCustomOption(3)
if rain == 4 then
rain = 1 + Map.Rand(3, "Random Rainfall - Lua");
end
local args = {rainfall = rain}
local featuregen = FeatureGenerator.Create(args);
-- False parameter removes mountains from coastlines.
featuregen:AddFeatures();
end
------------------------------------------------------------------------------
function StartPlotSystem()
-- Get Resources setting input by user.
local res = Map.GetCustomOption(5)
local start_method = Map.GetCustomOption(13)
if res == 6 then
res = 1 + Map.Rand(3, "Random Resources Option");
end
if start_method == 4 then
start_method = 1 + Map.Rand(3, "Random Player Distribution");
end
print("Creating start plot database.");
local start_plot_database = AssignStartingPlots.Create()
print("Dividing the map in to Regions.");
local args = {method = 3};
start_plot_database:GenerateRegions(args)
print("Choosing start locations for civilizations.");
start_plot_database:ChooseLocations()
print("Normalizing start locations and assigning them to Players.");
start_plot_database:BalanceAndAssign()
print("Placing Natural Wonders.");
start_plot_database:PlaceNaturalWonders()
print("Placing Resources and City States.");
start_plot_database:PlaceResourcesAndCityStates()
end