UnboundLocalError: local variable 'currentLineLength' referenced before assignment or 'currentLineLength' is not defined

Hi, I am trying to create a line reproduction where in the reproduction trial participants will use a mouse to scroll up and down to make the lines smaller or larger. I tried to generate a code like this, but I am not sure if it will work, I can’t even run it because I get:

start=(-[currentLineLength][0]/2.0, 0), end=(+[currentLineLength][0]/2.0, 0),

UnboundLocalError: local variable ‘currentLineLength’ referenced before assignment

or ‘currentLineLength’ is not defined.

What should I do




Did you fix this. It looks like the issue is that your line size is set to constant, but currentLineLength doesn’t have a value until Begin Routine.

Hi, no. I just changed the line size to set every frame. But should I add a value to the CurrentLineLength before Begin Routine because I already used builder for participants to see the lines but for the reproduction trial, I wrote that so that a line approximately 100 px to be seen and then they can make the adjustment. What’s wrong with this and the code? and when I run the study I just see a gray screen or it shows only 1 line and a gray screen.

Thank you!

Hi, I just added “currentLineLength=100” to the begin experiment but nothing is changing. What can I do?

Thanks!!

Why are you creating a mouse object in code and with a mouse component?

Try getting the basics of the experiment working before customising it with code components.

Because sometimes I see that you need to initialize some things so I thought I should. Ok so if you’re saying that I don’t need to do that I just deleted that part but I still see just one line and gray page and now I don’t get the error(currentlinelength not defined)What can I do?

Thanks!!

A line and a grey screen is consistent with your routine (one line polygon). What are you expecting

You shouldn’t use while in Each Frame code. It interrupts the Each Frame construction.

I have no idea whether you can use getWheelRel online. Maybe try with a arrow keys first.

Is there a reason why you have key_resp and event.getKeys()? Are they monitoring for something different?

Hi, I want to calculate the bias by subtracting the actual line length from each estimate. This one didn’t work, what do you think is wrong:

Calculate bias (difference between actual and adjusted line length)

adjusted_line_length = adjustable_line.end[0] - adjustable_line.start[0]

bias = actual_line_length - adjusted_line_length

Thanks!!

What is adjusted_line?

Why aren’t you just calculating bias = actual_line_length - currentLineLength ?

What error message do you get?

What is adjustable_line and are you sure it has .end and .start properties?





Hi, I am still working on this experiment, except now I need to create a different response condition( (imagine a dot on the screen with the cursor in the middle of the screen. I move the cursor upward only, and the dot extends into a line following the cursor. When I click, I save the response.) except I keep getting this error. Can you please tell me what did I miss?( it will be a online study so I am not sure if these will work online)

Thanks!!