Hey guys. Got a question for seasoned programmers. I'm trying to build an integer array with the numbers 1-4 in a random order. Having some trouble though. This particular bit of code doesn't have any syntax errors, but I'm worried about the semantics.
I ran the function with a debug message listing the order of the array it generates, but the debug message doesn't appear. I tried attaching a second debug message to at least let me know the function terminates, but apparently it just doesn't. I'm pretty sure it's because of the deeply nested while loop. Any suggestions on what I can do it get around this? Here's the code
void OnStart()
{
AddTimer("", 2.0f, "Test01CompileArray");
}
//pseudo callback I wrote to show how I run the function
void Test01CompileArray(string &in t)
{
UltDeathArray=CompileUltDeathArray();
//debug messages here
}
int[] UltDeathArray;
int[] CompileUltDeathArray()
{
int[] builder={0,0,0,0};
int temp;
int currIndex=0;
for(int i=1;i<=builder.length() ;i++)
{
currIndex++;
temp=RandInt(1,4);
for(int j=1;j<=builder.length();j++)
{
while(temp==builder[j-1]) temp=RandInt(1,4);
}
builder[currIndex]=temp;
}
return builder;
}