Thanks Andreas, for the quick help! Two problems solved! I am currently implementing AngelScript for the second iteration of my engine, Nephilim 2. It is coming out as a full blown pre compiled engine, with full scripting support to make any kind of game with it, 2D or 3D :) So far, so good, thanks for the awesome library.
I have one more question, if you don't mind. The documentation is good, but sometimes I fail to find/understand the right tool for the job in there.
I attach behavior scripts to my game world's entities. Then, every game tick, I call Update() on my behavior, so it does something with its parent entity.
To do this, the script has access to an entity variable, an handle to a Entity object. For now, the Entity class is basically a collection of pointers to components. So, entity.transform is either a valid transform or null. The same applies to other components like terrain, camera, light, mesh, collider, sprite etc.
The problem is that the amount of component types is growing fast and its a really bad design decision to list every component type available as a field in the Entity class. For example, a entity with only a Transform, will still have dozens of pointers to components taking space, even if they are all null. Even worse, when I create a component dynamically through scripts. Because of this I need a way to dynamically get the component by a identifier string/integer.
In C++, I would solve it by having a template function, which I'd call as entity.getComponent<BoxCollider>(); It would return null if there was no BoxCollider or the reference to the actual BoxCollider instance. Is this doable with angelscript?
I need to access the entity's components dynamically either with type, integer or string. As simple as possible, if possible, any ideas? :)