-

Answer is here…
discourse.panda3d.org/viewtopic.php?t=3

To qoute David…

If you need to access task.time, or other members of the Task structure, then you should explicitly include the Task structure as part of the extraArgs list.


task = Task(self.myCallback)
taskMgr.add(task, extraArgs = [task, myArg1, myArg2])

David

That’s an error with the way you have imported the Task module. Make sure you import it like this:


from Task import *

And not like this:


import Task

David

Call

Task.Task(self.spaceCraftFireTask)

I have the same problem. Can anybody tell me whats the matter of my code

from direct.task import *

player= Player.Player()

def childs(task,node):
	if node.getNumChildren() == 0:
		print "NODE: ", node, "\n\tHPR: ", node.getHpr(), "\n\tPos: ", node.getPos()
		return Task.cont
	else:
		for i in range(0, node.getNumChildren() ):
			childs(node.getChild(i))
		return Task.cont

task= Task.Task(childs)
#taskMgr.add(childstask, "viewtask")
taskMgr.add(task, "viewtask1", extraArgs= [task,player.model] )

This is what I get

  File "D:\Panda3D-1.1.0\direct\src\showbase\ShowBase.py", line 1798, in run
    self.taskMgr.run()
  File "D:\Panda3D-1.1.0\direct\src\task\Task.py", line 782, in run
    self.step()
  File "D:\Panda3D-1.1.0\direct\src\task\Task.py", line 730, in step
    self.__stepThroughList(taskPriList)
  File "D:\Panda3D-1.1.0\direct\src\task\Task.py", line 673, in __stepThroughLis
t
    ret = self.__executeTask(task)
  File "D:\Panda3D-1.1.0\direct\src\task\Task.py", line 602, in __executeTask
    ret = task(*task.extraArgs)
  File "VirtualWorld.py", line 32, in childs
    childs(node.getChild(i))
TypeError: childs() takes exactly 2 arguments (1 given)

Thanks Martin

Maybe you meant to type this instead:


childs(task, node.getChild(i))

David

O sh…
Sorry that i’ve bottered you with that.

Martin