Checking a range
-
Hi quick question.
Is there a preexisting function that will check if a value is within a limited range of another value? Or is the best way just to do an IF statement with 2 conditions using the max and min value through a custom function?
Thanks
-
You can use the clamp function to ensure a value remains between two values: https://fuzearena.com/help/view/clamp
-
Thanks for the reply pianofire, I'm not looking to restrict the first value, only check if it has passed through the range
-
Check if the clamped value differs from the original?
-
The answer might be obvious, but how would I check that? as i dont understand how the clamp output helps me do that
-
It would make sense to just use two conditions in an if statement:
if value >= min and value <= max then /* stuff */ endif
Or if you'd like to use clamp for this:
if clamp(value, min, max) == value then /* stuff */ endif
Or you could write your own function using either implementation:
function isInRange(value, min, max) return value >= min and value <= max if isInRange(value, min, max) then /* stuff */ endif
-
Pb__ thanks for clarifying
I slept on it and when I woke up realised what pianofire and vinicity meant instantly.. guess my brain was just a little fried yesterday
Thank you all