Difference between revisions of "Disk (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Note local and remote side parameters and change incorrectly named function)
(Add return values, update descriptions to match function pages, and use type template)
Line 1: Line 1:
''If you were looking for disks as in Floppies, go to [[Floppy Disk]].''
+
''If you were looking for the item, please see [[Floppy Disk]].''
 
+
  
 
The Disk API allows you to 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”).
 
The Disk API allows you to 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”).
  
 
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
 
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
+
<tr><td colspan="3" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
 
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;
 
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;
 
Disk (API)
 
Disk (API)
 
</td></tr>
 
</td></tr>
  
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
+
<tr><td style="width: 100px; background: #E0E0E0; padding: .4em; font-weight:bold;">Return</td><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.isPresent|disk.isPresent]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|boolean} present</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Checks the given side for a disk</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.isPresent|disk.isPresent]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Checks whether any item at all is in the disk drive.</td></tr>
  
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.hasData|disk.hasData]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|boolean} disk</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Checks whether the current disk is a [[Floppy Disk|floppy disk]], as opposed to a [http://www.minecraftwiki.net/wiki/Music_Discs music disk].</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.hasData|disk.hasData]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Checks whether the current disk is a [[Floppy Disk|floppy disk]], as opposed to a [http://www.minecraftwiki.net/wiki/Music_Discs music disc] or other item.</td></tr>
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.getMountPath|disk.getMountPath]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|string} path, or [[nil]]</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the directory path on which the disk on '''side''' has been mount (ex. /disk)</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.getMountPath|disk.getMountPath]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Finds the directory name on the local computer where the contents of the Floppy Disk currently inserted in the drive can be found.</td></tr>
  
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.setLabel|disk.setLabel]]([[string (type)|string]] side, [[string (type)|string]] label)</td>
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[nil]]</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets the label</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.setLabel|disk.setLabel]]({{Type|string}} side, {{Type|string}} label)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Writes a label to the floppy disk, which can be read with [[disk.getLabel]] and viewed in the item tooltip.</td></tr>
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.getLabel|disk.getLabel]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|string} label</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Finds label</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.getLabel|disk.getLabel]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Reads the label from the disk in the drive.</td></tr>
  
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.getID|disk.getID]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|int} id</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Finds ID (unique for every disk)</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.getID|disk.getID]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a number which uniquely identifies the disk in the drive and which is the name of the directory in the world’s <code>computer/disk</code> directory containing the disk’s data.</td></tr>
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.hasAudio|disk.hasAudio]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|boolean} audio</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Checks whether the current disk is a [http://www.minecraftwiki.net/wiki/Music_Discs music disk], as opposed to a [[Floppy Disk|floppy disk]].</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.hasAudio|disk.hasAudio]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Checks whether the current disk is a [http://www.minecraftwiki.net/wiki/Music_Discs music disk], as opposed to a [[Floppy Disk|floppy disk]] or other item.</td></tr>
  
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.getAudioTitle|disk.getAudioTitle]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|string} title</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the audio title on the disk</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.getAudioTitle|disk.getAudioTitle]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Reads the title of the audio track from the music record in the drive.</td></tr>
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.playAudio|disk.playAudio]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[nil]]</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Plays the audio</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.playAudio|disk.playAudio]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Starts playing the music record in the drive.</td></tr>
  
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.stopAudio|disk.stopAudio]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[nil]]</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Stops the audio</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.stopAudio|disk.stopAudio]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Stops the music record in the drive from playing, if it was started with [[disk.playAudio]].</td></tr>
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.eject|disk.eject]]([[string (type)|string]] side)</td>
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[nil]]</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Ejects the disk.</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.eject|disk.eject]]({{Type|string}} side)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Ejects any item currently in the drive, spilling it into the world as a loose item.</td></tr>
 
</table>
 
</table>
 
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 19:07, 22 April 2013

If you were looking for the item, please see Floppy Disk.

The Disk API allows you to 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”).

Grid disk.png   Disk (API)

ReturnMethod NameDescription
{{Type|boolean} present disk.isPresent(string side) Checks whether any item at all is in the disk drive.
{{Type|boolean} disk disk.hasData(string side) Checks whether the current disk is a floppy disk, as opposed to a music disc or other item.
{{Type|string} path, or nil disk.getMountPath(string side) Finds the directory name on the local computer where the contents of the Floppy Disk currently inserted in the drive can be found.
nil disk.setLabel(string side, string label) Writes a label to the floppy disk, which can be read with disk.getLabel and viewed in the item tooltip.
{{Type|string} label disk.getLabel(string side) Reads the label from the disk in the drive.
{{Type|int} id disk.getID(string side) Returns a number which uniquely identifies the disk in the drive and which is the name of the directory in the world’s computer/disk directory containing the disk’s data.
{{Type|boolean} audio disk.hasAudio(string side) Checks whether the current disk is a music disk, as opposed to a floppy disk or other item.
{{Type|string} title disk.getAudioTitle(string side) Reads the title of the audio track from the music record in the drive.
nil disk.playAudio(string side) Starts playing the music record in the drive.
nil disk.stopAudio(string side) Stops the music record in the drive from playing, if it was started with disk.playAudio.
nil disk.eject(string side) Ejects any item currently in the drive, spilling it into the world as a loose item.