Millisecond Forums

Changing a value depending on the presentation of a specific stimulus-item

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

By plush - 3/27/2018

Dear Inquisit,

I am trying to change a value depending on the presentation of a specific stimulus-item. The code below however does not work. Any suggestions will be much appreciated.

Thanks!

------------------------------------------------------------------------------------------------------

<values>
/totalearnings = 0
</values>
<expressions>
/ totalearnings = format("%.2f", values.totalearnings)
</expressions>

<text totalearnings>
/ items = ("Total Points: <%expressions.totalearnings%>    ")
/ position = (70%, 82%)
/ valign = bottom
/ halign = left
/ erase = false
</text>

<trial outcomeleftbutton1>
/stimulustimes = [1=outcomeleftbuttontext1,totalearnings]
/timeout = 1000
/ ontrialend = [if(text.outcomeleftbuttontext1=="1 point") values.totalearnings+=1]
/ ontrialend = [if(text.outcomeleftbuttontext1=="5 points") values.totalearnings+=5]
</trial>

<text outcomeleftbuttontext1>
/ items = ("5 points","5 points","5 points","1 point","5 points","5 points","5 points","1 point")
/ select = noreplace
</text>
By Dave - 3/28/2018

plush - Wednesday, March 28, 2018
Dear Inquisit,

I am trying to change a value depending on the presentation of a specific stimulus-item. The code below however does not work. Any suggestions will be much appreciated.

Thanks!

------------------------------------------------------------------------------------------------------

<values>
/totalearnings = 0
</values>
<expressions>
/ totalearnings = format("%.2f", values.totalearnings)
</expressions>

<text totalearnings>
/ items = ("Total Points: <%expressions.totalearnings%>    ")
/ position = (70%, 82%)
/ valign = bottom
/ halign = left
/ erase = false
</text>

<trial outcomeleftbutton1>
/stimulustimes = [1=outcomeleftbuttontext1,totalearnings]
/timeout = 1000
/ ontrialend = [if(text.outcomeleftbuttontext1=="1 point") values.totalearnings+=1]
/ ontrialend = [if(text.outcomeleftbuttontext1=="5 points") values.totalearnings+=5]
</trial>

<text outcomeleftbuttontext1>
/ items = ("5 points","5 points","5 points","1 point","5 points","5 points","5 points","1 point")
/ select = noreplace
</text>

<trial outcomeleftbutton1>
/stimulustimes = [1=outcomeleftbuttontext1,totalearnings]
/timeout = 1000
/ ontrialend = [if(text.outcomeleftbuttontext1=="1 point") values.totalearnings+=1]
/ ontrialend = [if(text.outcomeleftbuttontext1=="5 points") values.totalearnings+=5]
</trial>

text.outcomeleftbuttontext1 doesn't return anything. You apparently want to read the <text> element's currently selected item, so you should use the currentitem property:

<trial outcomeleftbutton1>
/stimulustimes = [1=outcomeleftbuttontext1,totalearnings]
/timeout = 1000
/ ontrialend = [if(text.outcomeleftbuttontext1.currentitem =="1 point") values.totalearnings+=1]
/ ontrialend = [if(text.outcomeleftbuttontext1.currentiitem =="5 points") values.totalearnings+=5]
</trial>