Advertisement
Guest User

startup

a guest
Aug 8th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.99 KB | None | 0 0
  1. local api_base_url = "https://ipod-2to6magyna-uc.a.run.app/"
  2.  
  3.  
  4.  
  5. local width, height = term.getSize()
  6.  
  7.  
  8.  
  9. local tab = 1
  10.  
  11. local waiting_for_input = false
  12.  
  13. local last_search = nil
  14.  
  15. local last_search_url = nil
  16.  
  17. local search_results = nil
  18.  
  19. local search_error = false
  20.  
  21. local in_fullscreen = 0
  22.  
  23. local clicked_result = nil
  24.  
  25.  
  26.  
  27. local playing = false
  28.  
  29. local queue = {}
  30.  
  31. local now_playing = nil
  32.  
  33. local looping = false
  34.  
  35.  
  36.  
  37. local playing_id = nil
  38.  
  39. local last_download_url = nil
  40.  
  41. local playing_status = 0
  42.  
  43.  
  44.  
  45. local player_handle = nil
  46.  
  47. local start = nil
  48.  
  49. local pcm = nil
  50.  
  51. local size = nil
  52.  
  53. local decoder = nil
  54.  
  55. local needs_next_chunk = 0
  56.  
  57. local buffer
  58.  
  59.  
  60.  
  61.  
  62.  
  63. local function getSpeakers()
  64.  
  65. local speakers = {}
  66.  
  67. for _, name in ipairs(peripheral.getNames()) do
  68.  
  69. if peripheral.getType(name) == "speaker" then
  70.  
  71. table.insert(speakers, peripheral.wrap(name))
  72.  
  73. end
  74.  
  75. end
  76.  
  77. return speakers
  78.  
  79. end
  80.  
  81. local speakers = getSpeakers()
  82.  
  83. if #speakers == 0 then
  84.  
  85.  error("no speakers attached", 0)
  86.  
  87.  end
  88.  
  89.  
  90.  
  91. local function playAudioOnSpeakers(buffer)
  92.  
  93. for _, speakers in ipairs(speakers) do
  94.  
  95. while not speakers.playAudio(buffer) do
  96.  
  97. sleep(0.05) -- Wait before retrying
  98.  
  99. end
  100.  
  101. end
  102.  
  103. end
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. local function redrawScreen()
  116.  
  117.     if waiting_for_input == true then
  118.  
  119.         return
  120.  
  121.     end
  122.  
  123.  
  124.  
  125.     -- DRAWING
  126.  
  127.     term.setBackgroundColor(colors.black)
  128.  
  129.     term.clear()
  130.  
  131.  
  132.  
  133.     --tabs
  134.  
  135.     term.setCursorPos(1,1)
  136.  
  137.     term.setBackgroundColor(colors.gray)
  138.  
  139.     term.clearLine()
  140.  
  141.  
  142.  
  143.     tabs = {" Now Playing ", " Search "}
  144.  
  145.  
  146.  
  147.     for i=1,2,1 do
  148.  
  149.         if tab == i then
  150.  
  151.             term.setTextColor(colors.black)
  152.  
  153.             term.setBackgroundColor(colors.white)
  154.  
  155.         else
  156.  
  157.             term.setTextColor(colors.white)
  158.  
  159.             term.setBackgroundColor(colors.gray)
  160.  
  161.         end
  162.  
  163.  
  164.  
  165.         term.setCursorPos((math.floor((width/2)*(i-0.5)))-math.ceil(#tabs[i]/2)+1, 1)
  166.  
  167.         term.write(tabs[i])
  168.  
  169.     end
  170.  
  171.  
  172.  
  173.     --now playing tab
  174.  
  175.     if tab == 1 then
  176.  
  177.         if now_playing ~= nil then
  178.  
  179.             term.setBackgroundColor(colors.black)
  180.  
  181.             term.setTextColor(colors.white)
  182.  
  183.             term.setCursorPos(2,3)
  184.  
  185.             term.write(now_playing.name)
  186.  
  187.             term.setTextColor(colors.lightGray)
  188.  
  189.             term.setCursorPos(2,4)
  190.  
  191.             term.write(now_playing.artist)
  192.  
  193.         else
  194.  
  195.             term.setBackgroundColor(colors.black)
  196.  
  197.             term.setTextColor(colors.lightGray)
  198.  
  199.             term.setCursorPos(2,3)
  200.  
  201.             term.write("Not playing")
  202.  
  203.         end
  204.  
  205.  
  206.  
  207.         term.setTextColor(colors.white)
  208.  
  209.         term.setBackgroundColor(colors.gray)
  210.  
  211.  
  212.  
  213.         if playing then
  214.  
  215.             term.setCursorPos(2, 6)
  216.  
  217.             term.write(" Stop ")
  218.  
  219.         else
  220.  
  221.             if now_playing ~= nil or #queue > 0 then
  222.  
  223.                 term.setTextColor(colors.white)
  224.  
  225.                 term.setBackgroundColor(colors.gray)
  226.  
  227.             else
  228.  
  229.                 term.setTextColor(colors.lightGray)
  230.  
  231.                 term.setBackgroundColor(colors.gray)
  232.  
  233.             end
  234.  
  235.             term.setCursorPos(2, 6)
  236.  
  237.             term.write(" Play ")
  238.  
  239.         end
  240.  
  241.  
  242.  
  243.         if now_playing ~= nil or #queue > 0 then
  244.  
  245.             term.setTextColor(colors.white)
  246.  
  247.             term.setBackgroundColor(colors.gray)
  248.  
  249.         else
  250.  
  251.             term.setTextColor(colors.lightGray)
  252.  
  253.             term.setBackgroundColor(colors.gray)
  254.  
  255.         end
  256.  
  257.         term.setCursorPos(2 + 8, 6)
  258.  
  259.         term.write(" Skip ")
  260.  
  261.  
  262.  
  263.         if looping then
  264.  
  265.             term.setTextColor(colors.black)
  266.  
  267.             term.setBackgroundColor(colors.white)
  268.  
  269.         else
  270.  
  271.             term.setTextColor(colors.white)
  272.  
  273.             term.setBackgroundColor(colors.gray)
  274.  
  275.         end
  276.  
  277.         term.setCursorPos(2 + 8 + 8, 6)
  278.  
  279.         term.write(" Loop ")
  280.  
  281.  
  282.  
  283.         --search results
  284.  
  285.         if #queue > 0 then
  286.  
  287.             term.setBackgroundColor(colors.black)
  288.  
  289.             for i=1,#queue do
  290.  
  291.                 term.setTextColor(colors.white)
  292.  
  293.                 term.setCursorPos(2,8 + (i-1)*2)
  294.  
  295.                 term.write(queue[i].name)
  296.  
  297.                 term.setTextColor(colors.lightGray)
  298.  
  299.                 term.setCursorPos(2,9 + (i-1)*2)
  300.  
  301.                 term.write(queue[i].artist)
  302.  
  303.             end
  304.  
  305.         end
  306.  
  307.     end
  308.  
  309.  
  310.  
  311.     --search tab
  312.  
  313.     if tab == 2 then
  314.  
  315.  
  316.  
  317.         -- search bar
  318.  
  319.         for a=3,5,1 do
  320.  
  321.             term.setCursorPos(2,a)
  322.  
  323.             term.setTextColor(colors.lightGray)
  324.  
  325.             term.setBackgroundColor(colors.lightGray)
  326.  
  327.             for i=1,width-2,1 do
  328.  
  329.                 term.write(" ")
  330.  
  331.             end
  332.  
  333.         end
  334.  
  335.         term.setCursorPos(3,4)
  336.  
  337.         term.setTextColor(colors.black)
  338.  
  339.         term.write(last_search or "Search...")
  340.  
  341.  
  342.  
  343.         --search results
  344.  
  345.         if search_results ~= nil then
  346.  
  347.             term.setBackgroundColor(colors.black)
  348.  
  349.             for i=1,#search_results do
  350.  
  351.                 term.setTextColor(colors.white)
  352.  
  353.                 term.setCursorPos(2,7 + (i-1)*2)
  354.  
  355.                 term.write(search_results[i].name)
  356.  
  357.                 term.setTextColor(colors.lightGray)
  358.  
  359.                 term.setCursorPos(2,8 + (i-1)*2)
  360.  
  361.                 term.write(search_results[i].artist)
  362.  
  363.             end
  364.  
  365.         else
  366.  
  367.             term.setCursorPos(2,7)
  368.  
  369.             term.setBackgroundColor(colors.black)
  370.  
  371.             if search_error == true then
  372.  
  373.                 term.setTextColor(colors.red)
  374.  
  375.                 term.write("Error")
  376.  
  377.             else
  378.  
  379.                 if last_search_url ~= nil then
  380.  
  381.                     term.setTextColor(colors.white)
  382.  
  383.                     term.write("Searching...")
  384.  
  385.                 else
  386.  
  387.  
  388.  
  389.                 end
  390.  
  391.             end
  392.  
  393.         end
  394.  
  395.  
  396.  
  397.         --fullscreen song options
  398.  
  399.         if in_fullscreen == 1 then
  400.  
  401.             term.setBackgroundColor(colors.black)
  402.  
  403.             term.clear()
  404.  
  405.             term.setCursorPos(2,2)
  406.  
  407.             term.setTextColor(colors.white)
  408.  
  409.             term.write(search_results[clicked_result].name)
  410.  
  411.             term.setCursorPos(2,3)
  412.  
  413.             term.setTextColor(colors.lightGray)
  414.  
  415.             term.write(search_results[clicked_result].artist)
  416.  
  417.  
  418.  
  419.             term.setBackgroundColor(colors.gray)
  420.  
  421.             term.setTextColor(colors.white)
  422.  
  423.  
  424.  
  425.             term.setCursorPos(2,6)
  426.  
  427.             term.clearLine()
  428.  
  429.             term.write("Play now")
  430.  
  431.  
  432.  
  433.             term.setCursorPos(2,8)
  434.  
  435.             term.clearLine()
  436.  
  437.             term.write("Play next")
  438.  
  439.  
  440.  
  441.             term.setCursorPos(2,10)
  442.  
  443.             term.clearLine()
  444.  
  445.             term.write("Add to queue")
  446.  
  447.  
  448.  
  449.             term.setCursorPos(2,13)
  450.  
  451.             term.clearLine()
  452.  
  453.             term.write("Cancel")
  454.  
  455.         end
  456.  
  457.  
  458.  
  459.     end
  460.  
  461. end
  462.  
  463.  
  464.  
  465. local function searchInput()
  466.  
  467.     while true do
  468.  
  469.         if waiting_for_input == true then
  470.  
  471.             for a=3,5,1 do
  472.  
  473.                 term.setCursorPos(2,a)
  474.  
  475.                 term.setTextColor(colors.white)
  476.  
  477.                 term.setBackgroundColor(colors.white)
  478.  
  479.                 for i=1,width-2,1 do
  480.  
  481.                     term.write(" ")
  482.  
  483.                 end
  484.  
  485.             end
  486.  
  487.             term.setCursorPos(3,4)
  488.  
  489.             term.setTextColor(colors.black)
  490.  
  491.             local input = read()
  492.  
  493.             if string.len(input) > 0 then
  494.  
  495.                 last_search = input
  496.  
  497.                 last_search_url = api_base_url .. "?search=" .. textutils.urlEncode(input)
  498.  
  499.                 http.request(last_search_url)
  500.  
  501.                 search_results = nil
  502.  
  503.                 search_error = false
  504.  
  505.             else
  506.  
  507.                 last_search = nil
  508.  
  509.                 last_search_url = nil
  510.  
  511.                 search_results = nil
  512.  
  513.                 search_error = false
  514.  
  515.             end
  516.  
  517.  
  518.  
  519.             waiting_for_input = false
  520.  
  521.  
  522.  
  523.             redrawScreen()
  524.  
  525.         end
  526.  
  527.  
  528.  
  529.         sleep(0.1)
  530.  
  531.     end
  532.  
  533. end
  534.  
  535.  
  536.  
  537. local function mainLoop()
  538.  
  539.     redrawScreen()
  540.  
  541.  
  542.  
  543.     while true do
  544.  
  545.  
  546.  
  547.         -- AUDIO
  548.  
  549.         if playing and now_playing then
  550.  
  551.             if playing_id ~= now_playing.id then
  552.  
  553.                 playing_id = now_playing.id
  554.  
  555.                 last_download_url = api_base_url .. "?id=" .. textutils.urlEncode(playing_id)
  556.  
  557.                 playing_status = 0
  558.  
  559.                 needs_next_chunk = 1
  560.  
  561.  
  562.  
  563.                 http.request({url = last_download_url, binary = true})
  564.  
  565.  
  566.  
  567.                 redrawScreen()
  568.  
  569.             end
  570.  
  571.             if playing_status == 1 and needs_next_chunk == 3 then
  572.  
  573.                 needs_next_chunk = 1
  574.  
  575.  
  576.  
  577.                 while not playAudioOnSpeakers(buffer) do
  578.  
  579.                     needs_next_chunk = 2
  580.  
  581.                     break
  582.  
  583.                 end
  584.  
  585.             end
  586.  
  587.             if playing_status == 1 and needs_next_chunk == 1 then
  588.  
  589.  
  590.  
  591.                 while true do
  592.  
  593.                     local chunk = player_handle.read(size)
  594.  
  595.                     if not chunk then
  596.  
  597.                         if looping then
  598.  
  599.                             playing_id = nil
  600.  
  601.                         else
  602.  
  603.                             if #queue > 0 then
  604.  
  605.                                 now_playing = queue[1]
  606.  
  607.                                 table.remove(queue, 1)
  608.  
  609.                                 playing_id = nil
  610.  
  611.                             else
  612.  
  613.                                 now_playing = nil
  614.  
  615.                                 playing = false
  616.  
  617.                                 playing_id = nil
  618.  
  619.                             end
  620.  
  621.                         end
  622.  
  623.  
  624.  
  625.                         redrawScreen()
  626.  
  627.  
  628.  
  629.                         player_handle.close()
  630.  
  631.                         needs_next_chunk = 0
  632.  
  633.                         break
  634.  
  635.                     else
  636.  
  637.                         if start then
  638.  
  639.                             chunk, start = start .. chunk, nil
  640.  
  641.                             size = size + 4
  642.  
  643.                         end
  644.  
  645.  
  646.  
  647.                         buffer = decoder(chunk)
  648.  
  649.                          playAudioOnSpeakers(buffer)
  650.  
  651.                             if needs_next_chunk == 2 then
  652.  
  653.                             break
  654.  
  655.                         end
  656.  
  657.                     end
  658.  
  659.                 end
  660.  
  661.  
  662.  
  663.             end
  664.  
  665.         end
  666.  
  667.  
  668.  
  669.         -- EVENTS
  670.  
  671.         local event, param1, param2, param3 = os.pullEvent()    
  672.  
  673.  
  674.  
  675.         -- CLICK EVENTS
  676.  
  677.         if event == "mouse_click" and waiting_for_input == false then
  678.  
  679.  
  680.  
  681.             local button = param1
  682.  
  683.             local x = param2
  684.  
  685.             local y = param3
  686.  
  687.  
  688.  
  689.             -- tabs
  690.  
  691.             if button == 1 and in_fullscreen == 0 then
  692.  
  693.                 if y == 1 then
  694.  
  695.                     if x < width/2 then
  696.  
  697.                         tab = 1
  698.  
  699.                     else
  700.  
  701.                         tab = 2
  702.  
  703.                     end
  704.  
  705.                 end
  706.  
  707.             end
  708.  
  709.  
  710.  
  711.             --fullscreen windows
  712.  
  713.             if in_fullscreen == 1 then
  714.  
  715.                 term.setBackgroundColor(colors.white)
  716.  
  717.                 term.setTextColor(colors.black)
  718.  
  719.  
  720.  
  721.                 if y == 6 then
  722.  
  723.                     term.setCursorPos(2,6)
  724.  
  725.                     term.clearLine()
  726.  
  727.                     term.write("Play now")
  728.  
  729.                     sleep(0.2)
  730.  
  731.                     in_fullscreen = 0
  732.  
  733.                     now_playing = search_results[clicked_result]
  734.  
  735.                     playing = true
  736.  
  737.                     playing_id = nil
  738.  
  739.                 end
  740.  
  741.  
  742.  
  743.                 if y == 8 then
  744.  
  745.                     term.setCursorPos(2,8)
  746.  
  747.                     term.clearLine()
  748.  
  749.                     term.write("Play next")
  750.  
  751.                     sleep(0.2)
  752.  
  753.                     in_fullscreen = 0
  754.  
  755.                     table.insert(queue, 1, search_results[clicked_result])
  756.  
  757.                 end
  758.  
  759.  
  760.  
  761.                 if y == 10 then
  762.  
  763.                     term.setCursorPos(2,10)
  764.  
  765.                     term.clearLine()
  766.  
  767.                     term.write("Add to queue")
  768.  
  769.                     sleep(0.2)
  770.  
  771.                     in_fullscreen = 0
  772.  
  773.                     table.insert(queue, search_results[clicked_result])
  774.  
  775.                 end
  776.  
  777.  
  778.  
  779.                 if y == 13 then
  780.  
  781.                     term.setCursorPos(2,13)
  782.  
  783.                     term.clearLine()
  784.  
  785.                     term.write("Cancel")
  786.  
  787.                     sleep(0.2)
  788.  
  789.                     in_fullscreen = 0
  790.  
  791.                 end
  792.  
  793.             else
  794.  
  795.  
  796.  
  797.                 -- now playing tab
  798.  
  799.                 if tab == 1 and button == 1 then
  800.  
  801.                     if y == 6 then
  802.  
  803.                         if x >= 2 and x <= 2 + 6 then
  804.  
  805.                             local animate = false
  806.  
  807.                             local was_playing = playing
  808.  
  809.                             if playing then
  810.  
  811.                                 playing = false
  812.  
  813.                                 animate = true
  814.  
  815.                                 for _, speakers in ipairs(speakers) do
  816.  
  817.                                 speakers.stop()
  818.  
  819.                                 end
  820.  
  821.                                 playing_id = nil
  822.  
  823.                             else
  824.  
  825.                                 if now_playing ~= nil then
  826.  
  827.                                     playing_id = nil
  828.  
  829.                                     playing = true
  830.  
  831.                                     animate = true
  832.  
  833.                                 else
  834.  
  835.                                     if #queue > 0 then
  836.  
  837.                                         now_playing = queue[1]
  838.  
  839.                                         table.remove(queue, 1)
  840.  
  841.                                         playing_id = nil
  842.  
  843.                                         playing = true
  844.  
  845.                                         animate = true
  846.  
  847.                                     end
  848.  
  849.                                 end
  850.  
  851.                             end
  852.  
  853.                             if animate == true then
  854.  
  855.                                 term.setBackgroundColor(colors.white)
  856.  
  857.                                 term.setTextColor(colors.black)
  858.  
  859.                                 term.setCursorPos(2, 6)
  860.  
  861.                                 if was_playing then
  862.  
  863.                                     term.write(" Stop ")
  864.  
  865.                                 else
  866.  
  867.                                     term.write(" Play ")
  868.  
  869.                                 end
  870.  
  871.                                 sleep(0.2)
  872.  
  873.                             end
  874.  
  875.                         end
  876.  
  877.                         if x >= 2 + 8 and x <= 2 + 8 + 6 then
  878.  
  879.                             local animate = false
  880.  
  881.                             if playing then
  882.  
  883.                                 for _, speakers in ipairs(speakers) do
  884.  
  885.                                 speakers.stop()
  886.  
  887.                                 end
  888.  
  889.                             end
  890.  
  891.                             if now_playing ~= nil or #queue > 0 then
  892.  
  893.                                 if #queue > 0 then
  894.  
  895.                                     now_playing = queue[1]
  896.  
  897.                                     table.remove(queue, 1)
  898.  
  899.                                     playing_id = nil
  900.  
  901.                                 else
  902.  
  903.                                     now_playing = nil
  904.  
  905.                                     playing = false
  906.  
  907.                                     playing_id = nil
  908.  
  909.                                 end
  910.  
  911.                                 animate = true
  912.  
  913.                             end
  914.  
  915.                             if animate == true then
  916.  
  917.                                 term.setBackgroundColor(colors.white)
  918.  
  919.                                 term.setTextColor(colors.black)
  920.  
  921.                                 term.setCursorPos(2 + 8, 6)
  922.  
  923.                                 term.write(" Skip ")
  924.  
  925.                                 sleep(0.2)
  926.  
  927.                             end
  928.  
  929.                         end
  930.  
  931.                         if x >= 2 + 8 + 8 and x <= 2 + 8 + 8 + 6 then
  932.  
  933.                             if looping then
  934.  
  935.                                 looping = false
  936.  
  937.                             else
  938.  
  939.                                 looping = true
  940.  
  941.                             end
  942.  
  943.                         end
  944.  
  945.                     end
  946.  
  947.                 end
  948.  
  949.  
  950.  
  951.                 -- search tab clicks
  952.  
  953.                 if tab == 2 and button == 1 then
  954.  
  955.                     -- search box click
  956.  
  957.                     if y >= 3 and y <= 5 and x >= 1 and x <= width-1 then
  958.  
  959.                         waiting_for_input = true
  960.  
  961.                     end
  962.  
  963.  
  964.  
  965.                     -- search result click
  966.  
  967.                     if search_results then
  968.  
  969.                         for i=1,#search_results do
  970.  
  971.                             if y == 7 + (i-1)*2 or y == 8 + (i-1)*2 then
  972.  
  973.                                 term.setBackgroundColor(colors.white)
  974.  
  975.                                 term.setTextColor(colors.black)
  976.  
  977.                                 term.setCursorPos(2,7 + (i-1)*2)
  978.  
  979.                                 term.clearLine()
  980.  
  981.                                 term.write(search_results[i].name)
  982.  
  983.                                 term.setTextColor(colors.gray)
  984.  
  985.                                 term.setCursorPos(2,8 + (i-1)*2)
  986.  
  987.                                 term.clearLine()
  988.  
  989.                                 term.write(search_results[i].artist)
  990.  
  991.                                 sleep(0.2)
  992.  
  993.                                 in_fullscreen = 1
  994.  
  995.                                 clicked_result = i
  996.  
  997.                             end
  998.  
  999.                         end
  1000.  
  1001.                     end
  1002.  
  1003.                 end
  1004.  
  1005.             end
  1006.  
  1007.  
  1008.  
  1009.             redrawScreen()
  1010.  
  1011.  
  1012.  
  1013.         end
  1014.  
  1015.  
  1016.  
  1017.         -- HTTP EVENTS
  1018.  
  1019.         if event == "http_success" then
  1020.  
  1021.             local url = param1
  1022.  
  1023.             local handle = param2
  1024.  
  1025.  
  1026.  
  1027.             if url == last_search_url then
  1028.  
  1029.                 search_results = textutils.unserialiseJSON(handle.readAll())
  1030.  
  1031.                 redrawScreen()
  1032.  
  1033.             end
  1034.  
  1035.             if url == last_download_url then
  1036.  
  1037.                 player_handle = handle
  1038.  
  1039.                 start = handle.read(4)
  1040.  
  1041.                 size = 16 * 1024 - 4
  1042.  
  1043.                 if start == "RIFF" then
  1044.  
  1045.                     error("WAV not supported!")
  1046.  
  1047.                 end
  1048.  
  1049.                 playing_status = 1
  1050.  
  1051.                 decoder = require "cc.audio.dfpwm".make_decoder()
  1052.  
  1053.             end
  1054.  
  1055.         end
  1056.  
  1057.  
  1058.  
  1059.         if event == "http_failure" then
  1060.  
  1061.             local url = param1
  1062.  
  1063.  
  1064.  
  1065.             if url == last_search_url then
  1066.  
  1067.                 search_error = true
  1068.  
  1069.                 redrawScreen()
  1070.  
  1071.             end
  1072.  
  1073.             if url == last_download_url then
  1074.  
  1075.                 if #queue > 0 then
  1076.  
  1077.                     now_playing = queue[1]
  1078.  
  1079.                     table.remove(queue, 1)
  1080.  
  1081.                     playing_id = nil
  1082.  
  1083.                 else
  1084.  
  1085.                     now_playing = nil
  1086.  
  1087.                     playing = false
  1088.  
  1089.                     playing_id = nil
  1090.  
  1091.                 end
  1092.  
  1093.                 redrawScreen()
  1094.  
  1095.             end
  1096.  
  1097.         end
  1098.  
  1099.  
  1100.  
  1101.         if event == "timer" then
  1102.  
  1103.             os.startTimer(1)
  1104.  
  1105.         end
  1106.  
  1107.  
  1108.  
  1109.         if event == "speakers_audio_empty" then
  1110.  
  1111.             for _, speaker in ipairs(speakers) do
  1112.  
  1113.             if needs_next_chunk == 2 then
  1114.  
  1115.                 needs_next_chunk = 3
  1116.  
  1117.             end
  1118.  
  1119.         end
  1120.  
  1121.     end
  1122.  
  1123.     end
  1124.  
  1125.  
  1126.  
  1127.     sleep(0.1)
  1128.  
  1129. end
  1130.  
  1131.  
  1132.  
  1133. parallel.waitForAny(mainLoop, searchInput)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement