Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Make value restart at 1 every time it exceeds 5

  • Make value restart at 1 every time it exceeds 5

    Posted by Mikael Holmström on June 21, 2016 at 8:18 pm

    Hi all,

    I’m looking for an expression that make a value property restart at 1 every time it exceeds a certain value. The value 5 for instance should give this result:

    1 = 1
    2 = 2
    3 = 3
    4 = 4
    5 = 5
    6 = 1
    7 = 2
    8 = 3
    9 = 4
    10 = 5
    11 = 1
    […]

    I would really appreciate help with this one!
    Thanks,
    Mikael

    Mikael Holmström replied 10 years, 1 month ago 2 Members · 3 Replies
  • 3 Replies
  • Jeangjenq Loh

    June 21, 2016 at 8:45 pm

    I’m not sure what value you’re trying to apply it on to, but I did it with slider control and modulus function, it looks like this

    v = effect("Slider Control")("Slider");
    vv = v % 5;

    if (vv == 0){
    5
    }else{
    vv
    }

  • Jeangjenq Loh

    June 21, 2016 at 8:51 pm

    Oh and I forgot this, but if you gotta deal with decimal place, you can add parseInt, that’s how I’d do this

    v = effect("Slider Control")("Slider");
    vv = parseInt(v % 5);
    if (vv == 0){
    5
    }else{
    vv
    }

  • Mikael Holmström

    June 21, 2016 at 8:59 pm

    Thanks! It works like a charm.
    Mikael

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy