WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-29-2011, 05:36 AM
new_horizon new_horizon is offline
Member
 
Join Date: Apr 2010
Posts: 43
Randomly Choosing a WaitTime

Hi All,

I am working on a program at the moment that requires an event to occur for 0.25s, but the timing of that event to occur at some point within a 1 second time frame.

I have tried setting up a new variable

probetime = random.choice([0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75])

and then using the following line...

yield viztask.waitTime(probetime) # wait before probe motion begins

The error message I receive is...

probetime = random.choice([0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75])
AttributeError: 'module' object has no attribute 'choice'

Am I trying to use the wrong commands here? I have used random.choice when dealing with speed in the past, but never time.

Thanks
Reply With Quote
  #2  
Old 06-29-2011, 05:04 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,459
You can use the random.choice command:
Code:
import viz
import viztask
import random

viz.go()

def MyTask():
	
	while True:
		randomTime = random.choice([0.25,0.5,0.75])
		yield viztask.waitTime(randomTime)
		print randomTime,'seconds elapsed'

viztask.schedule( MyTask() )
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Randomly and Continuously Change Avatar's Face Texture Karla Vizard 4 08-22-2008 01:14 PM
waittime cade_mccall Vizard 4 04-29-2005 04:39 PM


All times are GMT -7. The time now is 05:35 AM.


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