Using Sensor functions without the bricks?

Hey guys out there, I have a unique question.
Is it possible to use, for example the mouseOver function from the mouse brick, without the Brick?

I know that I could use

bge.logic.KX_INPUT_ACTIVE == bge.logic.keyboard.events[bge.events.XKEY]

to get the event on the x key (or every other key), so I don´t have to use the keyboard brick.

There is a mouse function in bge.logic but I don´t know how to handle it and I don´t found something like mouseOver there.

If someone has an idea, I would be curious to read it!
Thanks for your time ^^

You can add a object that is the sensor to get input from it next frame,

like
Sensor = bge.logic.getCurrentScene().addObject(‘Radar’,own,1)
Sensor[‘PropertySensorLooksFor’] = targetProperty

and have a brick marked first in the sensor object that applies the property to thr sensor, and then have a script attached to the sensor that sets the data in the script that called the sensor.

The mouse over sensor triggers the controller if something changed. This is pretty efficient. The sensor provides you with all information you can get from that event.

Here is a solution:
Use an always sensor that constantly triggers a Python controller.
The Python controller:

  • evaluates the mouse cursor position
  • transforms it into a ray from camera origin through this cursor position
  • when the ray hits something you get an hitObject

All of that is done by the Mouse over (any) sensor already … and it runs in native code.

yeah monster is right, if you want mouse over, just use 1?

you can even get at the data it creates with other sensors, if you use ‘run first order hack’ and store a property, and if the sensor is firing…

MouseOverAny----------python
always-----------------/


import bge
cont = bge.logic.getCurrentController()
own = cont.owner
MOA = cont.sensors['MouseOverAny']
if MOA.Positive:
    own['Positive']=True
    own['Target']=MOA.hitObject
else:
    own['Positive']=False
    own['Target']="Empty"

then other objects can lookup and store the mouse over sensor object, and grab data when it needs it?


if 'MouseOverObject' not in own:
    own['MouseOverObject']=bge.logic.getCurrentScene().objects['MouseOverOb']
else:
     MOO = own['MouseOverObject']
     if MOO['Positive']==True:
         own['Target']=MOO['Target']