T_KCommanderbly
Prince
So I want to spawn a unit at a certain time on a certain plot.
This is the code I have:
Ok so it is picking up the correct year (I know this is correct) but it has an error indexing iBarbarian afterward which I guess I just don't get.
So my main question is how do I get it too spawn a unit?
Then my second question is how do I get it too pick up if a player is human or not? (I have it 'commented out' but the current code right there doesn't work...
EDIT: nvm I figured it out I guess I posted this too soon
but If anyone has a question on how to do this I can post what I did.
This is the code I have:
Code:
function SpawnUnits(playerID)
Dprint ("-------------------------------------")
Dprint ("Spawning units!")
--local player = Players[playerID]
local SpawnPlot = GetPlot(80,40) -- Plot Spawned On
local SpawnYear = Game.GetGameTurnYear()
local WARRIOR = GameInfo.Units.UNIT_WARRIOR.ID
local BARBARIAN = GameInfo.Civilizations.CIVILIZATION_BARBARIAN.ID
local iBarbarian = GetPlayerIDFromCivID(BARBARIAN, true)
if (SpawnYear==-1500) then --and not Players[iBarbarian]:IsHuman() then -- Spawn Unit on this year (and not human)
Dprint ("Attempting to Spawn Barbarian Warrior!")
iBarbarian:InitUnit(WARRIOR, SpawnPlot.X, SpawnPlot.Y)
end
end
Ok so it is picking up the correct year (I know this is correct) but it has an error indexing iBarbarian afterward which I guess I just don't get.
So my main question is how do I get it too spawn a unit?
Then my second question is how do I get it too pick up if a player is human or not? (I have it 'commented out' but the current code right there doesn't work...
EDIT: nvm I figured it out I guess I posted this too soon
