How do I compare word in a text?

Get help using Construct 2

Post » Tue Oct 11, 2016 10:21 pm

I want to do this ;

If text sentence have "ball" word -> make text color =[rgb (255,255,255)

Example text object : "The ball rolled across the lawn."
B
29
S
14
G
1
Posts: 133
Reputation: 3,216

Post » Wed Oct 12, 2016 5:01 am

B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Wed Oct 12, 2016 1:56 pm

korbaach wrote:simplest way.... [Plugin] tag text

Image


redTagText.capx


You and rax are a savior! Thanks.
B
29
S
14
G
1
Posts: 133
Reputation: 3,216

Post » Wed Oct 12, 2016 3:24 pm

If you want to make the whole text red then you could also just use find(txtBox.text, "ball")

Scroll down to the Text section and several expressions you can use: https://www.scirra.com/manual/126/system-expressions
ImageImageImage
B
44
S
26
G
11
Posts: 520
Reputation: 10,506

Post » Fri Oct 14, 2016 7:15 am

badmoodtaylor wrote:If you want to make the whole text red then you could also just use find(txtBox.text, "ball")

Scroll down to the Text section and several expressions you can use: https://www.scirra.com/manual/126/system-expressions


Ok,i got this but another problem appeared :(

Can i compare a letter in textbox.text ?
B
29
S
14
G
1
Posts: 133
Reputation: 3,216

Post » Fri Oct 14, 2016 11:18 am

takamoto wrote:Ok,i got this but another problem appeared :(

Can i compare a letter in textbox.text ?


It would be the same just replace "ball" with the letter ("r")—not sure I understand what the problem is...
ImageImageImage
B
44
S
26
G
11
Posts: 520
Reputation: 10,506

Post » Fri Oct 14, 2016 1:24 pm

badmoodtaylor wrote:
takamoto wrote:Ok,i got this but another problem appeared :(

Can i compare a letter in textbox.text ?


It would be the same just replace "ball" with the letter ("r")—not sure I understand what the problem is...


Sorry,my bad.

I'm making a word search game.
I have a word list.
I load this list with ajax.
I give randomly 8 letters and player should create words using those letters.
Here's my problem;

I can't check player is used my letters or not.


Ugh! I can't explain my problem because of my english. :cry:

Here's my capx : https://drive.google.com/file/d/0B9xK1e ... gxcWc/view

Image

In this screenshot i entered "float" but those letters are different than the letters which are created by game below.When i entered "float" the game search the wordlist and founds "float" and says "it's ok" and give me points.It should be wrong because i didn't use the letters which are created randomly below.
B
29
S
14
G
1
Posts: 133
Reputation: 3,216

Post » Fri Oct 14, 2016 2:50 pm

Okay, I think I get your situation. I can't look at your capx now but will try to tomorrow if you are still having problems.

So I assume from this they are typing in the letters on the keyboard?

One idea off the top of my head is instead of using a textbox to detect keyboard input and only do anything if it matches.

Either way, I would probably start by loading the letters into an array.
Create a variable that starts as false (boolean or 0)
Loop for array.width
-if [letter to check] = array(loopindex) set variable to true/1
If variable = true/1 then update text/allow the letter to be added.

If you let them type anything in the textbox then you would have to check it after and remove as opposed to allow. But you can do the same in a nested loop
Loop for textboxt.length
-Loop for array.width
--if [letter to check] = array(loopindex) set variable to false and end loop


Can't look at the capx right now so not sure what you have already and if this helps or not...
ImageImageImage
B
44
S
26
G
11
Posts: 520
Reputation: 10,506

Post » Fri Oct 14, 2016 3:14 pm

B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Fri Oct 14, 2016 9:44 pm

korbaach wrote:arrayLetters.capx



Thank you.Problem solved.
B
29
S
14
G
1
Posts: 133
Reputation: 3,216

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests