Craig_Sutter
Deity
I have created very many (7) functions in the following form:
I have rethought my objective in this and determined that I only want these Declarations of War to be for nonHuman players.
I have 7 such functions all set up in one file. I have attempted to alter each individually, but keep getting errors. It's likely because of bad organization in my coding, but when I add "not IsHuman" as part of the "if" statements, the function breaks down and doesn't work.
I am wondering, is there a simple way to nest these functions such that one greater function based upon the player being not human would call these lesser functions? I've tinkered with doing so, but again, failed. Is there an easy way to accomplish this?
My knowledge of Lua is limited, and when I start getting into functions within or calling other functions, I'm out of my depth. I'm hoping it is a simple process that is simply unknown to me.
Thank-you for your help.
Code:
function DenmarkAnglesWar()
if Game.GetGameTurn() == 0 then
----print(">>>> DeclareWar");
local DenmarkTeam
local AnglesTeam
local DenmarkTeamID
local AnglesTeamID
for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do
local pDenmark = Players[iPlayer]
if (pDenmark:IsAlive()) then
--if (pDenmark:IsAlive() and not pDenmark:IsHuman()) then
if (GameInfo.Civilizations.CIVILIZATION_DENMARK.ID == pDenmark:GetCivilizationType()) then
DenmarkTeamID = pDenmark:GetTeam();
DenmarkTeam= Teams[ pDenmark:GetTeam() ]
--print(pDenmark:GetName());
--print(pDenmark:GetTeam());
else
end
end
end
for iPlayer=GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-1, 1 do
local pAngles = Players[iPlayer]
if (pAngles:IsAlive()) then
if (GameInfo.MinorCivilizations.MINOR_CIV_ANGLES.ID == pAngles:GetMinorCivType()) then
AnglesTeamID = pAngles:GetTeam();
AnglesTeam= Teams[ pAngles:GetTeam() ]
--print(pAngles:GetName());
--print(pAngles:GetTeam());
else
end
end
end
DenmarkTeam:DeclareWar( AnglesTeamID, true );
DenmarkTeam:SetPermanentWarPeace(AnglesTeamID, true);
AnglesTeam:SetPermanentWarPeace(DenmarkTeamID, true);
if (DenmarkTeam:IsAtWar(AnglesTeamID)) then
print ("Denmark is at war with the Angles");
end
end
end
Events.ActivePlayerTurnEnd.Add(DenmarkAnglesWar)
I have rethought my objective in this and determined that I only want these Declarations of War to be for nonHuman players.
I have 7 such functions all set up in one file. I have attempted to alter each individually, but keep getting errors. It's likely because of bad organization in my coding, but when I add "not IsHuman" as part of the "if" statements, the function breaks down and doesn't work.
I am wondering, is there a simple way to nest these functions such that one greater function based upon the player being not human would call these lesser functions? I've tinkered with doing so, but again, failed. Is there an easy way to accomplish this?
My knowledge of Lua is limited, and when I start getting into functions within or calling other functions, I'm out of my depth. I'm hoping it is a simple process that is simply unknown to me.
Thank-you for your help.