disk.getLabel

Returns the label of the disk inside the disk drive at the specified side or network name. Returns nil when no peripheral is attached at the specified side or network name or there is no disk inside the disk drive.

ExampleGet disk label
Gets and prints the label of the disk inside the disk drive attached to the top side.
Code
print(disk.getLabel("top"))
Output If a disk drive was attached and a disk was inside, the output would be the label of the disk.
ExampleCheck disk label
Checks whether the label of the disk inside the disk drive attached on the top side is a specified label, and then prints the result.
Code
local label = disk.getLabel("top")
if label == "Testing" then
  print("Valid disk!")
else
  print("Invalid disk.")
end
Output If a disk drive was attached, a disk was inside and also the disk label was 'Testing', then it would return 'Valid disk!'

disk.getLabel
Function
Syntax
disk.getLabel(
  • side or network name : string
)

Returns string label
API disk
Source CC:Tweaked (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.