Vizard 8 » Command Index » Vizard modules » viztask » <viztask>.waitAny
8.0

<viztask>.waitAny

Wait for one of the specified conditions to occur

<viztask>.waitAny(  
conditions  
)  
conditions
A list of Condition objects

Remarks

This command will create a Condition object that will wait for one of the specified conditions to occur.

The yielded command returns a viz.Data object with the following information about the condition:

Properties

condition

The Condition object which occured

data

The data returned by the condition object

Return Value

viztask.Condition object

Example

Example 1:
import viztask

def MyTask():

    while True:

        yield viztask.waitAny( [ viztask.waitKeyDown(' '), viztask.waitTime(2) ] )

        print('Spacebar pressed or 2 seconds elapsed')

viztask.schedule( MyTask() )

Example 2:
import viztask

def MyTask():

    waitKey = viztask.waitKeyDown(' ')
    waitTime = viztask.waitTime(2)

    while True:

        d = yield viztask.waitAny( [ waitKey, waitTime ] )

        if d.condition is waitKey:
            print('Spacebar was pressed')
        elif d.condition is waitTime:
            print('2 seconds passed')
        else:
            print('A miracle occurred')

viztask.schedule( MyTask() )

See also

<viztask>.waitAll
<viztask>.waitTrue