#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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() ) |
|
|
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 |