Python problems?

I have a code that should work but its not. It’s meant to move the object one unit away on one of the axis and change 2 boolean variables of an empty but somehow it wont work.

The move part itself works with that code:

if keyboard.getKeyStatus( == 1:
      own["MoveObject"] = own["E Empty"]
      Y = own["Velocity"]
MoveObject.worldPosition.y += Y

What I tried and didn’t work.

if (keyboard.getKeyStatus( == 1 && if own["N"]==False):
      own["MoveObject"] = own["E Empty"]
      Y = own["Velocity"]
MoveObject.worldPosition.y += Y

What’s the problem with the code?

try this:

if keyboard.getKeyStatus( == 1 and not own["N"]:

and also make sure that Y has an initial value

Oh now it works, thanks :slight_smile: This language’s syntax is a bit strange to me.

Also one more question. How can I detect Backspace pressed? Just BACKSPACEKEY?

In other post, I had recommended these pages:, like a 4 times…

There are just way too many pages there. I just needed these. It’s like reading through the whole cookbook when you only want a brownie.

I saved the keys menu for later use just forgot that i did.

“if (… && if …)” will not work in any language I know.
Most languages have “if (… && …)”, but Python has “if … and …”.

Rather than using 1 you better use the constants defined by the API.

This is as 1 represents a number or an amount in human reading. When you use the KX_INPUT_JUST_ACTIVATED a reader immediately know what is meant.

To check a boolean value against another boolean value … to get a boolean value …
It is better to use the boolean value as it is:

if not own["N"]:
# rather than
if own["N"]==False: