TheDoctor Posted March 5, 2011 Share Posted March 5, 2011 So I'm making my level code generator, and want to make an option that parses level code from the cfg. The thing is, I'm not quite sure how. I can just barely read a simple file with a colon delimiter, but the cfg has large amounts of whitespace. I was wondering how one would do this. I'm making this in Java (I know blargh) by the way. CURRENT OBJECTIVE: Find a line that has "Levels {" that doesn't have a semicolon anywhere in font of it. Link to comment Share on other sites More sharing options...
Addictgamer Posted March 5, 2011 Share Posted March 5, 2011 Look at ORR's CFG parser. It'll help. Whitespace and whatnot is ignored with a simple, "bool start_recording". It'll keep reading the cfg till it finds something other than whitespace, if you did it right. if(last_read_char != ' ' && last_read_char != '\t' && last_read_char != '\n') { start recording = true; } There. That should be enough help. C++ is close enough to Java for you to be able to port that code snippet yourself. Link to comment Share on other sites More sharing options...
TheDoctor Posted March 5, 2011 Author Share Posted March 5, 2011 Look at ORR's CFG parser. It'll help. Whitespace and whatnot is ignored with a simple, "bool start_recording". It'll keep reading the cfg till it finds something other than whitespace, if you did it right. if(last_read_char != ' ' && last_read_char != '\t' && last_read_char != '\n') { start recording = true; } There. That should be enough help. C++ is close enough to Java for you to be able to port that code snippet yourself. Eh, I see what you mean, but I have to use Java Scanners to do this. I have to read up a bit more on some things, but thanks. Edit: More of the parser code might help. Link to comment Share on other sites More sharing options...
Recommended Posts