User Tag List

Results 1 to 7 of 7

Thread: Expression help: Loop a value within a range

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Expression help: Loop a value within a range

    This is slightly difficult to explain for me. I need to loop a value within a range. The easiest comparasion is that "x mod y" loops x within the range 0 to y.

    Now, I instead need to loop x within the range y to z, and it needs to work with positive and negative numbers for all three variables. Anyone know a good expression for this?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Expression help: Loop a value within a range

    Share the formula for 0 to y?

  3. #3
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Expression help: Loop a value within a range

    it would be:


    (x - y) mod (z - y + 1) + y

    except that mod will malfunction when it is negative
    see the handy chart on wikipedia for why: http://en.wikipedia.org/wiki/Modulo_operation

    so you can just offset it by your biggest possible margin, something like:


    (x - y + (z - y + 1) * 500) mod (z - y + 1) + y

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Expression help: Loop a value within a range

    Looki: I did in the same sentence you quoted

    Pixelthief: Awesome, thanks! That'll definitely help me a lot!

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Expression help: Loop a value within a range

    Oh, sorry, I thought you had a more advanced formula for negative numbers.

  6. #6
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Expression help: Loop a value within a range

    Ouch, yeah, you're right. Here's the euclidean one: ((x mod y) + y) mod y

    In either case, I need this to be a simple expression because I intend to use it a lot, and MMF2 doesn't have customizable expression functions. It's steals so much time to hire an extension developer everytime I need a custom extension (though I'm always very thankful for the ones who helped me), but I guess now is a good time for me dig into C++ for the first time and start out with some "useful maths" extension.

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Expression help: Loop a value within a range

    Quote Originally Posted by Nifflas
    It's steals so much time to hire an extension developer everytime I need a custom extension (though I'm always very thankful for the ones who helped me)
    I might have something interesting in development for you there.

Similar Threads

  1. I dun goof'd: "Debug Assertion Failed! Expression: Vector subscript out of range"
    By GreenOnion in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th March 2013, 12:02 AM
  2. Replies: 7
    Last Post: 25th December 2012, 11:26 AM
  3. Range Handler
    By Phi in forum Widgets
    Replies: 1
    Last Post: 12th May 2011, 02:02 AM
  4. using a range of numbers in expression editor
    By takki in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 8th May 2011, 11:10 PM
  5. fast loop and loop index
    By willow in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 18th May 2010, 01:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •