I'm trying to make an install script for Nexus Mod Manager (nmm) for the game Skyrim. If you are not familiar with nmm, you can write scripts to make mod installs easy and dynamic. You have an option of using xml or c#. I am doing the latter. I can't get the below code to compile (by compile I mean nmm will give me an error). I'm new to c# so I'm probably doing something fundamentally wrong. I'm getting an error: "object reference not set to an instance of an object". I have read a little about this error, but do not understand what I'm doing wrong.
Anyways, here is some of my code:
static int maxRaceMods = 100;
static Race[][] raceOption = new Race[maxRaceMods][];
class Race
{
public string Name { get; set; }
public string PathMeshes { get; set; }
public string PathTextures { get; set; }
}
static void GetRaces()
{
for (int i = 0; i < raceOption.Length; i++)
{
raceOption[i] = new Race[1];
raceOption[i][0].Name = "unknown";
raceOption[i][0].PathMeshes = "unknown";
raceOption[i][0].PathTextures = "unknown";
}
}
My problem happens when I try to assign the class variables. If I comment out the last three lines in the for loop, the code compiles fine. Obviously, I plan to expand upon GetRaces, but I need to get this working first.