Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] change target colors

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:
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


  • edited 8:20AM

    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?


  • 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

  • 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,

  • edited 8:20AM

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

Sign In or Register to comment.