Loader
Description
A Loader is an object attached to a Profile that provides access to a file. It allows you to read, modify, save, and unload the data, as well as bind objects to a file so they get destroyed when the file is unloaded.
Properties
- Data - The data for the currently loaded file. Although this works, its recomended to use
Loader:GetData()to make your intention more clear, and to help prevent bugs.
Methods
GetData
Description:
Returns the data for the currently loaded file. Throws an error if there is no loaded file.
Parameters:
- Loader - The loader you want to get the data from.
Returns:
- Data - A reference to the data the in the loaded file.
Save
Description:
Marks the Profile the given loader is attached too, to save the currently loaded file. Uses NewData as the files new data if its passed or just Loader.Data.
Parameters:
- Loader - The loader you want to save from.
Unload
Description:
Makes the given loader load out of the currently loaded file. Throws an error if already not loaded in a file or if the loader is locked.
Parameters:
- Loader - The loader you want to load out of.
LoadInto
Description:
Makes the given loader load into a specified file. Throws an error if already loaded into a file or if the loader is locked.
Parameters:
- Loader - The loader you want to load into the given file.
- Key - The FileKey for the file which you want to load into.
IsLoaded
Description:
Returns a boolean where its true if the given loader is currently loaded in a file, and false if not.
Parameters:
- Loader - The loader you want to check.
Returns:
- Loaded - A boolean which determine's if the loader is loaded in a file.
BindTo
Description:
Binds an object to the currently loaded file. If the file is unloaded or the profile is deleted, this object will be destroyed. Check out Binding to Loaders for more information.
Parameters:
- Loader - The loader to bind the object to.
- Object - The object to bind to the file.
- Cleanup? - The name of the cleanup method for the object, If your object isnt an table, you don't need to pass this parameter.
Returns:
- Object - The object you passed into the
Objectparameters.
Signals
OnLoaded
Fires:
Fires whenever the Loader loads into a file.
Arguments:
- FileKey - The key for the file that was loaded into.
OnUnloaded
Fires:
Fires whenever the Loader loads out of a file.
OnFileCreated
Fires:
Fires whenever the Loader loads into a file that hasnt been loaded into before, meaning that its a new file.
Arguments:
- FileKey - The key for the file that was loaded into.