Kitomas

wipe

Jan 8th, 2020 (edited)
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. tape = peripheral.find("tape_drive")
  2. d = false
  3. run = false
  4. t = 0
  5. if tape then
  6.     function wipe(s)
  7.         for i=1,500000 do
  8.             if t < s then
  9.                 term.setCursorPos(1,5)
  10.                 term.write(t.."/"..s)
  11.             else
  12.                 term.setCursorPos(1,5)
  13.                 term.write(s.."/"..s)
  14.                 term.setCursorPos(1,6)
  15.                 term.write("Wrapping up..."..t)
  16.             end
  17.             tape.write(0)
  18.                 t = t + 1
  19.         end
  20.     end
  21.     if tape.isReady() then
  22.         run = true
  23.     else
  24.         print("Please insert a tape to use this program.")
  25.     end
  26. else
  27.     print("This program requires a tape drive to function.")
  28. end
  29. if run then
  30.     size = tape.getSize()
  31.         term.clear()
  32.         term.setCursorPos(1,1)
  33.         term.write("Are you sure you want to format this tape?(Y,N)")
  34.         print("(this might take a while)")
  35.         term.setCursorPos(1,3)
  36.         input = read()
  37.     if input == ("y") or input == ("yes") or input == ("Y") or input == ("Yes") then
  38.         tape.seek(-size)
  39.         tape.seek(-8000)
  40.         term.setCursorPos(1,4)
  41.         term.write("Phase 1:")
  42.         wipe(size)
  43.         sleep(.5)
  44.         if t < size then
  45.             term.setCursorPos(1,4)
  46.             term.write("Phase 2:")
  47.             wipe(size)
  48.         end
  49.         tape.seek(-size)
  50.         tape.seek(-8000)
  51.         d = true
  52.     else
  53.         print("Aborted.")
  54.     end
  55. end
  56. if d then
  57.     term.setCursorPos(1,7)
  58.     term.write("Done!")
  59.     term.setCursorPos(1,8)
  60. end
Add Comment
Please, Sign In to add comment