I'm trying to have a global function that resets an int array's elements, like so:
void resetIntArray(int array[], int n, int indexNum) {
for (int i = 0; i < n; i++)
array[i] = 0;
indexNum = 0;
}
then imported it in the header: import void resetIntArray(int array[], int n, int indexNum = 0);
but when I try to use it locally it gives me the error: Error (line 43): Type mismatch: cannot convert 'int*' to 'int[]'
I would use it like this: resetIntArray(playerInput, 9, indexNum);
where playerInput is an int array of 9 elements.
I think playerInput is the problem. Am I supposed to pass it a different way in the argument?
AGS only allows to pass dynamic arrays as function parameters, or as the function return values. Regular static arrays (of fixed size) cannot be passed like that because script currently does not support pointers to non-managed variables.
Anyway, the solution is to remake your playerInput into dynamic array.
https://github.com/adventuregamestudio/ags-manual/wiki/DynamicArrays
Ah, I see. Thanks!