Barnet

player_slave.lua

Jun 9th, 2021 (edited)
6,220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local playerslave = {}
  2.  
  3. local instinfo = dofile("EasyPlay/Core/noteinfo.lua")
  4.  
  5. playerslave.new = function(side, id, subid)
  6.     return function()
  7.         local speaker = peripheral.wrap(side)
  8.  
  9.         os.queueEvent("player:slaveinfo", id, subid, side)
  10.  
  11.         while true do
  12.             local evt, p1_id, p2_subid, p3_inst, p4_note, p5_volume =
  13.                 os.pullEvent("player:slave")
  14.             if id == p1_id and subid == p2_subid then
  15.                 local mcvolume = 3
  16.                 if p5_volume < 100 then
  17.                     mcvolume = p5_volume / 33.333333
  18.                 end
  19.                 local mcinstr = instinfo.instnames[p3_inst + 1]
  20.                 speaker.playNote(mcinstr, mcvolume, p4_note)
  21.             end
  22.         end
  23.     end
  24. end
  25.  
  26. return playerslave
  27.  
Add Comment
Please, Sign In to add comment