[lua] How to connect custom db?

There are two mod db's - one that only exists for the duration of a game and one that exists across games. As well as storing name/value pairs into them, you can also run arbitary SQL statements against them, including creating tables, indexes, etc

Modding.OpenUserData(name, version) gets you a handle to the permanent one, while Modding.OpenSaveData() gets a handle to the game only one.

See here for a brief discussion of the "trick" you need to execute non-query statements - http://forums.2kgames.com/showthread.php?108164-Modding.OpenSaveData()-for-beginners
 
There is only one "Save Data" database per game so you use Modding.OpenSaveData() - but that db is specific to a particular game.

You can have any number of "User Data" databases as they persist from one game to another. It is recommeneded that the parameters are the mod guid and version, but they don't have to be. All of my "Summary Bar" mods use the same user data db by calling Modding.OpenUserData("SummaryBar", 2) - the 2 indicates my private version number for the layout of the data inside the db

If you just used what you suggested how would it know which db file to open (if you look in the cache you'll find the db files that correspond to the parameters used in the open method)

HTH

W
 
There is only one "Save Data" database per game so you use Modding.OpenSaveData() - but that db is specific to a particular game.

You can have any number of "User Data" databases as they persist from one game to another. It is recommeneded that the parameters are the mod guid and version, but they don't have to be. All of my "Summary Bar" mods use the same user data db by calling Modding.OpenUserData("SummaryBar", 2) - the 2 indicates my private version number for the layout of the data inside the db

If you just used what you suggested how would it know which db file to open (if you look in the cache you'll find the db files that correspond to the parameters used in the open method)

HTH

W

Thank you.
 
Back
Top Bottom