Advertisement
Guest User

playnbs.lua

a guest
Oct 24th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. local opennbs = require('opennbs')
  2.  
  3. local instIndex = {
  4.  [1]  = "harp",           -- harp/piano (air/dirt)
  5.  [2]  = "bass",           -- double bass/bass (wood)
  6.  [3]  = "basedrum",       -- basedrum (stone)
  7.  [4]  = "snare",          -- snare (sand)
  8.  [5]  = "click",          -- click (glass)
  9.  [6]  = "guitar",         -- guitar (wool)
  10.  [7]  = "flute",          -- flute (clay)
  11.  [8]  = "bell",           -- bell (block of gold)
  12.  [9]  = "chime",          -- chime (packed ice)
  13.  [10] = "xylophone",      -- xylophone (bone block)
  14.  [11] = "iron_xylophone", -- iron xylophone (iron block)
  15.  [12] = "cow_bell",       -- cow bell (soul sand)
  16.  [13] = "didgeridoo",     -- didgeridoo (pumpkin)
  17.  [14] = "bit",            -- bit [square wave] (block of emerald)
  18.  [15] = "banjo",          -- banjo (hay)
  19.  [16] = "pling",          -- pling/electric piano (glowstone)
  20. }
  21.  
  22.  
  23. write('Song to play: ')
  24. local data = opennbs.parseNbs(read())
  25.  
  26. local outputs = {
  27.  function(instrument, instIndex_, volume, pitch, panning)
  28.   -- TODO: panning
  29.   if commands then
  30.    print('gdasidj')
  31.    commands.execute(
  32.     'as',
  33.     '@a',
  34.     'at',
  35.     '@s',
  36.     'run',
  37.     'playsound',
  38.      'minecraft:block.note_block.'..instrument,
  39.      'master',
  40.      '@s',
  41.      '~', '~', '~',
  42.      volume, pitch
  43.    )
  44.   end
  45.  end
  46. }
  47.  
  48. local parallels = {}
  49.  
  50. for _,layer in pairs(data.layers) do
  51.  parallels[#parallels+1] = function()
  52.   for _,note in ipairs(layer.notes) do
  53.    print(_,'aaaaaaaaaaaaaaa')
  54.    local a=require('cc.pretty')a.print(a.pretty(note))
  55.    sleep(data.info.tempo/400)
  56.    print(data.info.tempo, data.info.tempo/400, 'gfgf')
  57.    for _,func in pairs(outputs) do
  58.     func(instIndex[note.instrument], note.instrument, note.volume, note.pitch, note.panning)
  59.    end
  60.   end
  61.  end
  62. end
  63.  
  64. parallel.waitForAll(table.unpack(parallels))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement