Advertisement
colhaydutu

musicccc

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