Hi,
we have the following issue: we are setting up an experiment where four circles (“dots”) should remain the same color as long as they are not clicked on. When a circle is clicked on it should change color to a) yellow, if it is the first, third or fourth circle to be clicked, or b) navy, if it is the second circle to be clicked. We have written the following code for this.
<trial trial1>
/stimulusframes = [1= box1, dot1, box2, dot2, box3, dot3, box4, dot4]
/ontrialbegin = [
values.incorrect=0;
if (values.box1_click==0) shape.dot1.color = black;
if (values.box1_click==1 || values.box1_click==3 || values.box1_click==4) shape.dot1.color = yellow;
if (values.box1_click==2) shape.dot1.color = navy;
if (values.box2_click==0) shape.dot2.color = black;
if (values.box2_click==1 || values.box2_click==3 || values.box2_click==4) shape.dot2.color = yellow;
if (values.box2_click==2) shape.dot2.color = navy;
if (values.box3_click==0) shape.dot3.color = black;
if (values.box3_click==1 || values.box3_click==3 || values.box3_click==4) shape.dot3.color = yellow;
if (values.box3_click==2) shape.dot3.color = navy;
if (values.box4_click==0) shape.dot4.color = black;
if (values.box4_click==1 || values.box4_click==3 || values.box4_click==4) shape.dot4.color = yellow;
if (values.box4_click==2) shape.dot4.color = navy;
]
/inputdevice = mouse
/validresponse = (nexttext, box1, box2, box3, box4)
/ontrialend = [
(values.current_click=values.current_click+1);
if (values.box1_click<1 && trial.trial1.response=="box1") {values.box1_click=values.current_click}
else if (values.box2_click<1 && trial.trial1.response=="box2") {values.box2_click=values.current_click}
else if (values.box3_click<1 && trial.trial1.response=="box3") {values.box3_click=values.current_click}
else if (values.box4_click<1 && trial.trial1.response=="box4") {values.box4_click=values.current_click}
else if (values.current_click=values.current_click-1)(values.incorrect=1)]
/branch= [if (values.incorrect==1) trial.trial1]
</trial>
My question is whether there is a way to make the script more dynamic, specifically if there is a way to predefine 1, 3 and 4 to indicate yellow and 2 to be navy, so that when entering the /ontrialbegin if-statement, we can say something like “if the value is any of the values indicating yellow, then…”.
This would allow us, for example, to change the order of yellow and blue circles more easily in the beginning without having to re-write every if-statement for every circle.
Thank you very much for your help in advance.