kyriakos876 wrote:So if I exceed by 1 the max limit it will start from the min and climb back to the max?
Nope, it will be set and stay at the max.
While it is below the min it will be and stay the min. While it is above the max it will be and stay the max
Clamp() in and of itself is in no way any kind of "loop".
That why when you want grow and shrink something like a FontSize for instance, you need two ActionList(s) in the ActionTimer Measure:
One that adds a value to the #Variable# controlling the FontSize, using Clamp() (or you could just as easily use Max()) to restrict the value to the highest FontSize you want to allow. Whatever formula you have adding to the value will keep "trying" to add to it after it hits max, but just won't be able to. Clamp() will steadfastly refuse to the let the number go above the max.
One that subtracts a value from the #Variable# controlling the FontSize, using Clamp() (or you could just as easily use Min()) to restrict the value to the lowest FontSize you want to allow. Whatever formula you have subtracting from the value will keep "trying" to subtract from it after it hits min, but just won't be able to. Clamp() will steadfastly refuse to let the number go below the min.
Clamp() in and of itself in no way ever "starts over". That's not what it is about.
We use Clamp() in ActionTimer because it can be hard, or even impossible, to get "exactly" the right number of times to "repeat" adding or subtracting some "increment" to/from the value, creating some "total amount of change", that ends up not slightly over-runing or under-running the starting and ending values you want. This is particularly true in things that must be integers, like FontSize or X, or W. The idea is to "divide" the amount of change by the number of steps you want to do it in, and that is likely to end up being a few over or a few under the target.
We also use Clamp() in ActionTimer because you are likely to want to "stop" one action before it it through, and "start" the opposite one. If we have an example of changing the alpha value of a meter from 0-255, and we do it in 255 steps, if we "stop" it while it is on its way up, but it is currently only at 200 for instance, the other opposing action will try to move down, by subtracting in 255 steps. Without Clamp() that would end up with a value -55, which is completely invalid for an Alpha value, and would be disastrously wrong in an X or W. When Clamp(#Var#-1,0,255) sees the number at 0, the next 54 times you try to subtract from it, it will just stubbornly keep the number at 0.
Clamp() just says "Ask away, I'm not allowing the number to be below this, or above that."
How it works under the covers is:
Clamp(number,minvalue,maxvalue)
If number is less than minvaluue, then number is forced to be equal to minvalue.
If number is greater than maxvalue, then number is forced to be equal to maxvalue.