WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   exiting a yield statement (https://forum.worldviz.com/showthread.php?t=2459)

starbug 01-12-2010 12:58 PM

exiting a yield statement
 
Hello there,

I have a question regarding exiting a yield statement, after a certain time elapsed. I am changing a global variable according to a keypress (using yield viztask.waitKeyDown) within a function, if that keypress should not happen, I want to exit the yield statement after a certain time interval. And continue the protocol with the unchanged global variable.
I might be wrong using yield, and there is some other way (I read about python threading?Running a timer parallel to yield?), could you point me to some example code? I couldn't find this scenario in the tutorial.
Thank you.



Code:

Step=1
Motion = 15
def control():
        global Motion
        ..... #dosomething with Motion
        for i in range(1,x)
                d = viz.Data()
                yield viztask.waitKeyDown(['y','n'],d) #or, if no key was pressed, after 2 sec exit yield
                if d.key == 'y':
                        Motion = Motion - Step
                elif d.key == 'n':
                        Motion = Motion + Step


farshizzo 01-12-2010 02:19 PM

Have a look at the viztask.waitAny condition. I believe the example on that page does exactly what you want.

starbug 01-12-2010 03:16 PM

Thank you! that I must have overlooked!


All times are GMT -7. The time now is 07:03 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC