How do I choose random letters from string variable?

Get help using Construct 2

Post » Wed Mar 16, 2016 11:48 am

Let me explain myself better: I'm building a quiz/trivia app, the idea is, on start of each layout, it randomize the letters displayed. I already managed to do this, like shown here: Image

So basically, it randomizes the letters on start of layout. And it doesn't repeat the same letters. But now, I want to add multiple same letters in the variable, like this example: A, B, C, D, E, E, A, G, H

If i change the strings, it won't work because the While loop is made to not repeat the same strings. So how I do this easily?

Thanks and I hope I explained myself clearly!
B
24
S
6
Posts: 64
Reputation: 1,436

Post » Wed Mar 16, 2016 1:48 pm

Instead of setting the letter randomly through the system action why don't you draw it straight from the array itself (choosing a random cell of course). That way you could easily control what is in it and just delete the cell when the letter is chosen.
ImageImage
B
118
S
23
G
7
Posts: 1,070
Reputation: 12,964

Post » Wed Mar 16, 2016 3:19 pm

GenkiGenga wrote:Instead of setting the letter randomly through the system action why don't you draw it straight from the array itself (choosing a random cell of course). That way you could easily control what is in it and just delete the cell when the letter is chosen.

Can you please give me an example on how to do it?
B
24
S
6
Posts: 64
Reputation: 1,436

Post » Wed Mar 16, 2016 6:59 pm

just delete(disable) condition(just condition,not actions)
Array_letters X Contains Value random_letter 8-)
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Wed Mar 16, 2016 11:49 pm

korbaach wrote:just delete(disable) condition(just condition,not actions)
Array_letters X Contains Value random_letter 8-)

Yeah thanks, I already tried that, but now it gives me 3/4 times the same letter randomly. You see what I mean?
Maybe i should try and randomize another array containing the placement of the letters?
B
24
S
6
Posts: 64
Reputation: 1,436

Post » Thu Mar 17, 2016 1:01 am

No worries, https://db.tt/3b7YVAzB

You will have to change it to suit your needs but this should show you how.

Press space to get a random letter from the array. Using debug you can see the cells being removed
.
ImageImage
B
118
S
23
G
7
Posts: 1,070
Reputation: 12,964

Post » Thu Mar 17, 2016 10:01 am

Message: DonRIF can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
GenkiGenga wrote:No worries, https://db.tt/3b7YVAzB

You will have to change it to suit your needs but this should show you how.

Press space to get a random letter from the array. Using debug you can see the cells being removed
.

God bless my brother!
B
24
S
6
Posts: 64
Reputation: 1,436


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 19 guests