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

Get help using Construct 2

Post » Thu Apr 30, 2015 1:56 am

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
B
3
Posts: 5
Reputation: 189

Post » Thu Apr 30, 2015 2:44 am

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......
B
9
S
2
Posts: 54
Reputation: 638

Post » Thu Apr 30, 2015 5:35 am

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.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Tue May 12, 2015 4:05 am

Image

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?
B
3
Posts: 5
Reputation: 189

Post » Tue May 12, 2015 8:12 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue May 12, 2015 8:53 am

yuuzo wrote: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?
B
3
Posts: 5
Reputation: 189

Post » Tue May 12, 2015 9:09 am

I guess this is one way to do it:

textbox on text changed
Dictionary has key textbox.text
> perform action
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue May 12, 2015 10:08 am

LittleStain wrote: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 ..
B
3
Posts: 5
Reputation: 189

Post » Tue May 12, 2015 10:41 am

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri May 15, 2015 8:49 am

LittleStain wrote: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
B
3
Posts: 5
Reputation: 189

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 38 guests