run script with out True Level Trig?


When i code in the bge, i usually display prints in the console after i have done something (just for debugging purposes), but since i run my scripts using the Always actuator, with True Level Triggering enabled, i get too many of the same prints, is there a way to get around this?

any help appreciated

Hi! You can simply remove the true level triggering… But if you can’t, you can use:

if mySensor.status == 1: #just activated
    print(...)
if "init" not in own:
    print(...)
    own["init"] = True

Thanks very much!

Don’t use hard coded constants, use http://www.blender.org/api/blender_python_api_2_60a_release/bge.logic.html#sensor-status

@agoose77: It’s just really hard to write bge.logic.KX_INPUT_JUST_ACTIVATED on azerty keyboard :slight_smile: But for readability, it’s better…

As long as you have access to <ctrl+c> and <ctrl+p> it is really no problem :D.

You can also alias it to a shorter name, e.g


from bge import logic

JUST_ACTIVATED = bge.logic.<b>KX_SENSOR_JUST_ACTIVATED

def some_func(cont):
    pass