doMethodLater ... function never gets called

Hi all,

I’m trying to run this simple script below, but for some reason myFunction never gets called.
With DirectStart it is working, but at the moment I don’t want to use DirectStart. :cry:

It somehow works withpout DirectStart if I use a negative number, but that isn’t right.

Maybe someone can help me.

Greetings
Revington

used system:
Windows XP SP3
Python 2.6.6
Panda3D 1.7.0

# coding=cp1250

from direct.task.TaskManagerGlobal import taskMgr
from direct.task import Task

def myFunction():
    print "... counting ..."
    return Task.cont

myTask = taskMgr.doMethodLater(1, myFunction, 'tickTask')
    
taskMgr.run()

So I figured that the default task chain is not ticking:
If I do something like the below, it’s “working”:

# coding=cp1250

from direct.task.TaskManagerGlobal import taskMgr
from direct.task import Task
from panda3d.core import ClockObject 

def myFunction(task):
    print "... counting ..."
    return Task.again

    
myTask = taskMgr.doMethodLater(2, myFunction, 'tickTask')
globalClock = ClockObject.getGlobalClock()

while 1:
    globalClock.tick()
    taskMgr.step()

But I would like to simply do a taskMgr.run() :confused:

Hi again,

still can’t simply do a taskMgr.run but if I use setTickClock(True) on the default chain it works:

chain = taskMgr.mgr.findTaskChain("default")
chain.setTickClock(True)

Is it possible to get this to work without findTaskChain?

It is certainly possible. It means you have to do the setup stuff that would normally be done by importing DirectStart (or by creating a ShowBase instance). But why not just import DirectStart (or create a ShowBase)? This sets up all sorts of useful things that many subsystems in Panda assume will have already been set up.

If your only goal is to avoid opening a window, set “window-type none” in your Config.prc, before you import DirectStart. Plenty of examples of people doing this in the forums.

David

I’ll later probably go with an instance of ShowBase but for some tests it would be nice if the code could be as lean as possible.

I looked through ShowBase.py but unfortunately didn’t find anything besides the Clock/tick stuff.

Anyway - for the tests, it’s working. :slight_smile: