Two taskMgr questions

Hello all,

My first question is regarding taskManager’s arguments.
I was surprized when I used it like this:

taskMgr.doMethodLater(3,self.initGame,"initGame",extraArgs = [room])

that arguments take place of the elapsed/task keyword I was supposed to add.

Indeed, I firstly was tented to write something like this

  def initGame(self,task,room):
    return Task.done

which generate an error while this works:

  def initGame(self,room):   #APPARENTLY "task" IS NOT NEEDED HERE
    return Task.done

This confused me and I’m wondering (even no errors) if the second def is correct.
If yes, how can I call globalClock.getDt() ?

Second question is related to intervals and functions against taskMgr.
Sometimes, I’m hesitating about which one to use… Using Func within intervals can do the same thing than taskMgr so what’s the border between them ?

Correct, when you specify the extraArgs parameter, it replaces the default arguments, including the task variable. If you want the task variable to be included anyway, pass appendTask = True to the taskMgr.add() function.

Note that you don’t need the task variable to call globalClock.getDt(), but I guess you meant task.getDt().

There is considerable overlap between tasks and intervals. Some things can be done by either. But generally, intervals are designed for static, pre-scripted actions, and tasks are designed for dynamic, anything-goes stuff. Tasks are more powerful, in general, but can be harder to use for pre-scripted things.


As always straight and simple… :slight_smile:
Thanks David :slight_smile: