Help with calling text.

JFD

Kathigitarkh
Joined
Oct 19, 2010
Messages
9,132
Location
The Kingdom of New Zealand
I'm trying to call a string from a custom table definition, but it keeps returning the error: attempt to index field 'Civilization_LeaderTitles' (a nil value). I have no trouble calling the same information from existing tables, so I'm at a loss for what I'm doing wrong.

This is the SQL:

Spoiler :
Code:
-- Civilization Leader Titles Table
CREATE TABLE Civilization_LeaderTitles
( 
  CivilizationType TEXT DEFAULT NULL,
  MightLeaderTitleText TEXT DEFAULT TXT_KEY_CHIEF_TITLE,
  
);
[/SPOILER]

This is the Lua:

Spoiler :
Code:
local CivType = player:GetCivilizationType();
GameInfo.Civilization_LeaderTitles[CivType].MightLeaderTitleText, player:GetNameKey(), player:GetCivilizationShortDescriptionKey());
[/SPOILER]
 
Code:
-- Civilization Leader Titles Table
CREATE TABLE Civilization_LeaderTitles
( 
  CivilizationType TEXT DEFAULT NULL,
  MightLeaderTitleText TEXT DEFAULT TXT_KEY_CHIEF_TITLE,
  FOREIGN KEY (CivilizationType) REFERENCES Civilizations(Type)
  
);

Try that instead. You aren't telling it that CivilizationType is actually the identifier of a row in another table.
 
GetCivilizationType() returns the database ID (which is an integer) of the Civ for that player, not the string name that you look like you want. Also, I believe tables are only included in the GameInfo lua table if they have both an ID and a Type column.
 
Back
Top Bottom