I'm still rather new to Angel script but have managed to get most of it down. There are however a few things that I'm still unsure about.
The main one is the ref use in Angel script which from the looks of it is the same as a pointer or reference in c++. However when do I want to be using this over a value. For example if I am registering a class i wish to create within the script do I class it as a reference and set up (I believe) a factory function for it to construct a new instance within c++ and then reference it back to angel script or should I just use a valve and let angel script deal with its construction of the instance.
The other thing that I am unsure about (though I should do some test first before asking) is what do I do for pointer array and template returns/parameters.
Thanks for the help
Understanding some basics
Members - Reputation: 269
Posted 18 April 2013 - 08:00 AM
Moderators - Reputation: 3843
Posted 18 April 2013 - 06:51 PM
Reference types are those that are allocated on the memory heap rather than on the stack. Basically you'll want to use reference types for any type that should be able to outlive the scope in which it is created. On the other hand value types are those that will be allocated on the stack (or as local members of other objects). As these types can't outlive the scope in which they are created they should be used for those types that are used for quick calculations and can then be discarded. Also, for value types you'll want to keep the size and complexity down to a minimum. If the type is large or complex it is an indicator that the type should probably be a reference type.
C++ pointer arrays unfortunately have no match in AngelScript, so the recommended way of handling them is by wrapping the function to copy the content to a CScriptArray (see the add-ons).
C++ templated types are determined at compile type. You'll need to register the template function for each combination of return type and parameter types you expect the scripts to use.
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game