Hi everybody. First post here, and also my first time trying to make a custom civ. I've got a pretty good grasp on the xml side of things but trying to create a custom trait I'm finding to be pretty difficult. My trait says that the civ gets a free settler upon founding a pantheon, as well as whenever a great prophet is born. I went through some of the mods I had installed and found a similar ability from JFD's Nri Kingdom, where the Nri get a free Great Merchant upon founding a pantheon, and I modified it to be a Settler instead of a Great Merchant. This is the lua script:
Unfortunately, I can't figure out how to make this actually happen in game! If someone can tell me what I have to put in my xml files (or wherever) to make this function actually happen I would be really grateful.
Code:
--Chickasaw_PantheonFounded
local unitSettlerID = GameInfoTypes["UNIT_SETTLER"]
function Chickasaw_PantheonFounded(playerID)
local player = Players[playerID]
if (not player:IsAlive()) then return end
if (not HasTrait(player, traitChickasawID)) then return end
local capital = player:GetCapitalCity()
player:InitUnit(unitSettlerID, capital:GetX(), capital:GetY())
end
GameEvents.PantheonFounded.Add(Chickasaw_PantheonFounded)
Unfortunately, I can't figure out how to make this actually happen in game! If someone can tell me what I have to put in my xml files (or wherever) to make this function actually happen I would be really grateful.