-
Notifications
You must be signed in to change notification settings - Fork 2
Using ElysionStorage
Elysion's storage class is very similar to HTML5 LocalStorage. It can store a key which consists a key name (String) and a value (also a String). There are several functions which converts the value to a different type (Boolean, Integer, Single). It is also possible to convert Elysion types such as TelColor, TelVector2i, TelVector2f, TelVector3i, TelVector3f or TelSize to a key.
To add or modify a key simply add this little snippet:
Storage.SetKey(KeyName, Value);
If the key does not exist, it will be added. If the key exists with another value, it will be overwritten with the new value. If Storage.AutoSave
is set to true (which it is by default), the file will be saved.
To access a key use
Storage.GetKey(KeyName)
or
Storage.GetKeyValue(KeyName)
The first one returns the key object, the latter the key value.
To check if a key exists simply type Storage.KeyExists(KeyName);
which returns a true if this key exists and false if it does not. You don't need to check if a key exists each time you want to access a key, this is already done internally.
You should be careful not to add Storage-specific code into the game loop (e.g. Draw- and Update-methods of scenes).