# Build a Cuelist

> Add cues to a Cuelist, stack and delay their actions, group, condition or repeat them, and organize cues into sub-cues.

This guide builds a Cuelist from an empty list: adding cues, giving them actions, grouping, conditioning or repeating those actions, and organizing cues into sub-cues.

## Before you begin

- Access to **Cuelist** in the left navigation.
- The connections whose actions you plan to use, already added.

## Create the Cuelist and its first cue

1. Open **Cuelist**.
2. Create a new Cuelist, or open an existing one to add to it.
3. Select **+ Add Cue**.
4. Name the cue and set its color so it's easy to identify at a glance.

Selecting **+ Add Cue** again adds the next cue after whichever one is currently selected.

## Add actions to a cue

1. Select the cue.
2. Select **+ Add Action**.
3. Choose an action, either from **Recently Used Actions** or by searching a connection's own actions.
4. Repeat to stack more actions in the same cue.

Actions in a cue's stack run based on the delay you set on each one: leave a delay at zero to fire together with the previous action, or set one to have it fire after a pause.

## Group actions together

To have several actions execute as one unit rather than as separate stack entries:

1. Select **+ Add Action**, then choose **ActionGroup**.
2. Set the group to **Sequential** (one action after another) or **Concurrent** (all at once).
3. Add the actions that belong in this group.

## Make an action conditional

To have a cue's outcome depend on a live condition rather than always doing the same thing:

1. Select **+ Add Action**, then choose **ActionLogic**.
2. Set the condition: a feedback state, or an expression testing a variable.
3. Add the action that should fire under **When true**.
4. Add the action that should fire under **Else**, if the cue needs a different outcome when the condition doesn't hold.

For example, testing whether the current hour is 12 or later lets a single cue set a light to full brightness in the afternoon and to half brightness in the morning, without needing two separate cues.

A condition can also test a connection's live state. To take a different action depending on whether upstream key 1 is on air on an ATEM connection whose Variable Key is `ATEM`, use this expression:

```
$(ATEM.pgm1_usk_1_onAir) == true
```

The `ATEM.` prefix is required. Written as `$(pgm1_usk_1_onAir) == true`, the expression can't be resolved and the cue always runs its **Else** action. Insert the variable from the expression editor's suggestions to get the prefix right. See [Include the connection's prefix](/docs/buttons/v1.10/variables/use-variables#include-the-connection-s-prefix).

## Repeat actions while a condition holds

To have a cue repeat some actions for as long as a live condition is true:

1. Select **+ Add Action**, then choose **While**.
2. Set the **Condition**: a feedback state, or an expression testing a variable. With more than one feedback, all of them must be true.
3. Add the actions to repeat under **While true**, and give at least one of them a delay.

Buttons checks the condition, runs the **While true** actions in order, and checks again, until the condition is false. If it's false when the cue runs, the actions don't run at all.

<callout color="yellow" title="Warning">
  Buttons doesn't pause between rounds, so without a delay the loop repeats as fast as it can. A **While** also stops after 10,000 rounds, even if the condition is still true. An empty **Condition** counts as true, so it always runs to that limit.
</callout>

See [Repeat actions while a condition is true](/docs/buttons/v1.10/positions/button-actions#repeat-actions-while-a-condition-is-true) for an example.

## Organize cues into sub-cues and reorder them

- Drag a cue onto another cue to make it a sub-cue of that cue.
- Drag a cue between two others to reorder it at that level.

Cue numbering updates automatically as you add, remove, reorder, or nest cues: you never renumber cues by hand.

## If you get stuck

| What you see | What to try |
| --- | --- |
| An action fires at the wrong time relative to others in the same cue. | Check each action's own delay: a zero delay fires together with the action before it. |
| A cue never does what you expect under certain conditions. | Confirm the ActionLogic's condition and that both the **When true** and **Else** actions are the ones you intend. |
| A conditional cue always runs its **Else** action, whatever the device is doing. | Check the expression for a connection variable without its prefix: `$(ATEM.pgm1_usk_1_onAir)`, not `$(pgm1_usk_1_onAir)`. |
| A **While** seems to fire all at once, or stops early. | Add a delay to an action under **While true**: without one, the loop doesn't pause between rounds and can reach its 10,000-round limit almost at once. |
| Dragging a cue reorders it instead of nesting it, or the reverse. | Drop directly onto a cue to nest it as a sub-cue; drop between cues to reorder at the same level. |

## Where to go next

- [Read and advance a running Cuelist](/docs/buttons/v1.10/cuelists/run-a-cuelist).
- [Control a Cuelist from a Position](/docs/buttons/v1.10/cuelists/control-from-a-position).
