Travis wrote:Argh. That's gonna be a problem, since I'm looking for something that constantly moniters an array.
Hey, don't worry about it. Modern computers are lightning-fast little beasties.
This script will display a constantly-updated count of the number 2 within an array of 100 values:
Code: Select all
int MyArray[100];
script 200 ENTER {
int Count, i;
while (1) {
for (i=0; i<100; i++) if (MyArray[i] == 2) Count++;
Print(s:"Current count: ", n:Count);
delay(1);
}
}
This shouldn't faze ZDoom at all, even though it's running the loop 100 times per tic (3500 times a second).
TheDarkArchon wrote:Mine was supposed to be a declaration, though I made a couple of gaffs (missing ";" and missing "int" prefix).
To my knowledge you cannot assigned an entire array to a single number. Your code would assign the number 2 to the 0th element of the array and leave the rest as 0's.
However, you
can do something like this:
Code: Select all
int ArrayOfTwos[8] = { 2, 2, 2, 2, 2, 2, 2, 2 };
int MixedArray[10] = { 3, 1, 8, 2, 5, 0, -2, 4, 3, 0 };
int StringAndIntsCauseACSRox[5] = {
17,
"Charlie",
"Brown",
-2,
0
};