Text between trials

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2022.2.1
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?: I am trying to display text between my trials that show one trial has ended and the next one will start.

What did you try to make it work?: Used ‘condition’ for Start

What specifically went wrong when you tried that?: Got a Syntax error

I have attached the psyexp file for reference. I am referring to the components ‘trial_start’ and ‘trial_end’ in the WM_1 and WM_2 routines. This study will be run on Pavlovia (if this makes a difference).
low wm.psyexp (35.3 KB)
low wm_lastrun.py (34.1 KB)

I wonder what Syntax error you encountered

I currently have $len(key_resp_2.keys) > 0 in the Start condition of my ‘trial_end’ text component and I’m not getting a syntax error, but the “trial finished” txt doesn’t show.

I have updated the files with what I’m trying right now.

So far, I don’t know what part of the program you want to code

It’s the “trial_end” text component. I cannot get it to display after the keyboard press (key_resp_2) and presentProbe components end. I would like the text in trial_end to be displayed after presentProbe. Right now, it goes straight to the WM_1 routine after the keyboard press (‘z’ or ‘/’) in WM_2.

You can’t write it like that here, this doesn’t work

I have a suggestions:
You need to define end = 0 in WM
First, start a new Routine and insert code:
if end == 0:
continueRoutine = 0
continueRoutine = 0


I added the code in the “wm” code component in WM_2 routine

But I got the following error when I ran it

You’re getting caught up with unnecessary complexity – no code is needed to achieve this.

Simply delete the trial_end text component and instead put it on its own routine that follows the routine with the keyboard response. Set the keyboard component to “force end of routine”.

i.e. as soon as a key is pressed, your text will display automatically, no code required.

Hi @Michael

I have now temporarily done this as a workaround, but what I was hoping to achieve is pressing either a ‘z’ or ‘slash’ that is required in key_resp_2 to trigger the text to be displayed.

You need to be explain exactly what you want to achieve, or else we’ll keep going around in circles.

Are other options available to press in the keyboard response, or is it restricted to those two keys?

It is restricted to these two keys that are set as the correct responses in key_resp_2.
The WM_2 routine starts with fixation2, followed by presentProbe and requires a keyboard response which is either ‘z’ or ‘slash’ (programmed in key_resp_2) that ends the routine. I would like the text “Trial finished” to be displayed after the keyboard response and then have the trial end.

You can only have one correct value in the correct answer field (i.e. Builder assumes that there can only be one correct response).

What you are looking for is actually the “allowed keys” field. Simply put this in there:

'z', 'slash'

Then the solution above will work for you – the message will be displayed only if one of those keys is pushed. Any other keypresses will be ignored.

I already have ‘z’ and ‘slash’ in the Allowed keys of my key_resp_2 keyboard component. Could you please guide me on how to make the trial_end text component display right after either one of these keys is pressed?


I’ve explained exactly how to do that above - remove that text component and put it in its own routine, after the routine containing the keyboard component.

I’m not sure how much more explicit I can be – you need to describe exactly what difficulty you are facing with implementing that solution.