Driver Scripted expression help!

Hello, I am a total beginner on all this…

I would like the X Loc channel of one object to be driven by the X loc of another object, but in reverse. The following does this fine where I have called the vaiable ‘xCompensate’:

Scripted Expression:
-xCompensate

The next level of complexity is that I want the ‘-xCompensate’ to NOT happen to the driven object when the driving object has a Y loc value of above zero. So I thought something like this would work:

if y > 0: -xCompensate

But the error sign comes up! Can anyone show me how to get this to work please?

Is there a list of operators accepted by Blender Driver Scripted Expressions?

Thanks.

-xCompensate if y > 0 else 0.0

Assuming you have a variable “y” and you don’t want any compensation whatsoever

Hi there! I do have a variable called Y!
I pasted in that line you sent but the error still comes up!

This is for the ‘Scripted Expression’ dropdown entry field in Drivers.

-xCompensate * (y > 0.0)

EDIT:
I’m on my phone and it makes a decent response difficult.

For those who don’t get it. The parenthases evaluate the “y > 0.0” and return 1(True) or 0(False)

If you wanted to set a range you can do…


-xCompensate * ((y > 0.0) & (y < 0.5))

Have Fun!

Skip

Many thanks! I tried the code and it works… but has made me realise my concept is wrong!

-xCompensate needs to happen ONLY when y=0. So I need to swap ‘>’ for something else. I tried ‘=’ but it doesn’t work! Any ideas? Also, what is the grammatical name for ‘>’ in the world of scripted expressions?

Use == to check equality, or != for not equal.
>= greater or equal, <= equal or less.

This page lists python “operators”. The section on comparison operators covers what we’re talking about…
http://www.tutorialspoint.com/python/python_basic_operators.htm