View difference between Paste ID: 5jkpZRj6 and 7d5YGjCw
SHOW: | | - or go back to the newest paste.
1-
local nfaendframechar = "~"
1+
local tArgs = { ... }
2-
local endchar = nfaendframechar
2+
local f
3-
local framebuffer = {}
3+
4-
local frameend = false
4+
if #tArgs == 0 or tArgs[ 1 ] == nil then error( shell.getRunningProgram() .. " <file> [prefix]", 0 ) end
5-
local startf = 1
5+
f = tArgs[ 1 ]
6-
local endf = 16
6+
framename = tArgs[ 2 ] or "/"
7
--[[write( "Enter the location of the animation: " )
8-
local lineend
8+
old code
9-
write( "Enter the location of the animation: " )
9+
local f = read()
10-
loc = read()
10+
11-
f = fs.open( loc, "r" )
11+
12-
write( "How many frames are there? : " )
12+
13-
fr = read()
13+
local framename = read()
14
]]--
15-
framename = read()
15+
16-
print( "Writing " .. fr .. " files. Please wait..." )
16+
print( "Writing files. Please wait... (Huge animations may take a while)" )
17-
for i = 1, fr do
17+
18-
  while not frameend do
18+
local curFrame = 1
19-
    for x = startf, endf do
19+
local output = fs.open(framename..curFrame, "w")
20-
      if f.readLine( x ) == endchar then
20+
21-
        frameend = true
21+
for line in io.lines(f) do
22-
        lineend = x
22+
  if line == "~" then
23-
      else
23+
    curFrame = curFrame + 1
24-
        framebuffer[ x ] = f.readLine( x ) .. "\n"
24+
    output.close()
25-
        --print( framebuffer[ x ] )
25+
    output = fs.open(framename..curFrame, "w")
26-
      end
26+
  else
27-
    end
27+
    output.writeLine(line)
28
  end
29-
  fra = fs.open( framename .. i, "w" )
29+
end
30-
  for y = 1, 16 do
30+
31-
    fra.write( framebuffer[ y ] )
31+
output.close()