Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- networked=false
- if peripheral.isPresent("left") then
- if peripheral.getType("left") == "modem" then
- networked=true
- end
- end
- function findPeripheral()
- local dd = false
- local mon = false
- if peripheral.isPresent("right") then
- if peripheral.getType("right") == "drive" then
- doit=true
- end
- end
- if peripheral.isPresent("top") then
- if peripheral.getType("top") == "monitor" then
- mon=true
- end
- end
- if mon and doit then
- return true
- end
- end
- function playMusic()
- if findPeripheral() then
- if disk.hasAudio("right") then
- disp = peripheral.wrap("top")
- name = disk.getAudioTitle("right")
- disk.playAudio("right")
- local xx,yy = disp.getSize()
- xx = (xx/2)
- local offX = string.len(name)/2
- disp.clear()
- disp.setCursorPos(xx-offX,yy/2)
- disp.write(name)
- else
- term.write("no disk found!")
- end
- end
- end
- if networked then
- rednet.open("left")
- term.write("Networked mode - waiting for signal from client...")
- while true do
- local id,msg = rednet.receive()
- if id == 19 then
- if msg == "play" then
- playMusic()
- end
- if msg == "stop" then
- disk.stopAudio("right")
- end
- if msg == "eject" then
- disk.stopAudio("right")
- disk.eject("right")
- end
- if msg == "restart" then
- disk.stopAudio("right")
- disk.playAudio("right")
- end
- end
- sleep(1)
- end
- else
- playMusic()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement