WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Am I using 'ontimer' incorrectly? (https://forum.worldviz.com/showthread.php?t=4556)

andy_k 04-19-2013 05:55 AM

Am I using 'ontimer' incorrectly?
 
I am very new to programming in Vizard, but I am a pretty strong .js programmer. I have an art gallery and I want a man to walk from picture to picture. He needs to wait for a few seconds at each picture.

So I have a number of walking sequences and I'm trying to use the 'ontimer' function to call the next walk sequence and also add a few seconds of delay.

It works perfectly the first time it is called, in dostuff(), but doesn't work at all in dostuff2(). I assume I am using 'ontimer' incorrectly, could anyone explain where I am going wrong?

Any help or advice would be hugely appreciated!


walkOne = vizact.walkto(4, -0.5, 4)
turnOne = vizact.turn(60)
walking_sequence = vizact.sequence( [walkOne, turnOne])


walkTwo = vizact.walkto(5.350, -0.5, -2)
turnTwo = vizact.turn(60)
walking_sequenceTwo = vizact.sequence( [walkTwo, turnTwo])


def dostuff():
male.addAction(walking_sequence)
vizact.ontimer(10,dostuff2)

def dostuff2():
male.addAction(walking_sequenceTwo)
print(vizact.ontimer)
vizact.ontimer(20,dostuff)

Jeff 04-19-2013 09:34 AM

Instead of using timer functions you could insert vizact.waittime actions into the avatar's action sequence. The gallery.py world demo (Help -> World Demos) shows an example of that. Also, take a look at task functions, which are useful for controlling program flow.

I'm not sure if one of the vizact.ontimer commands is within a function. Please use the code tags to preserve indentation. If you only want a timer function to be called once, register the function with the ontimer2 command and set the repeats parameter to 0.

KoRnemuse 04-18-2014 01:18 AM

Hello everyone!
I post here cause I have a question about the using of ontimer.

I know that ontimer call a function but whenever I try to call a function which needs an argument I got an error on the type of my argument. It says 'Nonetype' object is not callable.

I precise that I created the argument before calling ontimer.

Here's what I want to do:

init = False
vizact.ontimer(0,suivi(init))

I can tell that my function is working perfectly because I tried it without the timer on.

Cheers KoRnemuse

farshizzo 04-18-2014 09:07 AM

In the future, please create a new post for your questions.

The vizact.ontimer command is expecting a function object as the second argument. Instead, you are giving it the result of calling the suivi function. You should just pass the function instead of calling it:
Code:

# Call 'suivi' every frame with 'init' argument
vizact.ontimer(0, suivi, init)


KoRnemuse 04-22-2014 07:17 AM

Thank you for your answer and sorry to up an ancient post.

I will ask an other question in a new post.

KoRnemuse


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

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