Continuously updating text stim on specific frame gaps

You want to cary out the letter selection only on every 20th frame. You can do this using the modulus operator:

if frameN % 20 == 0 # on every 20th frame 
    aux = randint(0,len(letras))
    yourTextComponentName.text = letras[aux]

Don’t use a variable (i.e. chosen) here, as it will be needlessly updating the text stimulus on every frame, even though it isn’t changing. Instead, set it to have some constant value (e.g. XXXX) and change it in code as above, which will only happen on every 20th frame. XXXX should never appear on screen, as the component should update on the first frame (when frameN == 0, so the remainder of dividing it by 20 is also 0). Make sure that the code competent is above the text component (a brief flash of XXXX will show that it isn’t), so that the text competent gets the new value before it re-draws.

1 Like