"choose" exceptions

1 favourites
  • 3 posts
From the Asset Store
Choose the right elementary arithmetic and complete the equation!
  • I have 2 variables, the first(var1) is a random integer number beetween 1 and 4, the second must be a random integer beetwen 1 and 4 except var1.

    How I can say to construct "except var1"? There is another way to do it?

    This is only an example, the exceptions can be more than 1, the number can be more than 4 or can be a string.

    I want to learn how apply this mechanic because i need it in many situations.

    Thanks for the help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • the easiest way to make sure you get unique results, without repeats, is to put all the possible numbers/strings in an array. Then pick a random entry out of the array, and delete that entry so it can't get picked again.

  • If these numbers are associated with object instances, it's easier to pick instances directly. For example, if you need to pick a random playing card - put all cards on the layout, pick one at random. Once you picked the card, mark it as used (set instance variable). Next time pick a random card excluding used:

    Card isUsed=false
    System pick random Card
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)