Python question

hey im kinda new to python and all and I have a question:
how can i code-by pyton the movment with the keys?
i know i need to make the sensors and conect them to the controllers but i dont know what the script will be …
well i tried to make one but it aint working:

movment Variables

cont = GameLogic.getCurrentController()
Forward = cont.getSensor(“forward”)
Backward = cont.getSensor(“back”)
Left = cont.getSensor(“left”)
Right = cont.getSensor(“right”)
movement - cont.getActuator(“movement”)

speed = .05
rl = 0
fb = 0

Keystroke Define

if forward.isPositive():
fb - speed
elif back.isPositive():
fb = -speed
if right.isPositive():
rl = -speed
elif left.isPositive():
rl = speed


Ok, there are a couple of problems with your script.

First, you name the “forward” sensor “Forward”. Then, later in the script, you use forward.isPositive(). forward doesn’t exist, Forward does. The other sensors have similar problems.

Then, in line 7, you have

movement - cont.getActuator("movement")

. This doesn’t do anything. I think you meant

movement = cont.getActuator("movement")

. You have the same problem in line 16.

I made a couple of changes, just to stop blender from whining about deprecated functions. Here’s your final script:

# movement Variables
cont = GameLogic.getCurrentController()
Forward = cont.sensors["forward"]
Backward = cont.sensors["back"]
Left = cont.sensors["left"]
Right = cont.sensors["right"]
movement = cont.actuators["movement"]
speed = .05
rl = 0
fb = 0
# Keystroke Define
if Forward.isPositive():
    fb = speed
elif Backward.isPositive():
    fb = -speed
if Right.isPositive():
    rl = -speed
elif Left.isPositive():
    rl = speed
movement.dLoc = [0,fb,0]
movement.dRot = [0,0,rl]