Skip to content
Tyler edited this page Mar 11, 2018 · 1 revision

GDT.getDataStore can be used to persist mod-specific data for both save-game specific data and game-wide settings.

Usage is fairly simply.

var dataStore = GDT.getDataStore("my-plugin-id");

This will return a object with a data and a settings member. You can use dataStore.data to access save-game specific data and dataStore.settings to access game-wide settings.

.data .settings
used to store save-game specific settings. when loading a game this will be reinitialized with the appropriate data from the save. all game-state related data should be stored here. used to store game-wide settings. regardless of save game these will always be there. only use this for general-purpose settings. do not use for game state.

Both data and settings objects are simply JS objects that will be persisted via JSON automatically when saving/loading games.

Example to check for a custom flag you can just use:

dataStore.data.myFlag;

to set the same flag you can use

dataStore.data.myFlag = true;

Note Data written to data while no game is loaded will vanish in nirvana. Only rely on that when a game is loaded/running.

Clone this wiki locally