MapTile¶
A MapTile is one map tile. Get one with GetMapTile(x, y),
GetAllMapTiles() or object:GetCurrentMapTile().
local tile = GetMapTile(40, 52)
if tile and tile:GetTerrain() == Terrain.WATER then
LogInfo("water at", tile:GetPosition().x, tile:GetPosition().y)
end
Calling a method on something that is not a MapTile raises a Lua error.
IsBuildable() exists but is not implemented.
Pitfalls¶
IsNavigatable()andIsWalkable()readfalseon plain, visible land. To test terrain, useGetPlacementTile(x, y): terrain flag8is water and its pathing flags mark blocked tiles. To test reachability, useCanReachPointorobject:GetNativeZoneAt.- A large building is registered on every tile it covers, so it counts on each.
GetObjects()includes enemies in fog. Checkobject:IsVisible()when your script must only use what the player can see.
The visibility mask¶
By default a tile the assigned player has never explored hides its contents:
GetTerrain() returns -1, GetElevation() 0, IsNavigatable() false,
GetObjectCount() 0 and GetObjects() an empty array. GetPosition(),
GetTileVisibility() and IsForestTerrain() are never masked.
The mask is a shared setting. Turn it off only when your script is meant to see the whole map, because it changes every script:
Settings.Module("MapTile"):SetBool("UseVisibilityMask", false)
GetPlacementTile and the placement checks never apply the mask.