[QUES] [SOLVED] (GDT-ModAPI) Persistent Data

Hey I am using

SprChrg.dataStore = GDT.getDataStore("SprChrg-mod");

But any data written to that datastore object does not persist. I must be missing something, I tried to look at the data for the save function but I am not even sure where its even getting the data to be persisted.

How are you setting the variables in the data store? Variables inside SprChrg.dataStore.data are saved to the save slot when the slot is saved either automatically or through the save button (wow, how many times did I say “save” there?). Variables inside SprChrg.dataStore.settings, on the other hand, won’t save without calling DataStore.saveSettings(); or manually changing something in the settings menu in-game.

1 Like

Alot of saves there but from what you said I think I got this cleared up

SprChrg.dataStore = GDT.getDataStore("SprChrg-mod");
SprChrg.dataStore.data.myFlag = true; /* Persists to save */
SprChrg.dataStore.myFlag = true; /* Does not persist */

Would that be correct usage? and Obviously I was doing the latter.

Correct usage is: SprChrg.dataStore.data.myFlag = true

There is currently a bug in the global persistence, see this for more information:
http://forum.greenheartgames.com/t/que-am-i-using-datastore-settings-wrong-or-is-it-broken/9006

If you’re using the UltimateLib, you can, however, make use of the UltimateLib.Storage class and have more control over the data, i.e.:

// Setup settings object with default values
var mySettingsObj = { speed: 1, rate: 2, name: "Test" };

// Read from storage using settings objects as default value(s)
var settingsFromStorage = UltimateLib.Storage.read('MyStorageId', mySettingsObj);

// Write to storage
UltimateLib.Storage.write('MyStorageId', mySettingsObj);

For more information, see: http://gdt-ultimatesuite.abesco.de/docs/classes/UltimateLib.Storage.html

2 Likes

Thanks for the help Alphabit & Darkly, I am using UltimateLib so that solution should also work.

3 Likes