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.
| Option | Default | What it does |
|---|---|---|
theme, baseColor, primary, themes, colors, colorRecipes, primitives, densities, density, styleParent | How the UI looks; see Theming | |
state | {} | Your starting data in the store |
adaptive | on | false 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 |
toastWidth | 356 | How wide toasts are on a desktop, in pixels |
toasters | More places toasts show, by id: { events = { position = "top-center" } }. See Holders | |
parent | the player's PlayerGui | Where the App's ScreenGuis go |
namePrefix | "Lucy_" | Starts the name of every ScreenGui and folder the App makes. A second App needs its own |
setCurrent | true | Makes this the App components use, and the one Lucy.App.current() returns |
devtools | true | false leaves the App out of Devtools (Studio only) |
server | true mirrors a Lucy.Server at server.* and makes app.server. See Share state with the server | |
input, actions | For Lucy's own tests |
What an App holds
| Field | What it is | More |
|---|---|---|
app.state | The store: UI state and your game data | The store |
app.theme | Themes, density and style rules: app.theme:set("light"), app.theme:addRules(name, rules) | Theming |
app.scenes | Screens, modal scenes and overlays | Build screens with scenes |
app.actions | Hotkeys, in sets you switch on and off | Hotkeys and modal input |
app.input | The input mode and device, focus and the back keys | Input and focus |
app.toast | Toasts: app.toast("Saved"), app.toast.success(...) | Toaster |
app.quiet | Quiet mode: app.quiet:push(reason), app.quiet:allows(channel), app.quiet:after(channel, fn) | Quiet mode |
app.server | With the server option: send and call requests to the server | Share state with the server |
Methods
| Method | What 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.