DeckerdJames
Warlord
- Joined
- Nov 1, 2019
- Messages
- 235
I was having a problem. I wanted to register for an event in my lua file. I put the following into my lua file that is in a UIContext. The game would hang while it was trying to load a new game.
It would hang when the game was loading at the last line of this, in the lua console of Firetuner. The leader description page was displayed but the button to enter the new game had not come up yet.
so I sought to register the event during the LoadGameViewStateDone event, which is the last line in the lua console output when loading a new game. Like this:
this caused the game to get a little further, but still, it had an error before the game was ready to be entered and it bounced me back to the main menu. In the lua log it had some errors but I do not have a copy of them. Essentially it said (i think) that it was trying to use a nil string as an operator which was not allowed in two of the official Firaxis UI assets. They were:
...\Sid Meier's Civilization VI\Base\Assets\UI\DiplomacyRibbon.lua
...\Sid Meier's Civilization VI\DLC\Expansion2\UI\Replacements\DiplomacyRibbon_Expansion2.lua
the error was either in the UpdateLeaders() function below: from ...\Sid Meier's Civilization VI\Base\Assets\UI\DiplomacyRibbon.lua
or the error was in the one from the expansion from ...\Sid Meier's Civilization VI\DLC\Expansion2\UI\Replacements\DiplomacyRibbon_Expansion2.lua
or the error was in both files, or perhaps neither files, and the cause is something else.
Well, I have just not tried anything further with this particular event, but I was wondering if anyone knows what is happening. Does this particular event need a gameplay context lua file rather than a UI context lua file?
Code:
function OnDiplomacyDeclareWar(FirstID, SecondID)
print("OnDiplomacyDeclareWar")
end
Events.DiplomacyDeclareWar(OnDiplomacyDeclareWar)
It would hang when the game was loading at the last line of this, in the lua console of Firetuner. The leader description page was displayed but the button to enter the new game had not come up yet.
Code:
TutorialUIRoot: Tutorial: Firaxis in game tutorial prompts.
TutorialUIRoot: Version: 1
TutorialUIRoot: Loading bank of items for tutorial scenario: 'BASE'
so I sought to register the event during the LoadGameViewStateDone event, which is the last line in the lua console output when loading a new game. Like this:
Code:
function OnLoadGameViewStateDone()
Events.DiplomacyDeclareWar(OnDiplomacyDeclareWar)
end
Events.LoadGameViewStateDone( OnLoadGameViewStateDone )
this caused the game to get a little further, but still, it had an error before the game was ready to be entered and it bounced me back to the main menu. In the lua log it had some errors but I do not have a copy of them. Essentially it said (i think) that it was trying to use a nil string as an operator which was not allowed in two of the official Firaxis UI assets. They were:
...\Sid Meier's Civilization VI\Base\Assets\UI\DiplomacyRibbon.lua
...\Sid Meier's Civilization VI\DLC\Expansion2\UI\Replacements\DiplomacyRibbon_Expansion2.lua
the error was either in the UpdateLeaders() function below: from ...\Sid Meier's Civilization VI\Base\Assets\UI\DiplomacyRibbon.lua
Code:
function UpdateLeaders()
ResetLeaders();
m_ribbonStats = Options.GetUserOption("Interface", "RibbonStats");
-- Add entries for everyone we know (Majors only)
local kPlayers :table = PlayerManager.GetAliveMajors();
local kMetPlayers :table = {};
local kUniqueLeaders:table = {};
local localPlayerID:number = Game.GetLocalPlayer();
local pPlayer : table = PlayerConfigurations[localPlayerID];
if localPlayerID ~= -1 then
local localPlayer :table = Players[localPlayerID];
local localDiplomacy:table = localPlayer:GetDiplomacy();
table.sort(kPlayers, function(a:table,b:table) return localDiplomacy:GetMetTurn(a:GetID()) < localDiplomacy:GetMetTurn(b:GetID()) end);
AddLeader("ICON_"..PlayerConfigurations[localPlayerID]:GetLeaderTypeName(), localPlayerID, {}); --First, add local player.
kMetPlayers, kUniqueLeaders = GetMetPlayersAndUniqueLeaders(); --Fill table for other players.
else
-- No local player so assume it's auto-playing, or local player is dead and observing; show everyone.
for _, pPlayer in ipairs(kPlayers) do
local playerID:number = pPlayer:GetID();
kMetPlayers[ playerID ] = true;
if (kUniqueLeaders[playerID] == nil) then
kUniqueLeaders[playerID] = true;
else
kUniqueLeaders[playerID] = false;
end
end
end
--Then, add the leader icons.
for _, pPlayer in ipairs(kPlayers) do
local playerID:number = pPlayer:GetID();
if(playerID ~= localPlayerID) then
local isMet :boolean = kMetPlayers[playerID];
local pPlayerConfig :table = PlayerConfigurations[playerID];
local isHumanMP :boolean = (GameConfiguration.IsAnyMultiplayer() and pPlayerConfig:IsHuman());
if (isMet or isHumanMP) then
local leaderName:string = pPlayerConfig:GetLeaderTypeName();
local isMasked :boolean = (isMet==false) and isHumanMP; -- Multiplayer human but haven't met
local isUnique :boolean = kUniqueLeaders[leaderName];
local iconName :string = "ICON_LEADER_DEFAULT";
-- If in an MP game and a player leaves the name returned will be NIL.
if isMet and (leaderName ~= nil) then
iconName = "ICON_"..leaderName;
end
AddLeader(iconName, playerID, {
isMasked=isMasked,
isUnique=isUnique
}
);
end
end
end
RealizeSize();
end
or the error was in the one from the expansion from ...\Sid Meier's Civilization VI\DLC\Expansion2\UI\Replacements\DiplomacyRibbon_Expansion2.lua
Code:
function UpdateLeaders()
-- Create and add World Congress button if one was allocated (based on capabilities)
if m_kCongressButtonIM then
if Game.GetEras():GetCurrentEra() >= GlobalParameters.WORLD_CONGRESS_INITIAL_ERA then
m_kCongressButtonIM:ResetInstances();
local pPlayer:table = PlayerConfigurations[Game.GetLocalPlayer()];
if(pPlayer ~= nil and pPlayer:IsAlive())then
m_oCongressButton = CongressButton:GetInstance( m_kCongressButtonIM );
m_congressButtonWidth = m_oCongressButton.Top:GetSizeX();
else
m_congressButtonWidth = 0;
end
end
end
BASE_UpdateLeaders();
end
or the error was in both files, or perhaps neither files, and the cause is something else.
Well, I have just not tried anything further with this particular event, but I was wondering if anyone knows what is happening. Does this particular event need a gameplay context lua file rather than a UI context lua file?