Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to get and display disk IDs
- local function checkDiskIDs()
- -- Get a list of all connected peripherals
- local peripherals = peripheral.getNames()
- -- Array to store disk IDs
- local diskIDs = {}
- -- Loop through all peripherals
- for _, name in ipairs(peripherals) do
- -- Check if the peripheral is a disk drive
- if peripheral.getType(name) == "drive" then
- -- Get the disk ID from the disk drive
- local diskID = disk.getID(name)
- -- If a disk is inserted, add its ID to the array
- if diskID then
- table.insert(diskIDs, diskID)
- end
- end
- end
- -- Check if any disks were found
- if #diskIDs > 0 then
- -- Display the disk IDs
- print("Disk IDs found:")
- for _, id in ipairs(diskIDs) do
- print("- " .. id)
- end
- else
- print("No disks found.")
- end
- end
- -- Call the function to check disk IDs
- checkDiskIDs()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement