BruceWplays

Notifcation

Oct 12th, 2022 (edited)
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. local inst_pl = "harp"
  2. local inst_pl_la = nil
  3. local notew = 0.2
  4. local note_pl = 0.2
  5. local note_pl_la = nil
  6.  
  7.  
  8. local function inst_sort(table,inst,i)
  9.     if inst_pl_la ~= nil and table[i].inst == nil then
  10.         inst_pl = inst_pl_la
  11.     elseif table[i].inst == nil and inst_pl_la == nil then
  12.         inst_pl = inst
  13.     else
  14.         inst_pl = table[i].inst
  15.         inst_pl_la = inst_pl
  16.     end
  17. end
  18.  
  19. local function wait_sort(table,wait,i)
  20.     if note_pl_la ~= nil and  table[i].wait == nil then
  21.         note_pl = note_pl_la
  22.     elseif table[i].wait == nil and note_pl_la  == nil then
  23.         note_pl = wait
  24.     else
  25.         note_pl = table[i].wait
  26.         note_pl_la = note_pl
  27.     end
  28. end
  29.  
  30.  
  31. function playnoti(table,wait,inst,vol)
  32. local speaker = peripheral.find("speaker")
  33. for i=1,#table do
  34.     inst_sort(table,inst,i)
  35.     wait_sort(table,wait,i)
  36.     for i2=1,#table[i].note do
  37.         speaker.playNote(inst_pl, vol, table[i].note[i2])
  38.     end
  39.     sleep(note_pl * wait)
  40. end
  41. return
  42. end
  43.  
  44.  
  45.  
  46.  
  47. local playnotitestnotes = {
  48.     {note = {6, 3, 11},wait = 0.2, inst = "guitar"},
  49.     {note = {8, 1, 15}},
  50.     {note = {10, 15, 18}},
  51.     {note = {6,10,13},wait = 0.4, inst = "harp"},
  52.     {note = {8,11,6}},
  53.     {note = {6,1,10}}
  54. }
  55. local waitmul = 0.8
  56. local instdef = "harp"
  57. local voldef = 80
  58. playnoti(playnotitestnotes, waitmul, instdef, voldef)
Advertisement
Add Comment
Please, Sign In to add comment