Sign in to follow this  

Create class by value of string

This topic is 1195 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

Basically what I'm trying to do is create an object by the value of a string (the string will refer to the Class that the object needs to be). This is to be used in an Item/Inventory system for the game I'm working on. What will happen is I'll save items to a folder based on their object type. Then later when I load those, I need to be able to recreate that object according to the class it used. Is this possible in AngelScript?

Share this post


Link to post
Share on other sites
Yes, it is perfectly possible. You can use asIScriptModule::GetObjectTypeByName to get the type and then asIScriptEngine::CreateScriptObject to create the instance.

If you plan to serialize the content of objects you can use the CreateUninitialedObject instead and the manually initializing the members by iterating over them.

Share this post


Link to post
Share on other sites

This topic is 1195 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this