Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Adds a new task to a triggerprocess instance. |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
triggerProcesses("myProcess").addTask(task, iterate, taskName, scope); |
Parameters
Parameter | Type | Mandatory | Notes | Pulse Version | |||||
---|---|---|---|---|---|---|---|---|---|
task | FunctionTask Array of FunctionTasks | The task function, or an array of task functionstasks. If an array of tasks is used, each task in the array will be added in sequence with the other parameters applied to it. The taskName for each task will be appended with the array index . | 0.1 | iterate | Constant | (see below). | 0.1 | ||
taskName | String | Optionally specify a name for the task(s). If no name is specified, the function name will be used if possible, otherwise the name will default to "AnonymousTask". If an array of tasks was passed in on the 'task' parameter, each task will be given a name in the form: "taskName._i" where "i" is the index of the array indextask in the array. It's recommended to always name your tasks (or make sure they are named functions) to aid with diagnostics. | 0.1 | ||||||
scope | Object | Optionally specify an object scope in which the task(s) should be run. This is ideal for scripts that use OO programming OOP as you can run the task(s) as if it were a method on some object. Defaults to global scope. | 0.1 |
Return value
Value | Type | Notes | Pulse Version | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
<trigger><instance> | TriggerProcess Instance | The trigger process instance to which the task is added is returned, so you can chain more trigger instance methods, eg:
| 0.1 | |||||||||
<error> | Error | If invalid parameters are passed to .addTask(), an error will be thrown. | Planned for 0.2 |
Examples
// the task will be performed roughly every 2 seconds after eventStartLevel() // taskName will be same as function name ("taskUpdateLasSat") // the task will be called for each living player in turn
Div | ||
---|---|---|
| ||
AvailabilityRequires:
Some changes are planned to the return value in Pulse Process v0.2. |
Div | ||
---|---|---|
| ||
See alsoEssential reading:
|