🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Passing array to registered functions

Started by
0 comments, last by WitchLord 9 years, 7 months ago

Dear all,

I have problems to pass script arrays to registered functions. I searched for examples without success.

In the script I have:


int[] Arr = { 123, 456, 789 };

void main(void)
{
  PassArray(Arr);
}

Then I registered a function:


engine->RegisterGlobalFunction("void PassArray(const array<uint32> &in Arr)",
                               asFUNCTION(PassArray), asCALL_CDECL);

But compiling the script I have the error:


 No matching signatures to 'PassArray(int[])'

I also tryed all possible variations adding and removing & and @ in both registration and script, without finding any correct way.

I coudn't check the real execution of this function but I thought I could declare it in C++ code as:


void PassArray(CScriptArray &Arr);

Any Idea on how to pass arrays to native functions?

Thanks.

Mau.

Advertisement

array<int> is not the same as array<uint32> that's why your function isn't found. Register the function with "void PassArray(const array<int> &in)" and it will work.

Yes, the C++ method should have the signature you used.

If you want example code to look at, I suggest you take a look at the scriptstdstring add-on's utility functions split and join. These show exactly how to receive an array, and also how to return a new array.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement