View Full Version : how to start golden age after certain tech discovered

Dec 22, 2011, 09:59 PM
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.:confused: 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.

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:GetGoldenAgeM odifier()*GameDefines.GOLDEN_AGE_LENGTH)

GameEvents.TeamTechResearched.Add(TechResearchedLi stener)

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~

Moved to the main forum.
Because the tutorials subforum is only for tutorials ;).