Storage
scripts/vscripts/alyxlib/storage.lua
Properties
version
Default value
"v3.3.0"
Methods
RegisterType
Registers a class table type with a name.
Parameters
name
string
Name that the type will be saved asT
table
Class table
UnregisterType
Unregisters a class type.
Parameters
name
string
Name to unregisterT
table
Class to unregister
Join
Joins a list of values by the hidden separator.
Parameters
...
Returns
- string
Joined string
SaveType
Helper function for saving the type correctly.
No failsafes are provided in this function, you must be sure you are saving correctly.
Parameters
handle
EntityHandle
Entity to save onname
string
Name prefix to save asT
string
String name ofT
SaveString
Saves a string.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save asvalue
string,nil
String to save
Returns
- boolean
If the save was successful
SaveNumber
Saves a number.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save asvalue
number,nil
Number to save
Returns
- boolean
If the save was successful
SaveBoolean
Saves a boolean.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save asbool
boolean,nil
Boolean to save
Returns
- boolean
If the save was successful
SaveVector
Saves a Vector.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save asvector
Vector,nil
Vector to save
Returns
- boolean
If the save was successful
SaveQAngle
Saves a QAngle.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save asqangle
QAngle,nil
QAngle to save
Returns
- boolean
If the save was successful
SaveTableCustom
Saves a table with a custom type. Should be used with custom save functions.
If trying to save a normal table use Storage.SaveTable.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save astbl
table<any,any>
Table to saveT
string
Type to save assave_meta(optional)
boolean
If keys starting with '__' should be saved
Returns
- boolean
If the save was successful
SaveTable
Saves a table.
May be ordered, unordered or mixed.
May have nested tables.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save astbl
table<any,any>
Table to save
Returns
- boolean
If the save was successful
SaveEntity
Saves an entity reference.
Entity handles change between game sessions so this function modifies the passed entity to make sure it can keep track of it.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save asentity
EntityHandle,nil
Entity to save
Returns
- boolean
If the save was successful
Save
Saves a value.
Uses type inference to save the value. If you are experiencing errors consider saving with one of the explicit type saves.
Parameters
handle
EntityHandle
Entity to save onname
string
Name to save asvalue
any
Value to save
Returns
- boolean
If the save was successful
LoadString
Loads a string.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name the string was saved asdefault(optional)
T
Optional default value
Returns
- string|T
Saved string or default
LoadNumber
Loads a number.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name the number was saved asdefault(optional)
T
Optional default value
Returns
- number|T
Saved number or default
LoadBoolean
Loads a boolean value.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name the boolean was saved asdefault(optional)
T
Optional default value
Returns
- boolean|T
Saved boolean or default
LoadVector
Loads a Vector.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name the Vector was saved asdefault(optional)
T
Optional default value
Returns
- Vector|T
Saved Vector or default
LoadQAngle
Loads a QAngle.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name the QAngle was saved asdefault(optional)
T
Optional default value
Returns
- QAngle|T
Saved QAngle or default
LoadTableCustom
Loads a table with a custom type. Should be used with custom load functions.
If trying to load a normal table use Storage.LoadTable.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name the table was saved asT
string
Type to save asdefault(optional)
T
Optional default value
Returns
- table|T
Saved table or default
LoadTable
Loads a table with a custom type.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name the table was saved asdefault(optional)
T
Optional default value
Returns
- table|T
Saved table or default
LoadEntity
Loads an entity.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name to save asdefault(optional)
T
Optional default value
Returns
- EntityHandle|T
Saved entity or default
Load
Loads a value.
Parameters
handle
EntityHandle
Entity to load fromname
string
Name the value was saved asdefault(optional)
any
Optional default value
Returns
- any
Saved value or default
LoadAll
Loads all values saved to an entity.
Parameters
handle
EntityHandle
Entity to load fromdirect(optional)
boolean
Optionally load values directly intohandleinstead of a new table
Returns
- table
Table of loaded values (or handle if direct is true)