Constructors

Started by
3 comments, last by WitchLord 19 years, 6 months ago
I just want to confirm, currently angelscript is unable to expose constructors with parameters, right? It would be nice to be able to do something like this: vec3 v(1,2,3); If you can do this, how? -Brian
Advertisement
This is not yet possible. What you can do is to write factory functions that return an initialized object.

Although, you could also wait a little, as I have received a contribution from Andres Carrera that will add constructors with parameters. I still have to incorporate it and test it though, but I hope to have that done in at most a couple of weeks.

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

Great! It's looking good.
It's great to hear that angelscript is going to support constructors with parameters !

My actualy solution is to provide exposed global vars (mainly structures) that are used when angelscript call constructors.

1/ Registrer structure datatype
2/ Register global var of that type
3/ Register the class and its constructor

then in the script

void myFunc(){  gConstParam.test = "the value";  gConstParam.second = 2;  MyClass theVar;}


of course this is not perfect, since you have to define/register on struct/global var per class constructor that need data when constructor is called. But it works fine for now !


Constructors with parameters are now fully supported by AngelScript.

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