Is there a lua function or a way to get the Trait from a player? Eg. test if the player has the Leader TraitType "TRAIT_SEVEN_CITIES" ? I only found GetLeaderType and GetCivilizationType ... but how to continue from there?
You need to translate the ID # for GetLeaderType into a text string so you can use this result in Database table LeaderTraits, looking to see which trait(s) a particular leader has.
Code:
local sHumanLeaderType = GameInfo.Leaders[Players[0]:GetLeaderType()].Type
for LeaderTrait in GameInfo.Leader_Traits("LeaderType='" .. sHumanLeaderType .. "'") do
-- do stuff here for the Trait(s) this leader has
end
Bear in mind that there quite a few mods out there that add multiple Traits to one Leader
Theoretically one Leader can have an unlimited number of Traits, but as a practical issue one Leader can only be given so much stuff before the game ignores any additional pile-on
It's surprisng how much the game will let be piled onto one Leader, but there are limits.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.