Cladoniaceae
Chieftain
- Joined
- Feb 25, 2017
- Messages
- 12
I'm trying to write a Lua script that will place a certain dummy building only in cities on or near Tundra when they are built, with the ultimate goal of making a National Wonder that requires all cities to be built on or near Tundra. What I have right now is based on a couple of examples put together, but it's not working. Any ideas what I'm doing wrong?
Code:
local DummyB = GameInfoTypes.BUILDING_DUMMY_TURF_HALL_REQ
GameEvents.PlayerCityFounded.Add(function(iPlayer, iCityX, iCityY)
local kplot = Map.GetPlot(iCityX, iCityY);
local kCity = kplot:GetPlotCity();
CheckNewCityTundra(kCity, true)
end)
function CheckNewCityTundra(iPlayer)
local pPlayer = Players[iPlayer]
for i = 0, kCity:GetNumCityPlots() - 1, 1 do
local pPlot = kCity:GetCityIndexPlot(i)
if pPlot:GetTerrainType() == TerrainTypes.TERRAIN_TUNDRA then
kCity:SetNumRealBuilding(DummyB, 1);
else
kCity:SetNumRealBuilding(DummyB, 0);
end
end
end
end