disk
Interact with disk drives.
These functions can operate on locally attached or remote disk drives. To use a
locally attached drive, specify “side” as one of the six sides (e.g. left); to
use a remote disk drive, specify its name as printed when enabling its modem
(e.g. drive_0).
tip
All computers (except command computers), turtles and pocket computers can be placed within a disk drive to access it's internal storage like a disk.
Changes
- New in version 1.2
| isPresent(name) | Checks whether any item at all is in the disk drive |
|---|---|
| getLabel(name) | Get the label of the floppy disk, record, or other media within the given disk drive. |
| setLabel(name, label) | Set the label of the floppy disk or other media |
| hasData(name) | Check whether the current disk provides a mount. |
| getMountPath(name) | Find the directory name on the local computer where the contents of the current floppy disk (or other mount) can be found. |
| hasAudio(name) | Whether the current disk is a music disk as opposed to a floppy disk or other item. |
| getAudioTitle(name) | Get the title of the audio track from the music record in the drive. |
| playAudio(name) | Starts playing the music record in the drive. |
| stopAudio(name) | Stops the music record in the drive from playing, if it was started with disk.playAudio. |
| eject(name) | Ejects any item currently in the drive, spilling it into the world as a loose item. |
| getID(name) | Returns a number which uniquely identifies the disk in the drive. |
- isPresent(name)Source
Checks whether any item at all is in the disk drive
Parameters
- name
stringThe name of the disk drive.
Returns
booleanIf something is in the disk drive.
Usage
disk.isPresent("top")
- name
- getLabel(name)Source
Get the label of the floppy disk, record, or other media within the given disk drive.
If there is a computer or turtle within the drive, this will set the label as read by
os.getComputerLabel.Parameters
- name
stringThe name of the disk drive.
Returns
string| nil The name of the current media, ornilif the drive is not present or empty.
See also
- name
- setLabel(name, label)Source
Set the label of the floppy disk or other media
Parameters
- hasData(name)Source
Check whether the current disk provides a mount.
This will return true for disks and computers, but not records.
Parameters
- name
stringThe name of the disk drive.
Returns
booleanIf the disk is present and provides a mount.
See also
- name
- getMountPath(name)Source
Find the directory name on the local computer where the contents of the current floppy disk (or other mount) can be found.
Parameters
- name
stringThe name of the disk drive.
Returns
string| nil The mount's directory, ornilif the drive does not contain a floppy or computer.
See also
- name
- hasAudio(name)Source
Whether the current disk is a music disk as opposed to a floppy disk or other item.
If this returns true, you will can play the record.
Parameters
- name
stringThe name of the disk drive.
Returns
booleanIf the disk is present and has audio saved on it.
- name
- getAudioTitle(name)Source
Get the title of the audio track from the music record in the drive.
This generally returns the same as
disk.getLabelfor records.Parameters
- name
stringThe name of the disk drive.
Returns
string| false | nil The track title,falseif there is not a music record in the drive ornilif no drive is present.
- name
- playAudio(name)Source
Starts playing the music record in the drive.
If any record is already playing on any disk drive, it stops before the target drive starts playing. The record stops when it reaches the end of the track, when it is removed from the drive, when
disk.stopAudiois called, or when another record is started.Parameters
- name
stringThe name of the disk drive.
Usage
disk.playAudio("bottom")
- name
- stopAudio(name)Source
Stops the music record in the drive from playing, if it was started with
disk.playAudio.Parameters
- name
stringThe name o the disk drive.
- name
- eject(name)Source
Ejects any item currently in the drive, spilling it into the world as a loose item.
Parameters
- name
stringThe name of the disk drive.
Usage
disk.eject("bottom")
- name
- getID(name)Source
Returns a number which uniquely identifies the disk in the drive.
Note, unlike
disk.getLabel, this does not return anything for other media, such as computers or turtles.Parameters
- name
stringThe name of the disk drive.
Returns
string| nil The disk ID, ornilif the drive does not contain a floppy disk.
Changes
- New in version 1.4
- name