Advertisement
XDjackieXD

diskutils - Einstellungen

Apr 19th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.27 KB | None | 0 0
  1. -- als .modderOS/diskutils speichern!
  2.  
  3.     shell.run("/.modderOS/einstellungen")
  4.     local xx,yy = term.getSize()
  5.     local quit = 0
  6.     local select = 0
  7.     local diskDrive
  8.     for _, side in ipairs(rs.getSides()) do
  9.        if peripheral.isPresent(side) and peripheral.getType(side) == "drive" then
  10.            diskDrive = side
  11.            break
  12.        end
  13.     end
  14.    
  15.      
  16.     local function reset()
  17.             local x,y = term.getSize()
  18.             term.setBackgroundColor(einstellungen[1])
  19.             term.setTextColor(einstellungen[3])
  20.             term.clear()
  21.             term.setCursorPos(1, 1)
  22.             paintutils.drawLine(1, 1, x, 1, einstellungen[2])
  23.             term.setCursorPos(1, 1)
  24.             print("Disk Utilities")
  25.             term.setBackgroundColor(einstellungen[2])
  26.             term.setTextColor(einstellungen[3])
  27.             local x1 = x-6
  28.             term.setCursorPos(x1,1)
  29.             print("Zurück")
  30.             term.setBackgroundColour(einstellungen[1])
  31.     end
  32.    
  33.     local function utils()
  34.             term.setCursorPos(2,3)
  35.             term.setBackgroundColor(einstellungen[1])
  36.             write("Disketten-Label: ")
  37.             print(disk.getLabel(diskDrive))
  38.             term.setCursorPos(2,5)
  39.             term.setBackgroundColor(colors.white)
  40.             term.setTextColor(colors.red)
  41.             print("                  ")
  42.             term.setCursorPos(2,6)
  43.             print("   Label setzen   ")
  44.             term.setCursorPos(2,7)
  45.             print("                  ")
  46.             term.setCursorPos(2,9)
  47.             print("                  ")
  48.             term.setCursorPos(2,10)
  49.             print(" Diskette Löschen ")
  50.             term.setCursorPos(2,11)
  51.             print("                  ")
  52.     end
  53.      
  54.     reset()
  55.  
  56. if diskDrive then
  57.  if disk.isPresent(diskDrive) then
  58.     utils()
  59.      
  60.     while quit == 0 do
  61.      
  62.      local event, button, x, y = os.pullEvent("mouse_click")
  63.             if event == "mouse_click" then
  64.               if y == 1 and x > xx-7 and x < xx then
  65.                    quit = 1
  66.               elseif y >= 5 and y <= 7 and x >= 2 and x <= 19 then
  67.                    select = 1
  68.               elseif y >= 9 and y <= 11 and x >= 2 and x <= 19 then
  69.                    select = 2
  70.               end
  71.      end
  72.      
  73.      if select == 1 then
  74.        select = 0
  75.        reset()
  76.        utils()
  77.        paintutils.drawLine(1,yy,xx,yy,colors.black)
  78.        term.setBackgroundColor(colors.black)
  79.        term.setTextColor(einstellungen[3])
  80.        term.setCursorPos(1,yy)
  81.        write("Label:")
  82.        term.setCursorPos(8,yy)
  83.        local label = read()
  84.        disk.setLabel(diskDrive, label)
  85.        reset()
  86.        utils()
  87.      elseif select == 2 then
  88.        select = 0
  89.        reset()
  90.        utils()
  91.        for _, sFile in pairs(fs.list("/disk")) do
  92.          fs.delete("/disk/" .. sFile)
  93.        end
  94.        paintutils.drawLine(1,yy,xx,yy,colors.black)
  95.        term.setBackgroundColor(colors.black)
  96.        term.setTextColor(einstellungen[3])
  97.        term.setCursorPos(xx/2-15,yy)
  98.        write("Diskette erfolgreich gelöscht!")
  99.        sleep(2)
  100.        reset()
  101.        utils()
  102.      end
  103.     end
  104.  else
  105.     paintutils.drawLine(xx/2-13,3,xx/2+13,3,colors.black)
  106.     paintutils.drawLine(xx/2-13,4,xx/2+13,4,colors.black)
  107.     paintutils.drawLine(xx/2-13,5,xx/2+13,5,colors.black)
  108.     term.setCursorPos(xx/2-12,4)
  109.     term.setTextColor(colors.red)
  110.     print("Keine Diskette gefunden!")
  111.     while quit == 0 do
  112.      local event, button, x, y = os.pullEvent("mouse_click")
  113.             if event == "mouse_click" then
  114.               if y == 1 and x > xx-7 and x < xx then
  115.                    quit = 1
  116.               end
  117.      end
  118.     end
  119.  end
  120. else
  121.     paintutils.drawLine(xx/2-17,3,xx/2+17,3,colors.black)
  122.     paintutils.drawLine(xx/2-17,4,xx/2+17,4,colors.black)
  123.     paintutils.drawLine(xx/2-17,5,xx/2+17,5,colors.black)
  124.     term.setCursorPos(xx/2-16,4)
  125.     term.setTextColor(colors.red)
  126.     print("Kein Diskettenlaufwerk gefunden!")
  127.     while quit == 0 do
  128.      local event, button, x, y = os.pullEvent("mouse_click")
  129.             if event == "mouse_click" then
  130.               if y == 1 and x > xx-7 and x < xx then
  131.                    quit = 1
  132.               end
  133.      end
  134.     end
  135. end
  136.      
  137.     os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement