Skip to content

Accessing global variables/ function as a timeline #718

Answered by jodeleeuw
plopezgamundi asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks @Vijaygopal1234 for IDing the function as a timeline. That's a problem. You can't use a function as a timeline (yet).

It looks like make_stim() is returning a whole set of choices objects. I think I understand what you are trying to do now.

One way that you could keep most of the code in place but fix the choice_pres timeline is to use loop_function

var loop_index = 0;
var choice_pres= {
	timeline: [{
		type: 'html-button-response',
		stimulus: ['<p>Which option do you prefer?</p>'],
		choices: function(){ return stim[loop_index]; }
	}],
	loop_function: function(){
		loop_index++;
		return loop_index < stim.length; // repeats trial if true
	}
}

You'll need to define stim somewhere.…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@plopezgamundi
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@plopezgamundi
Comment options

@jodeleeuw
Comment options

@plopezgamundi
Comment options

Answer selected by plopezgamundi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants