Oh yeah. Hells to the yeah. Yep, I know that last thing bordered quite precariously to being “douchey” but I honestly don’t care. The Map works. The import function into Paper Zeppelin works. I can build (and have!) an entire Paper Zeppelin level using Open Office. It’s pretty damn awesome, and was the trickiest bit of programming I had thought there was left to do, and now it’s behind me like so many vanquished foes and lusty women (not really).
It turned out there was a magic word. It wasn’t “Sesame” and it wasn’t “Rapunzel let down your golden hair.” Nope, it was File.ReadAllLines. What it does, or at least seems to do, is read a file that I feed it. It reads all the lines and if you do something like this:
String LevelData[] = File.ReadAllLines(theLevel.csv)
It makes the Level Data whatever the hell is in the file. Since the whole engine was already set up to assume that everything was read out of that LevelData information, changing where and, more importantly, how the information got there once I set it up correctly, it just ran. So cool. So bloody cool.
Couple things popped up. First of all, I had to set up an Importer. C# and specifically Visual Studio (the program or “Integrated Development Environment” ie “IDE” that let’s me code) has a lot of options for importing information. That’s because there is a lot of different types of information that goes into a program and a video game in particular. It may need to import pictures, data, sound effects, 3D models, textures (the pictures that wrap around 3D models to make them look good), music and all kinds of other stuff. Picking the wrong kind will make the system crash because a picture and a sound effect have fundamental differences in the way that the computer reads and understands their information.
The thing is, there wasn’t an Import option that said CSV file. So I did a few and crashed the program a couple of times until I ran across an option that just said “XML Content.” It still crashed, but the other options made even less sense. It turns out that C# and Visual Studio will also want to preprocess information and assets. What that means is instead of going to look for the file and then reading it, C# wants to do all of that crap before the program starts to run. Then it can optimize it and make it run fast. Again though, there are a number of different options. The thing is, I really didn’t want the computer to do anything to my level files. That seemed stupid. I just wanted the pure text and the sweet characters that live there, so I selected “Don’t Preprocess my Stuff Jerk.”
Then I hit F5, the magical key that unleashes Paper Zeppelin at me. It worked…sort of.
First, a quick explanation. This “CSV” file that I keep mentioning is called that because CSV stands for “Comma Separated Value.” The files are then named like this : Stuff.csv.
If one were to open a CSV file in a spreadsheet program like Excel it would have values in the different cells like a normal spreadsheet file would. However, if you opened it in something like Wordpad it would look something like this:
A,B,C,D,E,F
When Excel reads that it would put all of the different letters in their own cell. The other thing is this – the letters aren’t saved like that by default. No, because that would be easy. Instead, because they are Characters, they are saved like this:
“A”,”B”,”C”,”D”,”E”,”F”
But it gets stupider. They have the little quotes only because they are characters (or words, words {or as they are called in programming “strings”} also have quotes). Other things, like say a period, don’t get that special treatment.
The reason that this was a problem is that the whole thing was read into the system and it assumed that all the commas and quotes were there on purpose. When I made a quick map that loaded ground, it had blank spots all over the place and nothing lined up, because when I asked, “What’s the next character?” the computer replied correctly with, “It’s a quote thing…so I ignore it.”
Anyhow, I had considered coding a way to remove the quotes and the commas, but then instead I wondered if I could change Open Office to do it for me. Which it turns out it can. So I turned off the quotes and the commas and the thing just worked. So, hurray for that.
-For those of you playing along at home, the biggest reason that I am so surprised by all of this is that you may remember that I built a custom level editor for The Thief’s Tale. It took me almost 2 months. I got this sexiness done in an afternoon. What I am now going to do is set up a template for making the levels. I can make colors and stuff appear around different values. That’s awesome! I haven’t been this excited about a spreadsheet program since, well, never. Spreadsheet programs really aren’t known for being excitement inducing.