Sarin
Deity
- Joined
- Aug 18, 2013
- Messages
- 2,492
So, I'm trying to advance from a simple consumer to someone tinkering with mods. Right now, I'm trying to modify a map script (Planet Generator) to create 2 tile wide coasts.
I looked through script and looks to me that this is the part that needs change:
From what I can read, this generates 1 tile wide coasts, and if expanding coasts is enabled (no idea where that comes from though), each ocean tile bordering coastal one gets 1/4 chance of being turned into coast during each of two checks.
Now I'd like to change it to generate 2 tile wide coasts while keeping the expanding coasts part intact. Any idea how to do it? I'm quite at loss.
I looked through script and looks to me that this is the part that needs change:
Code:
function GenerateCoasts(args)
print("Setting coasts and oceans - Planet Simulator");
local args = args or {};
local bExpandCoasts = args.bExpandCoasts or true;
local expansion_diceroll_table = args.expansion_diceroll_table or {4, 4};
local shallowWater = GameDefines.SHALLOW_WATER_TERRAIN;
local deepWater = GameDefines.DEEP_WATER_TERRAIN;
for i, plot in Plots() do
if(plot:IsWater()) then
if(plot:IsAdjacentToLand()) then
plot:SetTerrainType(shallowWater, false, false);
else
plot:SetTerrainType(deepWater, false, false);
end
end
end
if bExpandCoasts == false then
return
end
-- print("Expanding coasts (MapGenerator.Lua)");
for loop, iExpansionDiceroll in ipairs(expansion_diceroll_table) do
local shallowWaterPlots = {};
for i, plot in Plots() do
if(plot:GetTerrainType() == deepWater) then
-- Chance for each eligible plot to become an expansion is 1 / iExpansionDiceroll.
-- Default is two passes at 1/4 chance per eligible plot on each pass.
if(plot:IsAdjacentToShallowWater() and PWRandInt(0, iExpansionDiceroll) == 0) then
table.insert(shallowWaterPlots, plot);
-- plot:SetTerrainType(shallowWater, false, false);
end
end
end
for i, plot in ipairs(shallowWaterPlots) do
plot:SetTerrainType(shallowWater, false, false);
end
end
end
From what I can read, this generates 1 tile wide coasts, and if expanding coasts is enabled (no idea where that comes from though), each ocean tile bordering coastal one gets 1/4 chance of being turned into coast during each of two checks.
Now I'd like to change it to generate 2 tile wide coasts while keeping the expanding coasts part intact. Any idea how to do it? I'm quite at loss.