Advertisement
HDR

Music System 2.3

HDR
Jun 25th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --# Made By HDR - @MartinRefseth #--
  2. --# Version 2.3 #--
  3. --# Thanks to Lyqyd for his Button API http://www.computercraft.info/forums2/index.php?/topic/14784-touchpoint-api/ #--
  4. os.loadAPI("touchpoint")
  5. for a,b in pairs(rs.getSides()) do
  6.   if peripheral.getType(b) == 'monitor' then
  7.    mon = peripheral.wrap(b)
  8.    t = touchpoint.new(b)
  9.    break
  10.   end
  11. end
  12.  
  13. --# Functions
  14. function play()
  15.  peripheral.find("drive", disk.stopAudio)
  16.  peripheral.find( "drive", function( name )
  17.   if disk.hasAudio( name ) and disk.getAudioTitle( name ) == title then
  18.     print("Now Playing"," ",( title) )
  19.     disk.playAudio( name )
  20.   end
  21.  end )
  22. end  
  23.  
  24. function Thir()
  25.    t:flash("13")
  26.    title = "C418 - 13"
  27.    play()
  28. end
  29.  
  30. function Cat()
  31.    t:flash("Cat")
  32.    title = "C418 - cat"
  33.    play()
  34. end
  35.  
  36. function Blocks()
  37.    t:flash("Blocks")
  38.    title = "C418 - blocks"
  39.    play()
  40. end  
  41.  
  42. function Chirp()
  43.    t:flash("Chirp")
  44.    title = "C418 - chirp"
  45.    play()
  46. end  
  47.  
  48. function Far()
  49.    t:flash("Far")
  50.    title = "C418 - far"
  51.    play()
  52. end
  53.  
  54. function Mall()
  55.    t:flash("Mall")
  56.    title = "C418 - mall"
  57.    play()
  58. end
  59.  
  60. function Mellohi()
  61.    t:flash("Mellohi")
  62.    title = "C418 - mellohi"
  63.    play()
  64. end
  65.  
  66. function Stal()
  67.    t:flash("Stal")
  68.    title = "C418 - stal"
  69.    play()
  70. end
  71.  
  72. function Strad()
  73.    t:flash("Strad")
  74.    title = "C418 - strad"
  75.    play()
  76. end
  77.    
  78. function Ward()
  79.    t:flash("Ward")
  80.    title = "C418 - ward"
  81.    play()
  82. end
  83.  
  84. function Elev()
  85.    t:flash("11")
  86.    title = "C418 - 11"
  87.    play()
  88. end
  89.  
  90. function Wait()
  91.    t:flash("Wait")
  92.    title = "C418 - wait"
  93.    play()
  94. end
  95.  
  96. --#Stops All Music
  97. function Stop()
  98.    t:flash("Stop")
  99.    print("Stopping Disk")
  100.    peripheral.find("drive", disk.stopAudio)
  101. end
  102. function Reboot()
  103.    t:flash("Reboot")
  104.    print("Rebooting")
  105.    peripheral.find("drive", disk.stopAudio)
  106.    mon.clear()
  107.    os.reboot()
  108. end
  109.  
  110. -- A list of all possible songs --# Thanks to http://pastebin.com/u/MechWipf for the Random function #--
  111. local Songs = {
  112.     Thir, Cat, Blocks, Chirp, Far, Mall, Mellohi, Stal, Strad, Ward,
  113.     Elev, Wait, Question, GaiaOne, GaiaTwo, Roop, Slive, WYG, Wander
  114. }
  115.  
  116. function Random()
  117.     t:flash("Random")
  118.     peripheral.find("drive", disk.stopAudio)
  119.     local maxSongs = #Songs -- the "#" gets the length of the list
  120.     local randomNumber = math.random( maxSongs )
  121.     Songs[randomNumber]() -- call the choosen song directly out of the list
  122. end
  123.  
  124. --#OverWrites Part Of Touchpoint API#--
  125.     t.draw = function(self)
  126.       local function cT(text)
  127.         x,y = term.getSize()
  128.         x1,y1 = term.getCursorPos()
  129.         term.setCursorPos((math.floor(x/2) - (math.floor(#text/2))), y1)
  130.         term.write(text)
  131.      end
  132.                 local old = term.redirect(self.mon)
  133.                 term.setTextColor(colors.white)
  134.                 term.setBackgroundColor(colors.gray)
  135.                 term.clear()
  136.                 term.setCursorPos(1,1)
  137.                 term.setTextColor(colors.orange)
  138.                 cT("HDR's Music System V2.3")
  139.                 for name, buttonData in pairs(self.buttonList) do
  140.                         if buttonData.active then
  141.                                 term.setBackgroundColor(buttonData.activeColor)
  142.                                 term.setTextColor(buttonData.activeText)
  143.                         else
  144.                                 term.setBackgroundColor(buttonData.inactiveColor)
  145.                                 term.setTextColor(buttonData.inactiveText)
  146.                         end
  147.                         for i = buttonData.yMin, buttonData.yMax do
  148.                                 term.setCursorPos(buttonData.xMin, i)
  149.                                 term.write(buttonData.label[i - buttonData.yMin + 1])
  150.                         end
  151.                 end
  152.                 if old then
  153.                         term.redirect(old)
  154.                 else
  155.                         term.restore()
  156.                 end
  157.         end
  158.  
  159. --# Buttons
  160. t:add("13", Thir, 3,3,13,5, colors.cyan, colors.lime, colors.orange, colors.orange)
  161. t:add("Cat", Cat, 15,3,25,5, colors.cyan, colors.lime, colors.orange, colors.orange)
  162. t:add("Blocks", Blocks, 27,3,37,5, colors.cyan, colors.lime, colors.orange, colors.orange)
  163. t:add("Chirp", Chirp, 3,7,13,9, colors.cyan, colors.lime, colors.orange, colors.orange)
  164. t:add("Far", Far, 15,7,25,9, colors.cyan, colors.lime, colors.orange, colors.orange)
  165. t:add("Mall", Mall, 27,7,37,9, colors.cyan, colors.lime, colors.orange, colors.orange)
  166. t:add("Mellohi", Mellohi, 3,11,13,13, colors.cyan, colors.lime, colors.orange, colors.orange)
  167. t:add("Stal", Stal, 15,11,25,13, colors.cyan, colors.lime, colors.orange, colors.orange)
  168. t:add("Strad", Strad, 27,11,37,13, colors.cyan, colors.lime, colors.orange, colors.orange)
  169. t:add("Ward", Ward, 3,15,13,17, colors.cyan, colors.lime, colors.orange, colors.orange)
  170. t:add("11", Elev, 15,15,25,17, colors.cyan, colors.lime, colors.orange, colors.orange)
  171. t:add("Wait", Wait, 27,15,37,17, colors.cyan, colors.lime, colors.orange, colors.orange)
  172. t:add("Random", Random, 3,19,13,19, colors.cyan, colors.lime, colors.orange, colors.orange)
  173. t:add("Stop", Stop, 15,19,25,19, colors.cyan, colors.lime, colors.orange, colors.orange)
  174. t:add("Reboot", Reboot, 27,19,37,19, colors.cyan, colors.lime, colors.orange, colors.orange)
  175. t:run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement