Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Checking a range

    Beginners
    4
    7
    228
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      ThePickleTickle last edited by

      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

      1 Reply Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team last edited by

        You can use the clamp function to ensure a value remains between two values: https://fuzearena.com/help/view/clamp

        1 Reply Last reply Reply Quote 0
        • T
          ThePickleTickle last edited by

          Thanks for the reply pianofire, I'm not looking to restrict the first value, only check if it has passed through the range

          1 Reply Last reply Reply Quote 0
          • vinicity
            vinicity F last edited by

            Check if the clamped value differs from the original?

            1 Reply Last reply Reply Quote 0
            • T
              ThePickleTickle last edited by

              The answer might be obvious, but how would I check that? as i dont understand how the clamp output helps me do that

              1 Reply Last reply Reply Quote 0
              • PB____
                PB____ last edited by

                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
                
                1 Reply Last reply Reply Quote 4
                • T
                  ThePickleTickle last edited by

                  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

                  1 Reply Last reply Reply Quote 2
                  • First post
                    Last post