Craig_Sutter
Deity
This code is meant to spawn a settler when sweden enters a new era... could not find a working example. Onmodactivated, etc. is set properly.
error in log:
Thank-you in advance.
error in log:
Code:
[1395416.978] Runtime Error: C:\Users\doms\Documents\My Games\Sid Meier's Civilization 5\MODS\The Viking Age for BNW (v 2)\LUA/SwedenTrait.lua:45: attempt to call field 'TeamSetEra' (a table value)
[1395416.978] Runtime Error: Error loading C:\Users\doms\Documents\My Games\Sid Meier's Civilization 5\MODS\The Viking Age for BNW (v 2)\LUA/SwedenTrait.lua.
Code:
-- Lua Script1
-- Author: Craig and Nancy
-- DateCreated: 7/23/2014 11:50:56 PM
--------------------------------------------------------------
function SwedenSettler(teamId, eEra)
-- Set up Sweden Player
for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do
local pSweden = Players[iPlayer]
if (GameInfo.Civilizations.CIVILIZATION_SWEDEN.ID == pSweden:GetCivilizationType()) then
Sweden = pSweden
SwedenTeamID = Sweden:GetTeam();
SwedenTeam= Teams[ Sweden:GetTeam() ]
end
end
--Spawn Units
if teamID==SwedenTeamID then
if eEra>0 then
local pCity = Sweden:GetCapitalCity()
if pCity then
local pPlot = pCity:Plot();
local Spawnunit;
local iSpawnX = pPlot:GetX();
local iSpawnY = pPlot:GetY();
Spawnunit = Sweden:InitUnit(GameInfoTypes["UNIT_SETTLER"], iSpawnX, iSpawnY, UNITAI_SETTLE, DIRECTION_NORTHWEST )
print (Sweden:GetName() ,"...is spawning settler due to Era change in...", pCity:GetName());
end
end
end
end
GameEvents.TeamSetEra(SwedenSettler);
Thank-you in advance.