Download

Can I refer to a UE4 class through string retrieved from XML file?

I’m working with Yarn (https://github.com/InfiniteAmmoInc/Yarn) to make dialogue for the game I’m developing and would like to be able to change simple NPC properties from text written in Yarn. Is there a way to refer to objects that are written in a std::string?

Currently, I retrieve the chunk of dialogue as a string from an XML file and then parse it to get the NPC dialogue as a string and the player options as a Vector of structs that have an index, a string containing what’s said and a string that indicates the node to navigate to if chosen.

I’d really like to be able to put some functions inside the dialogue text, like this:


Andrew: Nice to see you today

[Good to see you too!|GoodSee]]
{set Andrew.PosAttitude=1}And you’re looking nice today!|LookingNice]]

So if Andrew is an instance of my NPC class, I can write something in C++ to call Andrew’s PosAttitude property and set it to one. I can use my parser to pick out the strings so I end up with:

std::string code = “Andrew.PosAttitude=1”;
std::string class = “Andrew”;
std::string property = “PosAttitude”;
bool value = 1;

but how would I get from there to actually setting that property for that class?