Sign in to follow this  

Multi-dimensional arrays?

Recommended Posts

Hi, I recently discovered AngelScript, and I'm working on integrating it into a C++ game framework. I was wondering with Angelscript supports multi-dimensional arrays? I couldn't see them mentioned in the docs. Thanks,

Share this post

Link to post
Share on other sites
use a one dimensional array of length N*M and handle it as if it is it two dimesional.

index(a,b){ return array[a*M+b]}

not the answer to your question though.. sorry

Share this post

Link to post
Share on other sites
AngelScript has built-in support for multidimensional arrays, or rather, arrays of arrays. These are declared as follows:

// Declare a 3x3 matrix pre-initialized
int[][] multiarray = {{1,2,3},{1,2,3},{1,2,3}};

// Declare an empty array
int[][] multi2;

// Resize it to desired dimension

You can also register your template object type to function exactly the way you want. You can take a look at the add_on/scriptarray/scriptarray.cpp for an example on how that can be done. It registers a single dimensional array template, but you can easily expand it to multidimensional if you want.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this