(info) This AI is still in early stages of development.

Process()

Used to create and retrieve Process Instances.

 

Syntax

Note the capital "P" in the function name!

// Create an instance:
Process(processName, priority, interval, autoActivate, autoDeactivate);
 
// Retrieve existing instance:
Process(processName);

Properties

The properties are as follows:

PropertyTypeMandatoryNotesPulse Version
processNameString(tick)

The name of a Process Instance to create or retrieve.

If an instance with the name already exists, it will be returned. Otherwise, a new instance will be created.

When creating new instances, a global function of the same name is created – if there's already something in the global scope with that name, an error will be thrown and the instance won't be created.

0.1
priorityNumber(error)

The priority of the process. Higher priority processes will get the most processing time.

The bigger the number, the higher the priority.

Defaults to Process.PRIORITY_DEFAULT.

 
intervalNumber(error)

If a new instance is being created, this parameter defines the timer interval to use should its timer be activated.

Defaults to Process.INTERVAL_DEFAULT if no value specified.

Set to Process.INTERVAL_MIN if the stated interval is too small.

The interval time will have a random offset between 1 and Process.INTERVAL_RAND added to it – this helps reduce collisions when processes are running in multiple player scripts.

You can change the interval of existing instances using instance.setInterval().

0.1
autoActivateBoolean(error)

If true, the instance timer interval will be activated by eventStartLevel() and eventPlayerRevived(me), otherwise the instance will require manual activation or triggering.

Defaults to false.

0.1
autoDeactivateBoolean(error)

If true, the instance timer interval will be deactivated by eventPlayerKilled(me), otherwise it will keep running (if activated) until manually deactivated.

Defaults to true.

It's recommended you use the default setting so that your script basically goes in to "sleep mode" if the player it's associated with is killed. This frees up processing time for other players, which is particularly important as the game progresses as increase droid and structure counts will require more time to process.

0.1

Return Values

ValueTypeNotesPulse Version
<instance>Process Instance

An instance was created or retrieved.

0.1
<error>Error

If you try creating an instance with a name that's already used by something (other than an existing process) on the global scope, an error will be thrown.

This is because process triggers (functions of the name specified by "name" parameter listed earlier) are stored on the global scope so processes can be triggered by events, timers, etc.

0.1

Examples

Create new instance with default settings
Process("myProcess");
An instance with priority of 500, automatic de/activation, 1 second timer interval
Process("myProcess", 500, 1000, true, true);
Get an existing process
// if we already made a process called "existingProcess"...
Process("existingProcess") // returns the "existingProcess" instance
Process("existingProcess").addTask(someTask).activate(); // add a task, then activate it
Process("existingProcess").run(); // run "existingProcess"

// A process can be run via it's global trigger function...
existingProcess(); // run "existingProcess"

Availability

Requires:

See also

Process macro-management:

Â