Out-Feu

jukebox.lua

Apr 25th, 2024 (edited)
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 35.43 KB | Gaming | 0 0
  1. --[[
  2.  
  3. Jukebox program
  4. By The Juice
  5. Edited by Out-Feu
  6.  
  7. version 1.5.2
  8.  
  9. Free to distribute/alter
  10. so long as proper credit to original
  11. author is maintained.
  12.  
  13. Simply connect some drives with music discs
  14. and an advanced monitor (at least two blocks wide)
  15. in any way and start this program
  16.  
  17. The monitor must be at least 2 blocks high
  18. to access the basic preferences
  19. or 3 blocks high to access the advanced preferences
  20.  
  21. --]]
  22.  
  23. function loadJukebox()
  24.  per = peripheral.getNames()
  25.  drives = {}
  26.  for k,v in pairs(per) do
  27.   if peripheral.getType(v) == "drive" then
  28.    if peripheral.wrap(v).hasAudio() then
  29.     if lengths[getAudioTitle(peripheral.wrap(v))] ~= nil then
  30.      drives[#drives+1] = peripheral.wrap(v)
  31.     else
  32.      term.setTextColor(colors.red)
  33.      print("Track not found '" .. getAudioTitle(peripheral.wrap(v)) .. "'")
  34.      term.setTextColor(colors.white)
  35.     end
  36.    elseif peripheral.wrap(v).isDiskPresent() then
  37.     term.setTextColor(colors.red)
  38.     print("A disk drive contains an invalid item")
  39.     term.setTextColor(colors.white)
  40.    end
  41.   elseif peripheral.getType(v) == "monitor" then
  42.    mon = peripheral.wrap(v)
  43.    mon.setTextScale(textScale)
  44.   end
  45.  end
  46.  per = nil
  47.  table.sort(drives, sortDriveByTitle)
  48.  duplicateDrives = {}
  49.  duplicateCount = 0
  50.  if playDuplicate then
  51.   for i=#drives,2,-1 do
  52.    if getAudioTitle(drives[i]) == getAudioTitle(drives[i-1]) then
  53.     if duplicateDrives[getAudioTitle(drives[i])] == nil then
  54.      duplicateDrives[getAudioTitle(drives[i])] = {}
  55.      duplicateCount = duplicateCount + 1
  56.     end
  57.     duplicateDrives[getAudioTitle(drives[i])][#duplicateDrives[getAudioTitle(drives[i])]+1] = drives[i]
  58.     table.remove(drives, i)
  59.    end
  60.   end
  61.  end
  62.  disks = {}
  63.  for k,v in pairs(drives) do
  64.   disks[k] = getAudioTitle(drives[k])
  65.  end
  66.  print("Loaded " .. table.getn(disks) .. " tracks")
  67.  if playDuplicate and duplicateCount > 0 then
  68.   print(duplicateCount .. " of those tracks have duplicates")
  69.  end
  70. end
  71.  
  72. function loadPref(reloading)
  73.  if not fs.exists(configFile) then
  74.   setColors.text = colors.white
  75.   setColors.background = colors.black
  76.   setColors.skip = colors.blue
  77.   setColors.enabled = colors.green
  78.   setColors.disabled = colors.red
  79.   setColors.selected = colors.green
  80.   setColors.progress1 = colors.lightBlue
  81.   setColors.progress2 = colors.cyan
  82.   setColors.progress3 = colors.blue
  83.   setColors.duplicateText = colors.yellow
  84.   setColors.prefBack = colors.blue
  85.   setColors.prefText = colors.white
  86.  
  87.  else
  88.   local fil = fs.open(configFile,"r")
  89.  
  90.   setColors.text = tonumber(fil.readLine())
  91.   setColors.background = tonumber(fil.readLine())
  92.   setColors.skip = tonumber(fil.readLine())
  93.   setColors.enabled = tonumber(fil.readLine())
  94.   setColors.disabled = tonumber(fil.readLine())
  95.   setColors.selected = tonumber(fil.readLine())
  96.   setColors.progress1 = tonumber(fil.readLine())
  97.   setColors.progress2 = tonumber(fil.readLine())
  98.   setColors.progress3 = tonumber(fil.readLine())
  99.   setColors.duplicateText = tonumber(fil.readLine())
  100.   setColors.prefBack = tonumber(fil.readLine())
  101.   setColors.prefText = tonumber(fil.readLine())
  102.  
  103.   playingDefault = fil.readLine() == "true"
  104.   shuffleDefault = fil.readLine() == "true"
  105.   loopDefault = fil.readLine() == "true"
  106.   playDuplicate = fil.readLine() ~= "false"
  107.   fullProgressLine = fil.readLine() == "true"
  108.   if not reloading then
  109.    playing = playingDefault
  110.    shuffle = shuffleDefault
  111.    loop = loopDefault
  112.   end
  113.  
  114.   fil.close()
  115.  end
  116. end
  117.  
  118. function savePref()
  119.  fil=fs.open(configFile,"w")
  120.  fil.writeLine(setColors.text)
  121.  fil.writeLine(setColors.background)
  122.  fil.writeLine(setColors.skip)
  123.  fil.writeLine(setColors.enabled)
  124.  fil.writeLine(setColors.disabled)
  125.  fil.writeLine(setColors.selected)
  126.  fil.writeLine(setColors.progress1)
  127.  fil.writeLine(setColors.progress2)
  128.  fil.writeLine(setColors.progress3)
  129.  fil.writeLine(setColors.duplicateText)
  130.  fil.writeLine(setColors.prefBack)
  131.  fil.writeLine(setColors.prefText)
  132.  
  133.  fil.writeLine(playingDefault)
  134.  fil.writeLine(shuffleDefault)
  135.  fil.writeLine(loopDefault)
  136.  fil.writeLine(playDuplicate)
  137.  fil.writeLine(fullProgressLine)
  138.  
  139.  fil.close()
  140. end
  141.  
  142. function changePref()
  143.  while true do
  144.   w, h = mon.getSize()
  145.   showColor = h >= minColorSize and w >= minColorSize
  146.  
  147.   mon.setBackgroundColor(colors.black)
  148.   mon.setTextColor(colors.white)
  149.   mon.clear()
  150.  
  151.   mon.setCursorPos(1,1)
  152.   mon.write("Preferences")
  153.  
  154.   if showColor then
  155.    mon.setCursorPos(1,3)
  156.    mon.write("Edit colors")
  157.   end
  158.  
  159.   writePref(4, "Play by default", playingDefault)
  160.   writePref(5, "Shuffle by default", shuffleDefault)
  161.   writePref(6, "Loop by default", loopDefault)
  162.   writePref(14, "Handle duplicates", playDuplicate)
  163.   writePref(15, "Full progress bar", fullProgressLine)
  164.   writePref(17, "Cacophony", playing)
  165.  
  166.   mon.setBackgroundColor(colors.blue)
  167.   mon.setCursorPos(1, 8)
  168.   mon.write("Reload Jukebox")
  169.  
  170.   mon.setBackgroundColor(colors.black)
  171.  
  172.   mon.setCursorPos(1, 10)
  173.   mon.write("Save")
  174.  
  175.   mon.setCursorPos(1, 11)
  176.   mon.write("Load")
  177.  
  178.   mon.setCursorPos(1, 12)
  179.   mon.write("Back")
  180.  
  181.   mon.setCursorPos(1, 19)
  182.   mon.write("Close jukebox")
  183.  
  184.   local eve,id,cx,cy
  185.   eve,id,cx,cy=os.pullEvent("monitor_touch")
  186.  
  187.   if showColor and cy==3 then
  188.    changeColors()
  189.   elseif cy==4 then
  190.    playingDefault = not playingDefault
  191.   elseif cy==5 then
  192.    shuffleDefault = not shuffleDefault
  193.   elseif cy==6 then
  194.   loopDefault = not loopDefault
  195.   elseif cy==8 then
  196.    loadJukebox()
  197.   elseif cy==10 then
  198.    savePref()
  199.   elseif cy==11 then
  200.    loadPref(true)
  201.   elseif cy==12 then
  202.    stop()
  203.    return false
  204.   elseif cy==14 then
  205.    playDuplicate = not playDuplicate
  206.    loadJukebox()
  207.   elseif cy==15 then
  208.    fullProgressLine = not fullProgressLine
  209.   elseif cy==17 then
  210.    if playing then
  211.     stop()
  212.    else
  213.     playAll()
  214.    end
  215.   elseif cy==19 then
  216.    stop()
  217.    return true
  218.   end
  219.  
  220.  end
  221. end
  222.  
  223. function writePref(pos, name, active)
  224.   mon.setCursorPos(1, pos)
  225.   if active then
  226.    mon.setBackgroundColor(colors.green)
  227.   else
  228.    mon.setBackgroundColor(colors.red)
  229.   end
  230.   mon.write(name)
  231. end
  232.  
  233. function changeColors()
  234.  while true do
  235.   mon.setBackgroundColor(colors.black)
  236.   mon.clear()
  237.  
  238.   mon.setCursorPos(1,1)
  239.   mon.setTextColor(colors.white)
  240.   mon.write("Colors")
  241.  
  242.   writeColor(3, "Text", setColors.text, false)
  243.   writeColor(4, "Background", setColors.background, true)
  244.   writeColor(5, "Skip buttons", setColors.skip, true)
  245.   writeColor(6, "Enabled", setColors.enabled, true)
  246.   writeColor(7, "Disabled", setColors.disabled, true)
  247.   writeColor(8, "Selected track", setColors.selected, true)
  248.   writeColor(9, "Progress 1", setColors.progress1, true)
  249.   writeColor(10, "Progress 2", setColors.progress2, true)
  250.   writeColor(11, "Progress 3", setColors.progress3, true)
  251.   writeColor(12, "Duplicate track text", setColors.duplicateText, false)
  252.   writeColor(13, "p button background", setColors.prefBack, true)
  253.   writeColor(14, "p button text", setColors.prefText, false)
  254.  
  255.   mon.setCursorPos(1,16)
  256.   mon.setBackgroundColor(colors.black)
  257.   mon.setTextColor(colors.white)
  258.   mon.write("Back")
  259.  
  260.   local eve,id,cx,cy
  261.   eve,id,cx,cy=os.pullEvent("monitor_touch")
  262.  
  263.   if cy >= 3 and cy <= 14 then
  264.    mon.setCursorPos(1,cy)
  265.    mon.write(">")
  266.   end
  267.   if cy == 3 then
  268.    setColors.text = colorPicker(setColors.text)
  269.   elseif cy == 4 then
  270.    setColors.background = colorPicker(setColors.background)
  271.   elseif cy == 5 then
  272.    setColors.skip = colorPicker(setColors.skip)
  273.   elseif cy == 6 then
  274.    setColors.enabled = colorPicker(setColors.enabled)
  275.   elseif cy == 7 then
  276.    setColors.disabled = colorPicker(setColors.disabled)
  277.   elseif cy == 8 then
  278.    setColors.selected = colorPicker(setColors.selected)
  279.   elseif cy == 9 then
  280.    setColors.progress1 = colorPicker(setColors.progress1)
  281.   elseif cy == 10 then
  282.    setColors.progress2 = colorPicker(setColors.progress2)
  283.   elseif cy == 11 then
  284.    setColors.progress3 = colorPicker(setColors.progress3)
  285.   elseif cy == 12 then
  286.    setColors.duplicateText = colorPicker(setColors.duplicateText)
  287.   elseif cy == 13 then
  288.    setColors.prefBack = colorPicker(setColors.prefBack)
  289.   elseif cy == 14 then
  290.    setColors.prefText = colorPicker(setColors.prefText)
  291.   elseif cy == 16 then
  292.    return
  293.   end
  294.  
  295.  end
  296. end
  297.  
  298. function writeColor(pos, name, color, background)
  299.  mon.setCursorPos(1,pos)
  300.  mon.setBackgroundColor(colors.black)
  301.  mon.setTextColor(colors.white)
  302.  mon.write("-")
  303.  if background then
  304.   mon.setBackgroundColor(color)
  305.   if color == colors.white then
  306.    mon.setTextColor(colors.black)
  307.   end
  308.  else
  309.   mon.setTextColor(color)
  310.   if color == colors.black then
  311.    mon.setBackgroundColor(colors.white)
  312.   end
  313.  end
  314.  mon.write(name)
  315. end
  316.  
  317. function colorPicker(defaultColor)
  318.  mon.setCursorPos(15,1)
  319.  mon.setBackgroundColor(colors.white)
  320.  mon.write(" ")
  321.  mon.setBackgroundColor(colors.lightGray)
  322.  mon.write(" ")
  323.  mon.setBackgroundColor(colors.gray)
  324.  mon.write(" ")
  325.  mon.setBackgroundColor(colors.black)
  326.  mon.write(" ")
  327.  
  328.  mon.setCursorPos(15,2)
  329.  mon.setBackgroundColor(colors.blue)
  330.  mon.write(" ")
  331.  mon.setBackgroundColor(colors.cyan)
  332.  mon.write(" ")
  333.  mon.setBackgroundColor(colors.lightBlue)
  334.  mon.write(" ")
  335.  mon.setBackgroundColor(colors.brown)
  336.  mon.write(" ")
  337.  
  338.  mon.setCursorPos(15,3)
  339.  mon.setBackgroundColor(colors.green)
  340.  mon.write(" ")
  341.  mon.setBackgroundColor(colors.lime)
  342.  mon.write(" ")
  343.  mon.setBackgroundColor(colors.orange)
  344.  mon.write(" ")
  345.  mon.setBackgroundColor(colors.yellow)
  346.  mon.write(" ")
  347.  
  348.  mon.setCursorPos(15,4)
  349.  mon.setBackgroundColor(colors.red)
  350.  mon.write(" ")
  351.  mon.setBackgroundColor(colors.purple)
  352.  mon.write(" ")
  353.  mon.setBackgroundColor(colors.magenta)
  354.  mon.write(" ")
  355.  mon.setBackgroundColor(colors.pink)
  356.  mon.write(" ")
  357.  
  358.  mon.setCursorPos(15,5)
  359.  mon.setBackgroundColor(defaultColor)
  360.  if defaultColor == colors.white then
  361.   mon.setTextColor(colors.black)
  362.  else
  363.  mon.setTextColor(colors.white)
  364.  end
  365.  mon.write("Keep")
  366.  
  367.  local eve,id,cx,cy
  368.  repeat
  369.   eve,id,cx,cy=os.pullEvent("monitor_touch")
  370.  until cx >= 15 and cy <= 5 and cx <= 18 and cy >= 1
  371.  cx=cx-14
  372.  
  373.  if cx == 1 and cy == 1 then
  374.   return colors.white
  375.  elseif cx == 2 and cy == 1 then
  376.   return colors.lightGray
  377.  elseif cx == 3 and cy == 1 then
  378.   return colors.gray
  379.  elseif cx == 4 and cy == 1 then
  380.   return colors.black
  381.  elseif cx == 1 and cy == 2 then
  382.   return colors.blue
  383.  elseif cx == 2 and cy == 2 then
  384.   return colors.cyan
  385.  elseif cx == 3 and cy == 2 then
  386.   return colors.lightBlue
  387.  elseif cx == 4 and cy == 2 then
  388.   return colors.brown
  389.  elseif cx == 1 and cy == 3 then
  390.   return colors.green
  391.  elseif cx == 2 and cy == 3 then
  392.   return colors.lime
  393.  elseif cx == 3 and cy == 3 then
  394.   return colors.orange
  395.  elseif cx == 4 and cy == 3 then
  396.   return colors.yellow
  397.  elseif cx == 1 and cy == 4 then
  398.   return colors.red
  399.  elseif cx == 2 and cy == 4 then
  400.   return colors.purple
  401.  elseif cx == 3 and cy == 4 then
  402.   return colors.magenta
  403.  elseif cx == 4 and cy == 4 then
  404.   return colors.pink
  405.  elseif cy == 5 then
  406.   return defaultColor
  407.  end
  408. end
  409.  
  410. function restart() --restarts playback (more useful than it sounds)
  411.  stop()
  412.  play()
  413. end
  414.  
  415. function stop() --stops playback
  416.  playing=false
  417.  os.cancelTimer(timer)
  418.  os.cancelTimer(tickTimer)
  419.  elapsed=0
  420.  disk.stopAudio()
  421. end
  422.  
  423. function playAll() --starts all discs
  424.  playing = true
  425.  for k,v in pairs(drives) do
  426.   v.playAudio()
  427.  end
  428.  for k,duplicates in pairs(duplicateDrives) do
  429.   for k,v in pairs(duplicates) do
  430.    v.playAudio()
  431.   end
  432.  end
  433. end
  434.  
  435. function play() --starts playback
  436.  playing=true
  437.  timer=os.startTimer(lengths[disks[track]])
  438.  tickTimer=os.startTimer(0.25)
  439.  drives[track].playAudio()
  440.  if playDuplicate and duplicateDrives[getAudioTitle(drives[track])] ~= nil then
  441.   for k,v in pairs(duplicateDrives[getAudioTitle(drives[track])]) do
  442.    v.playAudio()
  443.   end
  444.  end
  445. end
  446.  
  447. function skip(playNext) --skips to the next track
  448.  if not loop and #disks>1 then
  449.   if shuffle then
  450.    local rd
  451.    repeat
  452.     rd=math.random(#drives)
  453.    until rd~=track
  454.    track=rd
  455.   else
  456.    track=track+1
  457.    if track>#disks then
  458.     track=1
  459.    end
  460.   end
  461.   updateDisplayStart()
  462.  end
  463.  if playNext then
  464.   restart() --see?
  465.  end
  466. end
  467.  
  468. function back() --goes back to the previous track
  469.  if not loop then
  470.   track=track-1
  471.   if track<1 then
  472.    track=#disks
  473.   end
  474.   updateDisplayStart()
  475.  end
  476.  restart()
  477. end
  478.  
  479. function skipto(tr) --skips to a particular track according to 'tr'
  480.  if tr==track then
  481.   return
  482.  end
  483.  track=tr
  484.  if track>#disks or track<1 then
  485.   return
  486.  end
  487.  restart()
  488. end
  489.  
  490. function updateDisplayStart()
  491.  if tooManyDisks then
  492.   if track-1 < displayStart then
  493.    displayStart = track-1
  494.   elseif track > displayStart+(h-2) then
  495.    displayStart = track-(h-2)
  496.   end
  497.  end
  498. end
  499.  
  500. function sortDriveByTitle(dr1, dr2)
  501.  return getAudioTitle(dr1) < getAudioTitle(dr2)
  502. end
  503.  
  504. function getAudioTitle(drive)
  505.  name = drive.getAudioTitle()
  506.  if names[name] ~= nil then
  507.   return names[name]
  508.  end
  509.  return name
  510. end
  511.  
  512. -------------------------------------------------------------------------------
  513.  
  514. disk.stopAudio() --stop all currently playing disks
  515.  
  516. lengths={} --length of all the disks in seconds
  517. -- Vanilla discs --
  518. lengths["C418 - 13"]=180
  519. lengths["C418 - cat"]=187
  520. lengths["C418 - blocks"]=347
  521. lengths["C418 - chirp"]=187
  522. lengths["C418 - far"]=176
  523. lengths["C418 - mall"]=199
  524. lengths["C418 - mellohi"]=98
  525. lengths["C418 - stal"]=152
  526. lengths["C418 - strad"]=190
  527. lengths["C418 - ward"]=253
  528. lengths["C418 - 11"]=73
  529. lengths["C418 - wait"]=240
  530. lengths["Lena Raine - Pigstep"]=150
  531. lengths["Lena Raine - otherside"]=197
  532. lengths["Samuel Åberg - 5"]=180
  533. lengths["Aaron Cherof - Relic"]=220
  534. lengths["Aaron Cherof - Precipice"]=300
  535. lengths["Lena Raine - Creator"]=178
  536. lengths["Lena Raine - Creator (Music Box)"]=75
  537. -- Modded discs --
  538. lengths["MissLilitu - Over the Rainbow"]=214 --[Let's Do] Beachparty
  539. lengths["adoghr - 0308"]=122 --Additional Additions
  540. lengths["adoghr - 1007"]=162 --Additional Additions
  541. lengths["adoghr - 1507"]=214 --Additional Additions
  542. lengths["AetherAudio - Aerwhale"]=178 --Aether II
  543. lengths["Moorziey - Demise"]=300 --Aether II
  544. lengths["Emile van Krieken - Approaches"]=275 --Aether II
  545. lengths["Emile van Krieken - ???"]=98 --Aether II
  546. lengths["Lachney - Legacy"]=296 --Aether: Lost Content
  547. lengths["Jesterguy - Sovereign of the Skies"]=221 --The Aether: Lost Content
  548. lengths["Ninni - Fusion"]=238 --Alex's Caves
  549. lengths["LudoCrypt - Thime"]=315 --Alex's Mobs
  550. lengths["LudoCrypt - Daze"]=193 --Alex's Mobs
  551. lengths["Bertsz - Horizon"]=72 --Aquamirae
  552. lengths["Krossy - Forsaken Drownage"]=154 --Aquamirae
  553. lengths["Firel - Aria Biblio"]=252 --Ars Nouveau
  554. lengths["Thistle - The Sound of Glass"]=184 --Ars Nouveau
  555. lengths["Firel - The Wild Hunt"]=120 --Ars Nouveau
  556. lengths["Mista Jub - Fox"]=118 --Berry Good
  557. lengths["RENREN - Fox"]=118 --Berry Good
  558. lengths["Firel - Strange And Alien"]=266 --BetterEnd Forge
  559. lengths["Firel - Grasping At Stars"]=528 --BetterEnd Forge
  560. lengths["Firel - Endseeker"]=462 --BetterEnd Forge
  561. lengths["Firel - Eo Dracona"]=360 --BetterEnd Forge
  562. lengths["Podington Bear - Button Mushrooms"]=110 --Biome Makeover
  563. lengths["Lobo Loco - Ghost Town"]=270 --Biome Makeover
  564. lengths["Isaac Chambers - Swamp Jives"]=267 --Biome Makeover
  565. lengths["Damiano Baldoni - Red Rose"]=138 --Biome Makeover
  566. lengths["Tim Rurkowski - Wanderer"]=179 --Biomes O' Plenty
  567. lengths["???"]=190 --Biomes O' Plenty
  568. lengths["Bleeding Edge of the Hidden Realm"]=215 --Blood Magic
  569. lengths["Jonathing - Blinding Rage"]=232 --Blue Skies
  570. lengths["Jonathing - Defying Starlight"]=148 --Blue Skies
  571. lengths["Jonathing - Venomous Encounter"]=155 --Blue Skies
  572. lengths["Lachney - Population"]=238 --Blue Skies
  573. lengths["Kain Vinosec - Endure Emptiness"]=204 --Botania
  574. lengths["Kain Vinosec - Fight For Quiescence"]=229 --Botania
  575. lengths["izofar - Wither Waltz"]=254 --Bygone Nether
  576. lengths["Cinematic Danger Background Music | No Copyright"]=170 --Cataclysm Mod
  577. lengths["??Symphony - God of Blaze"]=128 --Cataclysm Mod
  578. lengths["??Symphony - vs Titans"]=148 --Cataclysm Mod
  579. lengths["??Symphony - Endless Storm"]=143 --Cataclysm Mod
  580. lengths["Ean Grimm - Eternal"]=148 --Cataclysm Mod
  581. lengths["Sinyells - Monster Fight"]=184 --Cataclysm Mod
  582. lengths["Hippo0824 - Sands of Dominion"]=144 --Cataclysm Mod
  583. lengths["C418 - Minecraft"]=234 --Charm
  584. lengths["C418 - Clark"]=192 --Charm
  585. lengths["C418 - Sweden"]=216 --Charm
  586. lengths["C418 - Subwoofer Lullaby"]=209 --Charm
  587. lengths["C418 - Haggstrom"]=204 --Charm
  588. lengths["C418 - Danny"]=255 --Charm
  589. lengths["C418 - Key"]=65 --Charm
  590. lengths["C418 - Oxygène"]=65 --Charm
  591. lengths["C418 - Dry Hands"]=69 --Charm
  592. lengths["C418 - Wet Hands"]=90 --Charm
  593. lengths["C418 - Biome Fest"]=378 --Charm
  594. lengths["C418 - Blind Spots"]=333 --Charm
  595. lengths["C418 - Haunt Muskie"]=362 --Charm
  596. lengths["C418 - Aria Math"]=310 --Charm
  597. lengths["C418 - Dreiton"]=497 --Charm
  598. lengths["C418 - Taswell"]=516 --Charm
  599. lengths["C418 - Concrete Halls"]=234 --Charm
  600. lengths["C418 - Dead Voxel"]=296 --Charm
  601. lengths["C418 - Warmth"]=239 --Charm
  602. lengths["C418 - Ballad of the Cats"]=276 --Charm
  603. lengths["C418 - Mutation"]=185 --Charm
  604. lengths["C418 - Moog City 2"]=180 --Charm
  605. lengths["C418 - Beginning 2"]=176 --Charm
  606. lengths["C418 - Floating Trees"]=245 --Charm
  607. lengths["C418 - Axolotl"]=303 --Charm
  608. lengths["C418 - Dragon Fish"]=372 --Charm
  609. lengths["C418 - Shuniji"]=244 --Charm
  610. lengths["C418 - Boss"]=346 --Charm
  611. lengths["C418 - The End"]=905 --Charm
  612. lengths["C418 - Mice on Venus"]=282 --Charm --Rats
  613. lengths["C418 - Living Mice"]=178 --Charm --Rats
  614. lengths["LudoCrypt - Luminous Plantation"]=231 --Cinderscapes
  615. lengths["Etorna_Z - Chilling In Hell"]=136 --Cinderscapes
  616. lengths["Shroomy - Drift"]=146 --Cloud Storage
  617. lengths["Dance with Golems -Flan"]=360 --Craft and hunt
  618. lengths["Kevin MacLeod - Casa Bossa Nova"]=188 --Create: Connected
  619. lengths["Kevin MacLeod - Local Forecast - Elevator"]=188 --Create: Connected
  620. lengths["RedWolf - The Bright Side"]=160 --Create Confectionery
  621. lengths["Emile van Krieken - A Morning Wish"]=282--Deep Aether
  622. lengths["Emile van Krieken - Nabooru"]=364 --Deep Aether
  623. lengths["RaltsMC - Ashes"]=94 --Desolation
  624. lengths["Ashes"]=94 --Desolation (Forge)
  625. lengths["F. Chopin - Valse Du Petit Chien (DashieDev)"]=132 --Doggy Talents Next
  626. lengths["J.S. Bach - Art Of Fugue: Contrapunctus XI (Kimiko Ishizaka)"]=288 --Doggy Talents Next
  627. lengths["J.S. Bach - WTC I: Fugue in C# Minor (Kimiko Ishizaka)"]=156 --Doggy Talents Next
  628. lengths["Okami - \"Ryoshima Coast\" (Arr. DashieDev for Organ)"]=110 --Doggy Talents Next
  629. lengths["BooWho - coconut"]=110 --Ecologics
  630. lengths["Kitsune² - Parousia"]=185 --Eidolon
  631. lengths["Ultrasyd - 7F Patterns"]=222 --Embers Rekindled
  632. lengths["_humanoid - sprog"]=86 --Enlightend
  633. lengths["hatsondogs - Leaving Home"]=155 --Environmental
  634. lengths["Mista Jub - Slabrave"]=112 --Environmental
  635. lengths["RENREN - Slabrave"]=112 --Environmental
  636. lengths["Swordland"]=195 --ExtraBotany
  637. lengths["Salvation"]=48 --ExtraBotany
  638. lengths["Mr. Esuoh - Crashing Tides"]=176 --Fins and Tails
  639. lengths["qwertygiy - Banjolic"]=111 --Hardcore Ender Expension
  640. lengths["qwertygiy - In The End"]=224 --Hardcore Ender Expension
  641. lengths["qwertygiy - Asteroid"]=60 --Hardcore Ender Expension
  642. lengths["qwertygiy - Stewed"]=90 --Hardcore Ender Expension
  643. lengths["qwertygiy - Beat The Dragon"]=118 --Hardcore Ender Expension
  644. lengths["qwertygiy - Granite"]=130 --Hardcore Ender Expension
  645. lengths["qwertygiy - Remember This"]=87 --Hardcore Ender Expension
  646. lengths["qwertygiy - Spyder"]=135 --Hardcore Ender Expension
  647. lengths["qwertygiy - Onion"]=210 --Hardcore Ender Expension
  648. lengths["qwertygiy - Crying Soul"]=122 --Hardcore Ender Expension
  649. lengths["Lorian Ross - Kobblestone"]=184 --Kobolds
  650. lengths["Duped Shovels"]=642 --Incubus Core
  651. lengths["Llama Song"]=92 --Industrial Agriculture
  652. lengths["LudoCrypt - flush"]=262 --Infernal Expansion
  653. lengths["LudoCrypt - Soul Spunk"]=234 --Infernal Expansion
  654. lengths["Cama - Slither"]=122 --Integrated Dungeons and Structures
  655. lengths["Cama - calidum"]=196 --Integrated Dungeons and Structures
  656. lengths["Cama - Forlorn"]=144 --Integrated Stronghold
  657. lengths["Cama - sight"]=160 --Integrated Stronghold
  658. lengths["izofar - Bastille Blues"]=200 --It Takes a Pillage
  659. lengths["CF28 - Mournful Abyss"]=289 --Iter RPG
  660. lengths["Construct Dance Mix"]=164 --Mana and Artifice
  661. lengths["Endigo - Big Chungus (Official Main Theme)"]=111 --Marium's Soulslike Weaponry
  662. lengths["BoxCat Games - Trace Route"]=35 --MatterOverdrive
  663. lengths["Monkey Warhol - Magnum"]=90 --Meet Your Fight
  664. lengths["FireMuffin303 - Bouncyslime"]=134 --Muffin's Slime Golem
  665. lengths["LudoCrypt - Petiole"]=160 --Mowzie's Mobs
  666. lengths["Ali Bak?r - soot"]=180 --Mythic Upgrades
  667. lengths["Ali Bak?r - appomattox"]=420 --Mythic Upgrades
  668. lengths["Ali Bak?r - fierce"]=129 --Mythic Upgrades
  669. lengths["Ali Bak?r - nelumbo"]=118 --Mythic Upgrades
  670. lengths["Ali Bak?r - flow of the abyss"]=126 --Mythic Upgrades
  671. lengths["Ali Bak?r - tanker on the levantine's"]=205 --Mythic Upgrades
  672. lengths["RENREN - Hullabaloo"]=135 --Neapolitan
  673. lengths["Dion - The Wanderer"]=167 --NuclearCraft
  674. lengths["Skeeter Davis - The End of the World"]=178 --NuclearCraft
  675. lengths["Dire Straits - Money For Nothing"]=315 --NuclearCraft
  676. lengths["Ur-Quan Master - Hyperspace"]=185 --NuclearCraft
  677. lengths["elgavira - bathysphere"]=127 --Odd Water Mobs
  678. lengths["baggu - coelacanth"]=114 --Odd Water Mobs
  679. lengths["baggu - seapig"]=121 --Odd Water Mobs
  680. lengths["Valve - Still Alive"]=180 --Portal Gun
  681. lengths["Valve - Radio Loop"]=22 --Portal Gun
  682. lengths["Valve - Want You Gone"]=140 --Portal Gun
  683. lengths["Orangery - Coniferus Forest (Main Menu Theme)"]=128 --Prominent
  684. lengths["Mouse.Avi Scream - Unkown Artist"]=9 --Pyrologer And Friends
  685. lengths["Water Droplets"]=20 --Quark
  686. lengths["Ocean Waves"]=16 --Quark
  687. lengths["Rainy Mood"]=5 --Quark
  688. lengths["Heavy Wind"]=13 --Quark
  689. lengths["Soothing Cinders"]=16 --Quark
  690. lengths["Tick-Tock"]=1 --Quark
  691. lengths["Cricket Song"]=1 --Quark
  692. lengths["Packed Venue"]=10 --Quark
  693. lengths["Kain Vinosec - Endermosh"]=190 --Quark
  694. lengths["Bearfan - Nourish"]=130 --Simple Farming
  695. lengths["Luz - Frosty Snig"]=186 --Snow Pig
  696. lengths["STiiX - A Carol"]=160 --Snowy Spirit
  697. lengths["Spectrum Theme"]=120 --Spectrum
  698. lengths["Deeper Down Theme: Radiarc - Irrelevance Fading"]=265 --Spectrum
  699. lengths["Proper Motions - Everreflective"]=288 --Spectrum
  700. lengths["LudoCrypt - scour"]=249 --Sully's Mod
  701. lengths["Partyp - Pancake Music"]=230 --Supplementaries
  702. lengths["FantomenK - Playing With Power"]=290 --Tetra Pak
  703. lengths["Emile van Krieken - Ascending Dawn"]=350 --The Aether --Aether II
  704. lengths["Noisestorm - Aether Tune"]=150 --The Aether
  705. lengths["Voyed - Welcoming Skies"]=217 --The Aether
  706. lengths["Jon Lachney - Legacy"]=296 --The Aether
  707. lengths["RENREN - chinchilla"]=164 --The Aether
  708. lengths["RENREN - high"]=141 --The Aether
  709. lengths["Emile van Krieken - Labyrinth's Vengeance"]=214 --The Aether: Redux
  710. lengths["Voog2 - Astatos"]=366 --The Betweenlands
  711. lengths["Voog2 - Between You And Me"]=300 --The Betweenlands
  712. lengths["Voog2 - Christmas On The Marsh"]=220 --The Betweenlands
  713. lengths["Voog2 - The Explorer"]=400 --The Betweenlands
  714. lengths["Voog2 - Hag Dance"]=280 --The Betweenlands
  715. lengths["Voog2 - Lonely Fire"]=228 --The Betweenlands
  716. lengths["..."]=65 --The Betweenlands
  717. lengths["Voog2 - Ancient"]=182 --The Betweenlands
  718. lengths["Voog2 - Beneath A Green Sky"]=310 --The Betweenlands
  719. lengths["Voog2 - Rave In A Cave"]=228 --The Betweenlands
  720. lengths["Voog2 - Onwards"]=212 --The Betweenlands
  721. lengths["Voog2 - Stuck In The Mud"]=278 --The Betweenlands
  722. lengths["Voog2 - Wandering Wisps"]=205 --The Betweenlands
  723. lengths["Voog2 - Waterlogged"]=196 --The Betweenlands
  724. lengths["Rotch Gwylt - Deep Water"]=155 --The Betweenlands
  725. lengths["Rimsky Korsakov - Flight of the Bumblebee"]=84 --The Bumblezone
  726. lengths["Rat Faced Boy - Honey Bee"]=216 --The Bumblezone
  727. lengths["LudoCrypt - Bee-laxing with the Hom-bees"]=300 --The Bumblezone
  728. lengths["LudoCrypt - La Bee-da Loca"]=176 --The Bumblezone
  729. lengths["LudoCrypt - Bee-ware of the Temple"]=371  --The Bumblezone
  730. lengths["RenRen - Knowing"]=252 --The Bumblezone
  731. lengths["RenRen - Radiance"]=106 --The Bumblezone
  732. lengths["RenRen - Life"]=86 --The Bumblezone
  733. lengths["Punpudle - A Last First Last"]=652 --The Bumblezone
  734. lengths["Jesterguy - Delve Deeper"]=230 --The Conjurer
  735. lengths["Mista Jub - Kilobyte"]=165 --The Endergetic Expansion
  736. lengths["\"Incarnated Evil\" by Rotch Gwylt"]=270 --The Graveyard
  737. lengths["Blue Duck - Galactic Wave"]=157 --The Outer End
  738. lengths["Pyrocide - Unknown Frontier"]=66 --The Outer End
  739. lengths["Rotch Gwylt - Radiance"]=135 --The Twilight Forest
  740. lengths["Rotch Gwylt - Steps"]=195 --The Twilight Forest
  741. lengths["Rotch Gwylt - Superstitious"]=192 --The Twilight Forest
  742. lengths["MrCompost - Home"]=217 --The Twilight Forest
  743. lengths["MrCompost - Wayfarer"]=175 --The Twilight Forest
  744. lengths["MrCompost - Findings"]=198 --The Twilight Forest
  745. lengths["MrCompost - Maker"]=209 --The Twilight Forest
  746. lengths["MrCompost - Thread"]=203 --The Twilight Forest
  747. lengths["MrCompost - Motion"]=171 --The Twilight Forest
  748. lengths["Screem - Mammoth"]=196 --The Undergarden
  749. lengths["Screem - Limax Maximus"]=163 --The Undergarden
  750. lengths["Screem - Relict"]=189 --The Undergarden
  751. lengths["Screem - Gloomper Anthem"]=206 --The Undergarden
  752. lengths["An AI was given an image of a Gloomper and made this song"]=160 --The Undergarden
  753. lengths["Lonesome Avenue (YouTube Audio Library)"]=185 --Tinker I/O
  754. lengths["Emile Van Krieken - The Tribe"]=154 --Tropicraft
  755. lengths["Punchaface - Buried Treasure"]=360 --Tropicraft
  756. lengths["Punchaface - Low Tide"]=342 --Tropicraft
  757. lengths["Frox - Trade Winds"]=240 --Tropicraft
  758. lengths["Frox - Eastern Isles"]=370 --Tropicraft
  759. lengths["Billy Christiansen - Summering"]=295 --Tropicraft
  760. lengths["Mili -  Iron Lotus"]=236 --Twilight Delight
  761. lengths["Parallel - ComaMedia"]=130 --Ulterlands
  762. lengths["Elderwind - Harumachi"]=195 --Ulterlands
  763. lengths["Requiem - BalanceBay"]=625 --Ulterlands
  764. lengths["RedWolf - Endstone Golem Theme"]=182 --Unusual End
  765. lengths["RedWolf - Flying Ships"]=197 --Unusual End
  766. lengths["hatsondogs - Atlantis"]=115 --Upgrade Aquatic
  767. lengths["C418 - dog"]=146 --Variant16x
  768. lengths["C418 - eleven"]=70 --Variant16x
  769. lengths["Bramble"]=122 --ViesCraft Machines
  770. lengths["Castle"]=106 --ViesCraft Machines
  771. lengths["Dire"]=186 --ViesCraft Machines
  772. lengths["Jungle"]=168 --ViesCraft Machines
  773. lengths["Storms"]=98 --ViesCraft Machines
  774. lengths["Timescar"]=145 --ViesCraft Machines
  775. lengths["rose - rain"]=123 --Windswept
  776. lengths["rose - snow"]=120 --Windswept
  777. lengths["rose - bumblebee"]=54 --Windswept
  778.  
  779. names={} --modded discs with incorrect item descriptions
  780.  
  781. names["item.record.ascending_dawn.desc"] = "Emile van Krieken - Ascending Dawn"
  782. names["item.record.aether_tune.desc"] = "Noisestorm - Aether Tune"
  783. names["item.record.astatos.desc"] = "Voog2 - Astatos"
  784. names["item.record.between_you_and_me.desc"] = "Voog2 - Between You And Me"
  785. names["item.record.christmas_on_the_marsh.desc"] = "Voog2 - Christmas On The Marsh"
  786. names["item.record.the_explorer.desc"] = "Voog2 - The Explorer"
  787. names["item.record.hag_dance.desc"] = "Voog2 - Hag Dance"
  788. names["item.record.lonely_fire.desc"] = "Voog2 - Lonely Fire"
  789. names["item.record.16612.desc"] = "..."
  790. names["item.record.record_wanderer.desc"] = "Dion - The Wanderer"
  791. names["item.record.record_end_of_the_world.desc"] = "Skeeter Davis - The End of the World"
  792. names["item.record.record_money_for_nothing.desc"] = "Dire Straits - Money For Nothing"
  793. names["item.record.record_hyperspace.desc"] = "Ur-Quan Master - Hyperspace"
  794. names["item.record.ancient.desc"] = "Voog2 - Ancient"
  795. names["item.record.beneath_a_green_sky.desc"] = "Voog2 - Beneath A Green Sky"
  796. names["item.record.dj_wights_mixtape.desc"] = "Voog2 - Rave In A Cave"
  797. names["item.record.onwards.desc"] = "Voog2 - Onwards"
  798. names["item.record.stuck_in_the_mud.desc"] = "Voog2 - Stuck In The Mud"
  799. names["item.record.wandering_wisps.desc"] = "Voog2 - Wandering Wisps"
  800. names["item.record.waterlogged.desc"] = "Voog2 - Waterlogged"
  801. names["item.record.matteroverdrive.transformation.desc"] = "BoxCat Games - Trace Route"
  802. names["item.blue_skies.blinding_rage.desc"] = "Jonathing - Blinding Rage"
  803. names["item.blue_skies.defying_starlight.desc"] = "Jonathing - Defying Starlight"
  804. names["item.blue_skies.venomous_encounter.desc"] = "Jonathing - Venomous Encounter"
  805. names["item.blue_skies.population.desc"] = "Lachney - Population"
  806. names["item.conjurer_illager.music_disc_delve_deeper.desc"] = "Jesterguy - Delve Deeper"
  807. names["item.lost_aether_content.music_disc_legacy.desc"] = "Lachney - Legacy"
  808. names["item.lost_aether_content.music_disc_sovereign_of_the_skies.desc"] = "Jesterguy - Sovereign of the Skies"
  809. names["item.tropicraft.music_disc_the_tribe.desc"] = "Emile Van Krieken - The Tribe"
  810. names["item.tropicraft.music_disc_buried_treasure.desc"] = "Punchaface - Buried Treasure"
  811. names["item.tropicraft.music_disc_low_tide.desc"] = "Punchaface - Low Tide"
  812. names["item.tropicraft.music_disc_trade_winds.desc"] = "Frox - Trade Winds"
  813. names["item.tropicraft.music_disc_eastern_isles.desc"] = "Frox - Eastern Isles"
  814. names["item.tropicraft.music_disc_summering.desc"] = "Billy Christiansen - Summering"
  815. names["block.supplementaries.pancake.desc"] = "Partyp - Pancake Music"
  816. names["duped_shovels.tradetf.exe.ogg"] = "Duped Shovels"
  817. names["AetherAudio - Aerwhale§r"] = "AetherAudio - Aerwhale"
  818. names["Moorziey - Demise§r"] = "Moorziey - Demise"
  819. names["Emile van Krieken - Approaches§r"] = "Emile van Krieken - Approaches"
  820. names["Emile van Krieken - Ascending Dawn§r"] = "Emile van Krieken - Ascending Dawn"
  821. names["Emile van Krieken - ???§r"] = "Emile van Krieken - ???"
  822. names["§5Firel§r - §fStrange And Alien§r"] = "Firel - Strange And Alien"
  823. names["§5Firel§r - §fGrasping At Stars§r"] = "Firel - Grasping At Stars"
  824. names["§5Firel§r - §fEndseeker§r"] = "Firel - Endseeker"
  825. names["§5Firel§r - §fEo Dracona§r"] = "Firel - Eo Dracona"
  826.  
  827. drives = {} --all the drives with audio wrapped in one variable. handy, right?
  828. disks = {} --the name of the disk in the drive in the same corresponding 'drives' drive
  829. duplicateDrives = {} --if 'playDuplicate' is set to true, store the drives with a track already inside 'drives'
  830. setColors={}
  831.  
  832. configFile = "jukebox.ini" --name of the config file
  833. playing=false --i'm not going to insult you by explaining this one
  834. shuffle=false --when true; selects a random track when track is over
  835. loop=false --when true; loop the current track
  836. playingDefault=false
  837. shuffleDefault=false
  838. loopDefault=false
  839. track=1 --selected track
  840. timer=0 --token of the timer that signals the end of a track
  841. elapsed=0 --time that track was started
  842. tickTimer=0 --token of the timer that signals to update 'elapsed'
  843. textScale=1 --scale of the text
  844. minSize=25 --width under which buttons labels are shorten
  845. minPrefSize=12 --height under which the preference button not shown
  846. minColorSize=16 --height and width under which the color button not shown
  847. displayStart=0 --track to start the display on
  848. tooManyDiscs=false  --set to true when the number of discs is greater than the height of the monitor
  849. playDuplicate=true --play all the duplicates of the same disc at the same time and show the track only once in the list
  850. fullProgressLine=false --use the full width of the monitor to display the current track progress instead of the width of the track name
  851.  
  852. loadPref(false)
  853. loadJukebox()
  854.  
  855. --------------------------------------------------------------------------------
  856.  
  857. if shuffle then
  858.  skip(false)
  859. end
  860. if playing then
  861.  play()
  862. end
  863.  
  864. repeat --main loop
  865.  
  866.  --refresh display
  867.  w, h = mon.getSize()
  868.  miniMode = w < minSize
  869.  showPref = h >= minPrefSize
  870.  tooManyDisks = h - 2 < #disks
  871.  
  872.  mon.setTextColor(setColors.text)
  873.  mon.setBackgroundColor(setColors.background) --clearing
  874.  mon.clear()
  875.  
  876.  mon.setCursorPos(1,1) --drawing back, play, skip, and suffle
  877.  mon.setBackgroundColor(setColors.skip)
  878.  mon.write("<-")
  879.  
  880.  mon.setCursorPos(6,1)
  881.  mon.setBackgroundColor(setColors.skip)
  882.  mon.write("->")
  883.  
  884.  mon.setCursorPos(4,1)
  885.  if playing then
  886.   mon.setBackgroundColor(setColors.enabled)
  887.  else
  888.   mon.setBackgroundColor(setColors.disabled)
  889.  end
  890.  mon.write(">")
  891.  
  892.  mon.setCursorPos(9,1)
  893.  if shuffle then
  894.   mon.setBackgroundColor(setColors.enabled)
  895.  else
  896.   mon.setBackgroundColor(setColors.disabled)
  897.  end
  898.  if miniMode then
  899.   mon.write("Sh")
  900.  else
  901.   mon.write("Shuffle")
  902.  end
  903.  
  904.  if loop then
  905.   mon.setBackgroundColor(setColors.enabled)
  906.  else
  907.   mon.setBackgroundColor(setColors.disabled)
  908.  end
  909.  if miniMode then
  910.  mon.setCursorPos(12,1)
  911.   mon.write("L")
  912.  else
  913.  mon.setCursorPos(17,1)
  914.   mon.write("Loop")
  915.  end
  916.  
  917.  for k,v in pairs(disks) do --drawing tracks
  918.   if k > displayStart then
  919.    mon.setCursorPos(1,k+2-displayStart)
  920.    if playDuplicate and duplicateDrives[v] ~= nil then
  921.     mon.setTextColor(setColors.duplicateText)
  922.    else
  923.     mon.setTextColor(setColors.text)
  924.    end
  925.    if k == track then
  926.     if fullProgressLine then
  927.      v = string.format("%-" .. w .. "s", v);
  928.     end
  929.     mon.setBackgroundColor(setColors.progress3)
  930.     local leng = math.min(string.len(v), w)
  931.     local blueLeng = (elapsed) / lengths[disks[track]] * leng
  932.     for n=1,leng do
  933.      if n > math.ceil(blueLeng) then
  934.       mon.setBackgroundColor(setColors.selected)
  935.      elseif n == math.ceil(blueLeng) then
  936.       if n - blueLeng < .3333 then
  937.        mon.setBackgroundColor(setColors.progress3)
  938.       elseif n - blueLeng < .6666 then
  939.        mon.setBackgroundColor(setColors.progress2)
  940.       else
  941.        mon.setBackgroundColor(setColors.progress1)
  942.       end
  943.      end
  944.      mon.write(string.sub(v,n,n))
  945.     end
  946.    else
  947.     mon.setBackgroundColor(setColors.background)
  948.     mon.write(v)
  949.    end
  950.   end
  951.  end
  952.  mon.setTextColor(setColors.text)
  953.  
  954.  if tooManyDisks then
  955.   mon.setCursorPos(w-4,1)
  956.   if displayStart > 0 then
  957.    mon.setBackgroundColor(setColors.skip)
  958.   else
  959.    mon.setBackgroundColor(setColors.background)
  960.   end
  961.   mon.write("^")
  962.  
  963.   mon.setCursorPos(w-2,1)
  964.   if displayStart < #disks - (h-2) then
  965.    mon.setBackgroundColor(setColors.skip)
  966.   else
  967.    mon.setBackgroundColor(setColors.background)
  968.   end
  969.   mon.write("v")
  970.  end
  971.  
  972.  if showPref then
  973.   mon.setCursorPos(w,1)
  974.   mon.setBackgroundColor(setColors.prefBack)
  975.   mon.setTextColor(setColors.prefText)
  976.   mon.write("p")
  977.  end
  978.  
  979.  --wait for event
  980.  local eve,id,cx,cy
  981.  repeat
  982.   eve,id,cx,cy=os.pullEvent()
  983.  until eve=="timer" or eve=="monitor_touch" or  eve=="monitor_resize"
  984.  
  985.  --test event
  986.  if eve=="timer" then --the timer ended
  987.   if id==timer then
  988.    skip(true)
  989.   elseif id==tickTimer then
  990.    tickTimer=os.startTimer(0.25)
  991.    elapsed=elapsed+0.25
  992.   end
  993.  
  994.  elseif eve=="monitor_touch" then --the monitor was pressed
  995.   if cy > 1 then --a track was pressed
  996.    if cy > 2 and cy < #disks + 3 then
  997.     if tooManyDisks then
  998.      skipto(cy - 2 + displayStart)
  999.     else
  1000.      skipto(cy - 2)
  1001.     end
  1002.    end
  1003.   elseif cx <= 2 then --back was pressed
  1004.    back()
  1005.   elseif cx == 4 then --stop/play was pressed
  1006.    if playing then
  1007.     stop()
  1008.    else
  1009.     play()
  1010.    end
  1011.   elseif cx == 6 or cx == 7 then --skip was pressed
  1012.    skip(true)
  1013.   elseif cx >= 9 and (not miniMode and cx <= 15 or miniMode and cx <= 10) then --shuffle was pressed
  1014.    shuffle = not shuffle
  1015.   elseif (not miniMode and cx >= 17 and cx <= 20) or (miniMode and cx == 12) then --loop was pressed
  1016.    loop = not loop
  1017.   elseif tooManyDisks and cx == w - 4 and displayStart > 0 then --up was pressed
  1018.    displayStart = displayStart - 1
  1019.   elseif tooManyDisks and cx == w - 2 and displayStart < #disks - (h - 2) then --down was pressed
  1020.    displayStart = displayStart + 1
  1021.   elseif showPref and cx == w then --preferences button was pressed
  1022.    stop()
  1023.    if changePref() then
  1024.     return
  1025.    end
  1026.   end
  1027.  end
  1028.  
  1029. until false
Add Comment
Please, Sign In to add comment