Iceco
Warlord
- Joined
- Oct 27, 2010
- Messages
- 188
In the DiploList and DiploRelationships.lua I'm trying to make some changes to the city-states.
They are generated as elements in a stack and I'm having trouble making changes to them. I want to make them support new CS traits other than the 3 vanilla ones and for that, I need to make certain changes around line 448 in DiploList.lua and line 490 in DiploRelationships.lua
Here is what I have and where I get an error message (in red):
So basically, I can't input my changes in the elements of the minor civ stack (called 'CityStack') in the DiploRelationships file.
PS: I put some code in "--" comments, those are in the DiploRelationships file and I kept them for reference.
Also, Happy Easter.
They are generated as elements in a stack and I'm having trouble making changes to them. I want to make them support new CS traits other than the 3 vanilla ones and for that, I need to make certain changes around line 448 in DiploList.lua and line 490 in DiploRelationships.lua
Here is what I have and where I get an error message (in red):
Code:
-------------------------------------------------
-- Diplomatic
-------------------------------------------------
include( "IconSupport" );
include( "SupportFunctions" );
include( "InstanceManager" );
include( "InfoTooltipInclude" );
local m_PlayerTable = Matchmaking.GetPlayerList();
local m_PlayerNames = {};
for i = 1, #m_PlayerTable do
m_PlayerNames[ m_PlayerTable[i].playerID ] = m_PlayerTable[i].playerName;
end
local g_MajorCivButtonIM = InstanceManager:new( "MajorCivButtonInstance", "DiploButton", Controls.ButtonStack );
local g_MinorCivButtonIM = InstanceManager:new( "MinorCivButtonInstance", "LeaderButton", Controls.MinorButtonStack );
local g_MajorCivTradeRowIMList = {};
local g_iDealDuration = Game.GetDealDuration();
local g_Deal = UI.GetScratchDeal();
local g_iUs = -1; --Game.GetActivePlayer();
local g_pUs = -1;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
function ShowHideHandler( bIsHide, bInitState )
g_iUs = Game.GetActivePlayer();
g_pUs = Players[ g_iUs ];
InitMinorCivList();
end
ContextPtr:SetShowHideHandler( ShowHideHandler );
function InitMinorCivList()
-- Clear buttons
-- g_MinorCivButtonIM:ResetInstances();
local iPlayer = Game.GetActivePlayer();
local pPlayer = Players[ iPlayer ];
local pTeam = Teams[pPlayer:GetTeam()];
local iMinorMetCount = 0;
local firstCityStateFound = nil;
for iPlayerLoop = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-1, 1 do
pOtherPlayer = Players[iPlayerLoop];
iOtherTeam = pOtherPlayer:GetTeam();
if (pPlayer:GetTeam() ~= iOtherTeam and pOtherPlayer:IsAlive()) then
if (pTeam:IsHasMet(iOtherTeam)) then
if (pOtherPlayer:IsMinorCiv()) then
iMinorMetCount = iMinorMetCount + 1;
SetCityStateTrait(iPlayerLoop)
end
end
end
end
end
function SetCityStateTrait(iPlayer)
local pPlayer = Players[iPlayer];
local strTraitSuffix = "";
local strTraitText = "";
local strTraitTT = "";
local iTrait = pPlayer:GetMinorCivTrait();
local strTrait = GameInfo.MinorCivTraits[iTrait].Type
strTraitSuffix = string.sub( strTrait, 13 )
strTraitText = Locale.ConvertTextKey( "TXT_KEY_CITY_STATE_" .. strTraitSuffix .. "_ADJECTIVE" )
strTraitTT = Locale.ConvertTextKey( "TXT_KEY_CITY_STATE_" .. strTraitSuffix .. "_TT" )
strTraitText = "[COLOR_POSITIVE_TEXT]" .. strTraitText .. "[ENDCOLOR]";
if strTraitText ~= nil then
ContextPtr:LookUpControl("/InGame/DiploRelationships/TraitInfo"):LocalizeAndSetText(strTraitText)
[color=red]-- Runtime Error: [string "<file path to my file>"]:77: attempt to index a nil value[/color]
end
if strTraitTT ~= nil then
ContextPtr:LookUpControl("/InGame/DiploRelationships/TraitInfo"):SetToolTipString(strTraitTT)
ContextPtr:LookUpControl("/InGame/DiploRelationships/TraitLabel"):SetToolTipString(strTraitTT)
end
-- pStack.TraitInfo:SetText(strTraitText);
-- pStack.TraitInfo:SetToolTipString(strTraitTT);
-- pStack.TraitLabel:SetToolTipString(strTraitTT);
end
PS: I put some code in "--" comments, those are in the DiploRelationships file and I kept them for reference.
Also, Happy Easter.