psychopy.org | Reference | Downloads | Github

Feedback after incorrect trial

Hello,

for my experiment participants need to give four answers on four different slides and then click a “next” button. Once clicked, the program checks whether the answers were right and only then allows participants to continue two more of these practice trials before starting the actual experiment.
The “next” button is an image that was put into a mouse field.

My question is: How can I make a text appear that says “Sorry, try again!” every time the participant gets the answer wrong? The person should still be in the same trial.

This is the code so far:

pos1 = 0.72
pos2 = -0.7


//#getmouse
var position = mouse.getPos()

var posa = position [0]
var posb = position [1]
var buttons = mouse.getPressed()

if(posa > pos1-0.1 && posa < pos1+0.1) {
    if(posb > pos2-0.1 && posb < pos2+0.1) {
        if(buttons[0] == 1) {
            if(slider.getRating() == right1){
                if(slider_2.getRating() == right2){
                    if(slider_3.getRating() == right3){
                        if(slider_4.getRating() == right4){continueRoutine = false}
                        
                     }
                 }
            }
        buttons[0] = 0


}}}

I would really appreciate any kind of ideas!