Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- -- Change this to any connected monitor you want to use for system output
- mon = peripheral.wrap("monitor_2")
- -- This is the terminal's screen. Do not touch this!
- ter = term.current()
- -- If there are no arguments in the command then...
- if args == nil then
- term.setTextColor(colors.red)
- print("Warning: No parameters given!")
- print("Use \"swap #\" to select a drive")
- -- Otherwise, if there are arguments, if they match the case do...
- else
- if args[1] == "1" then
- print("Swapping to Drive 1")
- -- Sets the tape command to refer to the connected tape drive. Change this to whatever drive you want to use
- -- Copy this if/elseif section to connect more drives
- -- Stops the other tapes and rewinds them. If the 'hot' argument is given as the second argument, it will not rewind them
- if args[2] == nil then
- tape = peripheral.wrap("tape_drive_1")
- tape.stop()
- tape.seek(-tape.getSize())
- tape = peripheral.wrap("tape_drive_2")
- tape.stop()
- tape.seek(-tape.getSize())
- elseif args[2] == "hot" then
- tape = peripheral.wrap("tape_drive_1")
- tape.stop()
- tape = peripheral.wrap("tape_drive_2")
- tape.stop()
- end
- tape = peripheral.wrap("tape_drive_0")
- -- Displays a "Now Playing" message on the connected monitor
- print("Now Playing: " .. tape.getLabel())
- term.redirect(mon)
- term.setTextColor(colors.orange)
- print("Swapping to:")
- print(tape.getLabel())
- term.redirect(ter)
- elseif args[1] == "2" then
- print("Swapping to Drive 2")
- if args[2] == nil then
- tape = peripheral.wrap("tape_drive_0")
- tape.stop()
- tape.seek(-tape.getSize())
- tape = peripheral.wrap("tape_drive_2")
- tape.stop()
- tape.seek(-tape.getSize())
- elseif args[2] == "hot" then
- tape = peripheral.wrap("tape_drive_0")
- tape.stop()
- tape = peripheral.wrap("tape_drive_2")
- tape.stop()
- end
- tape = peripheral.wrap("tape_drive_1")
- print("Now Playing: " .. tape.getLabel())
- term.redirect(mon)
- term.setTextColor(colors.orange)
- print("Swapping to:")
- print(tape.getLabel())
- term.redirect(ter)
- elseif args[1] == "3" then
- print("Swapping to Drive 3")
- if args[2] == nil then
- tape = peripheral.wrap("tape_drive_0")
- tape.stop()
- tape.seek(-tape.getSize())
- tape = peripheral.wrap("tape_drive_1")
- tape.stop()
- tape.seek(-tape.getSize())
- elseif args[2] == "hot" then
- tape = peripheral.wrap("tape_drive_0")
- tape.stop()
- tape = peripheral.wrap("tape_drive_1")
- tape.stop()
- end
- tape = peripheral.wrap("tape_drive_2")
- print("Now Playing: " .. tape.getLabel())
- term.redirect(mon)
- term.setTextColor(colors.orange)
- print("Swapping to:")
- print(tape.getLabel())
- term.redirect(ter)
- end
- -- Rewinds and plays the tape for the selected drive. If the 'hot' argument is given, it won't rewind the tape before playing
- if args[2] == nil then
- tape.seek(-tape.getSize())
- elseif args[2] == "hot" then
- print("Hot Swapping")
- end
- tape.play()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement