Trigger API Reference\DCEI Functions\Save
void Save.Set(string key, object value)
void Save.Set(string key, object value)
Description
Sets the specified key-value pair in the save data. Save data must be committed with DCEI.Save.Commit()
to actually save the data.
Parameters
- string
key
the key of the pair. - object
value
the value of the pair.
Example Usage
DCEI.Save.Set("key", "value")
DCEI.Save.Commit()
object Save.Get(string key)
object Save.Get(string key)
Description
Returns the value associated with the given key.
Parameters
- string
key
the key to return the value of.
Example Usage
DCEI.Save.Set("key", "value")
DCEI.Save.Commit()
local save_val = DCEI.Save.Get("key")
DCEI.LogMessage(save_val)
void Save.Commit()
void Save.Commit()
Description
Writes the current save data to the user's save data. You can view the editor's local save data under Play Settings.
Example Usage
DCEI.Save.Set("key", "value")
DCEI.Save.Commit()
local save_val = DCEI.Save.Get("key")
DCEI.LogMessage(save_val)
void Save.SetMapEntry(string entry)
void Save.SetMapEntry(string entry)
Description
Sets the map entry in save data. Only works in mobile or web builds. Useful if your game has a series of maps to progress through instead of always loading the same entry map.
Parameters
- string
entry
the map entry name.
Example Usage
DCEI.Save.SetMapEntry("Map Entry")
DCEI.Save.Commit()
void Save.SetLockSaveData(bool set)
void Save.SetLockSaveData(bool set)
Description
Enable/disable the game's ability to write to save data. Intended for testing purposes only.
Parameters
- bool
set
set to true to prevent the game from modifying save data.
Example Usage
local current = DCEI.Save.GetLockSaveDataStatus(bool set)
DCEI.Save.SetLockSaveData(not current)
bool Save.GetLockSaveDataStatus()
bool Save.GetLockSaveDataStatus()
Description
Get the game's "locked save data" status, which is a player settings option for disabling the editor's ability to write save data. This is used for testing purposes, to retest a FTUE without having to reset save data manually.
Example Usage
local current = DCEI.Save.GetLockSaveDataStatus(bool set)
DCEI.Save.SetLockSaveData(not current)
object Save.GetAllKeys()
object Save.GetAllKeys()
Description
Gets all index keys for the players current save data and returns them as a lua table.
Example Usage
local save_data = DCEI.Save.GetAllKeys()
for k, v in pairs (save_data) do
DCEI.LogMessage(v)
end
object Save.GetCurrentSaveData()
object Save.GetCurrentSaveData()
Description
Gets all of the users current save data in one lua dictionary.
Example Usage
```lua
local save_data = DCEI.Save.GetCurrentSaveData()
for k, v in pairs (save_data) do
DCEI.LogMessage(k .. tostring(v))
end