Updating GameInfo from Lua (how come sometimes it works and sometimes it doesn't?)

Ryoga

King
Joined
Oct 12, 2010
Messages
993
So lately I've been messing with Gameinfo and I tried to find ways to retrieve and change data in its tables.
At first it was promising, it seemed to be quite easy, but then I reached a wall with tables related to leader dialogs.

As an example, this is the testing code that I created:

Code:
GameInfo.Diplomacy_Responses[655].Response = "Test String"
local temp = GameInfo.Diplomacy_Responses[655].Response
GameInfo.Technologies[0].Description = "Test String"
local temp2 = GameInfo.Technologies[0].Description
print( "This mod is working and: "..temp .." and " ..temp2)

Related XML codes:

Code:
<Row LeaderType="GENERIC">
	<ResponseType>RESPONSE_INFLUENTIAL_ON_AI</ResponseType>
	<Response>TXT_KEY_GENERIC_INFLUENTIAL_ON_AI%</Response>
</Row>

Code:
<Row>
	<ID>0</ID>
	<Type>TECH_AGRICULTURE</Type>
	<Cost>20</Cost>
	<Description>TXT_KEY_TECH_AGRICULTURE_TITLE</Description>
	<Civilopedia>TXT_KEY_TECH_AGRICULTURE_DESC</Civilopedia>
	<Help>TXT_KEY_TECH_AGRICULTURE_HELP</Help>
	<Era>ERA_ANCIENT</Era>
	<Trade>true</Trade>
	<GoodyTech>true</GoodyTech>
	<GridX>0</GridX>
	<GridY>5</GridY>
	<Quote>TXT_KEY_TECH_AGRICULTURE_QUOTE</Quote>
	<PortraitIndex>0</PortraitIndex>
	<IconAtlas>TECH_ATLAS_1</IconAtlas>
	<AudioIntro>AS2D_TECH_AGRICULTURE</AudioIntro>
	<AudioIntroHeader>AS2D_HEADING_TECH_AGRICULTURE</AudioIntroHeader>
</Row>


I used exactly the same method for both "Technologies" and "Diplomacy_Responses".
In both cases the system to retrieve data is correct as it gives the correct result on the print (the row's ID on Diplomacy_Responses is indeed 655).
However while in the case of "Technologies" both in the game and on Live Tuner the selected entry is correctly replaced with "Test String", absolutely nothing happens with "Diplomacy_Responses", not even an error notification and the default line "TXT_KEY_GENERIC_INFLUENTIAL_ON_AI%" is given instead.

Just why?

And let's suppose that I want to find another way to change an entry on "Diplomacy_Responses" or directly on the line on "Language_en_US" (which seems to be even harder as it isn't even a table in GameInfo), what should I do?
 
The GameInfo table reference is shorthand, and it only applies to tables with ID and Type columns (read this post).

What exactly are you trying to do? Since you're using Lua already, there's no need to change the database when you can just change the contents of the display.

...or directly on the line on "Language_en_US" (which seems to be even harder as it isn't even a table in GameInfo)
Language_en_US (and the other languages) pretend to be tables, but they are Views within the "Localization-Merged.db" SQLite database.
 
The GameInfo table reference is shorthand, and it only applies to tables with ID and Type columns (read this post).

What exactly are you trying to do? Since you're using Lua already, there's no need to change the database when you can just change the contents of the display.

I guess it's the only available path as there doesn't seem to be a reliable way to change the database (or at any rate all my attempts have failed). However I'm very unfamiliar with anything related to the UI.

What I'm trying to do is finding a way to change the text displayed during a leader dialog based on who YOU are rather than on who THEY are.

The line in my example that I tried to change is

Code:
<Row LeaderType="GENERIC">
	<ResponseType>RESPONSE_INFLUENTIAL_ON_AI</ResponseType>
	<Response>TXT_KEY_GENERIC_INFLUENTIAL_ON_AI%</Response>
</Row>

from "Civ5Diplomacy_Responses_Expansion2.xml"

Which redirects to

Code:
<Row Tag="TXT_KEY_GENERIC_INFLUENTIAL_ON_AI_1">
	<Text>Our people are now buying your blue jeans and listening to your pop music. I worry the rest of the world will also succumb to the influence of your culture.</Text>
</Row>

on "Civ5_Dialog__GENERIC.xml".


Now I've been looking for where this is handled in the "UI" specifically in "DiscussionDialog.lua". However I couldn't find anything about that specific line in there.
Instead I found it inside the DLL source code in "CvDiplomacyAI.cpp", which seems to suggest that that's where it's handled, and I have no clue on how the result is then used by the lua interface and in which form.
 
Back
Top Bottom