Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local name = ...
- local Bcol = colors.lightGray
- local xMax,yMax = term.getSize()
- local line = {}
- local activeColors = {["bottom"] = 0, ["left"] = 0, ["right"] = 0, ["top"] = 0, ["back"] = 0}
- function JoJa(xP,yP)
- term.setCursorPos(xP,yP)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.cyan)
- term.write("Jo")
- term.setTextColor(colors.orange)
- term.write("Ja ")
- term.setTextColor(colors.lightGray)
- term.write("Productions")
- end
- function Background(col)
- term.setBackgroundColor(col)
- for xP = 1,xMax do
- for yP = 1,yMax do
- term.setCursorPos(xP,yP)
- term.write(" ")
- end
- end
- end
- function readFile(n)
- if n ~= nil and fs.exists(n) then
- print("file found.")
- if string.find(n.."",".mf") then
- print("reading file...")
- local m = fs.open(n,"r")
- local i = 1
- local l = m.readLine()
- while l ~= nil do
- print("Line: "..l)
- line[i] = {}
- local p1 = string.find(l.."",";")
- local d = string.sub(l,0,p1-1)
- line[i][1] = tonumber(d)
- print("Delay: "..d)
- l = string.sub(l,p1+1)
- local j = 2
- p1 = string.find(l.."",";")
- while p1 ~= nil do
- line[i][j] = {}
- local th = string.sub(l,0,p1-1)
- local p2 = string.find(th.."",",")
- t = tonumber(string.sub(th,0,p2-1))
- line[i][j][1] = t
- h = tonumber(string.sub(th,p2+1))
- line[i][j][2] = h
- print("Ton: "..t.." Hoehe: "..h)
- l = string.sub(l,p1+1)
- j = j+1
- p1 = string.find(l.."",";")
- end
- i = i+1
- l = m.readLine()
- end
- m.close()
- print("reading finished...")
- sleep(.5)
- return true
- else
- print("wrong format.")
- return false
- end
- else
- print("file not found.")
- return false
- end
- end
- function parseNote(iNote, iInstrument)
- local bExtra = false
- local sSide = ""
- if iNote >= 16 then bExtra = true end
- if not bExtra then
- if iInstrument == 1 then sSide = "bottom" end
- if iInstrument == 2 then sSide = "back" end
- if iInstrument >= 3 then sSide = "right" end
- iColor = 2 ^ iNote
- else
- if iInstrument == 1 then sSide = "top" end
- if iInstrument == 2 then sSide = "left" end
- if iInstrument >= 3 then sSide = "right" end
- iColor = 2 ^ (iNote - 16)
- end
- return iColor, sSide
- end
- function setNoteState(iNote, iInstrument, bState)
- iC, sS = parseNote(iNote, iInstrument)
- if not bState then iC = -iC end
- activeColors[sS] = activeColors[sS] + iC
- rs.setBundledOutput(sS, activeColors[sS])
- end
- if readFile(name) then
- Background(Bcol)
- JoJa(xMax/2-7,1)
- term.setTextColor(colors.white)
- term.setCursorPos(3,yMax)
- term.write("in cooperation with eisenhower8")
- term.setTextColor(colors.red)
- term.setCursorPos(3,3)
- term.write("MF")
- term.setTextColor(colors.white)
- term.write("-Player")
- term.setCursorPos(3,5)
- term.write("Gerade wird abgespielt: "..name)
- for i = 1,#line do
- d = line[i][1]
- for j = 2,#line[i] do
- setNoteState(line[i][j][1], line[i][j][2], true)
- end
- sleep(d/2)
- for j = 2,#line[i] do
- setNoteState(line[i][j][1], line[i][j][2], false)
- end
- sleep(d/2)
- end
- else
- sleep(.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment