Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- vid = args[1]
- doUncompress = args[2]
- if doUncompress == "true" or doUncompress == "uncompress" or doUncrompess == "uncompressed" or doUncrompress == "-u" then
- doUncompress = true
- else
- doUncompress = true
- end
- bsl = "\\"
- dpc = "%%"
- pce = "%^"
- pmc = "%$"
- pop = "%("
- pcp = "%)"
- ppd = "%."
- psb = "%["
- pcb = "%]"
- pst = "%*"
- pad = "%+"
- psu = "%-"
- pqm = "%?"
- hex = {{"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"},{pcp,"!","@","#",pmc,dpc,pce,"&",pst,pop,"A","B","C","D","E","F"},{"q","w","r","t","y","u","i","o","p","s","g","h","j","k","l","z"},{"x","v","n","m","~","`",",","<",ppd,">","/",pqm,";",":","'",'"'},{pcb,"{",psb,"}","|",bsl,psu,"_","=",pad,"Q","W","R","T","Y","U"}}
- function unCompress(toUC)
- if doUncompress then
- for a = #hex, 2,-1 do
- for b = 1, #hex[1] do
- toUC = string.gsub(toUC, hex[a][b],hex[a-1][b]..hex[a-1][b])
- end
- end
- end
- return toUC
- end
- function openVideo(file)
- print("Giving /videos/"..vid.."/"..file)
- return fs.open("/videos/"..vid.."/"..file,"r")
- end
- function sep(str)
- t = {}
- while #str >= 1 do
- pos = str:find("\n")
- if pos then
- t[#t+1] = str:sub(1,pos-1)
- str = str:sub(pos+1,#str)
- else
- t[#t+1] = str:sub(1,#str)
- str = ""
- end
- end
- return t
- end
- function readLine()
- linePos = linePos+1
- if fileTable[linePos-1] then
- return fileTable[linePos-1]
- else
- return nil
- end
- end
- function openRead(file)
- f = openVideo(file)
- fd = f.readAll()
- fd = unCompress(fd)
- fileTable = sep(fd)
- f.close()
- linePos = 1
- end
- rf = openVideo("resolution")--openVideo("resolution")
- resX = tonumber(rf.readLine())
- resY = tonumber(rf.readLine())
- print("Videos is "..tostring(resX).."x"..tostring(resY))
- tf = openVideo("text")
- cont = true
- countera = 1
- counetrb = 1
- txt = {}
- function decode(doNorm,f)
- rTable = {}
- countera = 1
- counterb = 1
- tot = 1
- cont = true
- while cont do
- if not doNorm then
- cont = readLine()
- else
- cont = f.readLine()
- end
- if not rTable[countera] then
- rTable[countera] = {}
- end
- if cont then
- rTable[countera][counterb] = cont
- end
- counterb = counterb+1
- if counterb > resY then
- countera = countera+1
- counterb = 1
- tot = tot+1
- end
- end
- if doNorm then
- f.close()
- end
- return rTable, tot
- end
- txt, totalFrames = decode(true,tf)
- --fCol = openVideo("color")
- openRead("color")
- col = decode(fCol)
- openRead("bg")
- --fBG = openVideo("bg")
- bg = decode(fBG)
- cur = true
- frame = 1
- cFrame = {}
- start = os.time()
- sleepMode = "yield"
- while cur do
- if sleepMode == "yield" then
- bst = os.time()
- else
- sleep(0.05)
- end
- term.setCursorPos(1,1)
- cFrame = {txt[frame],col[frame],bg[frame]}
- cur = nil
- if txt[frame] and txt[frame][1] then
- cur = txt[frame][1]
- end
- if cur then
- for a = 1, #cFrame[1] do
- --print(cFrame[1][a])
- --print(cFrame[2][a])
- --print(cFrame[3][a])
- if cFrame[1][a] and cFrame[2][a] and cFrame[3][a] then
- term.blit(cFrame[1][a],cFrame[2][a],cFrame[3][a])
- end
- write("\n")
- end
- end
- frame = frame+1
- if sleepMode == "yield" then
- wait = true
- while wait do
- os.queueEvent("YIELD")
- os.pullEvent("YIELD")
- bet = os.time()
- if bet ~= bst then
- wait = false
- end
- end
- end
- end
- endTime = os.time()
- taken = endTime - start
- taken = taken*50
- print(tostring(totalFrames).." frames took "..tostring(taken).." seconds")
- print("That's "..tostring(totalFrames/taken).." FPS")
Advertisement
Add Comment
Please, Sign In to add comment