Millisecond Forums

Conditional use of a list

https://forums.millisecond.com/Topic26431.aspx

By EstherKlinkenberg - 2/13/2019

Dear all,

For an adjusted version of the cyberball game I am trying to use a list element within an if statement.

The idea is that when participants click on a certain player to throw the ball, the ball sometimes is thrown to a different player. Therefore, I created lists. When the participants' response is, for example, "player1label", I want to tell Inquisit to use the list.recipient1. Based on the value of this list I want values to change and the next trial also depends on the value of that list. Right now the script just quits, so obviously something is wrong. I am just not sure how to do this correctly.

I hope my question is clear, I included my code below.

<trial 1to2_unpred_motiv>
/ontrialbegin = [values.player = 2]
/ ontrialbegin = [shape.progressbar.width=100%*(values.count_throws/25)]
/ stimulusframes = [1 = 1to2, player1label, player2label, player3label, player4label, durgameinstr, progressbar, text.score]
/ validresponse = (text.player1label, text.player3label, text.player4label)
/ inputdevice = mouse
/ontrialend = [if (trial.1to2_unpred_motiv.response == "player1label") {values.recipient = list.recipient1}]
/ontrialend = [if (trial.1to2_unpred_motiv.response == "player3label") {values.recipient = list.recipient3}]
/ontrialend = [if (trial.1to2_unpred_motiv.response == "player4label") {values.recipient = list.recipient4}]
/ ontrialend = [if (values.recipient == 1){values.count_player2throws += 1; values.count_throws +=1; values.count_21 += 1; values.score -=2}]
/ ontrialend = [if (values.recipient == 3){values.count_player2throws += 1; values.count_throws +=1; values.count_23 += 1; values.score +=2}]
/ ontrialend = [if (values.recipient == 4){values.count_player2throws += 1; values.count_throws +=1; values.count_24 += 1; values.score +=2}]
/ branch = [if (list.recipient1.currentvalue == 1) trial.2to1_unpred_motiv]
/ branch = [if (list.recipient3.currentvalue == 3) trial.2to3_unpred_motiv]
/ branch = [if (list.recipient4.currentvalue == 4) trial.2to4_unpred_motiv]
</trial>


Thank you in advance for you answer.

Kind regards,

Esther

By Dave - 2/13/2019

EstherKlinkenberg - Thursday, February 14, 2019
Dear all,

For an adjusted version of the cyberball game I am trying to use a list element within an if statement.

The idea is that when participants click on a certain player to throw the ball, the ball sometimes is thrown to a different player. Therefore, I created lists. When the participants' response is, for example, "player1label", I want to tell Inquisit to use the list.recipient1. Based on the value of this list I want values to change and the next trial also depends on the value of that list. Right now the script just quits, so obviously something is wrong. I am just not sure how to do this correctly.

I hope my question is clear, I included my code below.

<trial 1to2_unpred_motiv>
/ontrialbegin = [values.player = 2]
/ ontrialbegin = [shape.progressbar.width=100%*(values.count_throws/25)]
/ stimulusframes = [1 = 1to2, player1label, player2label, player3label, player4label, durgameinstr, progressbar, text.score]
/ validresponse = (text.player1label, text.player3label, text.player4label)
/ inputdevice = mouse
/ontrialend = [if (trial.1to2_unpred_motiv.response == "player1label") {values.recipient = list.recipient1}]
/ontrialend = [if (trial.1to2_unpred_motiv.response == "player3label") {values.recipient = list.recipient3}]
/ontrialend = [if (trial.1to2_unpred_motiv.response == "player4label") {values.recipient = list.recipient4}]
/ ontrialend = [if (values.recipient == 1){values.count_player2throws += 1; values.count_throws +=1; values.count_21 += 1; values.score -=2}]
/ ontrialend = [if (values.recipient == 3){values.count_player2throws += 1; values.count_throws +=1; values.count_23 += 1; values.score +=2}]
/ ontrialend = [if (values.recipient == 4){values.count_player2throws += 1; values.count_throws +=1; values.count_24 += 1; values.score +=2}]
/ branch = [if (list.recipient1.currentvalue == 1) trial.2to1_unpred_motiv]
/ branch = [if (list.recipient3.currentvalue == 3) trial.2to3_unpred_motiv]
/ branch = [if (list.recipient4.currentvalue == 4) trial.2to4_unpred_motiv]
</trial>


Thank you in advance for you answer.

Kind regards,

Esther


The code is too incomplete to say anything about it. At a minimum, the actual <list> would be needed. Note that list.recipentX.currentvalue will not sample any value from the list. The way to sample a value from a list would be list.recipientX.nextvalue.

Also, these sections do not make sense:

/ontrialend = [if (trial.1to2_unpred_motiv.response == "player1label") {values.recipient = list.recipient1}]
/ontrialend = [if (trial.1to2_unpred_motiv.response == "player3label") {values.recipient = list.recipient3}]
/ontrialend = [if (trial.1to2_unpred_motiv.response == "player4label") {values.recipient = list.recipient4}]

You're not setting values.recipient to anything here. list.recipientX does not return anything. Again, to sample an item / value from the respective list, use the nextvalue property.