I'm trying to use timeout on python to make a quick time event. The problem arises when I try to change up the code a little bit.
This is the code:
import time
from threading import *
time.sleep(random.randint(1,5))
timeout = 5
#want to replace "you timed out" with function lets say menu.hall()
l = Timer(timeout, print, ["You timed out"] )
l.start()
start_time = time.time()
lol = f"You have {timeout} seconds to dodge, press enter...\n"
answer = input(lol)
l.cancel()
end_time = time.time()
reaction_time = end_time - start_time
if reaction_time < timeout:
print(f"You dodged in {reaction_time}! ")
time.sleep(3)
menu.startp()
I'm trying to replace "you timed out" with a function and the problem rose that the function wouldn't start until it got to the replacement, and then it wouldn't complete the quick time event. What should I do to fix this problem?