Advertisement
TechManDylan

WavePlayer

Feb 24th, 2023 (edited)
813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. function listWavFilesOnMonitor()
  2.   local files = fs.list(".")
  3.   local monitor = peripheral.find("monitor")
  4.   if monitor then
  5.     monitor.clear()
  6.     for i, file in ipairs(files) do
  7.       if fs.isDir(file) then
  8.         -- skip directories
  9.       elseif string.sub(file, -4) == ".wav" then
  10.         monitor.setCursorPos(1, i)
  11.         monitor.write(file)
  12.         local y = i
  13.         monitor.setCursorPos(1, y)
  14.         monitor.setTextColour(colours.blue)
  15.         monitor.setCursorBlink(false)
  16.         while true do
  17.           local event, side, x, y = os.pullEvent("monitor_touch")
  18.           if y == monitor.getY() + y - 1 then
  19.             print(file)
  20.             break
  21.           end
  22.         end
  23.         monitor.setTextColour(colours.white)
  24.         monitor.setCursorBlink(true)
  25.       end
  26.     end
  27.   end
  28. end
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement