Which variable has the biggest value ?

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi all.

    Let's say we have apple, pear, banana, watermelon variables. And they have random values.

    How can I get which one has the biggest value ? And If there are 2 or 3 varibles which have same biggest values, then learn that ?

    This is a very long way if there are more than 4 varibles;

    if apple > pear and apple > banana and apple > watermelon

    if pear > apple etc ect.

    Also if there are 2 variables which have same biggest values if condition goes bigger :(

    Is there any easier way ? Thank you very much.

  • Try something like this:

    variable largest

    variable largestValue

    for each item

        item.value > largestValue

        largest = item

        largestValue = item.value

    Items could be a family, a sprite or whatever fits your needs :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Or just use the max function.

    largestValue = Max(apple, pear, banana, watermelon)

  • Or just use the max function.

    largestValue = Max(apple, pear, banana, watermelon)

    Nice, didn't know of that!

  • vee41

    thank you very much. I'll try that too.

    Or just use the max function.

    largestValue = Max(apple, pear, banana, watermelon)

    Wow I didn't know this either.

    Well what if there are 2 variables which have same max values then what will be the result ?

    Thank you

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