Difference between revisions of "Disk (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Changed int to number)
m
 
(8 intermediate revisions by 6 users not shown)
Line 3: Line 3:
 
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;">
+
Note: as of ComputerCraft 1.77, all computers (except command computers) can be placed within a disk drive to access it's internal storage like a disk.
<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;
+
Disk (API)
+
</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>
+
{{API table|Disk|image=Grid disk.png|2=
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">{{Type|boolean}} present</td>
+
{{API table/row|[[disk.isPresent]]({{type|string}} side)|{{type|boolean}} present|Checks whether any item is in a disk drive.|odd}}
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[disk.isPresent|disk.isPresent]]({{Type|string}} side)</td>
+
{{API table/row|[[disk.hasData]]({{type|string}} side)|{{type|boolean}} hasData|Checks whether a [[Floppy Disk]] is in a disk drive.|}}
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Checks whether any item at all is in the disk drive.</td></tr>
+
{{API table/row|[[disk.getMountPath]]({{type|string}} side)|{{type|string}}/{{type|nil}} path|Gets the directory name where the contents of the floppy disk can be accessed.|odd}}
 +
{{API table/row|[[disk.setLabel]]({{type|string}} side, {{type|string}} label)|{{type|nil}}|Sets the floppy disk's label.|}}
 +
{{API table/row|[[disk.getLabel]]({{type|string}} side)|{{type|string}}/{{type|nil}} label|Gets the floppy disk's label.|odd}}
 +
{{API table/row|[[disk.getID]]({{type|string}} side)|{{type|number}}/{{type|nil}} id|Gets the floppy disk's unique ID number.|}}
 +
{{API table/row|[[disk.hasAudio]]({{type|string}} side)|{{type|boolean}} hasAudio|Checks whether a [https://minecraft.gamepedia.com/Music_Disc music disk] is in the drive.|odd}}
 +
{{API table/row|[[disk.getAudioTitle]]({{type|string}} side)|{{type|string}}/{{type|nil}} title|Gets the title of the music disc in the drive.|}}
 +
{{API table/row|[[disk.playAudio]]({{type|string}} side)|{{type|nil}}|Starts playing the music disc in the drive.|odd}}
 +
{{API table/row|[[disk.stopAudio]]({{type|string}} side)|{{type|nil}}|Stops playing the music disc in the drive.|}}
 +
{{API table/row|[[disk.eject]]({{type|string}} side)|{{type|nil}}|Ejects any item currently in the drive, spilling it into the world as a loose item.|odd}}
  
<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;">[[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;">{{Type|string}} path, or [[nil]]</td>
+
<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;">[[nil]]</td>
+
<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;">{{Type|string}} label</td>
+
<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;">{{Type|number}} id</td>
+
<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;">{{Type|boolean}} audio</td>
+
<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;">{{Type|string}} title</td>
+
<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;">[[nil]]</td>
+
<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;">[[nil]]</td>
+
<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;">[[nil]]</td>
+
<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>
+
  
 
[[Category:APIs]]
 
[[Category:APIs]]
/td>
 

Latest revision as of 07:02, 4 August 2020

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”).

Note: as of ComputerCraft 1.77, all computers (except command computers) can be placed within a disk drive to access it's internal storage like a disk.

Grid disk.png  Disk (API)
Function Return values Description
disk.isPresent(string side) boolean present Checks whether any item is in a disk drive.
disk.hasData(string side) boolean hasData Checks whether a Floppy Disk is in a disk drive.
disk.getMountPath(string side) string/nil path Gets the directory name where the contents of the floppy disk can be accessed.
disk.setLabel(string side, string label) nil Sets the floppy disk's label.
disk.getLabel(string side) string/nil label Gets the floppy disk's label.
disk.getID(string side) number/nil id Gets the floppy disk's unique ID number.
disk.hasAudio(string side) boolean hasAudio Checks whether a music disk is in the drive.
disk.getAudioTitle(string side) string/nil title Gets the title of the music disc in the drive.
disk.playAudio(string side) nil Starts playing the music disc in the drive.
disk.stopAudio(string side) nil Stops playing the music disc in the drive.
disk.eject(string side) nil Ejects any item currently in the drive, spilling it into the world as a loose item.