Hey all, I am a naive learner on civ5 modding; and I want to write a mod where certain civilization could start a golden age when certain tech is discovered. However, my code doesn't work for some reasons. Hope I can get some suggestions from you.
For example, I want Isabella start a default-length golden age when Spain finds Archery. And here is my Lua script.
Thank you for your help!!!
P.S. Perhaps as you noticed, I don't know how to find playerID given a teamID, and that's why I used a for sentence. Is there any function I can use to directly get player ID from a team? Thank you~
Moderator Action: Moved to the main forum.
Because the tutorials subforum is only for tutorials .
For example, I want Isabella start a default-length golden age when Spain finds Archery. And here is my Lua script.
local iTechArchery = GameInfo.Technologies["TECH_ARCHERY"].ID
function TechResearchedListener(iTeamId, iTechId, iChange)
pTeam = Teams[iTeamId]
if (pTeam:GetLeaderID() == GameInfo.Leaders["Isabella"].ID) then
if (iTechId == iTechArchery) then
for pPlayer in Players() do
if pPlayer:GetTeam() == iTeamId then
pPlayer:ChangeGoldenAgeTurns(pPlayer:GetGoldenAgeModifier()*GameDefines.GOLDEN_AGE_LENGTH)
end
end
end
end
end
GameEvents.TeamTechResearched.Add(TechResearchedListener)
Thank you for your help!!!
P.S. Perhaps as you noticed, I don't know how to find playerID given a teamID, and that's why I used a for sentence. Is there any function I can use to directly get player ID from a team? Thank you~
Moderator Action: Moved to the main forum.
Because the tutorials subforum is only for tutorials .