Skip to content

Tour

A tour points at the buttons your game already has, one at a time, and waits for the player to use each one. Use it to welcome new players, or to show off a new screen. It works with mouse, touch, keyboard and gamepad, and keeps the rest of the app quiet while it runs.

Tour exampleTour example
Lucy.Stack.new({
    direction = "horizontal",
    gap = "Space4",
    children = {
        Lucy.Button.new({ id = "play", text = "Play" }),
        Lucy.Button.new({ id = "shop", text = "Shop", variant = "outline" }),
    },
    Parent = hud,
})

local tour = Lucy.Tour.new(app, {
    id = "first-round",
    steps = {
        { id = "hi", title = "Welcome!", text = "Here is a quick look around." },
        { id = "play", target = "play", text = "Press Play to start a round." },
        { id = "shop", target = "shop", text = "The shop sells new looks.", side = "top" },
    },
    onDone = function() print("finished") end,
})
tour:start()

target is the id you gave a component (Lucy.Button.new({ id = "play" })). Write a tutorial walks through a whole one.

What the player sees

While a step’s target is on screen:

  • the screen dims, but for a cutout round the target, with a ring on it;
  • presses outside the cutout do nothing, presses on the target work as usual;
  • a callout next to the target holds the step’s title and text, with a small notch pointing at it;
  • a big Arrow points at the target from the other side, grows in and bounces toward it, and a ring ripples out from the target;
  • on a gamepad or keyboard, focus moves to the target and stays there.

Moving on, the cutout and callout glide to the next target and the callout fades and slides in. With reduced motion (see Accessibility) the tour jumps between targets, the callout only fades, the ripple is off and the arrow fades in and keeps still.

Until the target is on screen (a menu that has not opened yet), the tour waits and draws nothing, so the player can never get stuck behind it.

SKIP in the callout and the back keys (B, Backspace) ask first, in the callout itself (InlineConfirm): the step’s words step aside for “Are you sure?” with YES and NO; NO is the solid button and is picked first. YES skips; NO, or back again, puts the step back.

Options

OptionTypeDefaultWhat it does
idstringNames the tour (required)
stepstableThe steps, in order (below)
progressstringA state path the tour writes its progress to, so a rejoin carries on (see Progress)
quietbooleantrueKeeps the app quiet while it runs: toasts wait until it ends (see Write a tutorial)
skippablebooleantruefalse hides SKIP and makes back do nothing while a step shows
texttableYour own words for next, skip, confirm (“Are you sure?”), yes and no
pointertable or falseArrow props for every step’s arrow ({ variant = "chevron", color = "Primary" }), or false for none
onStepfunction(step, index), the first time each step is on screen. Play a voice line here
onDonefunctionThe player finished the last step
onSkipfunctionThe player skipped

Steps

FieldWhat it does
idNames the step, for onStep and tour.step()
title, textWhat the callout says (at least one)
targetThe component id to point at. Also a GuiObject, a component, or a function that returns one. Leave it out for a step that only talks: its callout sits in the middle with a NEXT button
waitForWhat moves the tour on (below)
sideauto (the default), top, bottom, left or right: where the callout sits. It moves to the other side when there is no room
actionAn action name (see Hotkeys) whose key shows in the callout
scrimfalse: no dimming. Presses outside the target are still blocked
padRoom between the target and the cutout’s edge, in pixels (8)
pointerArrow props for this step’s arrow, over the tour’s, or false for none

waitFor is one of:

ValueMoves on when
"press"The player presses the target, or something inside it, even when the press hides or removes it (a button that shuts its own panel). The default when there is a target
"next"The player presses NEXT. The default when there is no target
{ action = "dance" }The player presses the action’s key
{ state = "me.coins", equals = 100 }A state key has that value
{ state = "me.clips", where = function(clips) return #clips > 0 end }A state key passes your test
{ when = function() return ... end }Anything your function reads says so

A step whose condition is already true moves on at once.

Methods

MethodWhat it does
tour:start(step?)Starts it, from the saved step with progress. Returns false for a tour already finished; tour:start(1) replays it
tour:advance()Moves to the next step yourself
tour:skip()Ends it as skipped (onSkip runs)
tour:stop()Ends it without a callback, keeping its progress
tour:destroy()Stops it and removes what it made
tour.index(), tour.step()The step it is on
tour.running(), tour.waiting(), tour.confirming()Whether it runs, waits for a target, or is asking to skip

The getters are tracked: code that reads them runs again when they change. One tour runs at a time: starting another stops the first. While one runs the app publishes tour = { id, step, index, waiting }.

Progress

With progress = "save.tours.firstRound", the tour writes { step = 2 } there as the player goes, then { finished = "done" } or { finished = "skipped" }. Save that path with the rest of the player’s data; next time, tour:start() carries on from the step, or returns false when it is finished.

Voice and sound

Lucy plays no audio. Play a step’s line in onStep, which runs once, when the step is first on screen. Show the same words as text so players with the sound off get them too.

onStep = function(step)
    local sound = voiceLines[step.id] -- nil until it is recorded
    if sound then
        sound:Play()
    end
end,

Look

Rules on the tags ui-tour-scrim, ui-tour-ring, ui-tour-callout, ui-tour-arrow (the callout’s notch), ui-tour-cover, ui-tour-title and ui-tour-text, with the theme’s Overlay, Ring, Popover, PopoverForeground and Border colours. The ripple and the pointer take Ring. The tour floats above dialogs and below toasts.

Parts: tour.root, tour.blockers, tour.ring, tour.pulse (the ripple), tour.callout, tour.arrow, tour.cover, tour.pointer (an Arrow), tour.title, tour.text, tour.hint, tour.next, tour.skipButton and tour.confirm (an InlineConfirm). Tour.timing and Tour.motion hold the speeds and distances.

Preview

In Studio, from the command bar: Lucy.Preview.show("Tour").