Need someone to look over my code, nothing seems to be happening. (I am very new to lua.)
Tried to make this code from some guides online, however I might be missing something, since it doesn't actually spawn a warrior every 4 turns for the mongolia civ. This is all the code I have btw.
Code:
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
local pPlayer = Players[iPlayer]
local iPlayerCiv = pPlayer:GetCivilizationType()
local iMongoliaCiv = GameInfoTypes.CIVILIZATION_MONGOL
if iPlayerCiv == iMongoliaCiv then
local iTurnTrigger = 4
local iTurnsElapsed = Game.GetElapsedGameTurns()
if iTurnsElapsed % iTurnTrigger == 0 then
local unit
local playerStartPlot
playerStartPlot = pPlayer.GetStartingPlot()
unit = pPlayer:InitUnit(GameInfoTypes["UNIT_WARRIOR"], playerStartPlot:GetX(), playerStartPlot:GetY())
end
end
end)
Tried to make this code from some guides online, however I might be missing something, since it doesn't actually spawn a warrior every 4 turns for the mongolia civ. This is all the code I have btw.