Incrementing values based on another variable

I need a formula for the value of variable T, where it increases by 1/2 every time another variable t equals 2. (t goes from 0 to 2, and loops)
So like at first T is 0, then when t = 2, T = 1/2
then when t = 2 again, T=1, and when t equals 2 againn, T=1 1/2, etc.

I’m not sure there is a formula that can do this. You could probably do it via Actions and a ticker - so having something like T->T+0.5{t=2} in the ticker will increment T by 1/2 everytime t=2… but if t stays at 2 for longer than the ticker lasts then it will keep incrementing. You can avoid this by setting other variables temporarily but if you describe what exactly it is you’re trying to achieve (or link us to a work in progress) we might be able to assist further.

Nevermind, I found an equation for T :>

Would you like to share what it is?


Since t goes from 0 to 2 and repeats, it is exactly mod(u,2), (u is a new variable)
Turns out, T is equal to floor(u/2)/2
Nice and simple :>