🎉 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!
How to register an array member in class ?
Until AngelScript supports static arrays, you can register this by registering your own array type, which you then register as the member of the Box class:
RegisterObjectType("vec3arr8", sizeof(Vector3[8]), asOBJ_VALUE | asOBJ_POD | asOBJ_CLASS);RegisterObjectBehaviour("vec3arr8", asBEHAVE_INDEX, "Vector3 &f(uint)", asFUNCTION(vec3arr8_index), asCALL_CDECL_OBJLAST);...Vector3 *vec3arr8_index(unsigned int idx, Vector3 *arr){ if( idx >= 8 ) asGetActiveContext()->SetException("out of bounds"); return &arr[idx];}
r = engine->RegisterObjectProperty( "Box", "Vector3@[] mVectors(8)", offsetof( ScriptBox, mBox.mVectors ) );
can I register the array like this ?
can I register the array like this ?
No, unfortunately not. The built-in array object is not compatible with C++ static arrays.
I wish I could say yes, but the changes are too complex for me to be able to implement this for the next version.
If you can live without the array being an array in the script you can also register it as 8 separate properties, e.g:
RegisterObjectProperty("box", "float m1", offsetof(Box, mVectors));
RegisterObjectProperty("box", "float m2", offsetof(Box, mVectors) + 4);
RegisterObjectProperty("box", "float m3", offsetof(Box, mVectors) + 8);
etc
If you can live without the array being an array in the script you can also register it as 8 separate properties, e.g:
RegisterObjectProperty("box", "float m1", offsetof(Box, mVectors));
RegisterObjectProperty("box", "float m2", offsetof(Box, mVectors) + 4);
RegisterObjectProperty("box", "float m3", offsetof(Box, mVectors) + 8);
etc
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement