Conditional routine skipping

Hello, I’m trying to create a routine which prompts a user to choose a language for the instructions, if user presses ‘l’ key, the next routine would be ‘Lt_instr’ and then the ‘Eng_instr’ routine would be skipped. If user presses ‘e’ key, the ‘Lt_instr’ routine would be skipped. What would be the way to do that?
P.S. I’m planning to sync this experiment with pavlovia, so I assume the button component is not supported yet? Thank you!

If I were to do this, using key inputs I’d make use of a custom code component, insert one to your routine from the right hand side and follow these instructions:

If you are acquainted with Python you can use these to add custom code.

At the begin experiment section of your code component:

lt_instr_skip = False

set your key_resp_4 to force end routine from the settings and at end routine tab of your code component, use a code like

p_key = key_resp_4.keys[0]
if p_key == 'e': 
      lt_instr_skip = True

and to the Each frame tab of your code component:

if lt_instr_skip:
      continueRoutine = False

I however would prefer using the experiment settings and add a new field called “lang” and just check whatever “lang” is (at a code component) at the beginning of my experiment and set the variable that way.

Such as:

if str(expInfo['lang']) == 'e':
      lt_instr_skip = True

and add the same code to the each frame tab of my routine and skip it using:

if lt_instr_skip:
      continueRoutine = False

I solved it! I figured out a similar method, I added code component to ‘Lt_instr’ routine in the begin routine tab:

if key_resp_4.keys[0] == ‘e’:
continueRoutine = False

And did the same with ‘Eng_instr’ routine, adding this code:

if key_resp_4.keys[0] == ‘l’:
continueRoutine = False

Not the exact method as you listed, but you brought an understanding to me. Thank you!

1 Like