• Advertisement
Sign in to follow this  

How to register an array member in class ?

This topic is 3665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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];
}

Share this post


Link to post
Share on other sites
r = engine->RegisterObjectProperty( "Box", "Vector3@[] mVectors(8)", offsetof( ScriptBox, mBox.mVectors ) );

can I register the array like this ?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement