Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SETUP
- local barColor = colors.cyan
- local barTitleDefault = "Record Player"
- local notesInfoText = "&1Harp&9 &4Snare&9 &5Hat&9 &2Bass&9 &3BaseDrum&9"
- --END SETUP
- os.loadAPI("gcapi")
- --INTERNAL VARIABLES
- local barTitle = barTitleDefault
- local mon = peripheral.find("monitor")
- local max_x, max_y = mon.getSize()
- local song = {} --
- --PROGRAMS
- function updateTitleBar()
- if song["name"] then
- barTitle = barTitleDefault .. " - Playing: " .. song["name"]
- end
- mon.setBackgroundColor(barColor)
- for x=1, max_x, 1 do
- mon.setCursorPos(x,1)
- mon.write(" ")
- end
- mon.setCursorPos(gcapi.getCenter(max_x, barTitle), 1)
- mon.write(barTitle)
- end
- function setupMonitor()
- barTitle = barTitleDefault
- mon.setBackgroundColor(colors.white)
- mon.clear()
- mon.setTextColor(colors.black)
- updateTitleBar()
- for x=1, max_x, 1 do
- mon.setCursorPos(x,max_y)
- mon.write(" ")
- end
- mon.setCursorPos(gcapi.getCenter(max_x, string.len(notesInfoText)-((#string.split(notesInfoText, "&")-1)*2)), max_y)
- gcapi.customMonitorWrite(mon, notesInfoText)
- end
- function setSong(s)
- song = s
- end
- function printNotes(tick)
- local tarjetX = gcapi.getCenter(max_x)
- mon.setBackgroundColor(colors.black)
- for y=2, max_y-1,1 do
- mon.setCursorPos(tarjetX,y)
- mon.write(" ")
- end
- for i=1,#song,1 do
- tickTable = song[i]
- local x = -tick+gcapi.getCenter(max_x)+i
- if x > max_x then
- break
- end
- if (x > 0) and tickTable then
- for instrumentID, notePitchs in pairs(tickTable) do
- for _,pitchID in pairs(notePitchs) do
- mon.setBackgroundColor(2^instrumentID)
- mon.setCursorPos(x,gcapi.getCenter(max_y, 24)+pitchID)
- mon.write(" ")
- end
- end
- end
- end
- end
- function updateMonitor(tick)
- setupMonitor()
- printNotes(tick)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement