Starrynite120
Prince
- Joined
- Jul 15, 2015
- Messages
- 472
I'm trying to write a script for a wonder that gives you culture for every miasma tile you have in a city. This is what I've got.
I am getting an error on the lines that define the local variables Player and Perk, saying that they are a nil value, but I'm not sure why as I've defined them similarly elsewhere. Why am I getting this error?
Code:
function XenoDrome(playerID, cityID)
local Player = Players[playerID];
local Perk = GameInfo.PlayerPerks["PLAYERPERK_WONDER_STARRYNITE_XENODROME"].ID;
local City = player:GetCityByID(cityID)
local Wonder = GameInfo.Buildings["BUILDING_XENODROME"].ID;
local bonus = 0
if Player:HasPerk(Perk) then
for City in Player:Cities() do
if City:IsHasBuilding(Wonder) then
for Plot = 0,City:GetNumCityPlots(),1 do
SpecificPlot = City:GetCityIndexPlot(Plot);
if SpecificPlot:HasMiasma() then
print('Miasma Found')
bonus = bonus + 1;
end
end
end
end
end
if bonus > 0 then
Player:ChangeCulture(bonus);
-- Send a notification to the player
local text = Locale.ConvertTextKey("TXT_KEY_STARRYNITE_XENODROME_NOTIFICATION", tostring(bonus));
Player:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, text);
end
end
GameEvents.PlayerDoTurn.Add(XenoDrome)
I am getting an error on the lines that define the local variables Player and Perk, saying that they are a nil value, but I'm not sure why as I've defined them similarly elsewhere. Why am I getting this error?