How do I Get a Random word with no Duplicates

Get help using Construct 2

Post » Mon May 26, 2014 5:07 am

I am trying to get a random word without any duplicates. It looks something like: Choose("Hi", "Hello", "How are you?"). But with alot more words. I was wondering how to make sure it doesn't ever use the same word twice. An example would be much appreciated.
B
7
S
1
Posts: 74
Reputation: 1,368

Post » Mon May 26, 2014 5:29 am

Get your words into an array, then set whatever to arr.At(floor(random(arr.width))) after getting a random element in the array you remove it.
B
47
S
14
G
7
Posts: 603
Reputation: 8,141

Post » Mon May 26, 2014 5:58 am

I'm haveing a hard time getting it. Heres a small example capx. Everytime I click the text field one of the random words will appear, but I still get duplicates. Do you mind taking a look?
You do not have the required permissions to view the files attached to this post.
B
7
S
1
Posts: 74
Reputation: 1,368

Post » Mon May 26, 2014 6:50 am

EncryptedCow is a ninja, but here is a capx I was going to post with the same idea he mentioned.
https://dl.dropboxusercontent.com/u/542 ... epeat.capx

@thedigitalchamp
In your capx the main issue is you aren't putting the words into the array.
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999


Return to How do I....?

Who is online

Users browsing this forum: Ashley, dop2000, jatoblendy, MathNook, tarek2 and 33 guests