![]() |
timer counter
Is it possible to count how many times a timer has been called back (without the use of a counting variable)?
viz.elapsed() gives me the same numbers every time because it's only counting how long THIS instance has run. what about all instances? thanks! |
i guess this is a better question:
i want to draw a line between the coordinates an object was at two seconds ago and the coordinates the object is at now. so i ran a timer to repeat every 2 seconds. the problem is obvious, and i would imagine the solution is equally so. i just can't figure it out. the first time the function runs, i am told the variable 'oldLoc' is not defined. but if i define it in the first line of the function, it will be initialized every time the function is run and it will always be '[0,0,0]'. how can i work around this? i figure i could run a counter that assigns an arbitrary coordinate to 'oldLoc' the first time the function is run. but no matter how i do it, that counter is reset (initialized) every time the function is invoked. hope this makes sense. thanks! Code:
def mytimer(num): |
You need to declare the oldLocs variable as global. Your code should look like the following:
Code:
oldLocs = [ [0,0,0] for x in range(numLights) ] #Initialize to some value |
All times are GMT -7. The time now is 07:40 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC