Python does not work.

I’m having problems with python in regards to using it with blenders game engine.
I’m always getting errors.I downloaded this python code as a teaching example of how to control an object with the mouse in other words making the object take the position of the mouse continually.I put the code into blender and set up the logic as it was supposed to be and i got more than two pages of errors in the DOS window.I have no idea what is going on.
I have put a link for the mouse.blend file.If anyone can please have a look at the code and the logic and please tell me what im doing wrong.
thank you.
http://members.optusnet.com.au/vody13/

if you don’t have the latest version of python installed on your system that could be one thing -
or maybe you should reinstall a different version of blender

I have the latest version of python and the latest of blender.Do you think it could be that the latest version of blender does not work properly

The problems you have here:

  • You need to name the sensor brick “mouse” (no quotes), you can’t leave it as “sensor”.
  • You need to add 2 float properties (using that big add property button). One property named “x” (no quotes) and the other named “y” (no quotes)
  • You need to get rid of the whitespace:

#Wrong:
import Rasterizer

 ww = Rasterizer.getWindowWidth()


#Right:
import Rasterizer

ww = Rasterizer.getWindowWidth()

# No space between the beginning and ww. Same goes for all the other lines of code

I thank you very much for you help but theres still one problem.
I had done what you had told me to do but python still generates an error.
It says "ImportError:no module named gamelogic
I have uploaded the updated version of the file.
http://members.optusnet.com.au/vody13

That’s because it’s called GameLogic.

Python is case sensitive.

EDIT, you’re probably running the script directly with ALT-P, … “regular” Blender doesn’t know about the GameLogic module … … you need to run the game engine … pressing “P” with the mouse cursor in the 3d window

Mike

I’m not getting any errors when I run it.

PS: I said to name the properties x & y, not X & Y. Actually I have no idea how it’s working like that, but you should probably fix that to lowercase.

Python is case sensitive (or it should be).

If he didn’t know that, what the hell is he doing starting with python?

thanks everyone for your help
everything is working fine now