help please ...noob problem

this is my code

taskMgr.add(self.showtalk,‘showtalkPlayer’, [color=blue]extraArgs=[player])

def showtalk (self,[color=blue] instance):
pos =self.map3dToAspect2d(render,[color=blue]instance.dummy.getPos())

currentTime = [color=orange]task.time - timeOffset
    if currentTime >= 0.05 :
        instance.Timefag += 1
    timeOffset = task.time

if instance.Timefag <5:
	if pos==None:
    return Task.cont

then it show error like this
[color=red]Global name ‘task’ is not defind

and when i use this
def showtalk (self,[color=blue]task, instance):
then it show error like this
[color=red]showtalk() takes exactly 3 arguments (2 given)

how can i do?
if i want to use task.time and extraArgs

help please
i’m noob in panda and python

That is, uhm, a tricky problem.

You can try using the appendTask=True parameter in taskMgr.add, and swapping the two parameters in your task function. For example:

taskMgr.add(self.showtalk,'showtalkPlayer', extraArgs=[player], appendTask=True)

def showtalk (self,instance,task):
        #do your stuff here
        return task.cont

thank you for your answer

:confused: but it still have error like this
[color=red]add() got an unexpected keyword argument ‘appendTask’

and i see in manual
Class TaskManager Method add() have argument ‘appendTask’

why it show error?

Hmm. You must be using a very old version of Panda3D?

Do you have the latest version (as of writing 1.4.2)?

Ahh…i use 1.3.2

So…i have to upgrade right?


Thank you pro-rsoft

Thank you very much pro-rsoft

i can do it now