Access saver data from Lua
-
- Posts: 222
- Joined: Wed Jan 22, 2020 10:48 pm
Access saver data from Lua
Is it possible to access a saver's data from Lua? I'm wondering if I should have each object's state saved with a saver, or use lua variables for state that needs to be accessed from lua.
Re: Access saver data from Lua
Generally speaking, a saver's data is only updated when saving the game or changing scenes. If that's fine for your needs, you can write a C# function to get the data, and then register that function with Lua. Here's an example of getting the saved value of an ActiveSaver:
Code: Select all
bool IsActiveSaverActive(string key)
{
string serializedData = PixelCrushers.SaveSystem.savedGameData.GetData(key);
return PixelCrushers.SaveSystem.Deserialize<ActiveSaver.Data>(serializedData).active;
}
-
- Posts: 222
- Joined: Wed Jan 22, 2020 10:48 pm
Re: Access saver data from Lua
Ah ok that makes good sense. Thanks!