0 Favourites

How do I compare values and if not equals pick highest?

  • I need to check the values of the same variable in the 25 instances and get the instance that have the highest value if it is unique or request that the user changes the equal values. I believe I will need to use the "Sprite>Pick highest" event but I don't know how to build it.

  • I'd create a Function that fills an Array with all the values your looking at and then pick the highest value in the array.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Local variable TheHighest

    Sprite>Pick highest

    _____Set highest to the highest instance value

    Sub ____ System > pick all

    _________ Sprite > Compare instance variable =? TheHighest

    _________System > compare 2 values ... Sprite.PickedCount =? 1

    ___________________actions run if there is only 1 TheHighest

    _________Else

    ___________________actions run if there is more then 1 TheHighest

  • Local variable TheHighest

    Sprite>Pick highest

    _____Set highest to the highest instance value

    Sub ____ System > pick all

    _________ Sprite > Compare instance variable =? TheHighest

    _________System > compare 2 values ... Sprite.PickedCount =? 1

    ___________________actions run if there is only 1 TheHighest

    _________Else

    ___________________actions run if there is more then 1 TheHighest

    I was doing something like that but I forgot to include the "compare 2 values" condition in the same event of the two others. Thank you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
378 33,258
part12studios's avatar
part12studios
Unread hot topic
99 10,137
karshinkoff's avatar
karshinkoff
Unread hot topic Locked topic
115 17,211
Kyatric's avatar
Kyatric Construct Team Support