the disk allows you to save folders and files
it has a full-fledged file system
the file system in the original ScriptableComputer had A LOT OF BUGS. however, all of them have been fixed in SComputers
SComputers disks have a very small volume for a reason. the fact is that if you write too much data to blueprint, it will stop spawn
you can use the "world disks" addon, it saves data to the world and not to the blueprint. in this case, you can save a lot more data.
there is a computer with a built-in disk. its embedded disk is always identified under the first ID in the disk component table. the connected external drive will already be the second one
please note that this filesystem allows a folder and a file with the same name to exist
if you need to transfer a large amount of data along with your creation to the steam workshop, you can use a "ROM disk"
you can use the vfs library to mount multiple disks into a single virtual filesystem
component name - disk
methods:
- disk.clear() - clears the disk
- disk.getUsedSize():number - reads how much space is used on the disk in bytes
- disk.getMaxSize():number - returns the maximum amount of data that can be written to disk in bytes
- disk.isReadOnly():boolean - returns whether the filesystem is read-only. it is always false at the moment if we are talking about a general disk
- disk.getData():string - reads a line from a .fastsave file, if there is no such file yet, returns an empty line
- disk.setData(string) - saves a string to a .fastsave file
- disk.getTable():table - tries to deserialize a row from disk.getData as a table, if this fails, it will return an empty table
- disk.setTable(table) - writes a serialized table to disk.setData
- disk.openFolder(path) - changes the currently selected folder. if the path starts with /, then the folder relative to the root is selected. if without / then relative to the current folder. ".." is also supported
- disk.getCurrentPath():string - returns the path to the currently selected folder
- disk.createFile(path) - creates a file, if the file has already been created, it will throw an exception
- disk.createFolder(path) - creates a directory with the specified name. if it already exists, it throws an exception
- disk.deleteFile(path) - deletes the file if the file does not exist throws an exception
- disk.deleteFolder(path) - deletes the directory if the file does not exist throws an exception
- disk.writeFile(path, string) - writes a file, throws an exception if the file does not exist
- disk.readFile(path):string - reads the file. if the file does not exist, it throws an exception
- disk.hasFile(path):boolean - checks if a file with the specified name exists
- disk.hasFolder(path):boolean - checks if a directory with the specified name exists
- disk.getFileSize(path):number - reads the file size in bytes. takes into account the length of the file name
- disk.getFolderSize(path):number - recursively reads how much space a folder takes up, taking into account all the names and contents of all files
- disk.getFileList(path):table - returns a list of files in the current directory
- disk.getFolderList(path):table - returns a list of directories in the current directory