Hi Josh,
Thanks for very useful tool. I am stuck on a basic issue - updating the value of a variable ("k" which indexes elements of stimulus array) between trials. Right now I just want to do something basic like switch it from 0 to 1 from the first to second trial, and I will add more complexity once I can do that. I thought the on_finish function would help, but it does not seem to pass back into the stimuli parameter. Below is my code:
Thanks for help,
Garret
var k = 1;
var optdelay = ["NOW", "1 MONTH"];
var optamount = ["50", "100"];
/* define test block */
var block = {
type: "single-stim",
stimuli: ["<div class='left center-content'><p style=color:white>" + optdelay[k] + optamount[k] + "</p>"],
choices: [37,39],
on_finish: function(){
var k = 0;
},
is_html: true
}
var timeline = [];
var while_loop_chunk = {
chunk_type: 'while',
timeline: [block],
continue_function: function(data) {
var response = JSON.parse(data[0].key_press); // convert JSON to array
if (response[0] == 37) {
return false; // continue the loop
} else {
return true;
}
}
}