Jump to content
  • Advertisement
Sign in to follow this  
luveti

Create class by value of string

This topic is 1555 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!