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

Deletes a file saved with Data.save from 'settings/flux/', if it exists.
Deletes plugin data saved with Data.save_plugin for the current schema and map.
Deletes a file from the data folder of the current schema and map.
Lists the files inside a folder of the 'flux' data folder.
Loads a table saved with Data.save from 'settings/flux/'.
Loads plugin data saved with Data.save_plugin for the current schema and map.
Loads a table from the data folder of the current schema and map.
Saves a table to 'settings/flux/' in the game folder as JSON.
Saves plugin data.
Saves a table to the data folder of the current schema and map.

Functions

Data.delete(key)

shared packages/flow/lib/sh_data.lua:63

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

Data.delete_plugin(key)

shared packages/flow/lib/sh_data.lua:171

Deletes plugin data saved with Data.save_plugin for the current schema and map.

Parameters

  • key String

Data.delete_schema(key)

shared packages/flow/lib/sh_data.lua:145

Deletes a file from the data folder of the current schema and map.

Parameters

  • key String

Data.get_files(folder)

client packages/flow/lib/sh_data.lua:107

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

Data.load(key, default)

shared packages/flow/lib/sh_data.lua:45

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 nil returned 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 nil returned if the file does not exist

Returns

  • Map the loaded data, or the default

Defined in

Data.load_plugin(key, default)

shared packages/flow/lib/sh_data.lua:165

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 nil returned if nothing has been saved yet

Returns

  • Map the loaded data, or the default

See also

Data.load_schema(key, default)

shared packages/flow/lib/sh_data.lua:139

Loads a table from the data folder of the current schema and map.

Parameters

  • key String
  • default Any optional, defaults to nil returned if the file does not exist

Returns

  • Map the loaded data, or the default

See also

Data.save(key, value)

shared packages/flow/lib/sh_data.lua:34

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

Data.save_plugin(key, value)

shared packages/flow/lib/sh_data.lua:153

Saves plugin data. It is stored separately for every schema and map.

Parameters

  • key String
  • value Map data to save

See also

Data.save_schema(key, value)

shared packages/flow/lib/sh_data.lua:130

Saves a table to the data folder of the current schema and map.

Parameters

  • key String
  • value Map data to save

See also

Defined in