Advertisement
willwac

DJ Jocky - CCU2 Feature

Jan 4th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.56 KB | None | 0 0
  1. --[[
  2. DJ Jocky
  3. Made by: willwac (NewCoolPC) & Zambonie (PAT457)
  4. This is a simple DJ program that doesn't use turtles
  5. At CCU2, turtles cannot be accessed by students,
  6.  but we wanted a DJ system, so we made this!
  7.  
  8. To use:
  9. 1: Place down 12 disk drives, and network them to
  10.  the computer.
  11. 2: Edit the table below to match the drive numbers.
  12. 3: Edit the top bar text if you wish.
  13. 4: Save, and run DJ Jocky, make sure it works.
  14. 5: Rename DJ Jocky to "startup".
  15. 6: +1, comment, and suscribe to the forum thread
  16.  if you wish.
  17. 7: Talk about CCU2 if you wish.
  18. 8: Give us feedback, and please, please report bugs
  19. 9: After you've done the above, listen to some
  20.  great tunes!
  21. --]]
  22. local function menu()
  23. end
  24.   local tracks = {
  25.     --[[
  26.     Format:
  27.     ["SONG"] = {lengthInSeconds_num, "diskDriveNumber_string",yPos_num, orderIDLeaveAlone_num}
  28.     --]]
  29.     ["13"] = { 178, "11",3,1 },
  30.     ["cat"] = { 185, "12",4,2 },
  31.     ["blocks"] = { 13500, "13",5,3 },
  32.     ["chirp"] = { 185, "14",6,4 },
  33.     ["far"] = { 174, "15",7,5 },
  34.     ["mall"] = { 197, "16",8,6 },
  35.     ["mellohi"] = { 96, "22",9,7 },
  36.     ["stal"] = { 150, "21",10,8 },
  37.     ["strad"] = { 188, "17",11,9 },
  38.     ["ward"] = { 251, "18",12,10 },
  39.     ["11"] = { 71, "20",13,11 },
  40.     ["wait"] = { 230, "19",14,12 }
  41.   }
  42.  
  43.   local size = { term.getSize() }
  44.   term.setBackgroundColor( colors.lightGray )
  45.   term.clear()
  46.   paintutils.drawLine( 1, 1, size[1], 1, colors.gray )
  47.   term.setCursorPos( 2, 1 )
  48.   term.setTextColor( colors.white )
  49.   print( "CCU2 DJ Machine" )
  50.   print()
  51.   term.setTextColor( colors.lightGray )
  52.  
  53.   for k, v in pairs( tracks ) do
  54.     paintutils.drawLine( 1, tracks[k][3], size[1], tracks[k][3], colors.white )
  55.     term.setCursorPos( 2, tracks[k][3] )
  56.     print( tracks[k][4].." - "..k )
  57.   end
  58.  
  59.   paintutils.drawLine( 1, 16, size[1], 16, colors.gray)
  60.   term.setCursorPos( 2, 16)
  61.   term.setTextColor( colors.white )
  62.   print( "Panel" )
  63.   term.setCursorPos( 2, 17 )
  64.   term.setBackgroundColor( colors.lightGray )
  65.   print( "Press any track to play it." )
  66.  
  67.   local event, button, x, y = os.pullEvent( "mouse_click" )
  68.  
  69.   for k,v in pairs( tracks ) do
  70.     if y == tracks[k][3] then play( tracks[k][2], tracks[k][1] ) end
  71.   end
  72. end
  73.  
  74. function play( name, songKey )
  75.   local track = disk.getAudioTitle( "drive_"..name )
  76.   if track ~= "wait" then track = string.sub( track, 8 ) end
  77.   term.setCursorPos( 1, 17 )
  78.   term.clearLine()
  79.   term.setCursorPos( 2, 17 )
  80.   print( "You will be playing: "..track )
  81.   term.setBackgroundColor( colors.lime )
  82.   term.setCursorPos( 2, 18 )
  83.   write( " Play  " )
  84.   term.setCursorPos( 9, 18 )
  85.   term.setBackgroundColor( colors.lightGray )
  86.   write( " " )
  87.   term.setBackgroundColor( colors.red )
  88.   write( " Cancel " )
  89.   term.setBackgroundColor( colors.lightGray )
  90.   local event, button, x, y = os.pullEvent( "mouse_click" )
  91.   if x >= 2 and x <= 6 and y == 18 then
  92.     local sID = os.startTimer( songKey + .1 )
  93.     disk.playAudio( "drive_"..name )
  94.     term.setCursorPos( 2, 17 )
  95.     print("You are now playing: "..track )
  96.     term.clearLine()
  97.     term.setBackgroundColor( colors.red )
  98.     write( " Stop " )
  99.     term.setBackgroundColor( colors.lightGray )
  100.     while true do
  101.       local event, tID, x, y = os.pullEvent()
  102.       if x and y then
  103.         if (x >= 2 and x <= 6 and y == 18) and (event == "mouse_click" or event == "monitor_touch") then
  104.           disk.stopAudio()
  105.           menu()
  106.         end
  107.      end
  108.      if tID == sID and event == "timer" then
  109.         menu()
  110.       end
  111.     end
  112.   elseif x >= 9 and x <= 29 then
  113.     menu()
  114.   end
  115. end
  116.  
  117. menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement