How do I use a lot of "compare text"?

0 favourites
  • 11 posts
  • Hello guys okay?

    I'm with the following problem and would like you guys to help.

    I made a textbox and put the event "compare text" that's when the person typing the word that I specify the action will occur, so far so good, but I wanted to put several words to give in the same action, I could duplicate this event several times there and just go changing the words, would work, but there are many words, some 200.

    there is a way to in one event, I specify that it is entered in the textbox any of those words as opposed to just one, and any of them that is entered, activate the action?

    I thank since then and wait response

    graciously

    Gabriel

  • Maybe make the part that "Compares text" into an or event and then place each word into that or event? You could also probably make an array and then check the word against the array and then do array condition contains value textbox text......

  • Put the words into a text file, each word on its own line.

    Then at start, ajax request the project file.

    When the ajax-request finished, do a for loop from 1 to tokencount(ajax.lastdata, newline): dictionary add key: tokenat(ajax.lastdata, loopindex-1, newline) with value: 0

    Now each word is a key in your dictionary.

    Now you can use the comparison:

    dictionary has key "yourtexttocompare": do stuff

    Ofc you can also use a regex match, then you don't need the dictionary.

  • I do this, and not work.

    "abelha" is one of 500 words on my "ab.txt" file.

    How do i use, regexmatch in this situation? you show me a example?

  • I guess the ajax request isn't processed yet when you do the for loop..

    You should check if the ajax event is completed before you use the lastdata..

    create an event Ajax on completed "letras ab"

    put the system for loop as a subevent of that and all should work..

  • create an event Ajax on completed "letras ab"

    put the system for loop as a subevent of that and all should work..

    OK, its work, now I need when word (or one of the keys) is entered in the textbox the action happens, how do it?

  • I guess this is one way to do it:

    textbox on text changed

    Dictionary has key textbox.text

    perform action

  • I guess this is one way to do it:

    textbox on text changed

    Dictionary has key textbox.text

    > perform action

    Congratulations LittleStain, this work fine.

    but now I have another problem, see if you can help me:

    example, within my text file I have the words: ke and key.

    I want the action happens if the player enter any of the words, but this way, if the player wants to enter "key" before he enter the letter Y, the action will already occur because the word "KE" is also one of the words .

    so I wanted to do something that only happens to action when the player finished typing the desired word, and this, it is a correct word (in this case would be "KE" or "KEY")

    I tried for a condition that says that this event only occurs when the player press ENTER, but I could not ..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Would this work?

    create a button (you could set the text to "Check Word" or something)

    button on pressed

    Dictionary has key textbox.text

    perform action

    or add the keyboard object

    keyboard on key pressed - return

    Dictionary has key textbox.text

    perform action

  • button on pressed

    Dictionary has key textbox.text

    > perform action

    Thanks a Lot this work fine, but i have another problem, you can help-me again? *-*

    the event went well, but I did another event in the same way, but with another dictionary and their keys.

    the result I want is this: if the player enter one of the keys of the Dictionary1, the object 1 will appear and destroy the object 2 instead.

    However, if the player enter a key of Dictionary2, the object 1 will be destroyed and the object 3 that will appear instead.

    But what is happening is that the Dictionary1 event functions normally and appears the object 2, but if I use a key of Dictionary2 the objects 1 and 3 appears together, one above the other.

    How could to separate it?

    I thank since then and wait response

  • Without seeing how you have your events set up, I can't answer this question.

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