Jump to content




Frame splitting w/ NFA file format


7 replies to this topic

#1 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 13 July 2015 - 05:30 PM

Hello. I am trying to develop a program that can split the frames up in an NFA file.

The framesplit program is Pastebin ID: 5jkpZRj6
The test.nfa is Pastebin ID: KneqXszu

Please help!

I know the ending of a frame is the ~ character. It splits up the first frame fine, but 2 and 3 are completely blank.

Thanks!

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 13 July 2015 - 05:33 PM

    for x = startf, endf do
      if f.readLine( x ) == endchar then --#if this line is equal to the end character
        frameend = true --#end the loop
        lineend = x
      else --#else
        framebuffer[ x ] = f.readLine( x ) .. "\n" --#add the NEXT line to the file
        --print( framebuffer[ x ] )
      end
    end

...see the problem?

#3 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 14 July 2015 - 03:08 PM

framebuffer[ x ] = f.readLine( x ) .. "\n" --#add the NEXT line to the file

Is this what your talking about?

The reason I told it to add \n is because:
  • No where else in the program does it append \n
  • I'm lazy, so I append it now.
  • It doesn't automatically add \n


#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 14 July 2015 - 06:37 PM

I don't care about \n. I care that your reading the NEXT LINE not the line you just compared.

   --#is this line the end character?
                       7777777         --#no, lets save this line to the table      
                      7       7777          --#is this line the end character?
            77777777  77         77        --#no, lets save this line to the table
            777777777777          7        --#is this line the end character?
          777       77777777     77        --#no, lets save this line to the table.
         77             7777777777          
         7                  777            
         7                     777          
         7                       77        
         777                      7        
            77                   77        
              7777            777          
                  77777  77777              
~


             7                              
             777       7777777              
                777   7       7777          
            777777777 77         77        
            777777777777          7        
          777       77777777     77        
         77           777777777777          
         7             77   777            
         7              77     777          
         7                       77        
         777                      7        
            77                   77        
              7777            777          
                  77777  77777              
~


             7                              
             777       7777777              
                777   7       7777          
            777777777 77         77        
            777777777777          7        
          777       77777777     77        
         77           777777777777          
         7             77   777            
         7              77     777        77
         7                       77     777
         777                      7777777  
            77         777777777777        
              7777    77      777          
777777777777777777777                  77777  77777

Which means your table is going to end up saving lines 2, 4, 6, 8, 10, 12, 14, 16, etc. and scanning lines 1, 3, 5, 7, 9, 11, 13, 15, etc.

Edited by KingofGamesYami, 14 July 2015 - 06:38 PM.


#5 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 15 July 2015 - 05:07 PM

Incorrect.

if f.readLine( x ) == endchar then
		frameend = true
		lineend = x
	  else --#ELSE
		framebuffer[ x ] = f.readLine( x ) .. "\n"
		--print( framebuffer[ x ] )
end

This is basically scanning the line if it's the end char.
If so, add the line you are on to "lineend"
If it's not the correct line, then ignore it and add it to the table. --#ELSE
There is an else there, which says if it's not the line your looking for, add it to the table.

Edited by LewisTehMinerz, 15 July 2015 - 05:08 PM.


#6 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 15 July 2015 - 05:43 PM

Every time you call f.readLine it gives you a new line. f.readLine does not accept an argument.

#7 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 18 July 2015 - 10:07 AM

Still gives the same result w/out arg.

#8 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 18 July 2015 - 12:43 PM

Which for all we know means you didn't bother to re-organise the rest of your code to account for the fact that the argument is ignored, perhaps?

You also seem to be forgetting to set "frameend" back to false, which'd be why you're only getting data from the first frame.

Personally I'd script things out along these lines:

write( "Enter the location of the animation: " )

local f = read()

write( "Prefix for files: " )

lcoal framename = read()

print( "Writing files. Please wait..." )

local curFrame = 1
local output = fs.open(framename..curFrame, "w")

for line in io.lines(f) do
	if line == "~" then
		curFrame = curFrame + 1
		output.close()
		output = fs.open(framename..curFrame, "w")
	else
		output.writeLine(line)
	end
end

output.close()






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users