Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local redstoneOutput = "back"
- local lamba = true
- local monitor = peripheral.wrap("left")
- local tapeDrive = peripheral.wrap("right")
- local modemSide = "back"
- local isPlaying = false
- local volume = 1.0
- local maxBarWidth = 16 -- Maksimum çubuk genişliği
- local function drawControls()
- monitor.setBackgroundColor(colors.gray)
- monitor.clear()
- term.redirect(monitor)
- monitor.setCursorPos(6, 5)
- monitor.setTextScale(1.5)
- monitor.setTextColor(colors.white)
- if isPlaying then
- paintutils.drawLine(5, 6, 15, 6, colors.red)
- paintutils.drawLine(5, 4, 15, 4, colors.red)
- monitor.setCursorPos(5, 5)
- monitor.setBackgroundColor(colors.red)
- monitor.setTextColor(colors.white)
- monitor.write(" [Stop ||] ")
- else
- paintutils.drawLine(5, 6, 15, 6, colors.green)
- paintutils.drawLine(5, 4, 15, 4, colors.green)
- monitor.setCursorPos(5, 5)
- monitor.setBackgroundColor(colors.green)
- monitor.setTextColor(colors.white)
- monitor.write(" [Play |>] ")
- end
- paintutils.drawLine(4, 8, 16, 8, colors.blue)
- paintutils.drawLine(4, 10, 16, 10, colors.blue)
- monitor.setCursorPos(4, 9)
- monitor.setBackgroundColor(colors.blue)
- monitor.setTextColor(colors.white)
- monitor.write(" [Rewind <<] ")
- paintutils.drawLine(4, 17, 15, 17, colors.orange)
- paintutils.drawLine(4, 15, 15, 15, colors.orange)
- monitor.setCursorPos(4, 16)
- monitor.setBackgroundColor(colors.orange)
- monitor.setTextColor(colors.black)
- monitor.write(" [ Upload ] ")
- -- Draw volume bar
- monitor.setCursorPos(3, 12)
- monitor.setBackgroundColor(colors.gray)
- monitor.setTextColor(colors.white)
- monitor.write("[Volume: " .. tostring(volume * 100) .."%]")
- monitor.setCursorPos(2, 14)
- local barWidth = math.floor(volume * maxBarWidth)
- local emptyWidth = maxBarWidth - barWidth
- for i = 1, barWidth do
- monitor.setBackgroundColor(colors.green)
- monitor.write(" ")
- end
- for i = 1, emptyWidth do
- monitor.setBackgroundColor(colors.gray)
- monitor.write(" ")
- end
- monitor.setCursorPos(1, 14)
- monitor.setBackgroundColor(colors.gray)
- monitor.setTextColor(colors.white)
- monitor.write("[ ")
- monitor.setCursorPos(17, 14)
- monitor.setBackgroundColor(colors.gray)
- monitor.setTextColor(colors.white)
- monitor.write(" ]")
- monitor.setCursorPos(2, 12)
- monitor.setBackgroundColor(colors.blue)
- monitor.setTextColor(colors.white)
- monitor.write("<")
- monitor.setCursorPos(17, 12)
- monitor.setBackgroundColor(colors.blue)
- monitor.setTextColor(colors.white)
- monitor.write(">")
- local w, h = monitor.getSize()
- local tapeLabel = tapeDrive.getLabel()
- monitor.setCursorPos(1, 1)
- monitor.setBackgroundColor(colors.green)
- monitor.setTextColor(colors.white)
- monitor.write(" Now playing ")
- monitor.setCursorPos(1, 2)
- monitor.write(tapeLabel)
- if lamba then
- monitor.setCursorPos(17, 17)
- monitor.setBackgroundColor(colors.green)
- monitor.setTextColor(colors.white)
- monitor.write("on ")
- else
- monitor.setCursorPos(17, 17)
- monitor.setBackgroundColor(colors.red)
- monitor.setTextColor(colors.white)
- monitor.write("off")
- end
- end
- drawControls()
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- if x >= 1 and x <= 10 and y == 5 then
- if isPlaying then
- tapeDrive.stop()
- isPlaying = false
- else
- tapeDrive.play()
- isPlaying = true
- end
- elseif x >= 1 and x <= 13 and y == 9 then
- tapeDrive.stop()
- tapeDrive.seek(-tapeDrive.getSize())
- isPlaying = false
- elseif x >= 1 and x <= 3 and y == 12 then
- if volume > 0.0 then
- volume = volume - 0.1
- tapeDrive.setVolume(volume)
- drawControls()
- end
- elseif x >= 16 and x <= 17 and y == 12 then
- if volume < 1.0 then
- volume = volume + 0.1
- tapeDrive.setVolume(volume)
- drawControls()
- end
- elseif x >= 17 and x <= 20 and y == 17 then
- if lamba then
- redstone.setOutput(redstoneOutput, true)
- lamba = false
- else
- redstone.setOutput(redstoneOutput, false)
- lamba = true
- end
- elseif x >= 1 and x <= 15 and y >= 15 and y <= 17 then
- local tape = peripheral.find("tape_drive")
- term.clear()
- term.redirect(term.native())
- if tape == nil then
- print("No Tape Drive found!")
- else
- print("TapeWriter for Revelation")
- print("Where's the music at?")
- write("URL:")
- local url = read()
- if url == "cancel" then
- drawControls()
- else
- local response = http.get(url, nil, true)
- if response then
- print("Downloading")
- local tapePosition = tape.getPosition()
- tape.seek(-tapePosition)
- tape.write(response.readAll())
- response.close()
- tape.seek(-tapePosition)
- print("Got a name for this tape?")
- write("Name:")
- local name = read()
- tape.setLabel(name)
- print("Done!")
- term.redirect(monitor)
- else
- print("Failed to download from the provided URL.")
- end
- end
- end
- end
- drawControls()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement