You may have figured this out already but...
Just use a variable and add one to it each tick. Then reset it to 0 after you do something. Then check if it is greater than an amount (# of ticks) since you reset it to 0. Pretty simple. You can also use it inversely as well (Lag). You say: each tick, if Lag > 0, Lag = Lag-1
I'm making a fighting game so this is a great way to detect whether a combo is dropped, or a universal way to add a set amount of lag to stuff. For example, if I do an attack that has 40 frames of lag, I can set Lag to 40. Then on all my actions that can't be done if you are lagging, you just put a conditional of "if Lag <= 0" pretty simple. Usually, when Lag goes from being > 0 to being = 0 I will zero ANOTHER variable called FramesPassed. This variable keeps track of the number of frames since the END OF LAG. This is also useful, for example... if you jump but release the jump button quickly enough after the jump registers (and before lag ends or a certain few frames after Lag ends), you can have it perform a short hop (lower jump) instead of a full jump. There are plenty of ways to utilize this...
Similarly if you allow cancelling at the beginning and end of a move into certain other moves you can use variables that keep track of frames since the start of the move.
Basically in my game for example, I keep track of:
Frames of Lag
Frames since Lag ended
Frames since the start of a move
These allow me to have frame accurate control over my game (unlike many games, serious fighting games require constant framerates and timings for things)