How do I retrieve certain words from a document

0 favourites
  • 7 posts
From the Asset Store
Simple but fun word game. Restore an original word from shuffled letters.
  • Hello! I am making a wordpaste game and in it when the player writes a word the game should check is the word that the player has written in the dictionary and if it is a valid word. I have a document containing all the words of my language but I don't know how to retrieve that document and check is the word valid. Is there a way to do it?

  • You can use tokencount to see if the word exists in your document after you import your document as a project file.

    https://www.scirra.com/manual/126/system-expressions

    https://www.scirra.com/manual/141/files

    Edit: there is also a find() expression you can use, just discovered that after reading through the system expressions again.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • What I actually want to do is when a person writes for example a word "screen" the program detects the last 2 letters of that word and writes an entirely new word (which it picks up from the document from the list of words) and that word begins with the last 2 letters of the word that the person entered. Ex. "screEN", "ENtertainment". I've been trying to figure it out but I can't seem to do it. Any suggestions?

  • You can use the expression right(text,2) to get the two right most characters. You can use a dictionary to reference into an array based on those characters.

    Read in your words, get the right most characters. Check for that dictionary entry. If is exists, pick the array by UID, push the word onto the array. If it doesn't exist, create a new array, add the entry to the dictionary with the array UID, push the entry onto the array.

    Now you just need to grab the last two characters from the input, see if that entry exists in the dictionary, if it does, pick the array by UID, and grab some entry from the array.

  • But how do I save a list of words from .txt to a file format that Construct 2 can work with (like dictionary)?

  • Hey replying on my phone so I can only give a summary, but here goes:

    A basic parser of a text file will use the newline token for tokencount and tokenat.

    Use a loop to repeat tokencount(textfile,newline) times (repeat however many lines are in the text file). Tokenat(textfile,loopindex,newline) will give you the content of each line.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)