Posted 02 October 2012 - 12:31 AM
This is an attempted at making an ascii video play for Computer-craft. The basic format for the video is
movie/format
movie/frames
In the frames file make each frame as it should be displayed (new lines and all) and for each frame put <new frame> on a line separating the two frames. You can also put <change rate #> to change rate to #.
In format you will have to define:to loop forever or not, the amount of time between frames, and the width/height.
Sample video is now nyancat. Just put it on the computer you run the program on.
movie/format
movie/frames
In the frames file make each frame as it should be displayed (new lines and all) and for each frame put <new frame> on a line separating the two frames. You can also put <change rate #> to change rate to #.
In format you will have to define:to loop forever or not, the amount of time between frames, and the width/height.
Sample video is now nyancat. Just put it on the computer you run the program on.
shell.run( "movie/format" )
local w,h = term.getSize()
while loop do
local sPath = shell.resolve( "movie/frames")
tLines = {}
if fs.exists( sPath ) then
local file = io.open( sPath, "r" )
local sLine = file:read()
shell.run( "clear" )
line = 0
while sLine do
local startX = math.floor( (w - vw) / 2 )
local startY = math.floor( (h - vh) / 2 )
if sLine == "<new frame>" or string.find(sLine, "<change rate ") then
if string.find(sLine, "<change rate ") then
newrate = string.gsub(sLine, "<change rate ", "")
newrate = string.gsub(newrate, ">", "")
rate = newrate * 1
end
line = 0
sleep(rate)
else
term.setCursorPos(startX, startY + line)
term.write( sLine )
line = line + 1
end
sLine = file:read()
end
file:close()
end
end
shell.run( "clear" )