[SOLVED] sensor sends a pulse when the button is released, how to discard it?

Hello there.

I have a left mouse button sensor attached to my python script, however, the sensor actually sends two pulses when the mouse is clicked, because it also sends the negative as a pulse.

So i wonder how to discard it without having to link another script, I could not figure out how to read the actual value of the pulse (so i could discard the negative value for example), when i try to read the value that the sensor is sending, I get the sensor name.

Thanks.

sensor.positive

for example:

cont = GameLogic.getCurrentController()
click = cont.sensors['Left Click']

if click.positive:
    # do what you want to do on positive pulse

elif not click.positive:
    # handle the negative pulse

BTW, the API is changing in Blender 2.5. Use the above code if you are using 2.49b, but if 2.5, change the line

cont = GameLogic.getCurrentController()

to

import bge

cont = bge.logic.getCurrentController()

to be up to date with the new API (even though the old way of doing it will still work).

Thank you very much Blendenzo! :smiley: