xXm0dzXx

MiscPeripherals Iron Note Test

Dec 30th, 2012
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. local x,y = term.getSize()
  2. local cinstru = 0
  3. local maxnotes = 23
  4. local instruments = {
  5. [0] = "piano",
  6. [1] = "bass",
  7. [2] = "snare",
  8. [3] = "clicks",
  9. [4] = "bass guitar",
  10. }
  11.  
  12. function printGUI()
  13. term.setBackgroundColour( colors.black )
  14. term.setTextColour( colors.white )
  15. term.clear()
  16. term.setCursorPos(1,1)
  17.  
  18. if x ~= 29 then
  19. print("Instrument: " ..instruments[ cinstru ].. " (Right click to change) " )
  20. print( string.rep( "-", x ) )
  21. else
  22. print( instruments[ cinstru ] )
  23. print( string.rep( "-", 27 ) )
  24. end
  25.  
  26. term.setCursorPos(1,3)
  27. write( "|" )
  28. local color = colors.gray
  29. for i=0,maxnotes do
  30. term.setBackgroundColour( color )
  31. write( " " )
  32. if color == colors.gray then
  33. color = colors.lightGray
  34. else
  35. color = colors.gray
  36. end
  37. end
  38.  
  39. term.setBackgroundColour( colors.black )
  40.  
  41. if x ~= 29 then
  42. term.setBackgroundColour( colors.black )
  43. print( "| Notes: 24" )
  44. print( string.rep( "-", x ) )
  45. print( "Program by xXm0dzXx" )
  46. print( "Requires the following mods: ")
  47. print( " - MiscPeripherals" )
  48. print( " - ComputerCraft 1.481+" )
  49. print( "\nHow to use it:" )
  50. print( "C = Computer / N = Iron Noteblock" )
  51. print( "---" )
  52. print( " N " )
  53. print( " C " )
  54. else
  55. print( "|" )
  56. print( string.rep( "-", 27 ) )
  57. end
  58.  
  59. while true do
  60. local event, key, xPos, yPos = os.pullEvent()
  61. if event == "mouse_click" or event == "mouse_drag" then
  62. if key == 1 then
  63. local speaker = peripheral.wrap( "top" )
  64. if yPos == 3 then
  65. if xPos ~= 1 then
  66. note = xPos-1
  67. if note <= 25 and note ~= 25 then
  68. speaker.playNote( cinstru, note )
  69. end
  70. end
  71. end
  72. elseif key == 2 then
  73. break
  74. end
  75. end
  76. end
  77. end
  78.  
  79. while true do
  80. for i=0,4 do
  81. cinstru = i
  82. printGUI()
  83. end
  84. end
Advertisement
Add Comment
Please, Sign In to add comment