x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 damn 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?

Product Version: UE 4.10
Tags:
more ▼

asked Jan 14 '16 at 02:50 PM in Blueprint Scripting

avatar image

PSyCHoHaMSTeRza
10 1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

alt text

Here is an example of the function being used.

alt text

Make it a great day

findwordhelp1.png (112.8 kB)
findwordhelp2.png (88.0 kB)
more ▼

answered Jan 14 '16 at 04:08 PM

avatar image

Rudy Q ♦♦ STAFF
47.3k 545 132 525

avatar image PSyCHoHaMSTeRza Jan 15 '16 at 01:20 AM

Oh yes this is fantastic! Thank you very much

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question