import bge
def main():
cont = bge.logic.getCurrentController()
jumpBAR = cont.owner
keypress = bge.logic.keyboard.events
JUST_ACTIVE = bge.logic.KX_INPUT_ACTIVE
JUST_RELEASED = bge.logic.KX_INPUT_JUST_RELEASED
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
if (jumpBAR['animJUMP'] == 0):
jumpBAR.visible = False
if keypress[bge.events.SPACEKEY] == JUST_ACTIVE:
if not keypress[bge.events.SPACEKEY] == JUST_RELEASED:
jumpBAR['GcurJUMP'] = jumpBAR['curJUMP']
jumpBAR['curJUMP'] = jumpBAR['curJUMP'] + 2
percHP = jumpBAR['curJUMP'] / jumpBAR['maxJUMP'] * 100
GpercHP = jumpBAR['GcurJUMP'] / jumpBAR['maxJUMP'] * 100
jumpBAR['animJUMP'] = percHP * 5
jumpBAR['GanimJUMP'] = GpercHP * 5
jumpBAR.visible = True
jumpBAR.playAction("Bar-Jump-Move", jumpBAR['GanimJUMP'], jumpBAR['animJUMP'], play_mode=bge.logic.KX_ACTION_MODE_PLAY, speed = 10.0)
if jumpBAR['curJUMP'] > jumpBAR['maxJUMP']:
jumpBAR['curJUMP'] = 0
print("I only want to go here once the key is released")
main()
I am trying to charge / count a variable while the SPACEKEY is held. The problem is, ever tick the JUST_ACTIVE logic finishes going to the print line listed at the bottom every cycle. How can I start routine until a key is released and not break out of it until then? Thank you.