help! i added 4 extra tech options, and got it to work, but cant't get the civics options to work.. teach me master..
<pre class="_prettyXprint _lang-sql _linenums:65"> function OnPlayerTurnActivated( player, bIsFirstTime )
local currentTurn = Game.GetCurrentGameTurn(); local SpawnTurn = 0; local playerUnits; local adjacentPlot; local unitPlot; if currentTurn == GameConfiguration.GetStartTurn() then local pPlayer = Players[player] if pPlayer:IsHuman() then playerUnits = pPlayer:GetUnits() for i, unit in playerUnits:Members() do local unitTypeName = UnitManager.GetTypeName(unit) if "LOC_UNIT_SETTLER_NAME" == unitTypeName then SpawnTurn = 1; unitPlot = Map.GetPlot(unit:GetX(), unit:GetY()); end end end
if SpawnTurn == 1 then local lastPlot = unitPlot; if NumOne > 0 then for i = 1, NumOne do for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() + 1), lastPlot:GetY(), direction); if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then break end end pUnit = playerUnits:Create(iOne, unitPlot:GetX(), unitPlot:GetY()) lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY()); end end if NumTwo > 0 then for i = 1, NumTwo do for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX()), (lastPlot:GetY() - 1), direction); if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then break end end pUnit2 = playerUnits:Create(iTwo, adjacentPlot:GetX(), adjacentPlot:GetY()) lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY()); end end if NumThree > 0 then for i = 1, NumThree do for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() - 1), lastPlot:GetY(), direction); if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then break end end pUnit3 = playerUnits:Create(iThree, adjacentPlot:GetX(), adjacentPlot:GetY()) lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY()); end end if NumFour > 0 then for i = 1, NumFour do for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() ), (lastPlot:GetY() + 1), direction); if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then break end end pUnit4 = playerUnits:Create(iFour, adjacentPlot:GetX(), adjacentPlot:GetY()) lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY()); end end if NumFive > 0 then for i = 1, NumFive do for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() - 1), lastPlot:GetY(), direction); if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then break end end pUnit5 = playerUnits:Create(iFive, lastPlot:GetX(), lastPlot:GetY()) lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY()); end end pPlayer:GetTreasury():SetGoldBalance(PlayerGold); local curPlayerTech = pPlayer:GetTechs(); if(curPlayerTech ~= nil) then if (Tech_One ~= nil) then curPlayerTech:SetResearchProgress(Tech_One.Index, curPlayerTech:GetResearchCost(Tech_One.Index)); end if(Tech_Two ~= nil) then curPlayerTech:SetResearchProgress(Tech_Two.Index, curPlayerTech:GetResearchCost(Tech_Two.Index)); end if(Tech_Three ~= nil) then curPlayerTech:SetResearchProgress(Tech_Three.Index, curPlayerTech:GetResearchCost(Tech_Three.Index)); end if(Tech_Four ~= nil) then curPlayerTech:SetResearchProgress(Tech_Four.Index, curPlayerTech:GetResearchCost(Tech_Four.Index)); end if(Tech_Five ~= nil) then curPlayerTech:SetResearchProgress(Tech_Five.Index, curPlayerTech:GetResearchCost(Tech_Five.Index)); end if(Tech_Six ~= nil) then curPlayerTech:SetResearchProgress(Tech_Six.Index, curPlayerTech:GetResearchCost(Tech_Six.Index)); end if(Tech_Seven ~= nil) then curPlayerTech:SetResearchProgress(Tech_Seven.Index, curPlayerTech:GetResearchCost(Tech_Seven.Index)); end if(Tech_Eight ~= nil) then curPlayerTech:SetResearchProgress(Tech_Eight.Index, curPlayerTech:GetResearchCost(Tech_Eight.Index)); end end local curPlayerCivics = pPlayer:GetCivics(); if(curPlayerCivics ~= nil) then if (Civics_One ~= nil) then curPlayerCivics:SetResearchProgress(Civics_One.Index, curPlayerCivics:GetResearchCost(Civics_One.Index)); end if(Civics_Two ~= nil) then curPlayerCivics:SetResearchProgress(Civics_Two.Index, curPlayerCivics:GetResearchCost(Civics_Two.Index)); end if(Civics_Three ~= nil) then curPlayerCivics:SetResearchProgress(Civics_Three.Index, curPlayerCivics:GetResearchCost(Civics_Three.Index)); end if(Civics_Four ~= nil) then curPlayerCivics:SetResearchProgress(Civics_Four.Index, curPlayerCivics:GetResearchCost(Civics_Four.Index)); end if(Civics_Five ~= nil) then curPlayerCivics:SetResearchProgress(Civics_Five.Index, curPlayerCivics:GetResearchCost(Civics_Five.Index)); end if(Civics_Six ~= nil) then curPlayerCivics:SetResearchProgress(Civics_Six.Index, curPlayerCivics:GetResearchCost(Civics_Six.Index)); end if(Civics_Seven ~= nil) then curPlayerCivics:SetResearchProgress(Civics_Seven.Index, curPlayerCivics:GetResearchCost(Civics_Seven.Index)); end if(Civics_Eight ~= nil) then curPlayerCivics:SetResearchProgress(Civics_Eight.Index, curPlayerCivics:GetResearchCost(Civics_Eight.Index)); end end
end
end
end
function Initialize() Events.LocalPlayerChanged.Add( OnPlayerTurnActivated ); Events.PlayerTurnActivated.Add(OnPlayerTurnActivated); end
2 comments
<pre class="_prettyXprint _lang-sql _linenums:65">
function OnPlayerTurnActivated( player, bIsFirstTime )
local currentTurn = Game.GetCurrentGameTurn();
local SpawnTurn = 0;
local playerUnits;
local adjacentPlot;
local unitPlot;
if currentTurn == GameConfiguration.GetStartTurn() then
local pPlayer = Players[player]
if pPlayer:IsHuman() then
playerUnits = pPlayer:GetUnits()
for i, unit in playerUnits:Members() do
local unitTypeName = UnitManager.GetTypeName(unit)
if "LOC_UNIT_SETTLER_NAME" == unitTypeName then
SpawnTurn = 1;
unitPlot = Map.GetPlot(unit:GetX(), unit:GetY());
end
end
end
if SpawnTurn == 1 then
local lastPlot = unitPlot;
if NumOne > 0 then
for i = 1, NumOne do
for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() + 1), lastPlot:GetY(), direction);
if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then
break
end
end
pUnit = playerUnits:Create(iOne, unitPlot:GetX(), unitPlot:GetY())
lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY());
end
end
if NumTwo > 0 then
for i = 1, NumTwo do
for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX()), (lastPlot:GetY() - 1), direction);
if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then
break
end
end
pUnit2 = playerUnits:Create(iTwo, adjacentPlot:GetX(), adjacentPlot:GetY())
lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY());
end
end
if NumThree > 0 then
for i = 1, NumThree do
for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() - 1), lastPlot:GetY(), direction);
if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then
break
end
end
pUnit3 = playerUnits:Create(iThree, adjacentPlot:GetX(), adjacentPlot:GetY())
lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY());
end
end
if NumFour > 0 then
for i = 1, NumFour do
for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() ), (lastPlot:GetY() + 1), direction);
if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then
break
end
end
pUnit4 = playerUnits:Create(iFour, adjacentPlot:GetX(), adjacentPlot:GetY())
lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY());
end
end
if NumFive > 0 then
for i = 1, NumFive do
for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() - 1), lastPlot:GetY(), direction);
if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then
break
end
end
pUnit5 = playerUnits:Create(iFive, lastPlot:GetX(), lastPlot:GetY())
lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY());
end
end
pPlayer:GetTreasury():SetGoldBalance(PlayerGold);
local curPlayerTech = pPlayer:GetTechs();
if(curPlayerTech ~= nil) then
if (Tech_One ~= nil) then
curPlayerTech:SetResearchProgress(Tech_One.Index, curPlayerTech:GetResearchCost(Tech_One.Index));
end
if(Tech_Two ~= nil) then
curPlayerTech:SetResearchProgress(Tech_Two.Index, curPlayerTech:GetResearchCost(Tech_Two.Index));
end
if(Tech_Three ~= nil) then
curPlayerTech:SetResearchProgress(Tech_Three.Index, curPlayerTech:GetResearchCost(Tech_Three.Index));
end
if(Tech_Four ~= nil) then
curPlayerTech:SetResearchProgress(Tech_Four.Index, curPlayerTech:GetResearchCost(Tech_Four.Index));
end
if(Tech_Five ~= nil) then
curPlayerTech:SetResearchProgress(Tech_Five.Index, curPlayerTech:GetResearchCost(Tech_Five.Index));
end
if(Tech_Six ~= nil) then
curPlayerTech:SetResearchProgress(Tech_Six.Index, curPlayerTech:GetResearchCost(Tech_Six.Index));
end
if(Tech_Seven ~= nil) then
curPlayerTech:SetResearchProgress(Tech_Seven.Index, curPlayerTech:GetResearchCost(Tech_Seven.Index));
end
if(Tech_Eight ~= nil) then
curPlayerTech:SetResearchProgress(Tech_Eight.Index, curPlayerTech:GetResearchCost(Tech_Eight.Index));
end
end
local curPlayerCivics = pPlayer:GetCivics();
if(curPlayerCivics ~= nil) then
if (Civics_One ~= nil) then
curPlayerCivics:SetResearchProgress(Civics_One.Index, curPlayerCivics:GetResearchCost(Civics_One.Index));
end
if(Civics_Two ~= nil) then
curPlayerCivics:SetResearchProgress(Civics_Two.Index, curPlayerCivics:GetResearchCost(Civics_Two.Index));
end
if(Civics_Three ~= nil) then
curPlayerCivics:SetResearchProgress(Civics_Three.Index, curPlayerCivics:GetResearchCost(Civics_Three.Index));
end
if(Civics_Four ~= nil) then
curPlayerCivics:SetResearchProgress(Civics_Four.Index, curPlayerCivics:GetResearchCost(Civics_Four.Index));
end
if(Civics_Five ~= nil) then
curPlayerCivics:SetResearchProgress(Civics_Five.Index, curPlayerCivics:GetResearchCost(Civics_Five.Index));
end
if(Civics_Six ~= nil) then
curPlayerCivics:SetResearchProgress(Civics_Six.Index, curPlayerCivics:GetResearchCost(Civics_Six.Index));
end
if(Civics_Seven ~= nil) then
curPlayerCivics:SetResearchProgress(Civics_Seven.Index, curPlayerCivics:GetResearchCost(Civics_Seven.Index));
end
if(Civics_Eight ~= nil) then
curPlayerCivics:SetResearchProgress(Civics_Eight.Index, curPlayerCivics:GetResearchCost(Civics_Eight.Index));
end
end
end
end
end
function Initialize()
Events.LocalPlayerChanged.Add( OnPlayerTurnActivated );
Events.PlayerTurnActivated.Add(OnPlayerTurnActivated);
end
Initialize();
</pre>