Jump to content
  • Advertisement
Sign in to follow this  
gutripper

Multi-dimensional arrays?

This topic is 3069 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

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
Advertisement
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
multi2.resize(3);
multi2[0].resize(3);
multi2[1].resize(3);
multi2[2].resize(3);


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.

Regards,
Andreas

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!