Advertisement
colhaydutu

musicv3

Sep 7th, 2023 (edited)
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. local redstoneOutput = "back"
  2. local lamba = true
  3. local monitor = peripheral.wrap("left")
  4. local tapeDrive = peripheral.wrap("right")
  5. local modemSide = "back"
  6. local isPlaying = false
  7. local volume = 1.0
  8. local maxBarWidth = 16 -- Maksimum çubuk genişliği
  9.  
  10. local function drawControls()
  11. monitor.setBackgroundColor(colors.gray)
  12. monitor.clear()
  13. term.redirect(monitor)
  14. monitor.setCursorPos(6, 5)
  15. monitor.setTextScale(1.5)
  16. monitor.setTextColor(colors.white)
  17.  
  18. if isPlaying then
  19. paintutils.drawLine(5, 6, 15, 6, colors.red)
  20. paintutils.drawLine(5, 4, 15, 4, colors.red)
  21. monitor.setCursorPos(5, 5)
  22. monitor.setBackgroundColor(colors.red)
  23. monitor.setTextColor(colors.white)
  24. monitor.write(" [Stop ||] ")
  25. else
  26. paintutils.drawLine(5, 6, 15, 6, colors.green)
  27. paintutils.drawLine(5, 4, 15, 4, colors.green)
  28. monitor.setCursorPos(5, 5)
  29. monitor.setBackgroundColor(colors.green)
  30. monitor.setTextColor(colors.white)
  31. monitor.write(" [Play |>] ")
  32. end
  33.  
  34. paintutils.drawLine(4, 8, 16, 8, colors.blue)
  35. paintutils.drawLine(4, 10, 16, 10, colors.blue)
  36. monitor.setCursorPos(4, 9)
  37. monitor.setBackgroundColor(colors.blue)
  38. monitor.setTextColor(colors.white)
  39. monitor.write(" [Rewind <<] ")
  40.  
  41. paintutils.drawLine(4, 17, 15, 17, colors.orange)
  42. paintutils.drawLine(4, 15, 15, 15, colors.orange)
  43. monitor.setCursorPos(4, 16)
  44. monitor.setBackgroundColor(colors.orange)
  45. monitor.setTextColor(colors.black)
  46. monitor.write(" [ Upload ] ")
  47.  
  48. -- Draw volume bar
  49. monitor.setCursorPos(3, 12)
  50. monitor.setBackgroundColor(colors.gray)
  51. monitor.setTextColor(colors.white)
  52. monitor.write("[Volume: " .. tostring(volume * 100) .."%]")
  53.  
  54. monitor.setCursorPos(2, 14)
  55. local barWidth = math.floor(volume * maxBarWidth)
  56. local emptyWidth = maxBarWidth - barWidth
  57. for i = 1, barWidth do
  58. monitor.setBackgroundColor(colors.green)
  59. monitor.write(" ")
  60. end
  61. for i = 1, emptyWidth do
  62. monitor.setBackgroundColor(colors.gray)
  63. monitor.write(" ")
  64. end
  65.  
  66. monitor.setCursorPos(1, 14)
  67. monitor.setBackgroundColor(colors.gray)
  68. monitor.setTextColor(colors.white)
  69. monitor.write("[ ")
  70.  
  71. monitor.setCursorPos(17, 14)
  72. monitor.setBackgroundColor(colors.gray)
  73. monitor.setTextColor(colors.white)
  74. monitor.write(" ]")
  75.  
  76. monitor.setCursorPos(2, 12)
  77. monitor.setBackgroundColor(colors.blue)
  78. monitor.setTextColor(colors.white)
  79. monitor.write("<")
  80.  
  81. monitor.setCursorPos(17, 12)
  82. monitor.setBackgroundColor(colors.blue)
  83. monitor.setTextColor(colors.white)
  84. monitor.write(">")
  85.  
  86. local w, h = monitor.getSize()
  87. local tapeLabel = tapeDrive.getLabel()
  88. monitor.setCursorPos(1, 1)
  89. monitor.setBackgroundColor(colors.green)
  90. monitor.setTextColor(colors.white)
  91. monitor.write(" Now playing ")
  92. monitor.setCursorPos(1, 2)
  93. monitor.write(tapeLabel)
  94.  
  95. if lamba then
  96. monitor.setCursorPos(17, 17)
  97. monitor.setBackgroundColor(colors.green)
  98. monitor.setTextColor(colors.white)
  99. monitor.write("on ")
  100. else
  101. monitor.setCursorPos(17, 17)
  102. monitor.setBackgroundColor(colors.red)
  103. monitor.setTextColor(colors.white)
  104. monitor.write("off")
  105. end
  106. end
  107.  
  108.  
  109.  
  110. drawControls()
  111.  
  112.  
  113. while true do
  114. local event, side, x, y = os.pullEvent("monitor_touch")
  115.  
  116. if x >= 1 and x <= 10 and y == 5 then
  117. if isPlaying then
  118. tapeDrive.stop()
  119. isPlaying = false
  120. else
  121. tapeDrive.play()
  122. isPlaying = true
  123. end
  124. elseif x >= 1 and x <= 13 and y == 9 then
  125. tapeDrive.stop()
  126. tapeDrive.seek(-tapeDrive.getSize())
  127. isPlaying = false
  128. elseif x >= 1 and x <= 3 and y == 12 then
  129. if volume > 0.0 then
  130. volume = volume - 0.1
  131. tapeDrive.setVolume(volume)
  132. drawControls()
  133. end
  134. elseif x >= 16 and x <= 17 and y == 12 then
  135. if volume < 1.0 then
  136. volume = volume + 0.1
  137. tapeDrive.setVolume(volume)
  138. drawControls()
  139. end
  140. elseif x >= 17 and x <= 20 and y == 17 then
  141. if lamba then
  142. redstone.setOutput(redstoneOutput, true)
  143. lamba = false
  144. else
  145. redstone.setOutput(redstoneOutput, false)
  146. lamba = true
  147. end
  148. elseif x >= 1 and x <= 15 and y >= 15 and y <= 17 then
  149. local tape = peripheral.find("tape_drive")
  150. term.clear()
  151. term.redirect(term.native())
  152. if tape == nil then
  153. print("No Tape Drive found!")
  154. else
  155. print("TapeWriter for Revelation")
  156. print("Where's the music at?")
  157. write("URL:")
  158. local url = read()
  159.  
  160. if url == "cancel" then
  161. drawControls()
  162. else
  163. local response = http.get(url, nil, true)
  164.  
  165. if response then
  166. print("Downloading")
  167. local tapePosition = tape.getPosition()
  168. tape.seek(-tapePosition)
  169. tape.write(response.readAll())
  170. response.close()
  171. tape.seek(-tapePosition)
  172.  
  173. print("Got a name for this tape?")
  174. write("Name:")
  175. local name = read()
  176. tape.setLabel(name)
  177. print("Done!")
  178. term.redirect(monitor)
  179. else
  180. print("Failed to download from the provided URL.")
  181. end
  182. end
  183. end
  184. end
  185.  
  186. drawControls()
  187. end
  188.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement