Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ParameterTypeMandatoryNotesAPI Version
nameString(tick)

The name of the sequence to start.

Note: If the sequence is already running, this will immediately trigger the next step in the sequence.

 
commandConstant(error)

Run an internal command on the sequence:

  • Sequence.END – halt the sequence and reset it
  • Sequence.DELETE – same as Sequence.END, then deletes the sequence
  • Sequence.PAUSE – pause the sequence, use Sequence( <name> ) to resume from the next step
  • Sequence.NEXT – immediately run the next step in the sequence

Default: Sequence.NEXT

 

Steps Array

An array defining each step in the sequence, and the amount of time to wait before the next step starts.

...

In terms of the data elements, it's recommended that you set up some sort of define yourself some sort of vocabulary. For example:

  • If data is a string, it gets localised and sent to the console
  • If data is a function, the function is processed
  • If data is an array, iterate the array calling the processor function for each item in it
  • If data is an object, decide how to process it based on the data.type property
  • If data is a number, ...

And write down it down somewhere, with examples of the types of data you want to process, then implement the code to process those types of data in your processor function...

Processor Function

The sequencer has no idea what your data (in the Steps Array) looks like or means, so when a step is triggered a function is required to process the data. The function is defined along with steps array when you call Sequence.define(). The neat thing about this is that you can have sequences with completely different data formats - just provide a processor that understands it. And, you can use the same processor for multiple sequences.

Code Block
themeRDark
languagejavascript
titleSyntax
linenumberstrue
function <name>( datasequence, step, data ) {
	// process data
}

The function has two parameters:

  • datasequence – the data portion name of the step that needs processingsequence that's being processed
  • step – the index of this step in the sequence (eg. first step is 0) – note: you don't need to define this param if you're not using it
  • data – the data portion of the step that needs processing

Note: The function doesn't need to worry about how the next step gets triggered, the sequencer takes care of that. Your processor function should focus entirely on processing the data passed to it.

Return values:

  • No return value , or undefined , null – sequence will continue running as normal
  • Sequence.END – abort the sequence
  • Sequence.DELETE – same as Sequence.END, but also deletes the sequence data
  • <string> – same as Sequence.END, but also start another sequence (string defines the name of the sequence to start)
  • <function> – same as Sequence.END, but also run the function

...

This constant is used to define the end of a sequence in the Steps array. Your Processor Function can also return this value to abort a sequence.

Other constants

Getting sleepy so just jotting these down for now:

  • Sequence.DELETE – same as Sequence.END, but also deletes the sequence
  • Sequence.PAUSE – pauses the sequence, call Sequence(<sequence>) to continue at the next step
  • Sequence.NEXT – immediately trigger next step in sequence