Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("left")
- m = peripheral.wrap("right")
- m.clear()
- os.loadAPI("button")
- local radio = {}
- local frequence = 0
- local volume = 1
- local nom = {
- [1] = "off",
- [2] = "Nova",
- [3] = "Europe1",
- [4] = "RTL2",
- [5] = "Azenet"
- }
- button.setTable("off",0,23,26,2,2)
- button.setTable("Nova",1,3,14,5,7)
- button.setTable("Europe1",2,16,27,5,7)
- button.setTable("RTL2",3,3,14,9,11)
- button.setTable("Azenet",4,16,27,9,11)
- button.setTable("<",10,2,2,15,15)
- button.setTable(">",11,28,28,15,15)
- button.toggleButton("off")
- function execut(nb)
- if nb == 0 then
- volume = 1
- end
- if nb>=0 and nb <= 4 then
- button.toggleButton(nom[frequence+1])
- frequence = nb
- button.toggleButton(nom[nb+1])
- end
- if nb == 10 and volume > 1 then
- volume = volume-1
- end
- if nb == 11 and volume < 15 then
- volume = volume+1
- end
- radio["fr"] = frequence
- radio["vl"] = volume
- modem.transmit(123,12,textutils.serialize(radio))
- print(frequence..":"..volume)
- end
- function ecran()
- m.clear()
- button.screen()
- button.label(3,2,"OpenRadio")
- button.label(10,13,"Volume")
- button.label(12,17,volume.." V.")
- button.label(13,19,"By Darking560")
- local aff = math.floor((volume/15)*12)
- m.setBackgroundColor(colors.gray)
- for i=0,aff do
- m.setCursorPos(4+(2*i),15)
- m.write(" ")
- end
- m.setBackgroundColor(colors.black)
- end
- while true do
- ecran()
- sleep(2)
- event, side, x, y = os.pullEvent("monitor_touch")
- local nb = button.checkxy(x,y)
- execut(nb)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement