disk.getLabel

From ComputerCraft
Jump to: navigation, search

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

Returns string label
API disk
Source CC:Tweaked (source)

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.

ExampleExampleGet 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.
ExampleExampleCheck 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!'