Profile
Description
A Profile is an object that stores data and provides methods to interact with it. While this data is often associated with a player, it can be used independently of any player.
Properties
Error: boolean
Used to make checking if creation of a profile errored or not in strict mode easier. Doesn't serve any actual purpose aside from that.
Methods: {[string]: (...any) -> (...any)}
List of custom methods which is intended to be overwritten with: Profile:SetMethods(Methods).
For more information check out Defining Methods.
Methods
CreateLoader
Description:
Creteas a new Loader Object attached to the given Profile.
Parameters
- Profile - The Profile which the Loader will be attached too.
- ID - The Identifier used to reference this Loader.
- DefaultData - The data that new files will be, and the data which will fill into empty keys if the default is a table.
- DefaultKey? - An optional Parameter that lets you select what file the Loader will be loaded into initially.
- Locked? - An optional Parameter that determines if the created Loader is locked. For more information, check out Locked Loaders.
Returns:
- Loader - The created Loader.
CreateUpdatingLoader
Description:
Creteas a new Loader Object attached to the given Profile with extra logic to mark the data for saving every UpdateInterval by calling Save() on the Loader.
Parameters:
- Profile - The Profile which the Loader will be attached too.
- ID - The Identifier used to reference this Loader.
- DefaultData - The data that new files will be, and the data which will fill into empty keys if the default is a table.
- UpdateInterval - How often it will call the
Save()method on the loader. - DefaultKey? - An optional Parameter that lets you select what file the Loader will be loaded into initially.
- Locked? - An optional Parameter that determines if the created Loader is locked. For more information, check out Locked Loaders.
Returns:
- Loader - The created Loader.
Destroy
Description:
Removes all dependencys and strong connections to the Profile, and turns it into a frozen empty table. The Profile will get garbage collected once you remove your remaining references to it.
Parameters:
- Profile - The Profile you want to destroy.
SetMethods
Description:
Sets the Profile.Methods table to the given dictonary of methods.
For more information check out Defining Methods.
Parameters:
- Profile - The profile where you want to set the methods.
- Methods - The dictonary of methods you want to set the
Profile.Methodstable to.
IsFileLoaded
Description:
Returns a boolean determining if the passed file is currently loaded by a Loader attached to this profile.
Parameters:
- Profile - The profile you want to check.
- FileKey - The FileKey for the file you want to check is loaded.
Returns:
- Loaded - Is the file loaded or not.
CopyFile
Description:
Copies the data from the FromKey file into the ToKey file for this profile.
Parameters:
- Profile - The profile conatining the from and to files.
- FromKey - The FileKey of the source file.
- ToKey - The FileKey of the destination file.
DeleteFile
Description:
Deletes the data from the FileKey.
Parameters:
- Profile - The profile contianing the file you want to delete.
- FromKey - The FileKey for the file you want to delete.
Signals
OnDestroying
Fires:
Fires right before this profile is being destroyed.
OnSave
Fires:
Fires right before the profile is marked to save.