Advertisement
justync7

ccTunesCommandMP

Oct 17th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. commands = {}
  2. channel = 65535
  3. modem = {}
  4. commands.sides = {
  5.   [1] = "left",
  6.   [2] = "right",
  7.   [3] = "back",
  8.   [4] = "front",
  9.   [5] = "top",
  10.   ["left"] = 1,
  11.   ["right"] = 2,
  12.   ["back"] = 3,
  13.   ["front"] = 4,
  14.   ["top"] = 5
  15. }
  16. commands.noteblock = {}
  17. commands.ints = {
  18.   [0] = "note.harp",
  19.   [1] = "note.bd",
  20.   [2] = "note.snare",
  21.   [3] = "note.hat",
  22.   [4] = "note.bassattack"
  23. }
  24. for i=1,4 do
  25.     modem[i] = peripheral.wrap(commands.sides[i])
  26.     modem[i].open(channel)
  27.     commands[i] = {}
  28.     commands.noteblock[i] = {}
  29.     commands[i].execAsync = function(cmd)
  30.         modem[i].transmit(channel, channel, cmd)
  31.         return {}
  32.     end
  33.     commands[i].exec = commands.execAsync
  34.     commands.noteblock[i].playNote = function(int, note)
  35.         int = commands.ints[int]
  36.         note = math.pow(2, (note-12) / 12)
  37.         commands[i].execAsync("playsound "..int.." @a ~ ~ ~ 1 "..note)
  38.     end
  39. end
  40. peripheral.nwrap = function(side)
  41.     return commands.noteblock[commands.sides[side]]
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement