This AI is still in early stages of development.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Adds a new task to a trigger.

 

Syntax

trigger.addTask(task, iterate, taskName, scope);

Parameters

ParameterTypeMandatoryNotesPulse Version
task

Function

Array of Function

(tick)

The task function, or an array of task functions.

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
iterateConstant(error)

Optionally state whether the task(s) should be player iterated. Possible values are:

For more information, see Task Iteration.

0.1
taskNameString(error)

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 array index.

0.1
scopeObject(error)

Optionally specify an object scope in which the task(s) should be run.

This is ideal for scripts that use OO programming as you can run the task(s) as if it were a method on some object.

Defaults to global scope.

0.1

Return value

ValueTypeNotesPulse Version
<trigger>Trigger

The trigger to which the task is added is returned, so you can chain more trigger methods, eg:

trigger.addTask(...).addTask(...).start();
0.1
<error>ErrorIf invalid parameters are passed to .addTask(), an error will be thrown.Planned for 0.2

Examples

Add .hasLasSat field to player objects
// initialise player objects
playerData.forEach(function(data, player){
	data.hasLasSat = enumStruct(player, LASSAT).length;
});
 
// create our task
var taskUpdateLasSat = function(player) {
	playerData[player].hasLasSat = enumStruct(player, LASSAT).length;
}
 
// get/create "trigPlayerData" trigger, add task to it
Pulse("trigPlayerData", 2000, true).addTask(taskUpdateLasSat, PULSE_ITER_ALL);
 
// 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

Availability

Requires:

  • Warzone 3.1 or above
  • Pulse 0.1 or above

Some changes are planned to the return value in Pulse v0.2.

 

  • No labels