Advertisement

Multi-dimensional arrays?

Started by February 21, 2010 07:30 PM
1 comment, last by WitchLord 14 years, 9 months ago
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,
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
Advertisement
AngelScript has built-in support for multidimensional arrays, or rather, arrays of arrays. These are declared as follows:

// Declare a 3x3 matrix pre-initializedint[][] multiarray = {{1,2,3},{1,2,3},{1,2,3}};// Declare an empty arrayint[][] multi2;// Resize it to desired dimensionmulti2.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

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