From d043df7d4e3cc4c10c07f89f9e52f32ba8cb7898 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 18 Jan 2021 23:37:23 +0100 Subject: [PATCH] task: Add delay= argument to taskMgr.add() This has the same effect as doMethodLater, but slightly better describes what it does --- direct/src/task/Task.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index bc7b9b6e6a..7be8e077d4 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -333,7 +333,7 @@ class TaskManager: def add(self, funcOrTask, name = None, sort = None, extraArgs = None, 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 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 ownermeans. + delay: an optional amount of seconds to wait before starting + the task (equivalent to doMethodLater). + Returns: The new Task object that has been added, or the original Task object that was passed in. """ task = self.__setupTask(funcOrTask, name, priority, sort, extraArgs, taskChain, appendTask, owner, uponDeath) + if delay is not None: + task.setDelay(delay) self.mgr.add(task) return task