WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-12-2010, 01:58 PM
starbug starbug is offline
Member
 
Join Date: Dec 2009
Posts: 5
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
Reply With Quote
  #2  
Old 01-12-2010, 03:19 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Have a look at the viztask.waitAny condition. I believe the example on that page does exactly what you want.
Reply With Quote
  #3  
Old 01-12-2010, 04:16 PM
starbug starbug is offline
Member
 
Join Date: Dec 2009
Posts: 5
Thank you! that I must have overlooked!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vizard Tip of the Month: Use Tasks to Simplify your Code Gladsomebeast Vizard 5 05-02-2008 05:30 PM
switch statement vrlab Vizard 1 08-04-2004 11:23 AM


All times are GMT -7. The time now is 08:17 AM.


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