How do I use While

0 favourites
  • 4 posts
  • Hi everyone,

    how is the while condition used properly?

    I'm guessing it's what I need for what I want to do, but cant get it to work.

    I'd like to add two values to random cells of an array, but make sure that i dont write in to the same cell twice. I figured I might want to reroll the line until I find one how's value is zero, but i dont get how to articulate that in C2.

    Thanks for your time!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, you can do this with While:

  • Thanks dop2000

    Would I be able to use break loop instead of the comparison, too?

    Also, since I'd like to have it happen on start of layout, cant this also be done in a single pass?

    I feel like my approach might not the most streamlined, would you suggest another approach altogether?

  • Would I be able to use break loop instead of the comparison, too?

    Yes, you can use "break" - add a sub-event in the loop, in this sub-event check if loopindex>1000, then break loop. But it's easier just to add this condition to the While loop itself.

    Also, since I'd like to have it happen on start of layout, cant this also be done in a single pass?

    You mean add two cells in one loop? Yes, it's possible:

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