Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Breaking a loop based on amount of time passed

laurenrklaurenrk Posts: 4
edited August 30 in OpenSesame

Hi,

I think I have a simple problem, but I'm having a difficult time finding the solution. What I would like to do is loop simply 2 items: a sketchpad item with just a fixation +, followed by feedback with a text display when the ENTER key is pressed and duration of 5 seconds; for a total duration of 10 minutes for the task. This is how I've set it up so far:

inline_script that reads var.break_the_loop=False (before the loop item)
new_loop that runs the cycle many many times sequentially (my table has two columns, Text and Correct; [Text] is either + with [Correct] as ENTER, or FeedbackText with [Correct] left blank)
new_sequence (every "run_if" field has [break_the_loop]=False)
inline_script_2 that reads t0=clock.time()
sketchpad item with [Text]
keyboard_response with allowed responses as ENTER
feedback item with [Text] and duration 5000
inline_script_3 that reads if clock.time()-t0>60000 break_the_loop=True

I'm using 60000 here so I can test it without having to wait all 10 minutes.
The error I'm receiving is as follows:
Inline script, line 1
if clock.time()-t0>60000
^
SyntaxError: invalid syntax

Is there a simple solution to this that I'm just not seeing?

Thank you so much,
Lauren

Comments

  • eduardeduard Posts: 977

    Hi lauren,

    If you want to break, you need to break :wink:

    Try this code:

    if clock.time()-t0>60000:
        var.break_the_loop = True # important to use "var", also in your first inline_script!
        # If this does not work, try to uncomment these two lines:
        # items['new_loop'].var.break_if = u'always'
        # items.execute('new_loop')
    

    If it doesn't work, I would (personally) revert to inline_scripting everything. Your design should be quite easy implementable without Opensesame Items.

    Eduard

Sign In or Register to comment.