Advertisement
biodude100

Music Main Control

May 30th, 2015 (edited)
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. m=peripheral.wrap("right") --Monitor side (set for 3x3 advanced monitor)
  2.  
  3. n=peripheral.wrap("back")  --Noteblock side
  4.  
  5. m.setBackgroundColor(colors.black)
  6.  
  7. m.clear()
  8.  
  9. function wt(x,y,t,c)
  10.   m.setBackgroundColor(c)
  11.   m.setCursorPos(x,y)
  12.   m.write(t)
  13. end
  14.  
  15.  
  16. function pn(f,l)
  17.   n.setPitch(f)  --pitch {0-24}
  18.   n.triggerNote()
  19.   sleep(l)  --note length
  20. end
  21.  
  22. wt(10,2,"Choose song",colors.black)
  23. wt(14,4,"Moonlight",colors.purple)
  24. wt(14,5,"Sonata   ",colors.purple)
  25. wt(8,4,"NBC",colors.blue)
  26. wt(8,6,"One",colors.red)
  27. wt(7,8,"Zelda",colors.green)
  28. wt(7,10,"Viva ",colors.purple)
  29.  
  30. function nbc()
  31.   pn(15,.2)
  32.   pn(24,.2)
  33.   pn(20,.2)
  34. end
  35.  
  36.  
  37. function One()
  38.   pn(16,.2)
  39.   pn(23,.2)
  40.   pn(16,.2)
  41.   pn(19,1)
  42.   pn(12,.2)
  43.   pn(23,.2)
  44.   pn(12,.2)
  45.   pn(19,1)
  46.   pn(16,.2)
  47.   pn(23,.2)
  48.   pn(16,.2)
  49.   pn(19,1)
  50.   pn(12,.2)
  51.   pn(23,.2)
  52.   pn(12,.2)
  53.   pn(19,.4)
  54.   pn(24,.1)
  55. end
  56.  
  57. function viva()
  58.   pn(0,.2)
  59.   pn(0,.2)
  60.   pn(0,.2)
  61.   pn(0,.1)
  62.   pn(2,.2)
  63.   pn(2,.1)
  64.   pn(2,.2)
  65.   pn(2,.2)
  66.   pn(2,.2)
  67.   pn(7,.2)
  68.   pn(7,.2)
  69.   pn(7,.2)
  70.   pn(7,.1)
  71.   pn(4,.2)
  72.   pn(4,.1)
  73.   pn(4,.2)
  74.   pn(4,.2)
  75.   pn(4,.2)
  76. end
  77.  
  78. function zelda() --http://www.zeldacapital.com/sheet_music/piano/loz_pdfs/LegendofZelda-Overworld.pdf
  79.   pn(5,.8)
  80.   pn(5,.2)
  81.   pn(5,.1)
  82.   pn(5,.2)
  83.   pn(5,.1)
  84.   pn(5,.3)
  85.   pn(3,.1)
  86.   pn(5,.6)
  87.   pn(5,.2)
  88.   pn(5,.1)
  89.   pn(5,.2)
  90.   pn(5,.1)
  91.   pn(5,.3)
  92.   pn(3,.1)
  93.   pn(5,.6)
  94.   pn(5,.2)
  95.   pn(5,.1)
  96.   pn(5,.2)
  97.   pn(5,.1)
  98.   pn(5,.2)
  99.   pn(0,.1)
  100.   pn(0,.1)
  101.   pn(0,.2)
  102.   pn(0,.1)
  103.   pn(0,.1)
  104.   pn(0,.2)
  105.   pn(0,.1)
  106.   pn(0,.1)
  107.   pn(0,.2)
  108.   pn(0,.2)
  109.   pn(5,.4)
  110.   pn(0,.7)
  111.   pn(5,.1)
  112.   pn(5,.1)
  113.   pn(7,.1)
  114.   pn(9,.1)
  115.   pn(10,.1)
  116.   pn(12,.9)  -- not done
  117. end
  118.  
  119. function moonlight()
  120. end
  121.  
  122.  
  123. function touch()
  124.   if mouseWidth > 7 and mouseWidth < 11 and mouseHeight == 4 then
  125.     nbc()
  126.   elseif mouseWidth > 7 and mouseWidth < 11 and mouseHeight == 6 then
  127.     One()
  128.   elseif mouseWidth > 6 and mouseWidth < 12 and mouseHeight == 8 then
  129.     zelda()
  130.   elseif mouseWidth > 6 and mouseWidth < 12 and mouseHeight == 10 then
  131.     viva()
  132.   elseif mouseWidth > 13 and mouseWidth < 23 and mouseHeight > 3 and mouseHeight < 6 then
  133.     moonlight()
  134.   end
  135. end
  136.  
  137.  
  138. print("Screen is now ready.")
  139. print("Press 'x' to exit.")
  140.  
  141.  
  142. repeat
  143.    event,p1,p2,p3 = os.pullEvent()
  144.    if event=="monitor_touch" then
  145.      mouseWidth = p2
  146.      mouseHeight = p3
  147.      touch()
  148.     end  
  149. until event=="char" and p1==("x") --press x to exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement