Martmists

2-drive controller

Dec 11th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. m = peripheral.wrap("back")
  2. m.open(1)
  3. mon = peripheral.wrap("monitor_2")
  4. mon.clear()
  5. mon2 = peripheral.wrap("monitor_3")
  6. mon2.clear()
  7. p = peripheral.wrap("printer_0")
  8. d = peripheral.wrap("drive_0")
  9. d2 = peripheral.wrap("drive_5")
  10. if d.isDiskPresent() or d2.isDiskPresent() do
  11.   d.ejectDisk()
  12.   d2.ejectDisk()
  13.   m.transmit(1,1,"Ejecting disks...")
  14. end
  15. dvar = false
  16. dvar2 = false
  17. while true do
  18.   mon.setTextColor(colors.green)
  19.   mon2.setTextColor(colors.green)
  20.  
  21.   mon.setCursorPos(1,1)
  22.   mon.write("Drive 1:")
  23.  
  24.   mon.setCursorPos(1,3)
  25.   mon.write("Path:")
  26.  
  27.   mon.setCursorPos(1,5)
  28.   mon.write("Files: ")
  29.  
  30.   mon2.setCursorPos(1,1)
  31.   mon2.write("Drive 2:")
  32.  
  33.   mon2.setCursorPos(1,3)
  34.   mon2.write("Path:")
  35.  
  36.   mon2.setCursorPos(1,5)
  37.   mon2.write("Files: ")
  38.  
  39.   mon.setTextColor(colors.red)
  40.   mon2.setTextColor(colors.red)
  41.  
  42.   sleep(0.2)
  43.  
  44.   if dvar == false then
  45.     if d.isDiskPresent() then
  46.       m.transmit(1,1,"Reading disk on drive: 1")
  47.       dvar = true
  48.       dname = d.getDiskLabel()      
  49.       path = d.getMountPath()
  50.       dfiles = fs.list(path)
  51.  
  52.       mon.clear()
  53.  
  54.       mon.setCursorPos(1,2)
  55.       mon.write(dname)
  56.  
  57.       mon.setCursorPos(1,4)
  58.       mon.write(path.."/")
  59.  
  60.       for i = 1,#dfiles do
  61.         y = i + 5
  62.         mon.setCursorPos(1,y)
  63.         mon.write(dfiles[i])
  64.         sleep(0.5)
  65.  
  66.       end
  67.       m.transmit(1,1,"Finished reading disk on drive: 1")
  68.     end
  69.   else
  70.     if not d.isDiskPresent() then
  71.  
  72.       dvar = false
  73.       mon.clear()
  74.       m.transmit(1,1,"Disk removed from drive: 1")
  75.     end
  76.   end
  77.   if dvar2 == false then
  78.     if d2.isDiskPresent() then
  79.       m.transmit(1,1,"Reading disk on drive: 2")
  80.       dvar2 = true
  81.       dname2 = d2.getDiskLabel()      
  82.       path2 = d2.getMountPath()
  83.       dfiles2 = fs.list(path2)
  84.  
  85.       mon2.clear()
  86.  
  87.       mon2.setCursorPos(1,2)
  88.       mon2.write(dname2)
  89.  
  90.       mon2.setCursorPos(1,4)
  91.       mon2.write(path2.."/")
  92.  
  93.       for i = 1,#dfiles2 do
  94.         y = i + 5
  95.         mon2.setCursorPos(1,y)
  96.         mon2.write(dfiles2[i])
  97.         sleep(0.5)
  98.       end
  99.       m.transmit(1,1,"Finished reading disk on drive: 2")
  100.     end
  101.   else
  102.     if  not d2.isDiskPresent() then
  103.       dvar2 = false
  104.       mon2.clear()
  105.       m.transmit(1,1,"Disk removed from drive: 2")
  106.     end
  107.   end
  108. end
Advertisement
Add Comment
Please, Sign In to add comment