mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +00:00
Clone
3
Storage
Robert Beekman edited this page 2017-09-12 14:22:28 +02:00
Table of Contents
The Storage module allows you to store values to permanently for later use, useful for things like settings and highscores.
Overview
Usage
ProfileStorage
Used to store a value within the profile.
This is the preferred place to store things since it is not accesable outside the script's profile.
Example:
-- Set a value the same way as a regular LUA table
ProfileStorage["highscore"] = 500
-- Retrieve the value at a later time
local lastHighscore = ProfileStorage["highscore"]
GlobalStorage
Used to store a value globally within Artemis.
Anything you store here can be accessed by all LUA scripts, this is useful if you have settings that you want to reuse in other scripts.
Note: When storing things here other scripts could overwrite your value so make sure to pick a unique name.
Example:
-- Set a value the same way as a regular LUA table
GlobalStorage["favoriteColor"] = "blue"
-- Retrieve the value at a later time
local favoriteColor = GlobalStorage["favoriteColor"]
Notes
A few things to keep in mind when storing values
- You can only store primitive types and tables (which can also only contain primitive types). If you try to store something else Artemis will not save any of your settings.
- If you try to access a value that has never been set before, you'll get
nilso be sure to check for that, especially when concatenating strings. - Values are read from disk when the script is loaded and stored to disk when the script is unloaded.