Ciliste

noteblock

May 3rd, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.50 KB | None | 0 0
  1. local NoteBlock = peripheral.wrap("right")
  2. local NBBASS = peripheral.wrap("note_block_9")
  3. local NBSNARE = peripheral.wrap("note_block_8")
  4.  
  5. local NBPIANO1 = peripheral.wrap("note_block_10")
  6. local NBPIANO2 = peripheral.wrap("note_block_11")
  7. local NBPIANO3 = peripheral.wrap("note_block_12")
  8.  
  9. function getNotes (inputstr, sep)
  10. if sep == nil then
  11. sep = "%s"
  12. end
  13. local t={}
  14. for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  15. table.insert(t, str)
  16. end
  17. return t
  18. end
  19.  
  20. local notesBass = getNotes("X", "-")
  21. local notesSnare = getNotes("X", "-")
  22. local notesPiano1 = getNotes("18-#2-16-#2-15-#2-11-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-18-#6-16-#2-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-15-#2-18-#6-16-#2-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-15-#2-18-#6-16-#2-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-16-#2-16-#2-16-#2-16-#2-20-#2-20-#2-20-#2-20-#2-18-#2-18-#2-18-#2-18-#2-23-#2-23-#2-23-#2-23-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-18-#2-16-#2-15-#2-11-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-15-#2-18-#6-16-#2-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-15-#2-18-#6-16-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-16-#2-16-#2-16-#2-20-#2-20-#2-20-#2-20-#2-18-#2-18-#2-18-#2-18-#2-23-#2-23-#2-23-#2-23-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-X", "-")
  23. local notesPiano2 = getNotes("#22-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#40-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-X", "-")
  24. local notesPiano3 = getNotes("X", "-")
  25.  
  26. for _,v in pairs(notesBass) do
  27. print(v)
  28. end
  29.  
  30. local nbBass = 1
  31. local nbSnare = 1
  32. local nbPiano1 = 1
  33. local nbPiano2 = 1
  34. local nbPiano3 = 1
  35.  
  36. local TFBassBreak = false
  37. local TFSnareBreak = false
  38. local TFPiano1Break = false
  39. local TFPiano2Break = false
  40. local TFPiano3Break = false
  41.  
  42. local BASS = true
  43. local SNARE = true
  44. local PIANO1 = true
  45. local PIANO2 = true
  46. local PIANO3 = true
  47.  
  48. local BassBreakNB = 0
  49. local SnareBreakNB = 0
  50. local Piano1BreakNB = 0
  51. local Piano2BreakNB = 0
  52. local Piano3BreakNB = 0
  53.  
  54. local playBass = 0
  55. local playSnare = 0
  56. local playPiano1 = 0
  57. local playPiano2 = 0
  58. local playPiano3 = 0
  59.  
  60.  
  61. while true do
  62.  
  63. --BASS
  64.  
  65. if BASS == true then
  66. playBass = notesBass[nbBass]
  67. if TFBassBreak == true then
  68. BassBreakNB = BassBreakNB + 1
  69. if BassBreakNB == BassBreak then
  70. TFBassBreak = false
  71. BassBreakNB = 0
  72. nbBass = nbBass + 1
  73. end
  74. else
  75. if string.sub(playBass, 1, 1) == "#" then
  76. BassBreak = tonumber(string.sub(playBass, 2))
  77. TFBassBreak = true
  78. else
  79. if playBass == "/" then
  80. term.write(playBass.."\n")
  81. nbBass = nbBass + 1
  82. else
  83. if playBass == "X" then
  84. BASS = false
  85. else
  86. if playBass == "R" then
  87. nbBass = 1
  88. else
  89. term.write(playBass.."\n")
  90. NBBASS.setPitch(playBass)
  91. NBBASS.triggerNote()
  92. nbBass = nbBass + 1
  93. end
  94. end
  95. end
  96. end
  97. end
  98. end
  99.  
  100. --SNARE
  101.  
  102. if SNARE == true then
  103. playSnare = notesSnare[nbSnare]
  104. if TFSnareBreak == true then
  105. SnareBreakNB = SnareBreakNB + 1
  106. if SnareBreakNB == SnareBreak then
  107. TFSnareBreak = false
  108. SnareBreakNB = 0
  109. nbSnare = nbSnare + 1
  110. end
  111. else
  112. if string.sub(playSnare, 1, 1) == "#" then
  113. SnareBreak = tonumber(string.sub(playSnare, 2))
  114. TFSnareBreak = true
  115. else
  116. if playSnare == "/" then
  117. term.write(playSnare.."\n")
  118. nbSnare = nbSnare + 1
  119. else
  120. if playSnare == "X" then
  121. SNARE = false
  122. else
  123. if playSnare == "R" then
  124. nbSnare = 1
  125. else
  126. term.write(playSnare.."\n")
  127. NBSNARE.setPitch(playSnare)
  128. NBSNARE.triggerNote()
  129. nbSnare = nbSnare + 1
  130. end
  131. end
  132. end
  133. end
  134. end
  135. end
  136.  
  137. --PIANO
  138. --#1
  139.  
  140. if PIANO1 == true then
  141. playPiano1 = notesPiano1[nbPiano1]
  142. if TFPiano1Break == true then
  143. Piano1BreakNB = Piano1BreakNB + 1
  144. if Piano1BreakNB == Piano1Break then
  145. TFPiano1Break = false
  146. Piano1BreakNB = 0
  147. nbPiano1 = nbPiano1 + 1
  148. end
  149. else
  150. if string.sub(playPiano1, 1, 1) == "#" then
  151. Piano1Break = tonumber(string.sub(playPiano1, 2))
  152. TFPiano1Break = true
  153. else
  154. if playPiano1 == "/" then
  155. term.write(playPiano1.."\n")
  156. nbPiano1 = nbPiano1 + 1
  157. else
  158. if playPiano1 == "X" then
  159. PIANO1 = false
  160. else
  161. if playPiano1 == "R" then
  162. nbPiano1 = 1
  163. else
  164. term.write(playPiano1.."\n")
  165. NBPIANO1.setPitch(playPiano1)
  166. NBPIANO1.triggerNote()
  167. nbPiano1 = nbPiano1 + 1
  168. end
  169. end
  170. end
  171. end
  172. end
  173. end
  174.  
  175. --#2
  176.  
  177. if PIANO2 == true then
  178. playPiano2 = notesPiano2[nbPiano2]
  179. if TFPiano2Break == true then
  180. Piano2BreakNB = Piano2BreakNB + 1
  181. if Piano2BreakNB == Piano2Break then
  182. TFPiano2Break = false
  183. Piano2BreakNB = 0
  184. nbPiano2 = nbPiano2 + 1
  185. end
  186. else
  187. if string.sub(playPiano2, 1, 1) == "#" then
  188. Piano2Break = tonumber(string.sub(playPiano2, 2))
  189. TFPiano2Break = true
  190. else
  191. if playPiano2 == "/" then
  192. term.write(playPiano2.."\n")
  193. nbPiano2 = nbPiano2 + 1
  194. else
  195. if playPiano2 == "X" then
  196. PIANO2 = false
  197. else
  198. if playPiano2 == "R" then
  199. nbPiano2 = 1
  200. else
  201. term.write(playPiano2.."\n")
  202. NBPIANO2.setPitch(playPiano2)
  203. NBPIANO2.triggerNote()
  204. nbPiano2 = nbPiano2 + 1
  205. end
  206. end
  207. end
  208. end
  209. end
  210. end
  211.  
  212. --#3
  213.  
  214. if PIANO3 == true then
  215. playPiano3 = notesPiano3[nbPiano3]
  216. if TFPiano3Break == true then
  217. Piano3BreakNB = Piano3BreakNB + 1
  218. if Piano3BreakNB == Piano3Break then
  219. TFPiano3Break = false
  220. Piano3BreakNB = 0
  221. nbPiano3 = nbPiano3 + 1
  222. end
  223. else
  224. if string.sub(playPiano3, 1, 1) == "#" then
  225. Piano3Break = tonumber(string.sub(playPiano3, 2))
  226. TFPiano3Break = true
  227. else
  228. if playPiano3 == "/" then
  229. term.write(playPiano3.."\n")
  230. nbPiano3 = nbPiano3 + 1
  231. else
  232. if playPiano3 == "X" then
  233. PIANO3 = false
  234. else
  235. if playPiano3 == "R" then
  236. nbPiano3 = 1
  237. else
  238. term.write(playPiano1.."\n")
  239. NBPIANO3.setPitch(playPiano3)
  240. NBPIANO3.triggerNote()
  241. nbPiano3 = nbPiano3 + 1
  242. end
  243. end
  244. end
  245. end
  246. end
  247. end
  248.  
  249. --#4
  250.  
  251. if PIANO4 == true then
  252. playPiano4 = notesPiano4[nbPiano4]
  253. if TFPiano4Break == true then
  254. Piano4BreakNB = Piano4BreakNB + 1
  255. if Piano4BreakNB == Piano4Break then
  256. TFPiano4Break = false
  257. Piano4BreakNB = 0
  258. nbPiano4 = nbPiano4 + 1
  259. end
  260. else
  261. if string.sub(playPiano4, 1, 1) == "#" then
  262. Piano4Break = tonumber(string.sub(playPiano4, 2))
  263. TFPiano4Break = true
  264. else
  265. if playPiano4 == "/" then
  266. term.write(playPiano4.."\n")
  267. nbPiano4 = nbPiano4 + 1
  268. else
  269. if playPiano4 == "X" then
  270. PIANO4 = false
  271. else
  272. if playPiano4 == "R" then
  273. nbPiano4 = 1
  274. else
  275. term.write(playPiano1.."\n")
  276. NBPIANO4.setPitch(playPiano4)
  277. NBPIANO4.triggerNote()
  278. nbPiano4 = nbPiano4 + 1
  279. end
  280. end
  281. end
  282. end
  283. end
  284. end
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293. sleep(0)
  294.  
  295. end
Advertisement
Add Comment
Please, Sign In to add comment