[Lua] read/update GameInfo metatable

Nefliqus

Prince
Joined
Sep 16, 2010
Messages
400
Location
Poland
how to read and update values from this metatable:
GameInfo/MinorCivTrats

mini_Nefliqus_phpyfR5iW_gameinfo.jpg
 
GameInfo is just a convenient way of accessing some of tables in the internal database. So reading values is simple.

Direct access by ID:
Code:
t = GameInfo.MinorCivTraits[0]

Direct access by Type:
Code:
t = GameInfo.MinorCivTraits["MINOR_TRAIT_CULTURED"]

Iterating over all the entries:
Code:
for t in GameInfo.MinorCivTraits() do ... end

In every case, t is a table representing a database row and so you could access, for example t.TraitIcon or t.Description.

However, because this is disguised database access, any changes you make from Lua once the game is running won't actually do anything. i.e. if I make a change to one of the icons, subsequent calls to the GameInfo will show the new value, but the actual icon used by the game won't change. If you want to change that table, you must do it with an XML/SQL file linked to an UpdateDatabase action that will run when the mod loads.
 
Thank you very much. You have helped me alot.
I know that i can modify xml file but i can do it only before lunching the game. I want change some value during the game. Is there any method to do it by Lua command? Could I use DB.Query with SQL UPDATE to modify game parameters during game? How could I reload/refresh it into game? And which db base in proper to do it, Civ5DebugDatabase.db ?
 
Unfortunately, nobody here has yet figured out how to update the database from a running game. The Localization database can be changed on the fly, but the Core/Debug database just doesn't reflect any changes.
 
In the Action tab of the ModBuddy it says:
Mod actions control what a mod actually *does* once activated. Actions are grouped together in named Sets. Certain sets such as "OnModActivated" are executed automatically. It's possible to create their own named Action Set and manually execute it.
Doesn't that mean that if someone makes an OnWhatever that is triggered during gameplay, it should have an effect on the game? Why else would they allow for a mod to take effect other than on mod activation?
 
In the Action tab of the ModBuddy it says:

Doesn't that mean that if someone makes an OnWhatever that is triggered during gameplay, it should have an effect on the game? Why else would they allow for a mod to take effect other than on mod activation?

possibly during game setup.

but I've not found an usefull use for it yet :D

For example, for Ynaemp I've tried to update the city-states table with a custom selection based on game option at launch, but the table is not included in the savegame, so when you quit civ and launch/reload your game, the table is the one loaded with the mods, not the one that was updated during the initial game setting...
 
possibly during game setup.

but I've not found an usefull use for it yet :D

For example, for Ynaemp I've tried to update the city-states table with a custom selection based on game option at launch, but the table is not included in the savegame, so when you quit civ and launch/reload your game, the table is the one loaded with the mods, not the one that was updated during the initial game setting...

Could you past code of this city-states table update here.

PSI dont know why firaxis has blocked mods for multiplayer games :( So many thinks could be easier. I had idea to create own DLC and use it as a mod for multiplayer games but it is also impossible. :) a crazy idea :)
 
in the action tab of your Modbuddy property normal row are something like that:

OnModActivated | UpdateDatabase | RulesChange.xml

where RulesChange.xml contains the information to add/update/remove from the database.

if you set a row like that :

MyActionName | UpdateDatabase | RulesChange.xml

you can apply the content of RulesChange.xml when you want in LUA with :

Modding.PerformActions("MyActionName")

The problem, as stated, is that you can use it only before launch (ie during custom setup), during a game session the change will be made in the database but won't be read by the game engine.
 
Back
Top Bottom