The problem is that GetString() and GetInt() are for global string and int variables that are NOT arrays, and GetStringArray() and GetIntArray() are for one-dimensional global string and int arrays.
You can, however, do some hackery to manipulate values inside structures, but it's pretty out there and relies a lot on how structures and arrays get represented internally.
Here are the basic rules though to manipulate anything that is partially a global user-defined variable (local variables can't be manipulated, why would you want to?). These are scary. But I was bored one day and fudged around with things.
Let's define a structure for example purposes:
#define EQUIP_SLOTS 8
struct player_type
{
int hp;
int equipment[EQUIP_SLOTS];
};
player_type player;
player_type party[4];
There is a chr(1) (an unprintable character) added to the start of the variable's name if it's a structure. Nested structures will have several chr(1)s at the beginning. Where you'd use a "." normally, use a "_".
For example:
// Represents player.hp = 5;
SetInt(chr(1) + "player_hp", 5);
Whenever a structure has an array, you need to treat the variable as an array.
// Represents player.equip[2]
GetIntArray(chr(1) + "player_equip", 2);
// Represents party[3].hp
GetIntArray(chr(1) + "party_hp", 3);
Not bad? But, when there's more than one layer of arrays, then we get fun multiplication and adding. I can't really give you a good example for this off-hand, but, I know the pseudo-code algorithm for resolving a single array index out of the several:
let a variable (offset) represent the resultant one dimensional array index.
for each dimension in the variable:
let a variable called dimension offset (dimofs) be the index [] for that dimension
for each dimension after the current:
dimofs *= upper bound of dimension
offset += dimofs
GetIntArray(variable, offset);
I can confirm that these steps work, too. I wrote a crazy wrapper function to calculate the array offset based on a string of comma-separated indices (representing each [] needed), but it's a little too crazy. But eh, I suppose the damage's already done, so here you go:
int GetMultidimIntArray(string varname, string dim_list, string max_dim_list)
{
int i, j;
int ofs, dimofs;
int dim_count = TokenCount(dim_list, ",");
int passed_dim_count = TokenCount(dim_list, ",");
int max_dim_count = TokenCount(max_dim_list, ",");
// If a token's blank, ignore it.
while (!len(GetToken(dim_list, ",", 0)))
{
i++;
passed_dim_count--;
}
if (passed_dim_count != max_dim_count)
{
Exit("GetMultidimIntArray :: Expecting " + str(max_dim_count)
+ " dimensions but was passed " + str(passed_dim_count)
+ "! Get it right, jerk.");
}
for (i = 0; i < dim_count; i++)
{
dimofs = val(GetToken(dim_list, ",", i));
if (dimofs >= val(GetToken(max_dim_list, ",", i)) || dimofs < 0)
{
Exit("GetMultidimIntArray :: "
+ "Invalid index " + str(dimofs) + " passed to array '" + varname
+ "'. Index must be >= 0 and < " + GetToken(max_dim_list, ",", i) + ".");
}
for (j = i + 1; j < dim_count; j++)
{
dimofs = dimofs * val(GetToken(max_dim_list, ",", j));
}
ofs += dimofs;
}
return GetIntArray(varname, ofs);
}
I also have a corresponding setter function which is similar, and the the getter/setter for multi-dim string arrays. My guess is these are very slow. I dunno, I only used them to copy structures to each other. I was just bored when I was developing and wrote a test of the Set*()/Get*() behaviours based on the knowledge I developed of the source.
My recommendation, if possible, is to not go as far as I've gone. Accept that there are some crazy things that shouldn't be attempted through VC, and instead, use the useful stuff like the ability to nest structures and arrays and mish-mash of the two.