Need help generating word sequence.

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)