> Furthermore, I would like to have a black screen during practice and training trials, but the command shape.backgroundcolor.color = black did not work.
There is no such <shape> in the script you attached, so I'm not sure what effect this could have had. Either way, if you want a black screen color, set /screencolor to black in the script's <defaults>.
<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "5.0.0.0"
/ inputdevice = joystick
/ joystickthreshold = 30
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = white
/ txcolor = black
/ screencolor = black</defaults>
Now, as for preventing a trial from ending if the move is in the wrong direction. What you need to do is prevent the endincrease and enddecrease trial elements from running if the move is in the wrong direction. Those trials are called from the regular increase and decrease trials. Let's look at the practice trials for illustration.
*********ZOOM FEATURE: trial increase/decrease the size of the rectangles depending on participant's response*********
<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>
<trial practiceincrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "L"){
trial.practiceincrease.insertstimulustime(text.error, 0);
} else if (values.expcondition == 2 && values.targetformat == "R"){
trial.practiceincrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practiceincrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.intertrialinterval;
} else if (joystick.y >= 1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.endincrease_practice;} else if (joystick.y >= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practiceincrease;
} else if (joystick.y < values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practicedecrease;
};
]
/ recorddata = false
</trial>
Note: trials show the last size of the picture
<trial endincrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>
<trial enddecrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>
So, all you need to do is make this /branch not work if the direction is wrong:
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
...
That's actually easy, because the increase and decrease trials determine when the direction is wrong to display an error message -- i.e. the relevant logic is already mostly in place. Simply introduce a new variable, let's call it wrongdirection and set it to either true (direction is wrong) or false (direction is not wrong):
<values>
/ wrongdirection = false
</values>
<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;} else {
values.wrongdirection = false;};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
...
</trial>
Then just prevent the /branch if the direction is wrong.
<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000 && !values.wrongdirection) {values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>
You can do the same thing for the test trials.