Whenever I run my task code it says. “World instance had no attribute ‘time’”.
My code is…
import direct.directbase.DirectStart
from direct.task import Task
from direct.showbase.DirectObject import DirectObject
import time, math, sys, os
class world (DirectObject):
def __init__(self):
self.acceptOnce('a',self.taskOnTime,extraArgs=['hi'])
def taskOnTime(task, self):
if task.time < 2.0:
return task.cont
extra = OnscreenText(text="Game will begin in 5 seconds...",
style=1, fg=(1,1,1,1),
pos=(-.70,-.6), scale = .1)
return task.done
w = world()
run()
Actually, that’s because the argument passed in ‘task’ is in fact a string, which contains ‘hi’. That function is not a task, in fact, while you treat it like one.