trial counter
Hi all,
I'm trying to add a basic trial counter to my experiment ("You are on trial X of Y"). I have read the following threads:
I have specifically added Lotje's code from the first post to my experiment. Unfortunately, I get the following error when I try to run the experiment:
The variable 'count_trial_sequence' does not exist. Tip: Use the variable inspector (Ctrl+I) to see all variables.
item-stack: experiment[run].practice_loop[run].block_assignment[run].blocksequence[run].new_inline_script[run]
time: Mon Jul 16 11:57:07 2018
I've attached a picture of my experiment organization. The file itself is too large to attach, but please let me know if I can upload anything else to make it more clear.

Thanks for your help!
Comments
Hi,
I'm not sure whether this will do the trick, but in the loop item, you can check the box
skip on the first iterationor something like that. If this doesn't help, I would add an inline_script to the block_sequence (the first item or so) and add this line to its prepare phase:var.count_trial_sequence = 0Does that work?
Eudard
Hi all,
So I've come back to this project after several months. I have been able to implement a counter, and even a counter for my practice trials! Thank you to all for the help!
Unfortunately, I can't seem to figure out how to get the counter to start at 1 rather than 0. I have based my code off of Lotje's code (linked above), but for whatever reason, the following code doesn't seem to do anything on the first iteration of the counter:
trial_count = trial_count + 1I have the following inline script at the very beginning of my experiment (before the first loop):
And the following inline script in the trial sequence
Thanks for any help you might be able to provide! I can attach my experiment structure, or any other files that might help answer this question if need be.
Hi,
In the first part you set
var.trial_count = 0. However, in the next script, you also havetrial_count = self.get("count_trial_sequence"). So effectively, you are overwriting the trial count variable every single time with the count_trial_sequence variable. This variable is hardcoded in Opensesame and always starts at 0. I think if you replacetrial_count = self.get("count_trial_sequence")withtrial_count = self.get("trial_count"), or simply:trial_count = var.trial_count, you should be able to start at 1.Does that help?
Eduard