--- API: 2.1 OpenSesame: 3.3.7a7 Platform: posix --- set width 1024 set uniform_coordinates yes set title "Extended template" set subject_parity even set subject_nr 0 set start experiment set sound_sample_size -16 set sound_freq 48000 set sound_channels 2 set sound_buf_size 1024 set round_decimals 2 set height 768 set fullscreen no set form_clicks no set foreground white set font_underline no set font_size 18 set font_italic no set font_family mono set font_bold no set experiment_path "/home/lotje/Documents/Research, teaching and programming/OpenSesame/Scripts/Forum" set disable_garbage_collection yes set description "A template containing a practice and an experimental phase" set coordinates uniform set compensation 0 set canvas_backend psycho set bidi yes set background black define notepad about_this_template __note__ This template already contains the basic structure of a typical experiment. It consists of a practice phase, followed by an experimental phase. For more information, please visit Have fun with OpenSesame! __end__ set description "Some pointers to help you gest started!" define loop block_loop set source_file "" set source table set skip 0 set repeat 1 set order random set offset no set item trial_sequence set description "A single block of trials" set cycles 2 set continuous no set column_order "" set break_if_on_first yes set break_if never setcycle 0 interval 4000 setcycle 1 interval 8000 run trial_sequence define sequence block_sequence set flush_keyboard yes set description "A sequence containing a single block of trials followed by feedback to the participant" run block_loop always define inline_javascript evaluate_break_value set description "Executes JavaScript code (ECMA 5.1)" ___run__ // Get current time and determine whether trial should be ended: var current_time = new Date().getTime() var time_passed = current_time - starting_time if (time_passed > vars.interval){ vars.break_value = "yes"} console.log(vars.break_value) console.log(time_passed) __end__ set _prepare "" define sequence experiment set flush_keyboard yes set description "The main sequence of the experiment" run about_this_template always run instructions always run practice_loop always define inline_javascript get_number_of_clicks set description "Executes JavaScript code (ECMA 5.1)" ___run__ // Get number of clicks within interval: vars.number_of_clicks = vars.count_keyboard_response + 1 console.log(vars.count_keyboard_response) __end__ set _prepare "" define inline_javascript get_starting_time set description "Executes JavaScript code (ECMA 5.1)" ___run__ // Set starting time var starting_time = new Date().getTime() __end__ set _prepare "" define sketchpad instructions set start_response_interval no set duration keypress set description "A sketchpad containing the instructions for the participant" draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="Press any key to begin!" x=0 y=0 z_index=0 define keyboard_response keyboard_response set timeout infinite set flush yes set event_type keypress set duration keypress set description "Collects keyboard responses" define loop keypress_loop set source table set repeat 100 set order random set description "Repeatedly runs another item" set cycles 1 set continuous no set break_if_on_first yes set break_if "[break_value] = yes" setcycle 0 empty_column "" run keypress_sequence define sequence keypress_sequence set flush_keyboard yes set description "Runs a number of items in sequence" run new_sketchpad always run keyboard_response always run evaluate_break_value always define inline_javascript keypress_values set description "Executes JavaScript code (ECMA 5.1)" set _run "// Define the values that you want to log here, for example ..." set _prepare "" define logger logger set description "Logs experimental data" set auto_log yes define feedback new_feedback set reset_variables yes set duration keypress set description "Provides feedback to the participant" draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="You pressed the space bar [number_of_clicks] times" x=0 y=-160 z_index=0 define sketchpad new_sketchpad set duration 0 set description "Displays stimuli" draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="start pressing space" x=0 y=-128 z_index=0 define loop practice_loop set source_file "" set source table set skip 0 set repeat 1 set order random set offset no set item block_sequence set description "A loop containing one or more practice blocks" set cycles 1 set continuous no set column_order practice set break_if_on_first yes set break_if never setcycle 0 practice yes run block_sequence define inline_javascript set_break_value set description "Executes JavaScript code (ECMA 5.1)" set _run "" ___prepare__ vars.break_value = "no" __end__ define inline_javascript set_number_of_responses set description "Executes JavaScript code (ECMA 5.1)" set _run "" set _prepare "vars.number_of_responses = 0" define sketchpad sketchpad set start_response_interval no set duration 0 set description "Displays stimuli" draw fixdot color=white show_if=always style=default x=0 y=0 z_index=0 define sequence trial_sequence set flush_keyboard yes set description "A single trial" run sketchpad always run set_break_value always run get_starting_time always run keypress_loop always run get_number_of_clicks always run new_feedback always run logger always