Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Header
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- term.setBackgroundColour(colours.black)
- term.setTextColor(colors.white)
- end
- function colore(sfumatura) term.setTextColour(sfumatura) end
- function fineColore() term.setTextColour(colours.white) end
- function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
- function fineSfondo() term.setBackgroundColour(colours.black) end
- -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
- local function drawPixelInternal(xPos, yPos)
- term.setCursorPos(xPos, yPos)
- term.write(" ")
- end
- local tColourLookup = {}
- for n = 1, 16 do
- tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
- end
- function drawFilledBox(startX, startY, endX, endY, nColour)
- if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
- "number" or type(endY) ~= "number" or
- (nColour ~= nil and type(nColour) ~= "number") then
- error("Expected startX, startY, endX, endY, colour", 2)
- end
- startX = math.floor(startX)
- startY = math.floor(startY)
- endX = math.floor(endX)
- endY = math.floor(endY)
- if nColour then term.setBackgroundColor(nColour) end
- if startX == endX and startY == endY then
- drawPixelInternal(startX, startY)
- return
- end
- local minX = math.min(startX, endX)
- if minX == startX then
- minY = startY
- maxX = endX
- maxY = endY
- else
- minY = endY
- maxX = startX
- maxY = startY
- end
- for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
- end
- function errore(error)
- while true do
- clear()
- colore(colours.red)
- sfondo(colours.yellow)
- print("Errore!")
- fineSfondo()
- print("")
- print("Errore grave: ")
- fineColore()
- print(error)
- print("")
- print("Premere un tasto per riavviare")
- event, key = os.pullEvent("key")
- os.reboot()
- end
- end
- if peripheral.getType("top") ~= "NAudio" then
- errore("Collegare un NAudioSystem sopra al computer, quindi riavviare il computer")
- end
- currentStation = "In pausa "
- volume = 0.3
- n = peripheral.wrap("top")
- while true do
- n.setVolume(volume)
- -- Disegna la finestra del pannello utente
- sfondo(colours.black)
- clear()
- term.setCursorPos(1, 19)
- colore(colors.lime)
- term.write(currentStation)
- term.setCursorPos(1, 1)
- colore(colours.black)
- sfondo(colours.yellow)
- print("N Media Player ")
- sfondo(colors.red)
- colore(colors.white)
- term.setCursorPos(51, 1)
- term.write("X")
- term.setCursorPos(1, 2)
- sfondo(colours.black)
- colore(colours.white)
- print("")
- print("")
- sfondo(colours.purple)
- colore(colours.white)
- print("Lynnfield Rock Radio \n")
- print("Voice of New Radeon \n")
- print("RGRadio \n")
- print("Artemis Radio \n")
- term.setCursorPos(1, 17)
- sfondo(colours.lightBlue)
- term.write("Play/Pausa")
- term.setCursorPos(12, 17)
- sfondo(colours.lightBlue)
- term.write("-")
- term.setCursorPos(14, 17)
- sfondo(colours.black)
- term.write("Vol")
- term.setCursorPos(18, 17)
- sfondo(colours.lightBlue)
- term.write("+")
- sfondo(colours.black)
- colore(colours.lime)
- term.setCursorPos(25, 17)
- term.write("Volume: " .. volume)
- sfondo(colours.purple)
- colore(colours.white)
- term.setCursorPos(40, 17)
- term.write("URL...")
- os.startTimer(5)
- sfondo(colors.black)
- event, key, x, y = os.pullEvent()
- if event == "mouse_click" and y == 4 then
- n.play("http://alshain.a-centauri.com:8000/lrr.mp3")
- currentStation = "In riproduzione: Lynnfield Rock Radio"
- elseif event == "mouse_click" and y == 6 then
- n.play("http://alshain.a-centauri.com:8000/vonr.mp3")
- currentStation = "In riproduzione: Voice of New Radeon "
- elseif event == "mouse_click" and y == 8 then
- n.play("http://alshain.a-centauri.com:8000/rgradio.mp3")
- currentStation = "In riproduzione: RGradio "
- elseif event == "mouse_click" and y == 10 then
- n.play("http://alshain.a-centauri.com:8000/artemis.mp3")
- currentStation = "In riproduzione: Artemis Radio "
- elseif event == "mouse_click" and y == 17 and x < 10 then
- n.togglePlay()
- currentStation = "In pausa "
- elseif event == "mouse_click" and y == 17 and x == 12 then
- if volume > 0.1 then
- volume = volume - 0.1
- else
- volume = 0.1
- end
- elseif event == "mouse_click" and y == 17 and x == 18 then
- if volume < 1.0 then
- volume = volume + 0.1
- else
- volume = 1.0
- end
- elseif event == "mouse_click" and y == 17 and x > 40 and x < 46 then
- clear()
- print("Inserire l'URL personalizzato: ")
- print("Esempio: http://coolradio.com/stream.mp3")
- local url = read()
- n.play(url)
- currentStation = "URL personalizzato"
- elseif event == "mouse_click" and x == 51 and y == 1 then
- clear()
- break
- elseif event == "timer" then
- n.sendUpdate()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement