Scan text for certain words

Hi there.

I want to make an old school text adventure (like Zork), but I have trouble figuring out how to interpret the user input.

Here is kinda what I want to do.
Player is in a room. There is a sword and a shield. Player inputs “pick up sword”. That input is saved as a text variable called CurrentInput. Now, the game needs to scan that CurrentInput for certain keyphrases, eg “Go to” or “pick up”. Afterwards it scans for objects in the level, eg “sword” or “shield”. It should be able to bypass other words, so if the player inputs “just pick up the ■■■■ sword already” it just needs to recognize the “pick up” and the “sword” parts. Once the booleans for “pick up” and “sword” are set to true, it executes the action.

I am currently trying to do this in UMG.

Is there a way to scan a text variable for certain words like that? Is there an easier way to do it than the way I described?

Hello PSyCHoHaMSTeRza,

I have an example of a way to pick out words from a sentence. I have provided it below. I hope this information helps.

Example:

This is a function that I have created. It takes in text and converts it to a string so that a substring can be found. After this I use a get substring node to pull out the word I am looking for (if it is there) so as to compare it to the word I am searching for. If this returns true the sentence contains the word and if not, the sentence does not.

Here is an example of the function being used.

Make it a great day

Oh yes this is fantastic! Thank you very much