JFD
Kathigitarkh
I'm having some trouble understanding the problem with this:
It works perfectly fine when I don't check if the city is a costal city, so obviously this is where I'm failing to do it correctly.
In the log, it states: Italian Trait.lua:11: attempt to index local 'city' (a nil value)
I'm still warming up to lua, so if someone could explain the problem to me it would help immensely. Thanks.
Spoiler :
Code:
function OnCityCaptureComplete(iOldOwner, bIsCapital, iCityX, iCityY, iNewOwner, iPop, bConquest)
local pNewOwner = Players[iNewOwner];
if(pNewOwner:GetCivilizationType() == GameInfoTypes["CIVILIZATION_ITALY"]) then
if pNewOwner ~= pOldOwner then
local city = Map.GetPlot(iX, iY):GetPlotCity();
if city:IsCoastal() then
-- Adjust the size of the bonus based on the game speed
local bonusGoldenAge = 50;
local speedGoldenAgePercent = GameInfo.GameSpeeds[Game:GetGameSpeedType()].GoldenAgePercent;
local adjustedGoldenAgebonus = (bonusGoldenAge * speedGoldenAgePercent) / 100;
pNewOwner:ChangeGoldenAgeProgressMeter(adjustedGoldenAgebonus);
end
end
end
end
It works perfectly fine when I don't check if the city is a costal city, so obviously this is where I'm failing to do it correctly.
In the log, it states: Italian Trait.lua:11: attempt to index local 'city' (a nil value)
I'm still warming up to lua, so if someone could explain the problem to me it would help immensely. Thanks.