Mouse over and Left Mouse

Hello everybody!
I need help about the use of the Mouse sensor in Blender.
I have a simply object (named obj0 for example) that has 3 sensors: always, mouse over and left mouse linked to a python controller, so that when I click on it, the script runs and print the name of the object clicked.
So far, so good, but if I duplicate this object and name the copy obj1 for example, when I click on obj0 or obj1, the script returns the name of both objects.
What’s up?

import GameLogic
cont = GameLogic.getCurrentController()
own = cont.owner
s = str(own)
over = cont.sensors.get(‘over_’+s)
click = cont.sensors.get(‘click_’+s)
if (over.positive==1 and click.positive==1):
print (s)

The mouse over event is always negative and so the if statement gives a negative result, but also if I substitute

if (click.positive==1):

the script prints obj0 and obj1…:frowning:

First of all please use the

 tags to present scripts in the forum.

Checking mouse over and LMK mouse sensors to be positive is correct. 
The always sensor is not necessary, as the mouse sensors will be negative.

If your script returns both object names this means:
1. both controllers are triggered (this is correct as at least the LMK sensor triggeres both)
2. if mouse over is negative... the mouse cursor is not over the object with the mouse over sensor.

I hope it helps

The two points thaht you present are the same questions that I ask to myself. LMK mouse sensor triggeres both, but I put the cursor over obj0 and not obj1, but the sensor is always negative! If I write
[print (over.positive)]
this returns 0

not in my case:


# Test.py
def showMouse(cont):
    import Rasterizer
    Rasterizer.showMouse(1)
    
def test(cont):
    for sens in cont.sensors:
        print sens,sens.positive

Always (no Pulse) -> Python Module: Test.showMouse
Mouse over + Mouse LMK -> Python Module: Test.test

check the console

But it’s the first time that happens a similar case!
In my project I use the mouse over sensor more time and it was positive every time it was necessary.
But in this case it’s a mischievous sensor!
So I thought that the reason was in the duplication of the object.
Boh!