Looking through all city plots and placing an improvement

turingmachine

Emperor
Joined
May 4, 2008
Messages
1,438
Hi, so my goal is to look through all the plots in a city's three ring radius, find if one or more plots has a specific feature, then I do a specific event on that feature plot.

I was trying something like:

Code:
for i = 0, pCity:GetNumCityPlots() - 1, 1 do
  local plot = pCity:GetCityIndexPlot( i )
  if plot:GetFeatureType(GameInfoTypes.FEATURE_FOREST) then

With the next line setting an improvement. The problem I am having is that instead of just setting the improvement on the forest plot, it is setting it on every plot in the city's three rings. It also sets the improvement regardless of if there's any forest in the city's radius.

I think I've just completely confused myself. If anyone has any advice?
 
It should be:

Code:
if plot:GetFeatureType() == GameInfoTypes.FEATURE_FOREST then
 
It should be:

Code:
if plot:GetFeatureType() == GameInfoTypes.FEATURE_FOREST then

Wow, thanks a lot. It worked perfectly.

If I can ask one more question; how do I check if a tile is a Hills tile?

I've tried:

if plot:GetTerrainType() == GameInfoTypes.TERRAIN_HILL
if plot:GetPlotType() == PlotTypes.PLOT_HILL then

but neither seems to work.
 
Back
Top Bottom