Skip to content

The app

A game makes one App on the client, before it builds any UI. The App holds the store, the themes, input, hotkeys and scenes. Components find it by themselves, so you rarely pass it around.

local Lucy = require(ReplicatedStorage.Packages.Lucy)

local app = Lucy.App.new({
    theme = "dark",
    baseColor = "zinc",
    primary = "fuchsia",
    state = { player = { name = "DJ Lucy", coins = 0 } },
})

For a walkthrough, see Getting started.

Options

Every option is optional.

OptionDefaultWhat it does
theme, baseColor, primary, themes, colors, colorRecipes, primitives, densities, density, styleParentHow the UI looks; see Theming
state{}Your starting data in the store
adaptiveonfalse turns scaling off; a table such as { max = 1.5 } changes its numbers. See Scaling
backKeys{ ButtonB, Backspace }The keys that go back. See Back keys
toastPosition"bottom-right"Where toasts show. See Toaster
toastWidth356How wide toasts are on a desktop, in pixels
toastersMore places toasts show, by id: { events = { position = "top-center" } }. See Holders
parentthe player’s PlayerGuiWhere the App’s ScreenGuis go
namePrefix"Lucy_"Starts the name of every ScreenGui and folder the App makes. A second App needs its own
setCurrenttrueMakes this the App components use, and the one Lucy.App.current() returns
devtoolstruefalse leaves the App out of Devtools (Studio only)
servertrue mirrors a Lucy.Server at server.* and makes app.server. See Share state with the server
input, actionsFor Lucy’s own tests

What an App holds

FieldWhat it isMore
app.stateThe store: UI state and your game dataThe store
app.themeThemes, density and style rules: app.theme:set("light"), app.theme:addRules(name, rules)Theming
app.scenesScreens, modal scenes and overlaysBuild screens with scenes
app.actionsHotkeys, in sets you switch on and offHotkeys and modal input
app.inputThe input mode and device, focus and the back keysInput and focus
app.toastToasts: app.toast("Saved"), app.toast.success(...)Toaster
app.quietQuiet mode: app.quiet:push(reason), app.quiet:allows(channel), app.quiet:after(channel, fn)Quiet mode
app.serverWith the server option: send and call requests to the serverShare state with the server

Methods

MethodWhat it does
Lucy.App.current()The App made with setCurrent, or nil. For other scripts; see Getting started
app:modalOpen()True while a modal dialog, sheet or popup is open, or a modal scene is pushed. Code that reads it runs again when it changes; see While a menu is open
app:setTheme(name)Same as app.theme:set(name)
app:setDensity(name)Same as app.theme:setDensity(name)
app:handle(id)The component with that id, or nil
app:createGui(name, options?)A ScreenGui on the App’s theme and scaling. Options: displayOrder, ignoreGuiInset (true), enabled (true), parent
app:createSurface(name, options)A SurfaceGui on a part, on the App’s theme, that takes clicks. See UI in the world
app:createBillboard(name, options)A BillboardGui over a part or attachment, the same way. See UI in the world
app:destroy()Removes the App and everything it made, world guis included, except ScreenGuis from createGui: destroy those yourself

Scenes already give you a ScreenGui each (scene.gui), so use createGui only for UI that lives outside scenes.