1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

lua getPlayerTrait() ?

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

  1. Serp

    Serp King

    Joined:
    Apr 1, 2015
    Messages:
    615
    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

    Joined:
    Jul 23, 2013
    Messages:
    6,756
    Location:
    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.
    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.
     
    Serp likes this.

Share This Page