Pardon our dust while we move our docs here. The Godot (GDScript) docs are on this site, and the Yarn language, Unity, Godot (C#) and Unreal docs are still at docs.yarnspinner.dev.

The Options Presenter (YarnOptionsPresenter) shows your options as buttons. When the player picks one, it tells the Dialogue Runner which option was picked, and the dialogue carries on from there.

If you followed Adding Presenters, you already have one.

Where the buttons go

The Options Presenter needs a container to put its buttons in. In the scene from the previous pages, that’s an empty VBoxContainer:

YarnOptionsPresenter
OptionsContainerVBoxContainer
An Options Presenter with an empty container for its buttons.

When the scene starts, the Options Presenter uses the first Container directly under it. Each time the dialogue reaches some options, it adds a button to that container for each one, and removes them all again once the player has picked. Leave the container empty in the editor.

Godot's 2D view with OptionsContainer selected: its outline covers the same area along the bottom of the screen as the Line Presenter's panel, which shows Character, Line text and Continue
OptionsContainer selected in the 2D view. In this scene it covers the same area as the Line Presenter's panel, so options appear in the same place as lines.

To use a container somewhere else in your scene, assign it to the Options Presenter’s Options Container property.

The Options Presenter shows and hides the nodes under it, so there’s no need to hide the container when the scene starts.

Picking an option

When the options appear, the first one the player can choose has focus. The player can:

  • click an option,
  • move between options with the arrow keys or a gamepad, and choose one with ui_accept,
  • press a key you’ve set up for that option (see Keyboard shortcuts).

Hovering the mouse over an option also gives it focus. The focused option has a dot beside it.

While the options are showing, the Line Presenter ignores its Continue Action and clicks, so they go to the option buttons.

Use Fade Effect fades the options in when they appear and out once the player has picked. It’s on by default. Fade Up Duration and Fade Down Duration set how long each fade takes, in seconds.

Options the player can’t choose

An option with a condition is unavailable when the condition is false. In this example, the second option is only available if $has_key is true:

Rosa: Are you here about the lighthouse?
-> Yes. I heard the lamp went out.
-> I can open the door for you. <<if $has_key>>
-> No, I'm just passing through.
The second option is only available when $has_key is true.

By default, the Options Presenter doesn’t show unavailable options at all. Turn off Hide Unavailable to show them as buttons that can’t be pressed.

If every option is unavailable, the Options Presenter shows nothing. What happens next depends on the Dialogue Runner’s Allow Option Fallthrough setting. See Dialogue Behaviour.

Changing how the buttons look

The Options Presenter makes each button from the scene in Option Button Scene. By default that’s res://addons/yarn_spinner/ui/option_item.tscn:

OptionItemControl
Button
SelectionIndicatorLabel
The default option scene.

To change how the buttons look, make your own scene and assign it to Option Button Scene. Don’t edit the default scene: it’s part of the addon, and updating the addon replaces it.

Start by duplicating option_item.tscn into your own project and chaning the copy. The root node’s script is YarnOptionItem, which has these properties:

PropertyWhat it does
ButtonThe Button the player presses. If it’s empty, the first Button in the scene is used.
Text LabelA Label or RichTextLabel for the option’s text, if you don’t want the text on the button itself. The button’s text is set too.
Unavailable IndicatorA node that’s shown only when the option is unavailable, such as a lock icon.
Show When UnavailableTurn this off to hide unavailable options from this scene, even when Hide Unavailable is off.
Disabled Strike ThroughDraws a line through the text of unavailable options. It only works when Text Label is a RichTextLabel.
The properties of YarnOptionItem, the root of the default option scene.

The root of your scene can also be a plain Button. The Options Presenter sets its text to the option’s text, and disables it when the option is unavailable.

The option’s text never includes the character’s name, and any markup is removed.

Keyboard shortcuts

To let the player pick options by pressing number keys, add an input action for each option in ProjectProject SettingsInput Map, named with a shared prefix and a number starting at 1: option_1, option_2, option_3, and so on. Then set the Options Presenter’s Option Action Prefix to option_.

The numbers match the order of the options in your Yarn Script, including unavailable options. In the example above, if the player doesn’t have the key, option_3 still picks “No, I’m just passing through”, even though it’s the second button on screen.

Option Action Prefix is empty by default, which turns shortcuts off.

Showing the last line

When options appear, the line before them usually disappears. To keep it on screen above the options, turn on Show Last Line and assign a Label or RichTextLabel to Last Line Text.

YarnOptionsPresenter
OptionsContainerVBoxContainer
LastLinePanelContainer
VBoxContainer
LastLineNameLabel
LastLineTextRichTextLabel
An Options Presenter that shows the last line above its buttons.

In this tree, you’d set:

  • Last Line Text to LastLineText,
  • Last Line Container to LastLine, which is hidden when there’s no last line to show,
  • Last Line Character Name Text to LastLineName, for the speaker’s name.

If you don’t set Last Line Character Name Text, the speaker’s name is left off. Set Last Line Character Name Container to hide something bigger than the name label, such as a name plate, when a line has no speaker.

Keep OptionsContainer above any other container under the Options Presenter, or set Options Container yourself. Otherwise the Options Presenter uses the first container it finds, which might be the one meant for the last line.

Shortening the last line

A long line can take up too much space above the options. Put [lastline/] in the line where you want the shortened version to start:

Rosa: I've been keeping this light for thirty years, and I've never once let it go out. [lastline/]So, will you help me fix it?
-> Yes.
-> No.
A long line, shortened above the options with [lastline/].

The Line Presenter shows the whole line. Above the options, the Options Presenter shows only what comes after [lastline/], with “…” in front: “…So, will you help me fix it?”

Time limits

To give the player a limited time to choose, set Option Timeout on the Dialogue Runner, not the Options Presenter. When the time runs out, the Options Presenter removes the buttons, and the dialogue carries on after the options as if none had been picked. See Dialogue Behaviour.

To show the option the player picked as a line of dialogue, turn on Show Selected Option as Line on the Dialogue Runner.

Signals

SignalWhen it’s emitted
options_shown(options)The options have appeared.
option_selected(index, option)The player picked an option, after any fade. index is the option’s position in your Yarn Script, starting at 0.
The Options Presenter’s signals.

Settings

The Inspector for a YarnOptionsPresenter, showing three groups: Options, with Options Container, Option Button Scene set to option_item.tscn, Hide Unavailable and Option Action Prefix; Fade, with Use Fade Effect, Fade Up Duration and Fade Down Duration; and Last Line, with Show Last Line, Last Line Text, Last Line Container, Last Line Character Name Text and Last Line Character Name Container
An Options Presenter in the Inspector, with its default settings. Options Container is empty because the Options Presenter finds it itself when the scene starts.
SettingDefaultWhat it does
Options Containerfound for youThe container the buttons are added to.
Option Button Sceneoption_item.tscnThe scene each button is made from.
Hide UnavailableOnLeaves out options the player can’t choose.
Option Action PrefixemptyThe start of the input action names for keyboard shortcuts. Empty turns them off.
Use Fade EffectOnFades the options in and out.
Fade Up Duration0.25Seconds to fade in.
Fade Down Duration0.1Seconds to fade out.
Show Last LineOffShows the line before the options above them.
Last Line TextnoneThe Label or RichTextLabel for the last line’s text.
Last Line Containerthe last line textHidden when there’s no last line to show.
Last Line Character Name TextnoneThe label for the last line’s speaker.
Last Line Character Name Containerthe character name textHidden when the last line has no speaker.
Every Options Presenter setting.
Next step Typewriter and Effects Changing how text appears, and writing your own typewriter.