WorldViz User Forum

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

durf 04-14-2009 11:34 AM

stopping a sequence
 
HI,

This is the code Im running:

Code:


def moveFlowers():
       
        x,y,z = ball1.getPosition()

        if  x <= -12 and x >= -10:

                goto1 = vizact.sequence(vizact.goto(-11,10,-10,5),vizact.waittime(2),vizact.goto(-11,5,-10,6),vizact.waittime(2))
                goto2 = vizact.sequence(vizact.goto(-11,15,-10,5),vizact.waittime(2),vizact.goto(-11,6,-10,6),vizact.waittime(2))
                middle1.runAction(goto1)
                top1.runAction(goto2)
               
        elif x <= -11 and x >= -13:

                goto1 = vizact.sequence(vizact.goto(-12,10,25,5),vizact.waittime(3.5),vizact.goto(-12,5,25,6),vizact.waittime(2))
                goto2 = vizact.sequence(vizact.goto(-12,15,25,5),vizact.waittime(2),vizact.goto(-12,6,25,6),vizact.waittime(2))
                middle2.add(goto1)
                top2.add(goto2)

        elif x <= -10 and x >= -8:
               
                goto1 = vizact.sequence(vizact.goto(-9,10,22,5),vizact.waittime(3.5),vizact.goto(-9,5,22,6),vizact.waittime(2))
                goto2 = vizact.sequence(vizact.goto(-9,15,22,5),vizact.waittime(2),vizact.goto(-9,6,22,6),vizact.waittime(2))
                middle3.add(goto1)
                top3.add(goto2)

        elif x <= 1 and x >= -1:
               
                goto1 = vizact.sequence(vizact.goto(0,10,28,5),vizact.waittime(3.5),vizact.goto(0,5,28,6),vizact.waittime(2))
                goto2 = vizact.sequence(vizact.goto(0,15,28,5),vizact.waittime(2),vizact.goto(0,6,28,6),vizact.waittime(2))
                middle4.add(goto1)
                top4.add(goto2)
       
        elif x <= 8 and x >= 6:
               
                goto1 = vizact.sequence(vizact.goto(7,10,25,5),vizact.waittime(3.5),vizact.goto(7,5,25,6),vizact.waittime(2))
                goto2 = vizact.sequence(vizact.goto(7,15,25,5),vizact.waittime(2),vizact.goto(7,6,25,6),vizact.waittime(2))
                middle5.add(goto1)
                top5.add(goto2)

        elif x <= 13 and x >= 11:
               
                goto1 = vizact.sequence(vizact.goto(12,10,29,5),vizact.waittime(3.5),vizact.goto(12,5,29,6),vizact.waittime(2))
                goto2 = vizact.sequence(vizact.goto(12,15,29,5),vizact.waittime(2),vizact.goto(12,6,29,6),vizact.waittime(2))
                middle6.add(goto1)
                top6.add(goto2)
               
        elif x <= 17 and x >= 15:
               
                goto1 = vizact.sequence(vizact.goto(16,10,-10,5),vizact.waittime(3.5),vizact.goto(16,5,-10,6),vizact.waittime(2))
                goto2 = vizact.sequence(vizact.goto(16,15,-10,5),vizact.waittime(2),vizact.goto(16,6,-10,6),vizact.waittime(2))
                middle7.add(goto1)
                top7.add(goto2)
               
timer5 = vizact.ontimer2(0,viz.FOREVER,moveFlowers)
timer5.setEnabled(viz.OFF) # I enable it from else where

When the ppt sensors x position is true to one of the if statements the sequence runs. When I move the ppt sensor away from that x position, which would then make that if statement false, the sequence continues to run. I even tried putting 0 repeats at the end of the sequence but it keeps running like its in a loop. how do I get this so it runs once everytime the x position is true with the if statement and not in a loop.

moooh 04-14-2009 01:31 PM

They are not running in a loop and the statement will indeed turn false when you move the sensor away, however by the looks of it you are running the moveFlowers function every frame, so once you have the sensor in a position where a condition will be true, the actions will keep adding up for every frame you spend in that position.
Even if you move away really quickly you will probably have hundreds of actions queued after eachother, which is why it feels like they are running in a loop.

If you just want to replace the previous action with the new one you can try and clear the actions of each node before adding the new, using the .clearActions call.


All times are GMT -7. The time now is 12:57 AM.

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