Ignore crypticmind. He didn't realize that we are talking about AngelScript and not C/C++. [wink]
Don't take me wrong, crypticmind. I appreciate that you're trying to help.
It's not quite that simple. You see, arrays in AngelScript are actually objects, not just pointers to a memory buffer.
If you want the application to interact with the arrays in AngelScript, then you first need to register the interface the application will use to interact with the array. I suggest you use the RegisterVector() function that Deyja wrote for this:
RegisterVector<int>("int", "int", engine);
Then after compiling the script you will be able to do the following:
// Initialize the vector
vec = 5;
vec = 9;
// Pass the vector object by reference to the function
ctx->SetArguments(0, (asDWORD*)&vec, 1);
Don't forget to change the script function to take the array by reference, instead of by value.
// AS code
int adder(int& x)
return x + x;
If you don't do this you will have a hard time trying to pass the vector object by value to the script function. It can be done, but the code will become quite bloated and ugly since I haven't prepared the interface for passing objects by value to script functions. It would involve allocating memory, then copy constructing the object to the memory, then calling SetArguments() to copy the memory to the context stack, and finally deallocating the memory without destroying the object.
I'm going to write a detailed article on how exactly to call script functions with various types of parameters and return types. In the future the interface will also be very much improved.