What's wrong with this code?

import bge
from bge import render
render.showMouse(1)
def main()
    cont = bge.logic.getCurrentController()
    own = cont.owner
    
    sceneList = bge.logic.getSceneList()
    
    HUD = sceneList[1]
   
    mouseOver = cont.sensors["Mouse"]
    
    if mouseOver.positive:
        print ("Working.")
        target = mouseOver.hitObject
        Track = HUD.objects ["Tracker"]
        Mouse = Track.sensors["Mouse"]
        Track.activate(Mouse)
        
    else:
        Track.activate(Idle) 
main()

I can’t even get the print statement or mouse to be visible anymore. I almost had it working, then something went horribly wrong.

My goal is, when mouseOver any with a given property, to have the crosshairs (object "Tracker) in the HUD scene play an animation and revert back to the idle keyframe when not over said object(s).

I solved it with a simple logic message system, but I don’t know if this is the way to go since I want to add a dash-to object feature later on.

I think what might be wrong is you’re using an object to access sensors like so:


...
Track = HUD.objects["Tracker"] # This is an object.
Mouse = Track.sensors["Mouse"] # You can't access sensors using objects, only controllers.
...

Also, you can’t activate sensors that way. If you want to reset a sensor to run from its initial state, you can do:


...
someSensor.reset()
...

where someSensor is…well, some sensor.

And not sure about your ‘Idle’ variable - it’s not defined anywhere in that code.

Sidenote: Just so you know, running


render.showMouse(1)

frequently can cause a noticeable decrease in fps due to render workload.

Please also make sure all your variables are defined properly and have matching names (as in sensors) where necessary if you plan on using that code.

Hope that helps.