Browse Source

task: Add delay= argument to taskMgr.add()

This has the same effect as doMethodLater, but slightly better describes what it does
rdb 4 years ago
parent
commit
d043df7d4e
1 changed files with 6 additions and 1 deletions
  1. 6 1
      direct/src/task/Task.py

+ 6 - 1
direct/src/task/Task.py

@@ -333,7 +333,7 @@ class TaskManager:
 
 
     def add(self, funcOrTask, name = None, sort = None, extraArgs = None,
     def add(self, funcOrTask, name = None, sort = None, extraArgs = None,
             priority = None, uponDeath = None, appendTask = False,
             priority = None, uponDeath = None, appendTask = False,
-            taskChain = None, owner = None):
+            taskChain = None, owner = None, delay = None):
         """
         """
         Add a new task to the taskMgr.  The task will begin executing
         Add a new task to the taskMgr.  The task will begin executing
         immediately, or next frame if its sort value has already
         immediately, or next frame if its sort value has already
@@ -386,12 +386,17 @@ class TaskManager:
                 is called when the task terminates.  This is all the
                 is called when the task terminates.  This is all the
                 ownermeans.
                 ownermeans.
 
 
+            delay: an optional amount of seconds to wait before starting
+                the task (equivalent to doMethodLater).
+
         Returns:
         Returns:
             The new Task object that has been added, or the original
             The new Task object that has been added, or the original
             Task object that was passed in.
             Task object that was passed in.
         """
         """
 
 
         task = self.__setupTask(funcOrTask, name, priority, sort, extraArgs, taskChain, appendTask, owner, uponDeath)
         task = self.__setupTask(funcOrTask, name, priority, sort, extraArgs, taskChain, appendTask, owner, uponDeath)
+        if delay is not None:
+            task.setDelay(delay)
         self.mgr.add(task)
         self.mgr.add(task)
         return task
         return task