How do I have random word generator make a word only once?

Get help using Construct 2

Post » Sun Jul 02, 2017 12:27 pm

hi,
I am trying to make a word generator create words from given letters, but it can create a word several times.
I am using a wordlist array...

I only want to see a word only once in the produced list?

can anyone help me?
my capx:

http://www.englishpedia.net/capx/generator.capx
B
15
S
9
G
2
Posts: 24
Reputation: 2,425

Post » Sun Jul 02, 2017 2:07 pm

When the random word is generated keep it in an array, then when the next generated word is created compare the string with the array values if they are equal recall the random generation function.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Sun Jul 02, 2017 3:06 pm

In fact I tried to do that but it didn't work. I cannot compare two array values. Is there a way to compare two array values
B
15
S
9
G
2
Posts: 24
Reputation: 2,425

Post » Sun Jul 02, 2017 3:41 pm

http://www.blackhornettechnologies.com/Construct2Stuff/tetuan_randomwordgen.capx
Keep an array of your generated words, and just check if it's in there.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Sun Jul 02, 2017 9:45 pm

Or bring all words into the array.
Choose by ...
Index = floor(random(0,array.width))
word = array.at(index)
use that action Array > Delete to delete the entry at x = Index to exclude it from the next random choice.

When the array.width = zero, then all words are used.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 40 guests