Basic FunctionalityAssets ManagementContentOn this pageContent Description: The Content record is a singleton object that manages file searching, loading and other operations related to resources. Usage: local Content = require("Content")local text = Content:load("filename.txt") searchPaths Type: Field. Description: An array of directories to search for resource files. Signature: searchPaths: {string} assetPath Type: Field. Description: The path to the directory containing read-only resources. Can only be altered by the user on platform Windows, MacOS and Linux. Signature: assetPath: string writablePath Type: Field. Description: The path to the directory where files can be written. Can only be altered by the user on platform Windows, MacOS and Linux. Default is the same as the appPath. Signature: writablePath: string appPath Type: Field. Description: The path to the directory for the application storage. Signature: appPath: string load Type: Function. Description: Loads the content of the file with the specified filename. Signature: load: function(self: Content, filename: string): string Parameters: ParameterTypeDescriptionfilenamestringThe name of the file to load. Returns: Return TypeDescriptionstringThe content of the loaded file. loadExcel Type: Function. Description: Loads the content of an Excel file with the specified filename and optional sheet names Signature: loadExcel: function(self: Content, filename: string, sheetNames?: {string}): { --[[sheetName]] string: --[[rows]] { --[[colums]] {string | number} } } | nil Parameters: ParameterTypeDescriptionfilenamestringThe name of the Excel file to loadsheetNames{string}[optional] An array of strings representing the names of the sheets to load. If not provided, all sheets will be loaded. Returns: Return TypeDescriptiontableA table containing the data in the Excel file. The keys are the sheet names and the values are tables containing the rows and columns of the sheet. save Type: Function. Description: Saves the specified content to a file with the specified filename. Signature: save: function(self: Content, filename: string, content: string): boolean Parameters: ParameterTypeDescriptionfilenamestringThe name of the file to save.contentstringThe content to save to the file. Returns: Return TypeDescriptionbooleantrue if the content saves to file successfully, false otherwise. exist Type: Function. Description: Checks if a file with the specified filename exists. Signature: exist: function(self: Content, filename: string): boolean Parameters: ParameterTypeDescriptionfilenamestringThe name of the file to check. Returns: Return TypeDescriptionbooleantrue if the file exists, false otherwise. mkdir Type: Function. Description: Creates a new directory with the specified path. Signature: mkdir: function(self: Content, path: string): boolean Parameters: ParameterTypeDescriptionpathstringThe path of the directory to create. Returns: Return TypeDescriptionbooleantrue if the directory was created, false otherwise. isdir Type: Function. Description: Checks if the specified path is a directory. Signature: isdir: function(self: Content, path: string): boolean Parameters: ParameterTypeDescriptionpathstringThe path to check. Returns: Return TypeDescriptionbooleantrue if the path is a directory, false otherwise. remove Type: Function. Description: Removes the file or directory with the specified path. Signature: remove: function(self: Content, path: string): boolean Parameters: ParameterTypeDescriptionpathstringThe path of the file or directory to remove. Returns: Return TypeDescriptionbooleantrue if the file or directory was removed, false otherwise. copy Type: Function. Description: Copies the file or directory in the specified path to target path. Signature: copy: function(self: Content, srcPath: string, dstPath: string): boolean Parameters: ParameterTypeDescriptionsrcPathstringThe path of the file or directory to copy.dstPathstringThe path to copy files to. Returns: Return TypeDescriptionbooleantrue if the file or directory was copied to target path, false otherwise. move Type: Function. Description: Moves the file or directory in the specified path to target path. Signature: move: function(self: Content, srcPath: string, dstPath: string): boolean Parameters: ParameterTypeDescriptionsrcPathstringThe path of the file or directory to move.dstPathstringThe path to move files to. Returns: Return TypeDescriptionbooleantrue if the file or directory was moved to target path, false otherwise. isAbsolutePath Type: Function. Description: Checks if the specified path is an absolute path. Signature: isAbsolutePath: function(self: Content, path: string): boolean Parameters: ParameterTypeDescriptionpathstringThe path to check. Returns: Return TypeDescriptionbooleantrue if the path is an absolute path, false otherwise. getFullPath Type: Function. Description: Gets the full path of a file with the specified filename. Signature: getFullPath: function(self: Content, filename: string): string Parameters: ParameterTypeDescriptionfilenamestringThe name of the file to get the full path of. Returns: Return TypeDescriptionstringThe full path of the file. insertSearchPath Type: Function. Description: Inserts a search path at the specified index. Signature: insertSearchPath: function(self: Content, index: integer, path: string) Parameters: ParameterTypeDescriptionindexintegerThe index at which to insert the search path.pathstringThe search path to insert. addSearchPath Type: Function. Description: Adds a new search path to the end of the list. Signature: addSearchPath: function(self: Content, path: string) Parameters: ParameterTypeDescriptionpathstringThe search path to add. removeSearchPath Type: Function. Description: Removes the specified search path from the list. Signature: removeSearchPath: function(self: Content, path: string) Parameters: ParameterTypeDescriptionpathstringThe search path to remove. loadAsync Type: Function. Description: Asynchronously loads the content of the file with the specified filename. Signature: loadAsync: function(self: Content, filename: string): string Parameters: ParameterTypeDescriptionfilenamestringThe name of the file to load. Returns: Return TypeDescriptionstringThe content of the loaded file. loadExcelAsync Type: Function. Description: Asynchronously loads the content of an Excel file with the specified filename and optional sheet names. Signature: loadExcelAsync: function(self: Content, filename: string, sheetNames?: {string}): { --[[sheetName]] string: --[[rows]] { --[[colums]] {string | number} } } | nil Parameters: ParameterTypeDescriptionfilenamestringThe name of the Excel file to load.sheetNames{string}[optional] An array of strings representing the names of the sheets to load. If not provided, all sheets will be loaded. Returns: Return TypeDescriptiontableA table containing the data in the Excel file. The keys are the sheet names and the values are tables containing the rows and columns of the sheet. saveAsync Type: Function. Description: Asynchronously saves the specified content to a file with the specified filename. Signature: saveAsync: function(self: Content, filename: string, content: string): boolean Parameters: ParameterTypeDescriptionfilenamestringThe name of the file to save.contentstringThe content to save to the file. Returns: Return TypeDescriptionbooleantrue if the content was saved successfully, false otherwise. copyAsync Type: Function. Description: Asynchronously copies a file or a folder from the source path to the destination path. Signature: copyAsync: function(self: Content, src: string, dst: string): boolean Parameters: ParameterTypeDescriptionsrcstringThe path of the file or folder to copy.dststringThe destination path of the copied files. Returns: Return TypeDescriptionbooleantrue if the file or folder was copied successfully, false otherwise. zipAsync Type: Function. Description: Asynchronously compresses the specified folder to a ZIP archive with the specified filename. Signature: zipAsync: function(self: Content, folderPath: string, zipFile: string, filter?: function(string): boolean): boolean Parameters: ParameterTypeDescriptionfolderPathstringThe path of the folder to compress, should be under the asset writable path.zipFilestringThe name of the ZIP archive to create.filterfunction[optional] A function to filter the files to include in the archive. The function takes a filename as input and returns a boolean indicating whether to include the file. If not provided, all files will be included. Returns: Return TypeDescriptionbooleantrue if the folder was compressed successfully, false otherwise. unzipAsync Type: Function. Description: Asynchronously decompresses a ZIP archive to the specified folder. Signature: unzipAsync: function(self: Content, zipFile: string, folderPath: string, filter?: function(string): boolean): boolean Parameters: ParameterTypeDescriptionzipFilestringThe name of the ZIP archive to decompress, should be a file under the asset writable path.folderPathstringThe path of the folder to decompress to, should be under the asset writable path.filterfunction[optional] A function to filter the files to include in the archive. The function takes a filename as input and returns a boolean indicating whether to include the file. If not provided, all files will be included. Returns: Return TypeDescriptionbooleantrue if the folder was decompressed successfully, false otherwise. getDirs Type: Function. Description: Gets the names of all subdirectories in the specified directory. Signature: getDirs: function(self: Content, path: string): {string} Parameters: ParameterTypeDescriptionpathstringThe path of the directory to search. Returns: Return TypeDescriptiontableAn array of the names of all subdirectories in the specified directory. getFiles Type: Function. Description: Gets the names of all files in the specified directory. Signature: getFiles: function(self: Content, path: string): {string} Parameters: ParameterTypeDescriptionpathstringThe path of the directory to search. Returns: Return TypeDescriptiontableAn array of the names of all files in the specified directory. getAllFiles Type: Function. Description: Gets the names of all files in the specified directory and its subdirectories. Signature: getAllFiles: function(self: Content, path: string): {string} Parameters: ParameterTypeDescriptionpathstringThe path of the directory to search. Returns: Return TypeDescriptiontableAn array of the names of all files in the specified directory and its subdirectories. clearPathCache Type: Function. Description: Clears the search path cache of the map of relative paths to full paths. Signature: clearPathCache: function(self: Content)