Skip to main content

Custom Types

Custom types bundle related values into one object that travels through your flows together. Instead of a username list and a separate score list whose indexes have to line up, define a Player type with both fields and store one list of players.

A custom type is a name plus a set of primitive fields. Each field is one of:

  • Text: A string.
  • Number
  • Boolean
  • Color (hex): A #rrggbb string.
  • Text Style: One of your text styles. A Theme type with title, body and alert fields lets one variable hold a whole look. Widgets can follow each field: see Theme objects.

Fields can have a default value. Fields can't hold other objects or lists. For many of something, make the variable a list of your custom type.

Custom types belong to your account and are available in every flow, overlay and variable store.

Defining a type​

  • Custom Types page: Create, edit and delete types, with warnings before destructive changes.
  • Flow editor → New Type: Create a type without leaving the flow.

Type and field names must start with a letter and contain only letters, numbers and underscores.

Using a type in flows​

Each type adds two nodes to the add-node menu:

  • Create <Name>: One typed input per field. Wire values in or type defaults for unconnected fields. Outputs the object.
  • Break Apart <Name>: Takes the object and exposes one typed output per field. Wire only the fields you need.

A Player output only connects to Player inputs, and every Player edge shares one color.

Lists of custom objects​

Every list node works with custom-object lists. Nodes that look inside an item offer a Field dropdown with the type's fields (username, score, ...). The field input lets a flow choose the field at runtime.

Static List and Emit List can hold custom-typed items too, edited in a spreadsheet.

Example: a leaderboard​

Store a broadcaster variable leaderboard as a list of Player (username, score).

  • !addpoints: Update List Variable with Change Number Field, matching username to the chatter and adding the points to score. A new player gets an entry automatically.
  • !top: Get the variable, List Sort by score High to Low, List Take the first 5, then List To Text with the format {{position}}. {{item.username}} ({{item.score}}), into Send Chat Message.
  • !rank: List Sort by score, then List Find where username equals the chatter. The rank is its index + 1.

Tips:

  • For lists many viewers change at once (queues, leaderboards), use a broadcaster variable and Update List Variable. A Get Variable, change, Set Variable chain can lose an entry when two chat commands run at the same moment. Update List Variable can't.
  • To sort by two fields (score, then name), chain two sorts: the tie-breaker first, then the main field. Sorting keeps the existing order of equal entries.

Storing custom values​

All four variable stores accept custom-typed values, as single objects or lists:

StoreScopePersistence
Flow variablesone flowreset each run
Overlay variablesone overlaypersistent
Broadcaster variablesyour channelpersistent
Viewer (user) variablesper viewerpersistent

Get and Set variable nodes take their handle types from the variable, so a Player variable only accepts Player objects. The variable managers include object editors for inspecting and editing stored values field by field.

In {{template}} tokens, fields are addressable by path: {{viewer.stats.score}} reads the score field of a viewer's stats variable. A token for the whole object renders as JSON.

Editing a type​

Edits apply everywhere at once, and every stored value of the type is migrated:

  • Adding a field: Existing values get the field's default the next time they're read.
  • Renaming a field: Stored data carries over, and the field chosen on list nodes and in Static/Emit List items is updated. Text templates aren't rewritten, so edit a List To Text format that says {{item.oldName}} by hand.
  • Changing a field's type: Stored values are converted where possible (42 and "42") and reset to the field's default where not.
  • Removing a field: Deletes the field from every stored value. This can't be undone. The editor first warns you with a count of affected flows and variables.

Open flow editors reload when a type edit rewrites their flow.

Deleting a type​

A type can't be deleted while anything uses it. The delete dialog lists the flows and variable stores that reference it. Clear those out and delete again.