Commands are called twice after time condition met

In 2024.2.4 version,

Commands are called twice after time condition met:

if segundos == 5 and not segundos_5_executado: # second condition was my unsuccefull attepmt to solve the problem.
    
    segundos_5_executado = True # same. In the beggining of Routine, I set the state of this variable to False.
    segundos = 0
    contador -= 5 #This is running twice.
    reforcar = 0 
    tentativasLag += 1 #So as this.
    Inicio = relogio.getTime()
    continueRoutine = False

I tried moving both “contador -= 5” and “tentativasLag += 1” to End Routine, calling it with segundos_5_executado == True. Still unsuccefull. I have no ideia why it is running twice.

Do you have an ITI? If not, then maybe the whole routine is running twice without you noticing.

Add print commands

Check you are using the latest code

Thank you @wakecarter. The routine is indeed running twice, with the aggravating that for some reason calling

segundos_5_executado = False

at the beggining of the new routine is useless, as it seems that is quickly turned True and the routine ends. After this extra ending, everything works fine.

For context, I have a Loop of Trial Routine + Reward Routine. Trial routine keeps repeating until criteria is achieved for Reward Routine to be presented.

If criteria is not met in 5 s, then the person lose some points:

contador -= 5

, one trial is added to total number of trials:

tentativasLag += 1 # unfortunately, since one of the three possible ends of routine should not increase the number of trials, I can’t just work with the builder counter to end my loop, but I guess this should work.

and the trial routine start again.

I have to have a timer that starts on the beggining of the first Trial and restarts either at 5 s or just after Reward Routine. For some reason, it seems like this timer is not reseting after the first routine ending after 5 s elapsed without reward, only after the extra, unplanned, routine.

Also, I’m runnning this offline.

How does this happen? There must be more code?

That was it @wakecarter. There was an “extra” setting of segundos = another variable at the beggining of routine. That is probably something that came in an anternative version of the program that I carelessly didn’t pay enough attention when rebuilding the experiment.
Thank you very much for your help.