Blender Game Engine logics sensors and python script I'm trying to build a simple user interface in Blender Game Engine. 2 buttons (launch and quit).

Each button got a "Mousse Over" and "Left Button" sensors connect to a one Python controller. 

Here my script menu.py:

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

OverLancer = cont.sensors['Over.Lancer']
ClickLancer = cont.sensors['Click.Lancer']
OverQuitter = cont.sensors['Over.Quitter']
ClickQuitter = cont.sensors['Click.Quitter']

if OverLancer.positive and ClickLancer.positive :
    print("lancer")

if OverQuitter.positive and ClickQuitter.positive :
    print("Quitter")


Nothing works as expected. I got the error "sensor not found" for all of them and I don't understand where I'm wrong. I saw as well something strange. My sensor names change like that .Blender add .001 sometime ...why?

And there is old deleted code line in the error message, again strange.

Python script error - object 'Bouton lancer', controller 'And.002':
Traceback (most recent call last):
  File "menu.py", line 6, in &lt;module&gt;
    print (cont.sensors)
KeyError: 'requested item "Over.Lancer" does not exist'


For example "print (cont.sensors)" is not present in menu.py !?!?

If anybody got an idea, it's will be great.

Thanks!
Each object has a self "scope" or "namespace", so the (object 1) controller can no access sensors from (object 2) controller even if they are using the same script, which is your case.

BUT you CAN CONNECT SENSORS from multiples to one (or more) CONTROLERS

Simple select all objects which sensors would be used and at the last select the object with the controller. to select multiple objects keep press Shit and Mouse Rigth Button on objects.

objects: Sphere has "Mouse_Sphere" sensor while Cube has "Mouse_Cube" and i want to use each sensor in one script and the controller is in Torus.



[