Hmm.
In a nutshell, arrays a an easy way to cut down the size of cogs, but refferencing multiple variables in a single statement.
Example:
That cog, upon activation of the switch, will print out all the values of the "Var" series of ints to the console. Without the array, each variable would have to be printed seperatly.
In that example, I used For(), but that isnt the only way it could be done.
That will accomplish the same thing, I just used a different loop type.
The For() command is used because it combines the array operator (the I variable) directly.
For(I=0; I <= 4; I=I+1)
I=0; This part is setting the inital value of "I". We could start it at, say, 2, so only the values 2 - 4 would be printed...
I <= 4; This is the condition. Every time the loop is run, it checkes to see if the condition is true. If it is, it will go through with the loop. If it is not, the loop will terminate.
I=I+1 This is the Index increment. Every time the For() loop reaches the end of the code block, and starts over, this calculation is performed. It is not performed the first time the loop runs, but every time after that. On the last run, the variable is set to 5, making the condition return false, thereby terminating the loop.
Thats the For() command, in a nutshell.
Arrays in JK arent really arrays as all (in the classic sense).
The above is a valid array.
The array is composed of the three Flex variables, hte 'Gravity' series. In the Setgravity() command, only one variable is being called. Which one, depends on the difficuly. If hte difficulty is on easy, a '0' is returned from the 'Getdifficulty()' command, thereby calling the 'Gravity_easy' variable. If the difficulty was on hard, a '2' would be returned, calling the 'Gravity_hard' variable. That is because arrays in JK are nothing more than symbol offsets.
Var2 would be printed to the console. That is because the command is referencing 'Var0', with an offset of 2, which lands on Var2.
Again, Var2 would be called. Contrary to popular belief, the above is a valid array.
In a nutshell, to use an array..
1) You can use an array for just about anything. you dont need to use For() or While().
2) The array format is "Variable[offset]" The square brackets indicate an array operation.
3) Go back and re-read the Datamaster now. It should make more sense.
And when the moment is right, I'm gonna fly a kite.