GRxRedZero

Untitled

Apr 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. local playerslave = {}
  2.  
  3. playerslave.new = function(side, id, subid)
  4. return function()
  5. local modem = peripheral.wrap(side)
  6.  
  7. local peripherals = modem.getNamesRemote()
  8. local nperipherals = #peripherals
  9. os.queueEvent("player:slaveinfo", id, subid, side, nperipherals)
  10. local idx = 1
  11.  
  12. while true do
  13.  
  14. local evt, p1_id, p2_subid, p3_inst, p4_note, p5_volume = os.pullEvent("player:slave")
  15. if id == p1_id and subid == p2_subid then
  16.  
  17. modem.callRemote(peripherals[idx], "playNote", p3_inst, p4_note, p5_volume)
  18. idx = idx % nperipherals + 1
  19.  
  20. end
  21.  
  22. end
  23. end
  24. end
  25.  
  26. return playerslave
Add Comment
Please, Sign In to add comment