# Single expression to select lowest value?

0 favourites
• 7 posts
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
• I have a Repeat loop. I have 2 variables to compare and I would like the repeat loop to repeat the lowest value. Is there a single expression that I can put in the Repeat condition so it can be:

"Repeat: Lowest Variable1 | Variable2 times".

I was wanting to avoid an unneeded variable and conditions, but know how to do it this way.

• Min(variable1,variable2) will give you the lower of the two variables.

• Nevermind I found it.

Max(a,b,c)

Min(a,b,c)

"max(a, b [, c...]), min(a, b [, c...]) Calculate maximum or minimum of the given numbers. Any number of parameters can be used as long as there are at least two."

*************edit***********

Yes thank you oosyrag

I was posting this as you posted your message. I was searching for 'lowest' instead of 'min'. I am not sure how I found min, probably just by chance.

• So Max(a,b,c), Min(a,b,c) will get me the highest/lowest value. Is there a way I can select the variable though?

Variable1=5 and Variable2=7

Min(Variable1,Variable2)

Will give me 5. Is there an expression so I can get Variable1 back as a result instead of it's value? I know how to get it using conditions and actions though, but want to avoid extra conditions and actions if I can. I am thinking I won't be able to and I will have to use one condition, a variable and an action. I am hoping there is an expression I can wrap around Min() though.

• Off the top of my head, I would use an array to do this instead of two variables. Then you can use array.indexof(min()) to get the position of the value.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• I was hoping for an expression, they reduce the amount of conditions and actions if used correctly. Using min() and max() I will get everything I need except for selecting the name of the variable with longest length. I read through a lot of the manual and didn't see an answer to my question. For now I will just use a condition to compare and set a variable to the name of the variable with the longest length. I try to increase performance everywhere I can. An expression would be best though. I try to keep my eventsheets as short as possible. I think an array would use more device resources than a condition and action.

• An array is just a set of variables grouped together like a spreadsheet.

• 7 posts