LeeS
Imperator
I think I may have done something wrong. I have:
Code:function [COLOR="Red"]Religion[/COLOR]SpecificUnits(playerID, cityID, unitType) local majorityReligion = Cities[cityID]:GetReligiousMajority() -- Turn off the specifics for all but the correct religion if (unitType == GameInfoTypes["UNIT_SEEKERS_OF_TRUTH"]) then if not (majorityReligion == GameInfoTypes["RELIGION_CHANTRY"]) then return false end elseif (unitType == GameInfoTypes["UNIT_LEGION_OF_THE_DEAD"]) then if not (majorityReligion == GameInfoTypes["RELIGION_PARAGONS"]) then return false end end return true end GameEvents.CityCanTrain.Add([COLOR="red"]Religious[/COLOR]SpecificUnits)
and I'm wanting to make it so that only those that follow the Chantry can build the Seekers of Truth, and only those that follow the Paragons can build the Legion of the Dead. I just tested it out, and while neither units is build-able in a city with no religion, both can be built in a city that follows the Chantry.
(I can link the full mod if need be)
If that is a direct copy of your code, you have mismatched function names. Check your Database.log to be sure part or all of your xml is not being discarded by the game (because what you are describing sounds like a "nil == "nil" / "nil ~= "nil" issue). Otherwise it would be necessary to look at the actual mod -- with the current partial reestablishment of the forum it might be better to provide a link to an off-forum location where the mod can be downloaded rather than trying to attach direct to a post. I've seem to recall conflicting reports on that thread Thunderfall linked to re forum current status and attachments.
also, I would do this to see that you have valid data within the lua function:
Code:
print("GameInfoTypes["RELIGION_CHANTRY"] is " .. GameInfoTypes["RELIGION_CHANTRY"])
print("GameInfoTypes["RELIGION_PARAGONS"] is " .. GameInfoTypes["RELIGION_PARAGONS"])
print("GameInfoTypes["UNIT_SEEKERS_OF_TRUTH"] is " .. GameInfoTypes["UNIT_SEEKERS_OF_TRUTH"])
print("GameInfoTypes["UNIT_LEGION_OF_THE_DEAD"] is " .. GameInfoTypes["UNIT_LEGION_OF_THE_DEAD"])
function ReligionSpecificUnits(playerID, cityID, unitType)
local majorityReligion = Cities[cityID]:GetReligiousMajority()
print("A city majorityReligion is " .. majorityReligion)
-- Turn off the specifics for all but the correct religion
if (unitType == GameInfoTypes["UNIT_SEEKERS_OF_TRUTH"]) then
if not (majorityReligion == GameInfoTypes["RELIGION_CHANTRY"]) then
return false
end
elseif (unitType == GameInfoTypes["UNIT_LEGION_OF_THE_DEAD"]) then
if not (majorityReligion == GameInfoTypes["RELIGION_PARAGONS"]) then
return false
end
end
return true
end
GameEvents.CityCanTrain.Add(ReligionSpecificUnits)
-----------------------------------------------------------------------------------------
[edit = for concept issues]
There is, however, a larger issue with this sort of implimentation in that a city's religious majority is not static, it is volatile. Units or Buildings that can no longer be constructed or trained within a city go instantly *poof* from the build qeues when the volatile condition alters. It is necessary to decide what should happen when a city is building, for example, a UNIT_LEGION_OF_THE_DEAD and an adversary converts the city to their religion, and then it is necessary to add a function to the city-converted event
Code:
GameEvents.CityConvertsReligion(PlayerID owner, ReligionType religion, int x, int y)