civ specific bonus 2 problem

bismark439

Chieftain
Joined
Aug 26, 2013
Messages
34
THe screen shot is attatched.

I made a Civilization choosing screen. It only have option of greece.
Code:
----------------------------------------------------------------
include( "IconSupport" );
include( "UniqueBonuses" );
----------------------------------------------------------------

function ShowHideHandler( bIsHide, bIsInit )
    if( not bIsHide ) then
        Controls.MyGameScreenLogo:SetTexture( "Alex_BG.dds" );
    else
        Controls.MyGameScreenLogo:UnloadTexture();
    end
end
ContextPtr:SetShowHideHandler( ShowHideHandler );

----------------------------------------------------------------
----------------------------------------------------------------
function OnBack()
	UIManager:DequeuePopup( ContextPtr );
end
----------------------------------------------------------------       
Controls.BackButton:RegisterCallback(Mouse.eLClick, OnBack);
----------------------------------------------------------------
ContextPtr:SetInputHandler( function(uiMsg, wParam, lParam)
    if uiMsg == KeyEvents.KeyDown then
        if wParam == Keys.VK_ESCAPE or wParam == Keys.VK_RETURN then
			OnBack();
        end
    end
    return true;
end);
----------------------------------------------------------------
-- Handle Start Button
Controls.StartButton:RegisterCallback(Mouse.eLClick, function()
	for i = 0, GameDefines.MAX_MAJOR_CIVS do
		local civIndex = PreGame.GetCivilization(i);
		if(civIndex ~= -1) then
			if(GameInfo.Civilizations[i] == nil) then
				PreGame.SetCivilization(-1);
			end
		end
	end

	PreGame.SetRandomMapScript(false);
	PreGame.SetEarthMap(false);
	PreGame.SetLoadWBScenario(true);
	PreGame.SetOverrideScenarioHandicap(true);

	PreGame.SetHandicap(0, g_CurrentDifficulty);
	
	-- Disable all victory types except domination.
	for row in GameInfo.Victories() do
		PreGame.SetVictory(row.ID, false);
	end
	
	local victory = GameInfo.Victories.VICTORY_DOMINATION;
	if(victory) then
		PreGame.SetVictory(victory.ID, true);
	end

	local myModId = "5363a2f5-bcba-443b-80c1-fdac0f564d74";
	local myModVersion = Modding.GetActivatedModVersion(myModId);

	local file = Modding.GetEvaluatedFilePath(myModId, myModVersion, "AlexanderConquest.Civ5Map");
	PreGame.SetMapScript(file.EvaluatedPath);
	UI.ResetScenarioPlayerSlots();
	UI.MoveScenarioPlayerToSlot(0, 0);
	
	Events.SerialEventStartGame();
	UIManager:SetUICursor( 1 );
--	UIManager:DequeuePopup( ContextPtr );
end);
----------------------------------------------------------------

function DifficultySelected(button, difficulty)
	g_CurrentDifficulty = difficulty;
	g_CurrentDifficultyButton.SelectionAnim:SetHide(true);

	button.SelectionAnim:SetHide(false);
	g_CurrentDifficultyButton = button;
end

function Initialize()
	
	local defaultDifficulty = GameInfo.HandicapInfos["HANDICAP_KING"];
	if(defaultDifficulty == nil) then
		defaultDifficulty = GameInfo.HandicapInfos()();	-- Get first handicap found.
	end

	g_CurrentDifficulty = defaultDifficulty.ID;
	
	----------------------------------------------------------------        
	-- build the buttons
	----------------------------------------------------------------        
	for info in GameInfo.HandicapInfos() do
		local controlTable = {};
		ContextPtr:BuildInstanceForControl( "ItemInstance", controlTable, Controls.DifficultyStack );

		if(info.ID == g_CurrentDifficulty) then
			g_CurrentDifficultyButton = controlTable;
			controlTable.SelectionAnim:SetHide(false);
		end

		IconHookup( info.PortraitIndex, 64, info.IconAtlas, controlTable.Icon );
		controlTable.Help:LocalizeAndSetText(info.Help);
		controlTable.Name:LocalizeAndSetText(info.Description);
		controlTable.Button:SetToolTipString(Locale.ConvertTextKey( info.Help ) );
		controlTable.Button:RegisterCallback(Mouse.eLClick, function() DifficultySelected(controlTable, info.ID); end);
	end

	Controls.DifficultyStack:CalculateSize();
	Controls.DifficultyStack:ReprocessAnchoring();
	Controls.DifficultyScrollPanel:CalculateInternalSize();

    -- Use the Civilization_Leaders table to cross reference from this civ to the Leaders table
	local civ = GameInfo.Civilizations["CIVILIZATION_GREECE"];
    local leader = GameInfo.Leaders[GameInfo.Civilization_Leaders( "CivilizationType = '" .. civ.Type .. "'" )().LeaderheadType];
    local leaderDescription = leader.Description;

	-- Set Leader & Civ Text
	Controls.Civilization:LocalizeAndSetText( civ.Description );
	Controls.Leader:LocalizeAndSetText( leaderDescription );

	    -- Set Civ Leader Icon
	IconHookup( leader.PortraitIndex, 128, leader.IconAtlas, Controls.Portrait );
		
	-- Set Civ Icon
	IconHookup( civ.PortraitIndex, 80, civ.IconAtlas, Controls.IconShadow );
		
	-- Sets Trait bonus Text
    local leaderTrait = GameInfo.Leader_Traits("LeaderType ='" .. leader.Type .. "'")();
    local trait = leaderTrait.TraitType;
    Controls.BonusTitle:SetText( Locale.ConvertTextKey( GameInfo.Traits[trait].ShortDescription ));
    Controls.BonusDescription:SetText( Locale.ConvertTextKey( GameInfo.Traits[trait].Description ));
        
    -- Sets Bonus Icons
    local bonusText = PopulateUniqueBonuses( Controls, civ, leader, false );
        
    Controls.BonusUnit:LocalizeAndSetText( bonusText[1] or "" );
    Controls.BonusBuilding:LocalizeAndSetText( bonusText[2] or "" );
        
    -- Sets Dawn of Man Quote
	Controls.Quote:LocalizeAndSetText("TXT_KEY_BRIEFING_ALXSC");	

	Controls.MainStack:CalculateSize();
	Controls.MainStack:ReprocessAnchoring();
	Controls.DoMScrollPanel:CalculateInternalSize();
end

Initialize();
this is the content of scenario starting screen. lua.log says there is a problem of loading civilization name

Code:
 -- Use the Civilization_Leaders table to cross reference from this civ to the Leaders table
	local civ = GameInfo.Civilizations["CIVILIZATION_GREECE"];
    local leader = GameInfo.Leaders[GameInfo.Civilization_Leaders( "CivilizationType = '" .. civ.Type .. "'" )().LeaderheadType];
    local leaderDescription = leader.Description;

which is this part. but CIVILIZATION_GREECE obviously exist in XML. why is it nil value?
 

Attachments

  • CivilizationV 2014-06-24 23-16-07-895.jpg
    CivilizationV 2014-06-24 23-16-07-895.jpg
    374.5 KB · Views: 91
Back
Top Bottom