Variable in staircase for changing the level due to correct answers

Hi all!

My question:
Can somebody tell me which variable counts the correct answers and is responsible for changing the level of the staircase?
Or which variable I can use to achieve that the level only changes if the third answer is about variable “l”?

OS (Win10):
PsychoPy version (v.2022.2.5):

What are you trying to achieve?:
My experiment is a contrast vision test and should get the contrast threshold of a test person.

There are two things the test person sees randomly within a loop:

Variable “l”: Lines => correct answer = ‘num_8’

Variable “f”: White field => correct answer = ‘num_0’

The distance and number of lines will be adapted with the help of a staircase.
The level = number + distance of lines should change after three correct answers (N down = 3):

  1. If the third correct answer was for seen lines.
  2. If the third correct answer was for a white field, then it should show again lines before changing the level.

So, it should only change the level if the last correct answer was for lines

What did you try to make it work?:

I thought the variable I am searching for is self.correctCounter but it doesn´t seem to work with that. (See my code below)

#Set counter -1 if random choice = f and correct answers = 3
if random_lf == f and typed_key == [“num_0”] and trial_l.correctCounter == trial_h.nDown:
trial_l.correctCounter = trial_l.correctCounter - 1

Thank you in forward for your help!
I hope I did explain my problem well enough.


I found a solution for my problem.

Perhaps for those who are used to write code my solution will be easy but for those who are searching an answer for a similar problem it could be helpful:

I did now create my own counter which counts the correct answers.

Begin Experiment
#Count correct answers
count_corr = 0

Begin Routine
#Set random variable to l after two correct answers
if count_corr == 2:
random_lf = l

End Routine
#Get typed answer
typed_keys =
typed_keys = event.getKeys()

#Count the correct responses up to 3
if typed_keys == target_lf:
#target_lf is my variable for the correct answer
response = 1
response = 0

count_corr = count_corr + response
if count_corr == 4:
count_corr = 1