agot137

disks

Aug 5th, 2025 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. -- Disk Scanner for mounts like disk, diskX, diskXX
  2.  
  3. local function getDiskMounts()
  4. local mounts = {}
  5. for _, name in ipairs(peripheral.getNames()) do
  6. if peripheral.getType(name) == "diskDrive" then
  7. local mount = peripheral.call(name, "getMountPath")
  8. if mount and string.find(mount, "^disk") then
  9. table.insert(mounts, {name = name, path = mount})
  10. end
  11. end
  12. end
  13. return mounts
  14. end
  15.  
  16. local diskMounts = getDiskMounts()
  17. local totalSpace = 0
  18.  
  19. print("🔍 Scanning mounted disks:\n")
  20.  
  21. for i, disk in ipairs(diskMounts) do
  22. local free = fs.getFreeSpace(disk.path)
  23. totalSpace = totalSpace + free
  24. print(string.format("Disk %02d @ %s", i, disk.path))
  25. print(" Peripheral: " .. disk.name)
  26. print(" Free Space: " .. tostring(free) .. " bytes\n")
  27. end
  28.  
  29. print("📦 Total available space across all disks: " .. totalSpace .. " bytes")
  30.  
Advertisement
Add Comment
Please, Sign In to add comment