Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function split (inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={}
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- table.insert(t, str)
- end
- return t
- end
- local modemSide, speakerSide = ...
- local listenId = nil
- rednet.open(modemSide)
- local speaker = peripheral.wrap(speakerSide)
- while true do
- senderId, message, distance, protocol = rednet.receive()
- params = split(message, ",")
- cmd = params[1]
- if listenId == senderId and cmd == "groovy_play" then
- speaker.playNote(params[2], tonumber(params[3]), tonumber(params[4]))
- end
- if cmd == "groovy_start" then
- listenId = senderId
- elseif cmd == "groovy_stop" then
- listenId = nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement