Loop table row called one trial later?
I need to present a dot (either on the left or the right side of the screen) and a line starting from the dot (going towards the right if the dot is on the left, and vice versa.)
The position of the dot (rnd_x, rnd_y) should be randomized within a certain range. The length of the line should be as many "units" as the value (numbers 1 to 12) of the "op1" variable (specified in the trial loop).
Within the trial loop, the first thing is an inline_script:
import random var.rnd_x = random.randint(-550, -450) var.rnd_y = random.randint(-50, 50) var.x_2 = var.rnd_x + (var.op1 * 100)
Problem is, the length of the line and the dot position seem to be updated only one trial later, so the first trial has the dot in the center and there is no line. I think this is because before anything else I defined var.rnd_x = 0, var.rnd_y=0, and var.x_2=0 in an inline_script before the loop).
From the second trial until the value of "op1" changes from 1 to 2, everything is fine (because the line length is supposed to be the same). When "op1" changes to 2, the length of the line is 1 unit in the first trial, and switches to two units from the second trial on. This is the same everytime op1 changes.
Is this a problem with when the variables are being defined? Or any thoughts?
I am attaching an example experiment.
Thank you in advance, any help is greatly appreciated! 🙏
Hi @carlotta_isabella ,
This has to do with the prepare-run strategy that OpenSesame uses to optimize timing. Specifically,
sketchpaditems are prepared during the prepare phase, such that they can be shown without any delay during the time-critical run phase. However, this means that the contents of the
sketchpadcan only take into account what happens during the prepare phase.
In your case, you're setting the variables during the run phase of the random_pos_ltr script. This happens after the
sketchpaditems have already been prepared! The solution is simply to move the script from the run to the prepare tab.
Hope this helps!
Thank you so much @sebastiaan!! ❤️ This solved it!
Maybe see you at ESCoP :)