I try to put a
delay(10.0) statement inside the function
OnSignalTrigger() to delay the execution of the script of a bool signal map. But the ‘delay()’ statement is skipped.
I try to put
OnRun() function, the statement works. Does this mean that
delay() only effective inside
Yes, it is by design so each script can only have one “paused” execution state. It would get complicated if you would have e.g. multiple OnSignal method calls running in parallel within a script.
Thank you for your reply.
Is there a way to schedule executing some statements in Visual Components? Such as, let a signal to be sent after 10 sec?
You can add delays in OnRun(), and use triggerCondition to wait for signal triggers.
from vcScript import *
triggerCondition(lambda: getTrigger() == signal1 and signal1.Value)
print("delaying for 10 seconds")
comp = getComponent()
signal1 = comp.findBehaviour("BooleanSignal")
signal2 = comp.findBehaviour("BooleanSignal_2")