Howdy, Stranger!

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

Supported by

Possible to stop OpenSesame "tidying" my script?

Hi everyone,

I was just wondering if there is a way to prevent the script editor from rearranging my script (OpenSesame script, not the inline script, which seems to leave things as they were found)?

In particular I would like to be able to have multiple line breaks between sections of code, with a commented line at the top of each section, explaining, for example, what part of a sketchpad the following code corresponds to, and how I've variably-defined certain values. When I do this, all the comments get moved to the top and all the blocks of code get "squished" together.

Thanks!
-Jonathan

Comments

  • edited November 2016

    Sorry, I'm not sure if the above was clear. Just in case, here's an example...

    I start with this...~~~~

        set start_response_interval no
        set duration 0
        set description "Displays stimuli"
    
        # food images
        draw image center=1 file="[left_food][rand_int_l].jpg" scale=0.25 show_if=always x="-[target_eccentricity]" y=0 z_index=0
        draw image center=1 file="[right_food][rand_int_r].jpg" scale=0.25 show_if=always x="[target_eccentricity]" y=0 z_index=0
    
        # arrow cue
        # N.B. - x1 is the arrow's tail; x2 the arrow's head
        draw arrow arrow_body_length="[body_length_proportion]" arrow_body_width="[body_width_proportion]" arrow_head_width="[head_width]" color=white fill=1 penwidth="[pen]" show_if=always x1="[=-1*(var.arrow_halfwidth)*(var.cue_side)]" x2="[=(var.arrow_halfwidth)*(var.cue_side)]" y1=0 y2=0 z_index=0
    
        # probe (appears on top of one of the food images)
        draw circle color="#ffff00" fill=1 penwidth=1 r="[probe_size]" show_if=always x="[=(var.target_eccentricity)*(var.cue_side)]" y=0 z_index=0
        draw circle color=black fill=0 penwidth=4 r="[probe_size]" show_if=always x="[=(var.target_eccentricity)*(var.cue_side)]" y=0 z_index=0
    

    which gets corrected to this...

        # food images
        # arrow cue
        # N.B. - x1 is the arrow's tail; x2 the arrow's head~~~~
        # probe (appears on top of one of the food images)
        set start_response_interval no
        set duration 0
        set description "Displays stimuli"
        draw image center=1 file="[left_food][rand_int_l].jpg" scale=0.25 show_if=always x="-[target_eccentricity]" y=0 z_index=0
        draw image center=1 file="[right_food][rand_int_r].jpg" scale=0.25 show_if=always x="[target_eccentricity]" y=0 z_index=0
        draw arrow arrow_body_length="[body_length_proportion]" arrow_body_width="[body_width_proportion]" arrow_head_width="[head_width]" color=white fill=1 penwidth="[pen]" show_if=always x1="[=-1*(var.arrow_halfwidth)*(var.cue_side)]" x2="[=(var.arrow_halfwidth)*(var.cue_side)]" y1=0 y2=0 z_index=0
        draw circle color="#ffff00" fill=1 penwidth=1 r="[probe_size]" show_if=always x="[=(var.target_eccentricity)*(var.cue_side)]" y=0 z_index=0
        draw circle color=black fill=0 penwidth=4 r="[probe_size]" show_if=always x="[=(var.target_eccentricity)*(var.cue_side)]" y=0 z_index=0
    
  • Hi Jonathan,

    No, you cannot prevent OpenSesame from doing this. Essentially, OpenSesame parses the script to see if it's ok, and then regenerates it. And the regenerated script may differ slightly from the original script.

    For example, if you add unnecessary (but harmless) quotes to a number:

    set a_number "10"
    

    OpenSesame will remove them:

    set a_number 10
    

    In principle, what you're doing now is fine. But it's getting very close to full-fledged coding, which OpenSesame script isn't really optimal for. Why not just use Python?

    Cheers,
    Sebastiaan

  • Hmmm. Perhaps I will! Thanks for the explanation, Sebastiaan!

    Cheers,
    -Jonathan

Sign In or Register to comment.