• Advertisement
Sign in to follow this  

Constructors

This topic is 4860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 !


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement