With this function you can set the value of an index in an array to a value. The function requires you to provide a variable that holds the array as well as the index to set and the value to set it to. This function can also be used for multi-dimension arrays, as long as you specify which dimension you want to set when you supply the array index, following this pattern:
// 1D array
array_set(my_array, 0, 100);
// 2D array
array_set(my_array[0], 0, 100);
// 3D array
array_set(my_array[0][0], 0, 100);
// etc...
array_set(variable, index, value);
Argument | Type | Description |
---|---|---|
variable | Array | The variable that holds the array. |
index | Real | The index of the array element to set the value for. |
value | Any | The value to set. |
N/A
for (var i = 0; i < 10; ++i;)
{
array_set(score_array, i, i*100));
}
The above code will set the first 10 items in the given array to a value.