[Solved] GameInfo.CivilizationLeaders["LEADER_JAYAVARMAN"] is nil?

Serp

King
Joined
Apr 1, 2015
Messages
661
I'm currently experimenting with hellblazers UI Notification https://steamcommunity.com/sharedfiles/filedetails/?id=1304210829 mod and trying to fix some problems.

According to lua.log the following is nil:
GameInfo.CivilizationLeaders["LEADER_JAYAVARMAN"]
Why? Was sth about this changed?

The code is:
local leaderOne:string = PlayerConfigurations[PlayerID]:GetLeaderTypeName();
local civTypeO:string = GameInfo.CivilizationLeaders[leaderOne].CivilizationType;

with leaderOne being LEADER_JAYAVARMAN and the second line results in "attempt to index a nil value". Printing GameInfo.CivilizationLeaders[leaderOne] shows that it is indeed nil.
 
CivilizationLeaders is not a Parent table. If you want the text string of the civilization name for a player, just use
Code:
PlayerConfigurations[PlayerID]:GetCivilizationTypeName()
Otherwise to pull the data for a given leader from table CivilizationLeaders it is necessary to loop through the table:
Code:
local civTypeO
for row in GameInfo.CivilizationLeaders() do
   if row.LeaderType == PlayerConfigurations[PlayerID]:GetLeaderTypeName() then
      civTypeO = row.CivilizationType
      break
   end
end
 
Last edited:
@LeeS do you know if LeaderType (from PlayerConfigurations[secondPlayerID]:GetLeaderTypeName() ) was changed in GS ?
Someone reported that it returned "LEADER_ELEANOR_FRANCE" instead of "LEADER_ELEANOR" like I would expect, while the string I want to form should not contain "FRANCE" Locale.Lookup("LOC_" .. leaderOne .. "_NAME"). Can not test it myself, since I do not own GS yet.
 
"LEADER_ELEANOR_ENGLAND" -- "LOC_LEADER_ELEANOR_NAME"
"LEADER_ELEANOR_FRANCE" -- "LOC_LEADER_ELEANOR_NAME"

They actually use two different leaders, but both leaders use the same "Name" reference.

So you'll have to grab the LOC_SOMETHING direct and entirely from the Leaders table for column "Name" rather than concatenating.
Code:
local sLeaderType = PlayerConfigurations[secondPlayerID]:GetLeaderTypeName()
local sLeaderNameLOC = GameInfo.Leaders[sLeaderType].Name
local sTranslatedLeaderName = Locale.Lookup(sLeaderNameLOC)
Table "Leaders" requires "LeaderType" to be registered in table "Types" as a KIND_LEADER so you can use the direct-access GameInfo method to get the LOC_SOMETHING for the ".Name" column.
 
Last edited:
Top Bottom