Millisecond Forums

Problems converting BART to keyboard press

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

By ekothe - 7/1/2013

I'm trying to edit the default BART script to use keyboard responses rather than button presses. However I'm having problems with the script.



I've made changes to the choice trials but they are not performing as expected.



<trial choice>


/ ontrialbegin = [values.countchoice = values.countchoice + 1]


/ ontrialbegin = [values.pumpresult = counter.pumpresult.selectedvalue]


/ stimulustimes = [1=collectbutton, balloon, pumpbutton, totalearnings, pumpcount, potentialearnings, ballooncount]


/ inputdevice = keyboard


/ validresponse = ("1", "2")


/ ontrialend = [if (trial.choice.response == "1" && values.countchoice == 1) 


                  values.timebefore1stpump = trial.choice.latency ]


/ ontrialend = [if (trial.choice.response == "1"  && values.countchoice > 1) 


                  {values.timebtwpumps = trial.choice.latency; 


                  values.sum_timebtwpumps = values.sum_timebtwpumps + values.timebtwpumps }]


/ ontrialend = [if (trial.choice.response == "2" && values.countchoice == 1) 


                  values.timebeforecollectwithoutpump =  trial.choice.latency ]


/ ontrialend = [if (trial.choice.response == "2" && values.countchoice > 1) 


                  values.timebtwlastpumpandcollect =  trial.choice.latency ]



/ branch = [if ( trial.choice.response == "1") trial.pump]


/ branch = [if ( trial.choice.response == "2") trial.collect]



/ recorddata = true


</trial>



When I run this script a keyboard press of 1 is registered as a collect, and a keyboard press of 2 takes me straight to the final instructions "Congratulations you've made $0.0". So there is no way to pump the balloon! 



If edit the script so that...


<trial choice>


/ ontrialbegin = [values.countchoice = values.countchoice + 1]


/ ontrialbegin = [values.pumpresult = counter.pumpresult.selectedvalue]


/ stimulustimes = [1=collectbutton, balloon, pumpbutton, totalearnings, pumpcount, potentialearnings, ballooncount]


/ inputdevice = keyboard


/ validresponse = ("2", "3")


/ ontrialend = [if (trial.choice.response == "3" && values.countchoice == 1) 


                  values.timebefore1stpump = trial.choice.latency ]


/ ontrialend = [if (trial.choice.response == "3"  && values.countchoice > 1) 


                  {values.timebtwpumps = trial.choice.latency; 


                  values.sum_timebtwpumps = values.sum_timebtwpumps + values.timebtwpumps }]


/ ontrialend = [if (trial.choice.response == "2" && values.countchoice == 1) 


                  values.timebeforecollectwithoutpump =  trial.choice.latency ]


/ ontrialend = [if (trial.choice.response == "2" && values.countchoice > 1) 


                  values.timebtwlastpumpandcollect =  trial.choice.latency ]



/ branch = [if ( trial.choice.response == "3") trial.pump]


/ branch = [if ( trial.choice.response == "2") trial.collect]



/ recorddata = true


</trial>


When I run this script a keyboard press of 2 is registered as a pump, and a keyboard press of 3 takes me straight to the final instructions "Congratulations you've made $0.0". So there is no way to collect my winnings! 

If I set the valid responses to "a" and "f" (and change all of the trial.choice.response to corresponding values) then both responses take me straight to the final instructions.


Any ideas about what might be causing this and a potential fix? 

By Dave - 7/1/2013

You need to work with keyboard scancodes in your /branch etc. attributes. "Literal" key values will not work, as that is not what the response property returns. See the "Keyboard Scan Codes" topic in the documentation as well as Tools -> Keyboard Scancodes...

By ekothe - 7/16/2013

Thanks Dave, I managed to get it working.



Out of interest what is the logic about when Inquisit will use "literal" key values and when it uses keyboard scan codes?