After a WARNING alert, if another batch returns issue CRITICAL

I am trying to write a tickscript that runs a batch every 5 minutes and checks for a certain condition. I want to alert a WARNING if the condition is true for the first time, but if it happens a second time I want it to be a critical. I have tried to do this with warnReset and statescount but can’t seem to get it to work. Any ideas?