WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   stopping a function (https://forum.worldviz.com/showthread.php?t=1940)

durf 03-31-2009 09:50 AM

stopping a function
 
Hello,

I have def func1() and def func2() that do not run on timers of there own. I have a def maintask() that controls when each of the def() will start. The problem I am having is once func1() time has expired and func2() timer starts func1() keeps runnning.
Code:


def MainTask():
       
        #Run func1 for 10 seconds
        timer = vizact.ontimer2(0,0,func1)
        yield viztask.waitTime(10)
        timer.remove()
       
        #Run func2 for 10 seconds
        timer = vizact.ontimer2(0,0,func2)
        yield viztask.waitTime(10)
        timer.remove()

        #Quit script
        timer = vizact.ontimer2(0,0,func3)
        yield viztask.waitTime(viz.FOREVER)
       
viztask.schedule( MainTask() )

how do I stop func1() from running once func2() has started?

I can supply more code if need be. Just looking for an example

masaki 03-31-2009 04:45 PM

in order to kill a vizact timer, use the following code:
Code:

timer.setEnabled(viz.OFF)
if you want to kill a viztask function use the following code:
Code:

task = viztask.schedule( sometask() )
task.kill()

-masaki


All times are GMT -7. The time now is 03:04 AM.

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