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

Detecting Disk Drive

Started by ImNutzForCoal, 07 August 2012 - 02:26 PM
ImNutzForCoal #1
Posted 07 August 2012 - 04:26 PM
I *think* I read somewhere about a program that can detect a disk drive, but I cannot, for the life of me, remember what the code is. Can anyone help?
OmegaVest #2
Posted 07 August 2012 - 04:56 PM
Okay, so I'm pretty sure the disk drive is called "drive" in the code for getType, so you can use this. Otherwise, just put one on a side, and use getType.

Oh, and for disks themselves, you can use an event pull. Just look for disk or disk_eject. There's probably a simpler way, but . . .


side = "right"
if peripheral.getType(side) == "drive" then
   print ("Yup, Disk Drive on the starboard side.")
end
ImNutzForCoal #3
Posted 07 August 2012 - 07:32 PM
Okay, so I'm pretty sure the disk drive is called "drive" in the code for getType, so you can use this. Otherwise, just put one on a side, and use getType.

Oh, and for disks themselves, you can use an event pull. Just look for disk or disk_eject. There's probably a simpler way, but . . .


side = "right"
if peripheral.getType(side) == "drive" then
   print ("Yup, Disk Drive on the starboard side.")
end

Thanks

I like to write all LUA in Notepad++ before adding them to CC, dunno why, but I think it has something to do with the highlighting
Pharap #4
Posted 08 August 2012 - 04:31 AM
Okay, so I'm pretty sure the disk drive is called "drive" in the code for getType, so you can use this. Otherwise, just put one on a side, and use getType.

Oh, and for disks themselves, you can use an event pull. Just look for disk or disk_eject. There's probably a simpler way, but . . .


side = "right"
if peripheral.getType(side) == "drive" then
   print ("Yup, Disk Drive on the starboard side.")
end

Thanks

I like to write all LUA in Notepad++ before adding them to CC, dunno why, but I think it has something to do with the highlighting

It's probably because you can flick around with the mouse instead of having to go through the code with your cursor.
ImNutzForCoal #5
Posted 08 August 2012 - 11:07 AM
Okay, so I'm pretty sure the disk drive is called "drive" in the code for getType, so you can use this. Otherwise, just put one on a side, and use getType.

Oh, and for disks themselves, you can use an event pull. Just look for disk or disk_eject. There's probably a simpler way, but . . .


side = "right"
if peripheral.getType(side) == "drive" then
   print ("Yup, Disk Drive on the starboard side.")
end

Thanks

I like to write all LUA in Notepad++ before adding them to CC, dunno why, but I think it has something to do with the highlighting

It's probably because you can flick around with the mouse instead of having to go through the code with your cursor.

I rarely use the mouse in Notepad++. Its mainly that syntax highlighting shows me if i type something wrong. But yea, N++ is alot easier to navigate.