No it wouldn't, you're using a local variable so it will be 1 after ++ every time, and gone after the command is finished.
Yeah. For that situation, you would want to use a global variable to make it go up ever time you called it. ($ are global variables and % are local).
More stuff on variables:
Most of the time, you will use a local variable (%) in a function. The function uses this variable until the function stops running. However, if you want to
keep that variable every time you run the function, you should use a global ($).
When using a local variable, it doesn't really matter what you name it at the beginning, as long as you use that same name throughout the entire function. For example:
%a = 12; echo(%a); returns 12 (obviously, but that's not my point.)
%b = 12; echo(%b); it really doesn't matter what you name it, but you have to use the same name throughout the function.
Yes, I know you can change the name of the variable during the function and then use that, but for basic purposes, we're not going to cover that. Here's a tutorial on for loops:
A for loop repeats a statement or block of code for a set number of iterations. - From the official GarageGames website.
You will want to use a for loop every time you want to repeat a certain operation with a different number.
Here's a basic explanation:
for(starting condition; ending condition; by how much)
Using a for loop, you will want to start at a number to go to a number by using different increments or decrements. (going up or going down).
A really simple for loop that uses numbers 0 - 2:
for(%i = 0; %i < 3; %i++)As stated above, every %i doesn't need to actually be an I. You could name it %atutle, or practically anything you want as long as it doesn't contain numbers or weird characters (like !, ^, &, etc.)
The for loop above tells us to start at the starting index, where %i is stated as 0. It then repeats the loop by one (++) until it reaches the middle index (less than 3.)
for(%i = 0; %i < 3; %i++)
echo(%i);
Shows us this:
0
1
2
So, in your code, you use
for(%i = 0; %i < ClientGroup.getCount(); %i++).
This tells us to start at 0, going by 1 until we reach the count of the ClientGroup (which is basically the number of clients in the server).
When using anything with .getCount(); the object you're doing getCount() on has a .getObject() method, which allows us to see the objects that are part of that group.
For example:
Group
{
Object
}
If we used group.getObject() it would allow us to get all of the children (objects) of the parents (Groups). So,
ClientGroup.getObject(%i); is telling us to get every object of the clientGroup because you looped through it with a for loop.
Also, you can change the way for loops go up/down, using mathematical functions. For example, using %i += 10 on the last index would allow us to run the for loop, but going up 10 every time instead of 1. Like so:
for(%i = 0; %i < 100; %i += 10)
echo(%i);
Shows us:
0
10
20
30
40
50
60
70
80
90
If you need any other help,
click here for the Torque3D website for more references.
Also, in your buildMinigame() code, setting the %object.minigame to NULL actually makes the minigame output "NULL", not an actual NULL (I think), so you would want to use %object.minigame = "";