nguyenforthewin13
Chieftain
- Joined
- Jul 5, 2017
- Messages
- 35
I've created scenarios where I successfully had religions founded at game start before, using Lua, but for whatever reason this time I'm unable to get religions founded on the map. The code I'm using this time for founding religions is taken straight out of the Earth 2014 mod, and so it looks like this:
When I use this code, it only founds the religion founded by the Civ I'm playing as (so if I play Russia, it founds Orthodoxy; if I play Italy, it founds Catholicism), and then fails to found all the other religions. For whatever reason, the British pantheon for Anglicanism also always shows up no matter what - it seems that the United Kingdom is the first non-player Civ that is iterated, but then the code fails.
I don't believe I've made any mistakes implementing the modded non-Vanilla beliefs, because they're rendering in the Civilopedia just fine and I was meticulous in making sure I coded them all in correctly through XML. Also, the new religions have been added properly, I'm relatively sure, because they are all showing up in the Civilopedia with the correct symbols. They've just been taken from the various Historical Religion mods on Steam.
However, this is the recurring issue I see in the Lua log every time I try to fire this code:
I've tried a variety of solutions already to fix this problem from other areas on the forum. Craig Sutter said that if you have a religion founded in a City-State, you should reduce the number of major religions because apparently otherwise you could get a crash. I did that, but it didn't make a difference. I also tried founding religions using a code written in a different format from Craig Sutter, but that founds five of the religions above and for some reason fails to found the other four. That code is much longer because the arguments utilized to found each religion are separated. This is that code:
That code always ends up founding all the religions up to Lutheranism correctly, and then it gives me that same error in the Lua log and goes kaput. As for the code I've used to spread religions across the map, I know that works perfectly fine because I tested it separately from the other codes, and it does spread religions to all the right cities even if they're not founded (but of course not having the religions founded when they're spread crashes the game upon opening the religion overview). So I suspect the problem is somewhere in the code I presented.
There is some other Lua with my mod, but it's really just the other Lua in the Earth 2014 mod, another Lua code for the Chartres Cathedral mod on Steam, and the Lua code for the Hex Conquer and Release mod. I'm not sure if there would be a conflict but I will test with all those codes disabled.
Code:
-- Found a religion (function by Craig_Sutter)
function FoundReligion(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], iBelief4, iBelief5, pCity)
end
-- Set up the religions to be present in the scenario
function SetupReligions()
if Game.GetElapsedGameTurns() == 0 then
for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
local pPlayer = Players[iPlayer];
print("Iterating players..." .. pPlayer:GetName());
if pPlayer:IsEverAlive() then
for cityIndex = 0, pPlayer:GetNumCities() - 1, 1 do
local pCity = pPlayer:GetCityByID(cityIndex)
-- Found Judaism
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_JERUSALEM" then
FoundReligion(pCity, "RELIGION_JUDAISM", "BELIEF_FERTILITY_RITES", "BELIEF_CHOSEN_PEOPLE", "BELIEF_SYNAGOGUES", "BELIEF_ISRAELITE_INGENUITY", "BELIEF_MESSIAH");
print("Founding Judaism in " .. pCity:GetName());
end
-- Found Roman Catholicism
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_ROME" then
FoundReligion(pCity, "RELIGION_CHRISTIANITY", "BELIEF_COMMUNION_CATHOLIC", "BELIEF_PAPAL_PRIMACY", "BELIEF_CATHEDRALS", "BELIEF_CHORAL_MUSIC", "BELIEF_HOLY_ORDER");
print("Founding Roman Catholicism in " .. pCity:GetName());
--return pCity;
end
-- Found Eastern Orthodoxy
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_MOSCOW" then
FoundReligion(pCity, "RELIGION_ORTHODOXY", "BELIEF_COMMUNION_EASTERN", "BELIEF_CHURCH_PROPERTY", "BELIEF_MONASTERIES", "BELIEF_RELIGIOUS_ICONS", "BELIEF_RELIQUARY");
print("Founding Eastern Orthodoxy in " .. pCity:GetName());
end
-- Found Oriental Orthodoxy
if pCity ~= nil and pCity:GetName() == "Yerevan" then
FoundReligion(pCity, "RELIGION_ORIENTAL_ORTHODOXY", "BELIEF_COMMUNION_ORIENTAL", "BELIEF_CHURCH_PROPERTY_ORIENTAL", "BELIEF_MONASTERIES_ORIENTAL", "BELIEF_INDEPENDENT_LITURGY", "BELIEF_ITINERANT_PREACHERS");
print("Founding Eastern Orthodoxy in " .. pCity:GetName());
end
-- Found Lutheranism
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_BERLIN" then
FoundReligion(pCity, "RELIGION_PROTESTANTISM", "BELIEF_COMMUNION_LUTHERAN", "BELIEF_SOLA_GRATIA", "BELIEF_CATHEDRALS_LUTHERAN", "BELIEF_CHORAL_MUSIC_LUTHERAN", "BELIEF_RELIGIOUS_TEXTS");
print("Founding Lutheranism in " .. pCity:GetName());
end
-- Found Calvinism
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_AMSTERDAM" then
FoundReligion(pCity, "RELIGION_CALVINISM", "BELIEF_COMMUNION_CALVINIST", "BELIEF_SOLA_GRATIA_CALVINIST", "BELIEF_PRESBYTERIANISM", "BELIEF_PREDESTINATION", "BELIEF_RELIGIOUS_TEXTS_CALVINIST");
print("Founding Calvinism in " .. pCity:GetName());
end
-- Found Anglicanism
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_LONDON" then
FoundReligion(pCity, "RELIGION_ANGLICANISM", "BELIEF_COMMUNION_ANGLICAN", "BELIEF_INTERFAITH_DIALOUGE", "BELIEF_CATHEDRALS_ANGLICAN", "BELIEF_FEED_WORLD", "BELIEF_RELIGIOUS_TEXTS_ANGLICAN");
print("Founding Anglicanism in " .. pCity:GetName());
end
-- Found Sunni
if pCity ~= nil and pCity:GetName() == "TXT_KEY_CITY_NAME_MEDINA" then
FoundReligion(pCity, "RELIGION_ISLAM", "BELIEF_DESERT_FOLKLORE", "BELIEF_PILGRIMAGE", "BELIEF_MOSQUES", "BELIEF_JIHAD", "BELIEF_ISLAMIC_SCHOLARSHIP");
print("Founding Islam in " .. pCity:GetName());
end
-- Found Shia
if pCity ~= nil and pCity:GetName() == "TXT_KEY_2014_CITY_NAME_TEHRAN" then
FoundReligion(pCity, "RELIGION_ISLAM_SHIA", "BELIEF_DESERT_FOLKLORE_SHIA", "BELIEF_WORLD_CHURCH", "BELIEF_MOSQUES_SHIA", "BELIEF_JIHAD_SHIA", "BELIEF_ISLAMIC_SCHOLARSHIP_SHIA");
print("Founding Islam in " .. pCity:GetName());
end
end
end
end
end
end
Events.SequenceGameInitComplete.Add(SetupReligions);
When I use this code, it only founds the religion founded by the Civ I'm playing as (so if I play Russia, it founds Orthodoxy; if I play Italy, it founds Catholicism), and then fails to found all the other religions. For whatever reason, the British pantheon for Anglicanism also always shows up no matter what - it seems that the United Kingdom is the first non-player Civ that is iterated, but then the code fails.
I don't believe I've made any mistakes implementing the modded non-Vanilla beliefs, because they're rendering in the Civilopedia just fine and I was meticulous in making sure I coded them all in correctly through XML. Also, the new religions have been added properly, I'm relatively sure, because they are all showing up in the Civilopedia with the correct symbols. They've just been taken from the various Historical Religion mods on Steam.
However, this is the recurring issue I see in the Lua log every time I try to fire this code:
Code:
[133194.609] Europe2014ReligionSetup: Iterating players...Vladimir Putin
[133194.750] Europe2014ReligionSetup: Founding Eastern Orthodoxy in Moscow
[133194.750] Europe2014ReligionSetup: Iterating players...David Cameron
[133194.765] Runtime Error: C:\Users\Brian\Documents\My Games\Sid Meier's Civilization 5\MODS\Europe 2014 (v 1)\Lua/Europe2014ReligionSetup.lua:16: bad argument #2 to 'FoundReligion' (number expected, got nil)
I've tried a variety of solutions already to fix this problem from other areas on the forum. Craig Sutter said that if you have a religion founded in a City-State, you should reduce the number of major religions because apparently otherwise you could get a crash. I did that, but it didn't make a difference. I also tried founding religions using a code written in a different format from Craig Sutter, but that founds five of the religions above and for some reason fails to found the other four. That code is much longer because the arguments utilized to found each religion are separated. This is that code:
Code:
function EstablishJewish()
if Game.GetElapsedGameTurns() == 0 then
function CreateJewishHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundJudaism()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_JERUSALEM" then
CreateJewishHolyCity(pCity, "RELIGION_JUDAISM", "BELIEF_FERTILITY_RITES",
"BELIEF_CHOSEN_PEOPLE", "BELIEF_SYNAGOGUES", "BELIEF_ISRAELITE_INGENUITY", "BELIEF_MESSIAH");
print("Founding Judaism in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pJewishPlot = FoundJudaism():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishJewish)
function EstablishCatholic()
if Game.GetElapsedGameTurns() == 0 then
function CreateCatholicHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundCatholicism()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_ROME" then
CreateCatholicHolyCity(pCity, "RELIGION_CHRISTIANITY", "BELIEF_COMMUNION_CATHOLIC",
"BELIEF_PAPAL_PRIMACY", "BELIEF_CATHEDRALS", "BELIEF_CHORAL_MUSIC", "BELIEF_HOLY_ORDER");
print("Founding Catholicism in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pCatholicPlot = FoundCatholicism():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishCatholic)
function EstablishOrthodox()
if Game.GetElapsedGameTurns() == 0 then
function CreateOrthodoxHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundOrthodoxy()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_MOSCOW" then
CreateOrthodoxHolyCity(pCity, "RELIGION_ORTHODOXY", "BELIEF_COMMUNION_EASTERN",
"BELIEF_CHURCH_PROPERTY", "BELIEF_MONASTERIES", "BELIEF_RELIGIOUS_ICONS", "BELIEF_RELIQUARY");
print("Founding Orthodoxy in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pOrthodoxPlot = FoundOrthodoxy():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishOrthodox)
function EstablishOrientalOrthodox()
if Game.GetElapsedGameTurns() == 0 then
function CreateOrientalOrthodoxHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundOrientalOrthodoxy()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetName() == "Yerevan" then
CreateOrientalOrthodoxHolyCity(pCity, "RELIGION_ORIENTAL_ORTHODOXY", "BELIEF_COMMUNION_EASTERN",
"BELIEF_CHURCH_PROPERTY", "BELIEF_MONASTERIES", "BELIEF_RELIGIOUS_ICONS", "BELIEF_RELIQUARY");
print("Founding Oriental Orthodoxy in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pOrientalOrthodoxPlot = FoundOrientalOrthodoxy():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishOrientalOrthodox)
function EstablishLutheran()
if Game.GetElapsedGameTurns() == 0 then
function CreateLutheranHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundLutheranism()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_BERLIN" then
CreateLutheranHolyCity(pCity, "RELIGION_PROTESTANTISM", "BELIEF_COMMUNION_LUTHERAN",
"BELIEF_SOLA_GRATIA", "BELIEF_CATHEDRALS_LUTHERAN", "BELIEF_CHORAL_MUSIC_LUTHERAN", "BELIEF_RELIGIOUS_TEXTS");
print("Founding Lutheranism in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pLutheranPlot = FoundLutheranism():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishLutheran)
function EstablishCalvinist()
if Game.GetElapsedGameTurns() == 0 then
function CreateCalvinistHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundCalvinism()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_AMSTERDAM" then
CreateCalvinistHolyCity(pCity, "RELIGION_CALVINISM", "BELIEF_COMMUNION_CALVINIST",
"BELIEF_SOLA_GRATIA_CALVINIST", "BELIEF_PRESBYTERIANISM", "BELIEF_PREDESTINATION", "BELIEF_RELIGIOUS_TEXTS_CALVINIST");
print("Founding Calvinism in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pCalvinistPlot = FoundCalvinism():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishCalvinist)
function EstablishAnglican()
if Game.GetElapsedGameTurns() == 0 then
function CreateAnglicanHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundAnglicanism()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetName() == "TXT_KEY_CITY_NAME_LONDON" then
CreateAnglicanHolyCity(pCity, "RELIGION_ANGLICANISM", "BELIEF_COMMUNION_ANGLICAN",
"BELIEF_INTERFAITH_DIALOUGE", "BELIEF_CATHEDRALS_ANGLICAN", "BELIEF_FEED_WORLD", "BELIEF_RELIGIOUS_TEXTS_ANGLICAN");
print("Founding Anglicanism in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pAnglicanPlot = FoundAnglicanism():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishAnglican)
function EstablishSunni()
if Game.GetElapsedGameTurns() == 0 then
function CreateSunniHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundSunni()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_CITY_NAME_MEDINA" then
CreateSunniHolyCity(pCity, "RELIGION_ISLAM", "BELIEF_DESERT_FOLKLORE",
"BELIEF_PILGRIMAGE", "BELIEF_MOSQUES", "BELIEF_JIHAD", "BELIEF_ISLAMIC_SCHOLARSHIP");
print("Founding Sunni in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pSunniPlot = FoundSunni():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishSunni)
function EstablishShia()
if Game.GetElapsedGameTurns() == 0 then
function CreateShiaHolyCity(pCity, religion, pantheonBelief, founderBelief, followerBelief, followerBelief2, enhancerBelief)
local iPlayer = pCity:GetOwner()
local iReligion = GameInfoTypes[religion]
-- Optional extra beliefs
local iBelief4 = followerBelief2 and GameInfoTypes[followerBelief2] or -1
local iBelief5 = enhancerBelief and GameInfoTypes[enhancerBelief] or -1
Game.FoundPantheon(iPlayer, GameInfoTypes[pantheonBelief])
Game.FoundReligion(iPlayer, iReligion, nil, GameInfoTypes[founderBelief], GameInfoTypes[followerBelief], -1, -1, pCity)
Game.EnhanceReligion(iPlayer, iReligion, GameInfoTypes[followerBelief2], GameInfoTypes[enhancerBelief]);
end
function FoundShia()
for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
local pPlayer = Players[iPlayer]
if (pPlayer:IsEverAlive()) then
for pCity in pPlayer:Cities() do
-- City exists and has the proper name?
if pCity ~= nil and pCity:GetNameKey() == "TXT_KEY_2014_CITY_NAME_TEHRAN" then
CreateShiaHolyCity(pCity, "RELIGION_ISLAM_SHIA", "BELIEF_DESERT_FOLKLORE_SHIA",
"BELIEF_WORLD_CHURCH", "BELIEF_MOSQUES_SHIA", "BELIEF_JIHAD_SHIA", "BELIEF_ISLAMIC_SCHOLARSHIP_SHIA");
print("Founding Shia in " .. pCity:GetName());
return pCity
end
end
end
end
end
local pShiaPlot = FoundShia():Plot()
end
end
Events.SequenceGameInitComplete.Add(EstablishShia)
That code always ends up founding all the religions up to Lutheranism correctly, and then it gives me that same error in the Lua log and goes kaput. As for the code I've used to spread religions across the map, I know that works perfectly fine because I tested it separately from the other codes, and it does spread religions to all the right cities even if they're not founded (but of course not having the religions founded when they're spread crashes the game upon opening the religion overview). So I suspect the problem is somewhere in the code I presented.
There is some other Lua with my mod, but it's really just the other Lua in the Earth 2014 mod, another Lua code for the Chartres Cathedral mod on Steam, and the Lua code for the Hex Conquer and Release mod. I'm not sure if there would be a conflict but I will test with all those codes disabled.