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
#rrggbbstring. - Text Style: One of your text styles. A
Themetype withtitle,bodyandalertfields 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.
- Search and check: List Find (first match, its index, pass/fail), List Contains, List Filter (matching and not-matching lists). Find and Filter take a condition: equals, greater than, contains and so on.
- Order and trim: List Sort by any field, List Take / List Skip for the first or last N, List Reverse, List Shuffle.
- Summarise: List Math (sum, average, min, max, plus the entry holding the min or max), List Tally (count each value, such as votes), List Unique (one entry per field value).
- Reshape: List Get Field (a list of one field's values), List To Text (chat-ready text), List Combine (append, or in both / only in first by field).
- Pick: List Random Item, optionally weighted by a number field for ticket raffles.
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, matchingusernameto the chatter and adding the points toscore. A new player gets an entry automatically.!top: Get the variable, List Sort byscoreHigh 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 byscore, then List Find whereusernameequals the chatter. The rank is itsindex+ 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:
| Store | Scope | Persistence |
|---|---|---|
| Flow variables | one flow | reset each run |
| Overlay variables | one overlay | persistent |
| Broadcaster variables | your channel | persistent |
| Viewer (user) variables | per viewer | persistent |
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 (
42and"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.