arrays anyone

Started by
2 comments, last by leblebi 20 years ago
Hi everybody. This may sound silly but, how can I use arrays in the scripts? I couldn''t find anything about them. Thanks
Advertisement
Not a silly question at all. You didn''t find anything about them because they are not yet supported.

I''m working on a solution for this to come out in the near future. In the meantime you can register objects with methods for accessing array elements.

Example:

struct MyArray
{
void SetLength(int numElements);
element &Item(int index);
int numElements;
element *obj;
};

Where element can be whatever type you want to store. It is not so elegant as native support for arrays, but it is a solution that works.

The reason I haven''t just added the index operator [] for pointers is that I want AngelScript to be secure, using the index operator directly would allow out-of-bounds accessing in scripts and could easily compromise security for both application and operative system.

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

How about adding the [] operator as an overloaded one, so the program can do the bounds checking itself?
That is already on the list of todos. There is not much missing to add this feature. AngelScript already supports overloading for the dual operators. And adding support for the unary operators is a similar process.

Unfortunately I''m currently very short on time right now. What I was thinking was going to take a couple of days to finish is taking weeks, just because I only get a couple of hours in the weekend to work on AngelScript. This shortage on time will probably last at most until the middle of May if things go as planned.

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library

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