Multiple owners?

def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner
    scene = bge.logic.getCurrentScene()
    ring = scene.objects["sel_ring"]
    newPos = own.position
    sens = cont.sensors['Mouse']

    if sens.positive:
        aaa = "asdf"
        ring.position = newPos
        aaa = "asdf"


This script runs when object a or object b is mouse clicked.
print( will print BOTH objects names to the console.
Both objects have a sensor called “Mouse”.

Question: Does that mean every sensor for every object that calls this script… is the owner? I was thinking the owner would be the object… of the sensor… that currently called the script.

Basically, I dont know how to know which object is being clicked… Hmmm.

Gah… figured it out… and it really has nothing to do with that. EVERY time a mouse was clicked, all the scripts associated with a mouse click would run… since the scripts dont run AFTER the AND. So ANY mouse click would trigger everything.

It would be nice to call the script after the Mouse click, and the Mouse over were combined.

You can use mouseevent 3 [[if mouseEv[189] ==3]]. Which will only run whats under after the click is released. Also with a mouseover sensor of some type.

I have a script that tuns on the “selected” status of object b from object a with mouseoverany and objectHit. On the object b itself, it has in inverted mouseover. So it clears"selected" when not mouseover anymore and click.

I eventually just added script that checks If mouseLeft and mouseOver then… this must be ok to execute. This way, it only executes while mouse is over that object, and not just any random clicked object.

Im getting a headache, lol.

No, sensors do not call Python code. Sensors trigger controllers which execute whatever they do (e.g. execute AND, execute Python code). Each controller can be executed just once within a logic frame.

The owner of a controller is the object the controller is assigned to.
The owner of a sensor is the object the sensor is assigned to.
The owner of an actuator is the object the actuator is assigned to.

All this owners do not need to be the same (in most cases they are ;))

Lol, I figured that out. I managed to trick myself. Eh. =)

good work :smiley: