For seconds, add time_step/16 each frame.
Yeh i originally tried that but it doesn't always work when using it in a comparison statement...
var alarm_timer = 0;
while(1)
{
if(alarm_timer == 5) // after 5 seconds
{
beep();
}
alarm_timer += time_step / 16;
wait(1);
}
It seems to only work sometimes, and not 100% of the time.