Quantcast
Viewing all articles
Browse latest Browse all 12856

Convert city to Player Religion on found/conquest.

I'm trying to get the lua from this thread: http://forums.civfanatics.com/showthread.php?t=498519 to work, but am not sure what I'm doing wrong.

Spoiler:
function convertCityOnCapture(oldPlayerID, capital, iX, iY, newPlayerID, conquest1, conquest2)
print("In the convertCityOnCapture code");
player = Players[newPlayerID];
// Make sure the conqueror has the trait and has founded a religion
if(player:GetCivilizationType() == GameInfoTypes["CIVILIZATION_SPAIN"] and player:GetReligionCreatedByPlayer() >= 1) then
// get the city object
city = Map.GetPlot(iX, iY).GetPlotCity();
city:AdoptReligionFully(player.GetReligionCreatedB yPlayer());
end
end

GameEvents.CityCaptureComplete.Add(convertCityOnCa pture)


In the log file it says:

Runtime Error: Spain/ConvertOnCapture.lua:7: attempt to index global 'player' (a nil value)

I'm not sure what this means and cannot find any information on the wiki.

Once this is working, I'd like to change it over to convert when a new city is founded instead, which I'd appreciate advice towards.

I'd appreciate any help at all.

Viewing all articles
Browse latest Browse all 12856

Trending Articles