Advertisement
Rolcam

Computronics - Cassette Tape Writer

Aug 24th, 2023 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.92 KB | Software | 0 0
  1. tape = peripheral.find("tape_drive")
  2. term.clear()
  3. if tape == nil then
  4.     print("No Tape Drive found!")
  5. else
  6.     x = 1
  7.     while x == 1 do
  8.         term.clear()
  9.         term.setCursorPos(1,1)
  10.         print("TapeWriter V2 - Now with Mixtape Capabilities!")
  11.         print("Is this going to be a brand new tape? y/n")
  12.         print("If you are adding onto an existing tape, select 'n'")
  13.         confirm = read()
  14.             if confirm == "y" then
  15.                 print("Got it. I will now wipe and rewind the tape")
  16.                 local k = tape.getSize()
  17.                 tape.stop()
  18.                 tape.seek(-k)
  19.                 tape.stop() --Just making sure
  20.                 tape.seek(-90000)
  21.                 local s = string.rep("\xAA", 8192)
  22.                 for i = 1, k + 8191, 8192 do
  23.                     tape.write(s)
  24.                 end
  25.                 tape.seek(-tape.getSize())
  26.                 print("Tape has been wiped.")
  27.                 x = 0
  28.                 z = 1
  29.                 sleep(2)
  30.             elseif confirm == "n" then
  31.                 print("Understood. Your tape won't be rewound or wiped.")
  32.                 print("Before we continue, please set your tape to the end of the last track!")
  33.                 print(" ")
  34.                 print("We wouldn't want to write over any songs would we?")
  35.                 x = 0
  36.                 z = 0
  37.                 print("Press any key to continue...")
  38.                 os.pullEvent("key")
  39.             else
  40.                 print("Invalid answer!")
  41.                 sleep(2)
  42.             end
  43.         while z == 1 do
  44.             term.clear()
  45.             term.setCursorPos(1,1)
  46.             print("TapeWriter V2 - Now with Mixtape Capabilities!")
  47.             print("Ok, let's get started. First thing's first!")
  48.             print("What's the name of your tape?")
  49.             tapeTitle = read()
  50.             y = 1
  51.             while y == 1 do
  52.                 term.setCursorPos(1,5)
  53.                 print(tapeTitle)
  54.                 print("Is that correct? y/n")
  55.                 print("                                  ")
  56.                 print("                                  ")
  57.                 print("                                  ")
  58.                 print("                                  ")
  59.                 term.setCursorPos(1,7)
  60.                 confirm = read()
  61.                 if confirm == "y" then
  62.                     print("Got it! I will now set your tape's label.")
  63.                     tape.setLabel(tapeTitle)
  64.                     z = 0
  65.                     y = 0
  66.                     sleep(2)
  67.                 elseif confirm == "n" then
  68.                     print("I see. Let's try this again shall we?")
  69.                     y = 0
  70.                     sleep(2)
  71.                 else
  72.                     print("Invalid answer!")
  73.                     sleep(2)
  74.                 end
  75.             end
  76.         end
  77.     end
  78.     x = 1
  79.     while x == 1 do
  80.         term.clear()
  81.         term.setCursorPos(1,1)
  82.         print("TapeWriter V2 - Now with Mixtape Capabilities!")
  83.         print("How many tracks are we downloading?")
  84.         print("Make sure your tape has enough space!")
  85.         print("Cause I'm not going to check!")
  86.         trackNumbers = tonumber(read())
  87.         if type(trackNumbers) == "number" then
  88.             print(trackNumbers .. " tracks. Got it!")
  89.             x = 0
  90.             sleep(2)
  91.         else
  92.             print("I didn't quite get that. Please enter a number!")
  93.             sleep(2)
  94.         end
  95.     end
  96.     x = 1
  97.     while x <= trackNumbers do
  98.         term.clear()
  99.         term.setCursorPos(1,1)
  100.         print("Where's track " .. x .. " at DJ?")
  101.         print("URL (Including https://):")
  102.         url = read()
  103.         local response = http.get(url, nil, true)
  104.         print("Downloading")
  105.         print("Starting tape position is: " .. tape.getPosition())
  106.         tape.write(response.readAll())
  107.         response.close()
  108.         print("Ending tape position is: " .. tape.getPosition())
  109.         sleep(2)
  110.         print("Download Complete!")
  111.         x = x + 1
  112.         print("Press any key to continue...")
  113.         os.pullEvent("key")
  114.     end
  115.     term.clear()
  116.     term.setCursorPos(1,1)
  117.     print("Your mixtape is now ready!")
  118.     print("Thanks for using TapeWriter V2 for your mixtape needs!")
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement