How to limit the rotation angle?

Hi!
I need rotate an object in the range of -45 to 45 centi-degree, but I don’t know how to limit the angle. please help me! Thank U!
The blender file can’t be uploaded, so I paste the script here.
##############################################################
cont = GameLogic.getCurrentController()
own = cont.getOwner()
pressLeft=cont.getSensor(‘left’)
pressRight=cont.getSensor(‘right’)
pressStop=cont.getSensor(‘stop’)
objectRotate=cont.getActuator(‘object’)
speed=objectRotate.getDRot()[2]
if pressLeft.isPositive():
own.go = -1
elif pressRight.isPositive():
own.go = 1
elif pressStop.isPositive():
own.go = 0
if own.go == -1:
speed = speed-0.0001
objectRotate.setDRot(0.0, 0.0, speed, 1)
GameLogic.addActiveActuator(objectRotate,1)
elif own.go == 1:
speed = speed+0.0001
objectRotate.setDRot(0.0, 0.0, speed, 1)
GameLogic.addActiveActuator(objectRotate,1)
elif own.go == 0:
speed = 0
objectRotate.setDRot(0.0, 0.0, speed, 1)
GameLogic.addActiveActuator(objectRotate,0)
##############################################################

The rotation limit can’t be found in the constraint actuator except the length limit–>LocX, LocY, LocZ:?
http://bbs.blendercn.org/files/constraint_260.jpg

try getOrientation.

you could get the current Orientation and use some if statements to determine if the object is within bounds.

I’m new to the BGE as well so I hope this will work for you.

You can achieve this using generic constraints. Check out this demo here