🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Constructors
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
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.
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.
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
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 !
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 !
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement