Set Religions from Game Start???

If you are using this code, I have refined it a bit to start during the opening sequence... at follows:

Code:
-- Find Paris player and found Christianity in their city, returning the city

function EstablishChristian()
if Game.GetElapsedGameTurns() == 0 then

function CreateChristianHolyCity(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 FoundChristianity()
  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() == "Paris" then

		             CreateChristianHolyCity(pCity, "RELIGION_CHRISTIANITY", "BELIEF_GOD_KING",
					"BELIEF_PAPAL_PRIMACY", "BELIEF_CATHEDRALS",  "BELIEF_MOSQUES", "BELIEF_RELIGIOUS_TEXTS");
					print ("okay, Paris is the Catholic holy city")
				return pCity
				end
			end
		end
	end
end

local pChristianPlot = FoundChristianity():Plot()

end
end

Events.SequenceGameInitComplete.Add(EstablishChristian)

And to give an existing religion to a city...

Code:
-- Enumerate Playable Civ Cities with Christianity

function FollowChristianityA()
if Game.GetElapsedGameTurns() == 0 then

for iPlayer=0, GameDefines.MAX_CIV_PLAYERS - 1 do
	local pPlayer = Players[iPlayer];
		if pPlayer:IsEverAlive() then 
			
			-- Enumerate cities
			for pCity in pPlayer:Cities() do

				-- City exists and has the proper name?
    			
				
				if pCity ~= nil and pCity:GetName() == "Aachen" then
					pCity:ConvertPercentFollowers(2, -1, 75);
					print(pCity:GetName(), "...is getting Christian followers...");
				return pCity							
    			end
			end
		end
end
end
end

Events.SequenceGameInitComplete.Add(FollowChristianityA)

Hope this helps.
 
Is there a way to generalize this, giving every civilization its preferred religion from the start (even if this means "Civ A founds it; Civ B, with the same preference, converts")? I've got other ideas for auto-setting parts of the religion system, but they belong in a different thread.
 
I'm just going to come out and say I'm a complete noob when it comes to Lua and modding. I've played around with XML in Civ 4 and dabbled in the IDEModbuddy for civ5, but that's about it.

So I'm just going to noob it up and ask noob questions. Sorry in advance.
This code you've written (thank you, btw) is it typed into the Firaxis live tuner as the game is being played or are you first creating a Mod for the data and calling it up?
A previous post said it had to added using InGameUIAddin. I'm assuming that's in the Live Tuner, yes?
I prefer using the SDK's world builder program over creating scenario's in-game. Is it possible to use your code in that program?

Again, sorry for the all the questions and hopefully I didn't annoy anyone on this thread too much with them.

Also, if there's a guide on the internet that explains all this stuff (about Live Tuner and World Builder) you can just point me in that direction if you don't want to answer. Thanks in advance.
 
First off, I'm no expert... but here it goes.

The above code needs to be added to a mod. I suppose it could be added via livetuner, but I've never tried it. Don't know if it would work. It's a pretty hard thing to just fly by the seat of your pants... I think a mod is best.

World builder creates maps for scenarios. Whatever mod is active will be effective in world builder. Civs/units/etc. you have created via modbuddy will be active either by selecting your mod from the worldbuilder initiation menu or if they were the last mods used in a game. Then you can add modded units and civs to your maps. Just keep in mind that unless the mods are selected with that particular map when it is loaded, the worldbuilder additions you have created (units/civs/etc.) will not be in effect and will disappear if you save the map without your mods being active.

InGameAddIn is set in Modbuddy and is not a live tuner thing.

That being said, religion cannot be added via worldbuilder maps. A mod is required. There is nothing in regards to religion in the worldbuilder menus.

Just to be clear... mods and worldbuilder are two separate things. If a mod is active, then it will function with any map, worldbuilder or otherwise, to a degree. Some lua files and xml may not work with a map not specifically created with a mod in mind, as for example, in the code above which is dependent on certain cities being on the map. You may get a ctd (crash to desktop) using a map created with a specific mod if you do not use that mod or use an incompatible mod.

As to the above, I stand to be corrected, but this is what I think.

I think you may be able to use the above code in firetuner, but I am unsure. You'd have to adjust city and civ names to match those on the map, I think. Some of the lines like the function name , Game turn and event hook lines would be unneeded, I think... and you'd have to get rid of the "end" that matches each "if" you remove (I think the last 2). Then I suppose pasting in the code into firetuner may work. Firetune is not my area of expertise to say the least, though, so this is all speculative on my part.

Hope this helps a bit.
 
Yep, that helps a lot. Thanks for taking the time to respond Craig_Sutter, it's greatly appreciated. :)
 
Back
Top Bottom