Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local term = require("term")
- local event = require("event")
- local colors = require("colors")
- local gpu = component.gpu
- if not component.isAvailable("jukebox") then
- error("No jukebox detected !")
- end
- local jukebox = component.jukebox
- local sError = ""
- local bTerminated = false
- local nOldMonX, nOldMonY = gpu.getResolution()
- gpu.setResolution(80, 25)
- local nMonX, nMonY = gpu.getResolution()
- term.clear()
- gpu.setBackground(0x4C4C4C)
- gpu.fill(1, 1, nMonX, 1, " ")
- term.setCursor(1, 1)
- term.write("music by arc13")
- gpu.setBackground(0xCC4C4C)
- gpu.fill(nMonX - 4, 1, nMonX, 1, " ")
- term.setCursor(nMonX - 2, 1)
- term.write("X")
- gpu.setBackground(0x999999)
- gpu.fill(1, 2, nMonX, nMonY, " ")
- gpu.setBackground(0x3366CC)
- gpu.fill(1, nMonY, nMonX, nMonY, " ")
- term.setCursor(1, nMonY)
- term.write("["..os.date().."] No notifications !")
- gpu.setBackground(0x57A64E)
- gpu.fill(1, 10, nMonX / 3, nMonY / 2, " ")
- gpu.setBackground(0xCC4C4C)
- gpu.fill(nMonX / 3 + nMonX / 3, 10, nMonX, nMonY / 2, " ")
- gpu.setBackground(0xFFFFFF)
- gpu.fill(10, 12, 1, nMonY / 2 - 4, " ")
- gpu.set(11, 12, " ")
- gpu.set(12, 13, " ")
- gpu.set(13, 14, " ")
- gpu.set(14, 15, " ")
- gpu.set(11, 12 + nMonY / 2 - 5, " ")
- gpu.set(12, 12 + nMonY / 2 - 6, " ")
- gpu.set(13, 12 + nMonY / 2 - 7, " ")
- gpu.set(14, 12 + nMonY / 2 - 8, " ")
- gpu.fill(nMonX - 10, 12, 2, nMonY / 2 - 4, " ")
- gpu.fill(nMonX - 16, 12, 2, nMonY / 2 - 4, " ")
- term.setCursor(1, 2)
- gpu.setBackground(0x4C4C4C)
- local function toast(sText, bDefault)
- if sText then
- term.setCursor(1, nMonY)
- gpu.setBackground(0x3366CC)
- term.clearLine()
- if bDefault then
- term.write(sText)
- else
- term.write("["..os.date().."] "..sText)
- end
- end
- end
- local function touchHandler(_, _, nMouseX, nMouseY)
- if nMouseX >= nMonX - 4 and nMouseY == 1 then
- bTerminated = true
- elseif nMouseX >= 1 and nMouseX <= nMonX / 3 and nMouseY >= 10 and nMouseY <= 10 + nMonY / 2 - 1 then
- toast("Music played !")
- jukebox.play()
- elseif nMouseX >= nMonX / 3 + nMonX / 3 and nMouseX <= nMonX and nMouseY >= 10 and nMouseY <= 10 + nMonY / 2 - 1 then
- toast("Music stopped !")
- jukebox.stop()
- end
- end
- local function keyHandler(_, _, nChar, nCode)
- if nChar == 112 and nCode == 25 then
- toast("Music played !")
- jukebox.play()
- elseif nChar == 115 and nCode == 31 then
- toast("Music stopped !")
- jukebox.stop()
- end
- end
- local function removeHandler(_, sType)
- if sType == "jukebox" then
- bTerminated = true
- sError = "Jukebox has been removed !"
- end
- end
- event.listen("touch", touchHandler)
- event.listen("key_up", keyHandler)
- event.listen("component_unavailable", removeHandler)
- while bTerminated == false do
- term.setCursor(1, 3)
- gpu.setBackground(0x999999)
- term.clearLine()
- _, sThing = jukebox.getRecord()
- term.write(sThing)
- os.sleep(1)
- end
- gpu.setResolution(nOldMonX, nOldMonY)
- event.ignore("touch", touchHandler)
- event.ignore("key_up", keyHandler)
- event.ignore("component_unavailable", removeHandler)
- gpu.setBackground(0x000000)
- term.clear()
- if sError ~= "" then
- gpu.setForeground(0xCC4C4C)
- term.write(sError)
- gpu.setForeground(0xFFFFFF)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement