Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- mon = peripheral.wrap("monitor_0")
- ter = term.current()
- -- the taper variables are the names/side of each drive. Since they are called multiple times, I am using variables to set them so it is easier to rename them
- taper1 = "tape_drive_3"
- taper2 = "tape_drive_4"
- taper3 = "tape_drive_5"
- -- Stops the tape and rewinds it if the "hot" parameter is not used when calling the program
- function rewinder()
- term.redirect(mon)
- term.setTextColor(colors.red)
- print("Stopped:")
- print(tape.getLabel())
- term.redirect(ter)
- if args[2] == nil then
- if tape == nil then
- sleep(0.1)
- else
- tape.seek(-tape.getSize())
- end
- elseif args[2] == "hot" then
- term.setTextColor(colors.orange)
- print("hot parameter used! Not rewinding the tape!")
- term.setTextColor(colors.white)
- else
- term.setTextColor(colors.red)
- print("Parameter 2 Invalid! Using Default Value...")
- term.setTextColor(colors.white)
- tape.seek(-tape.getSize())
- end
- if tape == nil then
- sleep(0.1)
- else
- tape.stop()
- end
- end
- if args == nil then
- term.setTextColor(colors.red)
- print("Warning: No parameters given!")
- print("Use \"stop #\" to select a drive")
- else
- if args[1] == "1" then
- print("Stopping Drive 1")
- tape = peripheral.wrap(taper1)
- rewinder()
- elseif args[1] == "2" then
- print("Stopping Drive 2")
- tape = peripheral.wrap(taper2)
- rewinder()
- elseif args[1] == "3" then
- print("Stopping Drive 3")
- tape = peripheral.wrap(taper3)
- rewinder()
- elseif args[1] == "all" then
- print("Stopping all tape drives...")
- print("Stopping Drive 1")
- tape = peripheral.wrap(taper1)
- rewinder()
- print("Stopping Drive 2")
- tape = peripheral.wrap(taper2)
- rewinder()
- print("Stopping Drive 3")
- tape = peripheral.wrap(taper3)
- rewinder()
- print("All tape drives were stopped!")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement