lua getPlayerTrait() ?

Discussion in 'Civ5 - Creation & Customization' started by Serp, Apr 8, 2020.

  1. Serp

    Serp King

    Apr 1, 2015
    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?
  2. LeeS

    LeeS Imperator

    Jul 23, 2013
    Illinois, USA
    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.
    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
    • 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.
    Serp likes this.

Share This Page