# [SOLVED] Check if a variable is between two values

Hi!
I’m making a coffee shop management minigame where the player has to create drinks using coffee, milk and foam. The idea is that the player will receive a recipe with the required % of each (example: 45% coffee, 45%milk, 5% foam) and will have to match those values on a coffee machine.
I would like to give the player a safe range, where, for example, if he made the drink with 42% coffee, 46% milk and 3% foam it would still be right, but I’m having trouble on finding a function or logic that would validate any value between a given range.
Each item of the recipe is a variable that will be generated randomly, so I want something that would be like:
CupCoffee = Coffee + or - 5, where any value between Coffee + 5 and Coffee - 5 would be valid.

Does anyone have experience with it?

Welcome. You can use the compare 2 numbers condition. It’s in [other conditions] [events and control flow]

abs(CupCoffee - Coffee) <= 5

You can use multiple conditions per event. One for each ingredient.

“abs(#) returns the absolute value of a number. The number without its sign”

You can type abs() or use the expression builder. absolute is under [mathematical tools]

It worked perfectly! Thank you so much, Keith!

1 Like