Map areas

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
Running Live Tuner with a Tiny Continents map:

for area in Map.Areas() do print(area) end

--this prints integers 1 through 29 (not area objects as I expected)

for iPlot = 0, Map.GetNumPlots() - 1 do print(Map.GetPlotByIndex(iPlot):GetArea()) end

--this prints integers too, but they are like 573441, 688143, 745494, etc. They print out in a clustered way that makes me think they do correspond to different areas.

So my conclusion is: don't use Map.Areas() as an iterator to get areas or iAreas.

A few questions though:
  1. Can I get a list of actual iAreas without iterating over all plots? (Not a big problem)
  2. Do areas change during a game?
  3. It seems that all plots belong to an area (GetArea() returns some integer). Do islands get put in their own area, in an "ocean area", or are they put with a nearby continental area?
 
  1. Can I get a list of actual iAreas without iterating over all plots? (Not a big problem)
  2. Do areas change during a game?
  3. It seems that all plots belong to an area (GetArea() returns some integer). Do islands get put in their own area, in an "ocean area", or are they put with a nearby continental area?


1) From WorldBuilderRandomItems.lua

Code:
for id, area in Map.Areas() do

(so a non-standard approach to the iterator)

2) No, or the Polynesia scenario code won't work

Code:
local adjacentAreaID = adjacentPlot:GetArea();
local iTargetArea = savedData.GetValue("HawaiiArea");
if (iTargetArea == adjacentAreaID) then

3) From MapGenerator.lua

Code:
-- Don't allow on tiny islands.
local areaID = plot:GetArea();
local area = Map.GetArea(areaID);
local numTiles = area:GetNumTiles();
if (numTiles < 3) then
  return false;
end

So it would appear each island is its own area
 
About 2/, it would be interesting to check if Map:RecalculateAreas() changes the number/IDs of area after changing an ocean plot to a single island for example.
 
About 2/, it would be interesting to check if Map:RecalculateAreas() changes the number/IDs of area after changing an ocean plot to a single island for example.

Both are changed.

The island is inserted into the middle of the list, and all the ids change

Code:
 WorldView: 30	1007645	6		 WorldView: 30	1441821	6
 WorldView: 31	1015838	1		 WorldView: 31	1450014	1
 WorldView: 32	1024031	1		 WorldView: 32	1458207	1
 WorldView: 33	1032224	37		 WorldView: 33	1466400	1
 WorldView: 34	1040417	1		 WorldView: 34	1474593	37
 
Thanks, that's good to know (in case we can change terrain type without needing to reload the game I mean...)
 
Back
Top Bottom