Simple 3d Cursor script not working [blender 2.5]

Hello. I’m trying to learn python better along with BGE’s API; I’m using recent builds of blender 2.5x

I’ve been trying to code something that should be fairly simple, a 3d cursor:
I get the coordinates of the mouse and use them to move a 3d object to those coordinates.

The 2d mouse cursor displays and moves, but the 3d cursor doesn’t move at all (it’s from an overlayed scene)
Here’s part of the code:

import bge
import Rasterizer
Rasterizer.showMouse(1)
#getting 2d mouse coordinates
#is SCA_MouseSensor a better function? http://www.blender.org/documentation/250PythonDoc/bge.types.html#bge.types.SCA_MouseSensor
pos = bge.logic.SCA_PythonMouse.position
x = pos[0]*bge.render.getWindowWidth()
y = pos[1]*bge.render.getWindowHeight()

#assigning the 2d coordinates to the 3d cursor
cursor=bge.logic.getCurrentController().owner
cursor.worldPosition = [x, 0, y]

Also, here’s my blend file: http://www.pasteall.org/blend/4406

Please help me out; this has been driving me crazy. Everything I try to do with BGE overall fails, due to bugs or crappy documentation…
Maybe I’m not thinking this through properly or something like that.

On IRC I’ve been threaded with a “learn python attitude” which is not very cool; I learned the basics and I need to start somewhere with this kind of stuff…

Hi. Write instead of pos = bge.logic.SCA_PythonMouse.position --> pos = bge.logic.mouse.position (http://www.blender.org/documentation/250PythonDoc/bge.logic.html#input-status). And you must enable the true puls on the always sensor. Now you get the relative position from the mouse. But if I look at the rest of your code, the mouse just jump out of the screen.

I changed Blendenzo’s CustomCursor.blend file to Blender 2.5x and add your cursor to it.
custom3DCursor2_5x.blend (309 KB)

Yeah, I managed to get a somewhat functional version since I’ve posted, but I had to simplify the scene, so no more overlayed scene and also, the 2d cursor coordinates had to be better mapped/translated to the 3d cursor (cursor was having inverted move as well).

wiseman helped me with a script using the mouse sensor as well, but it didn’t worked with overlay and it sort of rotated the cursor oddly.
The blend you provided works fine for me.Thanks for the help, I really appreciate it!