Again a python question

Hey,
Yesterday I started learning python. cthames and vibrunazo helped me to make the following script for movement:

get the current controller

cont = GameLogic.getCurrentController()

get owner

own = cont.getOwner()

import GameKeys Module

import GameKeys

get sensor named key

keys = cont.getSensor(“key”)

get actuator named motion

motion = cont.getActuator(“motion”)

set variables

speed = 0.1
rspeed = 0.02
walk = 0.0
turn = 0.0

get Game key code for W key

wKey = GameKeys.WKEY
sKey = GameKeys.SKEY
aKey = GameKeys.AKEY
dKey = GameKeys.DKEY

if get key status is 1 (just pressed)

if keys.getKeyStatus(wKey) == 1:
walk = speed
if keys.getKeyStatus(sKey) == 1:
walk = -speed
if keys.getKeyStatus(aKey) == 1:
turn = rspeed
if keys.getKeyStatus(dKey) == 1:
turn = -rspeed

move on local y axis

motion.setDLoc(0, walk, 0, True)

rotate on world z axis

motion.setDRot(0, 0, turn, False)

use actuator

GameLogic.addActiveActuator(motion, True)

The problem is that I can’t press 2 keys at a same time, to move forward and rotate at the same time. How can I make this?

Thank you =]

You can use KeyboardSensor.events for a list of pressed keys. See http://www.blender.org/documentation/249PythonDoc/GE/toc-GameKeys-module.html for an example.

Edit: Sorry, your script should work as it is. You just have to check for 2 as well.
The status is this:
KX_INPUT_NONE =0,
KX_INPUT_JUST_ACTIVATED =1,
KX_INPUT_ACTIVE =2,
KX_INPUT_JUST_RELEASED =3

Is there any tutorial? :blush: I’m super noob

hi gamemaster,

As a ‘super noob’, learning python would be a lot easier if you upgraded from Blender 2.48 to Blender 2.49a. If that’s possible, it’s something you consider.

The python you are using is from 2.48 and it received a major upgrade in 2.49. If you stick with 2.48 a lot of the Blender python you learn will just have to be relearned when you do upgrade Blender. Plus the python in 2.49 is much easier to use now. Not to mention the huge number of bugs that have fixed.

Also, as a ‘super noob’, you might find the python documentation on my site easier to understand.

link to Python Game Functions 2.49 and 2.48

Clark

How do I add a downloaded python? :blush: