This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CitricThunder's profile picture

[SOLVED] How to detect which side the disk drive is on?

Started by CitricThunder, 17 September 2012 - 07:33 PM
CitricThunder #1
Posted 17 September 2012 - 09:33 PM
Im trying to make a program that allows you to make a user, which writes it to a floppy disk in any drive around the computer. Is there any way to make the program detect a disk drive with a floppy in it and a program on it named "Users", thus allowing it to write to that program and disk.eject("driveSide")? I hope that made sense.
MysticT #2
Posted 17 September 2012 - 09:54 PM
You can loop through all the sides and check if there's a disk drive, and if there's one use it:

local driveSide
for _, side in ipairs(rs.getSides()) do
  if peripheral.isPresent(side) and peripheral.getType(side) == "drive" then
    driveSide = side
    break
  end
end

if driveSide then
  -- do stuff with the disk drive
else
  error("No disk drive found.")
end
CitricThunder #3
Posted 17 September 2012 - 09:57 PM
Thank you so much this worked perfect!
Recoskyler #4
Posted 22 September 2013 - 05:34 PM
Or you can do;

event, side = os.pullEvent("side")
print"Waiting for audio disk..."
if event ~= nil then
   print"Audio Disk Detected!"
   print"Playing Disk..."
   disk.playAudio(side)
end
Lyqyd #5
Posted 22 September 2013 - 08:01 PM
If you're going to bring a topic back from the dead, at least reply with some code that actually works.

Locked.