Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tape = peripheral.find("tape_drive")
- term.clear()
- if tape == nil then
- print("No Tape Drive found!")
- else
- x = 1
- while x == 1 do
- term.clear()
- term.setCursorPos(1,1)
- print("TapeWriter V2 - Now with Mixtape Capabilities!")
- print("Is this going to be a brand new tape? y/n")
- print("If you are adding onto an existing tape, select 'n'")
- confirm = read()
- if confirm == "y" then
- print("Got it. I will now wipe and rewind the tape")
- local k = tape.getSize()
- tape.stop()
- tape.seek(-k)
- tape.stop() --Just making sure
- tape.seek(-90000)
- local s = string.rep("\xAA", 8192)
- for i = 1, k + 8191, 8192 do
- tape.write(s)
- end
- tape.seek(-tape.getSize())
- print("Tape has been wiped.")
- x = 0
- z = 1
- sleep(2)
- elseif confirm == "n" then
- print("Understood. Your tape won't be rewound or wiped.")
- print("Before we continue, please set your tape to the end of the last track!")
- print(" ")
- print("We wouldn't want to write over any songs would we?")
- x = 0
- z = 0
- print("Press any key to continue...")
- os.pullEvent("key")
- else
- print("Invalid answer!")
- sleep(2)
- end
- while z == 1 do
- term.clear()
- term.setCursorPos(1,1)
- print("TapeWriter V2 - Now with Mixtape Capabilities!")
- print("Ok, let's get started. First thing's first!")
- print("What's the name of your tape?")
- tapeTitle = read()
- y = 1
- while y == 1 do
- term.setCursorPos(1,5)
- print(tapeTitle)
- print("Is that correct? y/n")
- print(" ")
- print(" ")
- print(" ")
- print(" ")
- term.setCursorPos(1,7)
- confirm = read()
- if confirm == "y" then
- print("Got it! I will now set your tape's label.")
- tape.setLabel(tapeTitle)
- z = 0
- y = 0
- sleep(2)
- elseif confirm == "n" then
- print("I see. Let's try this again shall we?")
- y = 0
- sleep(2)
- else
- print("Invalid answer!")
- sleep(2)
- end
- end
- end
- end
- x = 1
- while x == 1 do
- term.clear()
- term.setCursorPos(1,1)
- print("TapeWriter V2 - Now with Mixtape Capabilities!")
- print("How many tracks are we downloading?")
- print("Make sure your tape has enough space!")
- print("Cause I'm not going to check!")
- trackNumbers = tonumber(read())
- if type(trackNumbers) == "number" then
- print(trackNumbers .. " tracks. Got it!")
- x = 0
- sleep(2)
- else
- print("I didn't quite get that. Please enter a number!")
- sleep(2)
- end
- end
- x = 1
- while x <= trackNumbers do
- term.clear()
- term.setCursorPos(1,1)
- print("Where's track " .. x .. " at DJ?")
- print("URL (Including https://):")
- url = read()
- local response = http.get(url, nil, true)
- print("Downloading")
- print("Starting tape position is: " .. tape.getPosition())
- tape.write(response.readAll())
- response.close()
- print("Ending tape position is: " .. tape.getPosition())
- sleep(2)
- print("Download Complete!")
- x = x + 1
- print("Press any key to continue...")
- os.pullEvent("key")
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Your mixtape is now ready!")
- print("Thanks for using TapeWriter V2 for your mixtape needs!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement