@br = ch("../../blinkrate"); @bv = ch("../../blinkratevar"); @f = 0; @fr = @br + rint(fit(rand(@f), 0, 1, -@bv, @bv)); @f += @fr; if ($F == @f) { @fr = @br + rint(fit(rand(@f), 0, 1, -@bv, @bv)); @f += @fr; }
The idea is that @fr (@br +/- a random integer within @bv of @br) is the number of frames before the next blink, and @f is the absolute frame number of the blink. Currently, @br = 60 and @bv = 5, and I start with initial values of 59 for @f and @fr, so far so good. At frame 59, I get new values of @f = 115 and @fr = 56. Sounds good, right? But after frame 59, it reverts to the initial values, so there's never a second blink. Why isn't the last line, which should add the interval of the next blink onto the frame number of the previous blink, actually doing that?