Advertisement
DOGGYWOOF

DISK GRABER

Jun 28th, 2024
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. -- Function to get and display disk IDs
  2. local function checkDiskIDs()
  3. -- Get a list of all connected peripherals
  4. local peripherals = peripheral.getNames()
  5.  
  6. -- Array to store disk IDs
  7. local diskIDs = {}
  8.  
  9. -- Loop through all peripherals
  10. for _, name in ipairs(peripherals) do
  11. -- Check if the peripheral is a disk drive
  12. if peripheral.getType(name) == "drive" then
  13. -- Get the disk ID from the disk drive
  14. local diskID = disk.getID(name)
  15.  
  16. -- If a disk is inserted, add its ID to the array
  17. if diskID then
  18. table.insert(diskIDs, diskID)
  19. end
  20. end
  21. end
  22.  
  23. -- Check if any disks were found
  24. if #diskIDs > 0 then
  25. -- Display the disk IDs
  26. print("Disk IDs found:")
  27. for _, id in ipairs(diskIDs) do
  28. print("- " .. id)
  29. end
  30. else
  31. print("No disks found.")
  32. end
  33. end
  34.  
  35. -- Call the function to check disk IDs
  36. checkDiskIDs()
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement