WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-08-2009, 12:14 PM
durf durf is offline
Member
 
Join Date: Feb 2009
Posts: 61
stopping ontimer

My program runs on onkeydown() that are assigned to different def func:. When i switch from func A to func B. A is still running. The reason is I think is becuase of the ontimers that I have associated with it. So is there anyway to stop and ontimer? Any other suggestions to handle this problem?
Code:
 
def funcA():

  def calculate():
  #CODE  

  vizact.ontimer2(0,viz.FOREVER,calculate)
vizact.onkeydown('a',funcA)

def funcB():

  def speed():
  #CODE

  vizact.ontimer2(0,viz.FOREVER,speed)
vizact.onkeydown('b',funcB)
Reply With Quote
  #2  
Old 04-09-2009, 11:03 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You could try this to keep only one timer active at a time.
Code:
import viz
viz.go()

def calculate():
      print 'calculate'  

def speed():
      print 'speed'

timer1 = vizact.ontimer2(1,viz.FOREVER,calculate)
timer2 = vizact.ontimer2(1,viz.FOREVER,speed)
timer1.setEnabled(viz.OFF)
timer2.setEnabled(viz.OFF)

def funcA():
  
  timer1.setEnabled(viz.ON)
  timer2.setEnabled(viz.OFF)

vizact.onkeydown('a',funcA)


def funcB():
  
  timer1.setEnabled(viz.OFF)
  timer2.setEnabled(viz.ON)
  
vizact.onkeydown('b',funcB)
Reply With Quote
  #3  
Old 04-11-2009, 10:06 AM
durf durf is offline
Member
 
Join Date: Feb 2009
Posts: 61
Is there a way to use the same key to turn on and turn off the same function?

IE. If I hit 'a' to enable def calculate() then I hit 'a' again to disable def calculate().

I have the idea I think for it. Which would be to have a bool value and then change it from true to false and have if else statements to check it. Could be wrong thats why Im asking.
Reply With Quote
  #4  
Old 04-11-2009, 06:50 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You could use viz.TOGGLE so that each time you press the key the timer will change states and your function will either start or stop being called

Code:
def funcA():
  timer1.setEnabled(viz.TOGGLE)

vizact.onkeydown('a',funcA)


def funcB():
  timer2.setEnabled(viz.TOGGLE)
  
vizact.onkeydown('b',funcB)
Reply With Quote
  #5  
Old 06-02-2009, 11:38 AM
yak yak is offline
Member
 
Join Date: May 2009
Posts: 22
i have an application where i have my 3d human model walking but i want it to freeze...or pause how can i do that.
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
stopping a function durf Vizard 1 03-31-2009 04:45 PM
stopping a goto() vsully Vizard 1 01-24-2006 01:43 PM
partially stopping tracking vsully Vizard 1 01-12-2005 09:02 AM


All times are GMT -7. The time now is 02:32 PM.


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