| Reference | Downloads | Github

How can I pause or run a routine based on text from a condition file?

I am designing a donation experiment.
I have to randomly display the number of ‘ratingrt_raw’ in the condition file 20 times(the loop reps is 20).
If the number on the screen is 0, the loop continues. If it is not 0, the loop must be stopped.
I thought the variable that display the number on the screen is .setText(ratingrt_raw) or pick_rt, which is the name of the block itself showing the text.
So I entered the following code.

   # *pick_rt* updates
    if t >= 0.0 and pick_rt.status == NOT_STARTED:
        # keep track of start time/frame for later
        pick_rt.tStart = t
        pick_rt.frameNStart = frameN  # exact frame index
    miss = pick_rt.setText()
    if miss == 0.0:
        continueRoutine = True
        continueRoutine = False
        trials_3.finished = True
    frameRemains = 0.0 + 8.0- win.monitorFramePeriod * 0.75  # most of one frame period left
    if pick_rt.status == STARTED and t >= frameRemains:

I tried to define the miss variable as pick_rt, but the result was not different.
Regardless of the number, the loop continued.

How can I solve this problem?

I appreciate for your help in advance.

+Routine components

# Initialize components for Routine "pick_charity" 
     pick_charityClock = core.Clock()
     pick_char = visual.ImageStim(
          win=win, name='pick_char',
          image='sin', mask=None,
          ori=0, pos=(0, 0), size=(1.0, 1.0),
          color=[1,1,1], colorSpace='rgb', opacity=1,
          flipHoriz=False, flipVert=False,
          texRes=128, interpolate=True, depth=-2.0)
     pick_rating = visual.TextStim(win=win, name='pick_rating',
          text='default text',
          pos=(0.7, 0), height=0.1, wrapWidth=None, ori=0, 
          color=u'black', colorSpace='rgb', opacity=1,
     pick_rt = visual.TextStim(win=win, name='pick_rt',
         text='default text',
         pos=(0.7, -0.8), height=0.1, wrapWidth=None, ori=0, 
         color=u'black', colorSpace='rgb', opacity=1,
  1. Do you ever actually check what the value of miss is? You need to debug these things by inspecting the values of your variables. It doesn’t look to me like it can ever be the number 0. Try print(miss) and print(type(miss))
  2. Avoid comparing floating point numbers like 0.0 for equality. Computers don’t store floating point numbers precisely. You can compare integers for equality, but not (safely), floating point numbers.
  3. There are some basic issues here that make me think you’d be far better off using code components within Builder, rather than editing the Builder-generarted scripts by hand.