Storage¶
This plugin's saved values: text by key, kept across launches, one file per plugin in
%LOCALAPPDATA%\Ballest\Saved\PluginManager\storage\. Each plugin only sees its own. Settings are saved
automatically; use Storage for everything else.
Get¶
string Storage::Get(const string &in key, const string &in fallback = "")
The saved value for a key, or fallback if there's none.
Example
// Load on start
void Main()
{
seconds = parseFloat(Storage::Get("seconds", "0"));
paused = Storage::Get("paused", "false") == "true";
}
Set¶
void Storage::Set(const string &in key, const string &in value)
Saves a value for a key. A changed value is written to disk straight away (setting the same value again writes nothing), so don't save a value that changes every frame. Save it every few seconds instead.
Example
// Save every 5 seconds while something changed
if (dirty && Host::Time() - lastSave > 5.0)
{
Storage::Set("seconds", formatFloat(seconds, "", 0, 3));
lastSave = Host::Time();
dirty = false;
}