I have a config file that stores two arrays of strings. One array of strings holds the names of all of the loaded mutators. The other array of strings holds the mutators that are available but not currently loaded. When I start a new game, I just append “?Mutator=___” to the start command, for each mutator currently loaded.
That works fine. But not all mutators are valid for each game type. I’m trying to make a way to check that a mutator is valid. What I think I would like to do is this:
- Store the available mutators as strings in a config file, as I have been doing.
- Use a string to instantiate a new mutator object instance dynamically. We’ll call the new instance NewMutator.
- Create an interface with a function that will tell me which game type the mutator was designed for.
if(MyMutatorInterface(NewMutator) != none) AllowedGameType = MyMutatorInterface(NewMutator).GetDesiredGameType();
I don’t know how to do step 2. Can I take a string, use it as the name of a class, and then create a new instance of that class dynamically?