showMouse don´t work everytime.

OK… i´m realy new to Phyton and the Game-Engine so its probably my
fault.

This is what i´ve done:

Adding one Always Sensore to the default Cube.
Adding a Phyton Controller to the default Cube.
My Script looks like this:


  import GameLogic
  from Rasterizer import showMouse

  showMouse(1)

Obviously i just want the Mousecursor to show up.
It simply don´t work.

What did i do wrong??:confused:


By the Way…
I got the Blender-Gamekit and i´m realy disapointed!!:mad:
I expected good dokumentations about all the aspects of the Game-Engine and some Phyton tutorials.
Instead it covers mostly Blender Basics in very little detail. And just cover Phyton very hasty. The Game Reference Guide is much better, and its free.
So if you own the Blender Guide, you don´t need the Game-Kit.

Your code should work. One thing you want to be careful of is the use of an always sensor. For something like this it’s fine if you turn off the pulses so it only fires once. That’s all it needs to be called.

oh…oh… i´m Guilty!:o
I broke one of the bigest Rules when it comes to Forums. Search the other Threads before posting…

So i know the answer now…
of course i have to initalise a Rasterizer Object like this:

import Rasterizer as r

After realizing that Phyton is organiced in Classes it became clear.

just add a Rasterizer. before showMouse(1)

import GameLogic
from Rasterizer import showMouse

Rasterizer.showMouse(1)

Your first code worked I tried it. Because you imported it the way you did, you didn’t have to name the module. The other ways will work. Most of those are bad coding practices that people have picked up. The best way is:
import Rasterizer
Rasterizer.showMouse(1)

It’s the best because it’s the clearest and it avoids name collisions. It’s rediculous to import Rasterizer as r when it’s only used one time like that. If you name the module or class you won’t ever have to go to the top of the program and see where it came from. Most of these people that use those short cuts would be a lot better off doing some typing excersizes.

Ditto,


import Rasterizer

Rasterizer.showMouse(1)

End of story.

Thanks Guys!

that make sense!

But i ashure you my first code didn´t worked. I still don´t now why.

The only problem it had was that it wasn’t indented all the way to the left, but if it keeps you from writing code like that, all the better.

import Rasterizer as r
r.showMouse(1)