Need help generating word sequence.

Get help using Construct 2

Post » Sun Jun 04, 2017 10:59 am

Okay, so say I have 10 words I can use for a sequence. For simplicity, I'll just use A, B, C, D, E, F, G, H, I, J.
If I want to generate something like A C D E F J I G H then append it to a text object, how do I do that?

Any help would be very appreciated. I have been trying to do this for a while but cannot figure it out. :D
B
4
S
1
Posts: 7
Reputation: 374

Post » Sun Jun 04, 2017 11:27 am

Use the choose system expression 10 times. and it will generate a random string of words.

Example: global variable string add to choose("A","B","C") repeat 10 times.
Last edited by imhotep22 on Sun Jun 04, 2017 1:12 pm, edited 1 time in total.
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 Jun 04, 2017 12:46 pm

Thanks! What if I don't want it to repeat the same character twice? Such as
"A, B, C, b, D, e, E" being good while
"A, a, B, B, C, D, d" being bad?
B
4
S
1
Posts: 7
Reputation: 374

Post » Sun Jun 04, 2017 1:11 pm

Well you can add a sub event to check if the next word is same as the previous one, and if it is just recall the function or the event to change it. You will also need to keep a temp variable where you will keep the last generated word.

It will be harder to implement it like that, I suggest using a function to call the word generator.
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 Jun 04, 2017 2:56 pm

@EamonWong

A while ago I made myself a function to shuffle a comma separated list, and it sounds like that is what you need.

Shuffle Comma String capx (r244)

The function is self-contained, you just pass it the string as a parameter and it returns it to you re-ordered, so as long as you have the Function object in your project, you should be able to copy and paste the function from the example.
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
33
S
9
G
7
Posts: 450
Reputation: 6,780


Return to How do I....?

Who is online

Users browsing this forum: David181 and 11 guests