Path: /sdk/add_on/scriptarray/
The array
type is a template object that allow the scripts to declare arrays of any type. Since it is a generic class it is not the most performatic due to the need to determine characteristics at runtime. For that reason it is recommended that the application registers a template specialization for the array types that are most commonly used.
The type is registered with RegisterScriptArray(asIScriptEngine *engine, bool defaultArrayType)
. The second parameter should be set to true if you wish to allow the syntax form type[]
to declare arrays.
Compile the add-on with the pre-processor define AS_USE_STLNAMES=1 to register the methods with the same names as used by C++ STL where the methods have the same significance. Not all methods from STL is implemented in the add-on, but many of the most frequent once are so a port from script to C++ and vice versa might be easier if STL names are used.
Compile the add-on with the pre-processor define AS_USE_ACCESSORS=1 to register length as a virtual property instead of the method length().
This function shows how a script array can be instantiated from the application and then passed to the script.