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

[solved] change target colors

AnnaAnna Posts: 6
edited March 2012 in OpenSesame

Hi Sebastiaan,
I have a problem with the colors of my targets and the randomization. I want to present rectangles in different colors. So I created two sketchpads in my trial sequence (fixation dot and target). I modificated the Edit script of the target by substitute the code of the color by the variable „target_color“, which I had defined in the block loop (according to he hexadecimal RGB notation). I defined it like this:
target_color
1 =#00ff00
2 =#ff0000
3 =#0000ff

It didn´t work and I have no other ideas. What could I change , that it will work?
Thanks a lot for your help!
kind regards, Anna

Comments

  • sebastiaansebastiaan Posts: 2,737
    edited 4:58AM

    Hi Anna,

    It seems that your general approach is correct, so there's probably some simple mistake in there (a typo, or incorrect syntax). Could you perhaps provide some more details on what you did exactly (e.g., show the script) and what kind of error you get?

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • AnnaAnna Posts: 6
    edited March 2012

    Hi Sebastiaan,

    Thanks for your help! That´s the target script. I changed the color in my variable [target_colour]. I also copied the error message.

    set duration "300"
    set description "Displays stimuli"
    set start_response_interval "no"
    draw rect -64 -64 128 128 fill=1 penwidth=1 color=[target_colour] show_if="always"
    draw textline 0 -128 "[target_number]" center=1 color=white font_family=mono font_size=18 show_if="always"

    Error: Runtime error
    Description: Failed to evaluate '#00ff00' in loop item 'block_loop_right': unexpected EOF while parsing (, line 1)

    Kind regards, Anna

  • sebastiaansebastiaan Posts: 2,737
    edited March 2012

    Hi Anna,

    You probably used '=#00ff00' for the variable target_colour, and not '#00ff00' (without the '=' sign), right?

    It is a little advertised feature of OpenSesame that you can define variables in loop items using Python statements. You indicate this by prepending an '=' sign, kind of like you would do in a spreadsheet. So, for example, using '=randint(0,10)' would give you a random integer between 0 and 10 (link).

    In your case, '=#00ff00' leads OpenSesame to evaluate the string '#00ff00' as Python code. This is just a comment (# = comment), so there's nothing to evaluate, and you get this obscure error message. But the solution is simple: Just omit the '=' sign.

    Please let me know if this doesn't work for you!

    Kindest regards,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • AnnaAnna Posts: 6
    edited 4:58AM

    It works :) Again: Thank you very much for your help!

Sign In or Register to comment.