Data library
Part of Flow
Stores tables as JSON files on disk, for data that does not belong in the database. On the
server the files go to settings/flux/ in the game folder, on the client to the flux
folder inside the data folder of the game. Data.save, Data.load and Data.delete take
a key that is the name of the file inside that folder. The _schema variants keep the data
apart for every schema and map, and the _plugin variants build on those for the data of
plugins, which is usually loaded in a LoadData handler and saved in a SaveData handler:
function PLUGIN:LoadData()
self.texts = Data.load_plugin('3dtexts', {})
end
function PLUGIN:SaveData()
Data.save_plugin('3dtexts', self.texts)
end
Summary
Functions
Functions
On the server
Deletes a file saved with Data.save from 'settings/flux/', if it exists.
Parameters
- key String name of the file, '.json' is added if it has no extension
On the client
Deletes a file saved with Data.save from the 'flux' data folder, if it exists.
Parameters
- key String name of the file, '.dat' is added if it has no extension
Defined in
Deletes plugin data saved with Data.save_plugin for the current schema and map.
Parameters
- key String
Deletes a file from the data folder of the current schema and map.
Parameters
- key String
Lists the files inside a folder of the 'flux' data folder. Clientside only.
Parameters
- folder String
Returns
- List<String> file names, nil if the folder is not a string
On the server
Loads a table saved with Data.save from 'settings/flux/'. Throws an error in development mode if the file does not exist and no default is specified.
Parameters
- key String name of the file, '.json' is added if it has no extension
- default Any optional, defaults to
nilreturned if the file does not exist
Returns
- Map the loaded data, or the default
On the client
Loads a table saved with Data.save from the 'flux' data folder. Throws an error in development mode if the file does not exist and no default is specified.
Parameters
- key String name of the file, '.dat' is added if it has no extension
- default Any optional, defaults to
nilreturned if the file does not exist
Returns
- Map the loaded data, or the default
Defined in
Loads plugin data saved with Data.save_plugin for the current schema and map.
local loaded = Data.load_plugin('3dtexts', {})
Parameters
- key String
- default Any optional, defaults to
nilreturned if nothing has been saved yet
Returns
- Map the loaded data, or the default
See also
Loads a table from the data folder of the current schema and map.
Parameters
- key String
- default Any optional, defaults to
nilreturned if the file does not exist
Returns
- Map the loaded data, or the default
See also
On the server
Saves a table to 'settings/flux/' in the game folder as JSON. The '.json' extension is added if the key does not have one. Does nothing unless the value is a table.
Parameters
- key String name of the file, can include folders
- value Map data to save
On the client
Saves a table to the 'flux' folder inside the client's 'data' folder as JSON. The '.dat' extension is added if the key does not have one. Does nothing unless the value is a table.
Parameters
- key String name of the file, can include folders
- value Map data to save
Defined in
Saves plugin data. It is stored separately for every schema and map.
Parameters
- key String
- value Map data to save
See also
Saves a table to the data folder of the current schema and map.
Parameters
- key String
- value Map data to save