Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Excerpt

Triggers are task containers that be can run either automatically, eg. on a scheduled interval or triggered by game events, or manually.

 

Child pages (Children Display)

 

Process instances contain one or more tasks, and run those tasks over several game ticks to avoid game stutter/freezing.

 

What is a Process Instance?

You can think of process instances as very basic threads.

Each process instance has a unique name and some other settings that are defined when it's created, and can store a number of Tasks that it will carry out when it's run.

How do I create one?

Use Processes() to create new instances, or retrieve existing instances.

How do I add tasks to an instance?

You'll need to create some tasks – see Tasks for more information.

Then add your tasks to a process, in the order you want them to be executed, using the instance.addTask() method.

How do I run an instance?

There are several ways to run a process:

  • Execute the instance directly (it's a function) – see instance() and instance.run()
  • Activate the instance and it will run on a regular interval – see instance.activate()
  • You can also automatically activate instances when the game starts, see - Automatic activation and deactivation
  • Link the instance to a game event and it will run whenever that event fires – see Using events to trigger instances

What happens when the instance runs?

When the instance runs, it will process each of its tasks in turn.

If there isn't enough processing time on the current game tick, remaining tasks will be deferred to later game ticks when there's more processing time.

How do I know when a run starts and stops?

All instances have two events - instance.onRun() and instance.onEnd(). These events are called at the start and finish of every run, they are useful for initialising instance.data or triggering other processes, etc.

What happens if I try and run an instance that's already running?

If you try running an instance that's already running, the current run will finish first before the next run starts.

Each run has it's own data object, and an array of these can be found in instance.runData.

When a task is triggered the data for the current run is passed in as one of the parameters - see Tasks for more information.

How do I abort a run?

You can abort the current run by returning PROCESS_STATE_ABORT from a task - see Tasks for more information.

Alternatively, you can call instance.abort() to abort either the current run or all runs.

When a run is aborted, no further tasks will be processed for that run, and the process will either return to it's ready state (waiting for a future run) or, if there are other runs queued, the next run will start.

How do I delete an instance?

To delete process instances, use Processes.destroy(processName).

Div
classbox

Documentation

Instances have a number of methods, properties and events. For more information see:

Child pages (Children Display)
alltrue
depthall
excerpttrue