Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- Stravides Radio Station Program
- --
- m = peripheral.wrap("top")
- os.unloadAPI("button")
- os.loadAPI("button")
- local currentSide="back"
- local currentStation="Trance"
- local currentVolume=3
- local radio1
- local radio2
- local radio3
- local radio4
- radio1=peripheral.wrap("back")
- radio2=peripheral.wrap("right")
- radio3=peripheral.wrap("left")
- radio4=peripheral.wrap("bottom")
- function quietplease()
- rs.setAnalogOutput("left",0)
- button.setState("radio1",false)
- rs.setAnalogOutput("right",0)
- button.setState("radio2",false)
- rs.setAnalogOutput("back",0)
- button.setState("radio3",false)
- rs.setAnalogOutput("bottom",0)
- button.setState("radio4",false)
- end
- function play(side,volume)
- quietplease()
- currentSide=side
- currentVolume=volume
- rs.setAnalogOutput(side,volume)
- screen()
- end
- function station(side)
- if side=="back" then currentStation="Trance Radio" end
- if side=="left" then currentStation="Slay Radio" end
- if side=="right" then currentStation="Gamers Radio" end
- if side=="bottom" then currentStation="Capitol Radio" end
- end
- function addVol()
- if currentVolume<15 then
- currentVolume=currentVolume+1
- play(currentSide,currentVolume)
- screen()
- end
- end
- function decVol()
- if currentVolume>0 then
- currentVolume=currentVolume -1
- play(currentSide,currentVolume)
- screen()
- end
- end
- function screen()
- station(currentSide)
- m.setCursorPos(15,2)
- m.write("Stravides Radio Jukebox")
- m.setCursorPos(19,5)
- m.write("Volume: "..currentVolume.." ")
- m.setCursorPos(20,16)
- m.write("You are listening to :")
- m.setCursorPos(20,17)
- m.write(currentStation)
- end
- button.setMon("top")
- button.add("radio1","Trance","flash",2,4,15,6,colors.red,colors.green,colors.white,function() play("back",currentVolume) end)
- button.setState("radio1",false)
- button.add("radio2","Slay Radio","flash",2,8,15,10,colors.red,colors.green,colors.white, function() play("left",currentVolume) end)
- button.setState("radio2",false)
- button.add("radio3","Gamerz","flash",2,12,15,14,colors.red,colors.green,colors.white,function() play("right",currentVolume) end)
- button.setState("radio3",false)
- button.add("radio4","Capitol","flash",2,16,15,18,colors.red,colors.green,colors.white,function() play("bottom",currentVolume) end)
- button.setState("radio4",false)
- button.add("incVol","+","flash",23,7,25,9,colors.red,colors.green,colors.white,function() addVol() end)
- button.add("decVol","-","flash",23,11,25,13,colors.red,colors.green,colors.white,function() decVol() end)
- button.draw()
- screen()
- quietplease()
- while true do
- button.check()
- end
Advertisement
Add Comment
Please, Sign In to add comment