UI API
Every function of the UI builder handed to Map/Hud and Menu scripts.
The UI object is passed to build, refresh and menu in Mod UI scripts. Every Create… call returns a widget handle you pass back to other UI: functions; nil as a parent means the script's root.
Containers
UI:CreateBorder(parent, r, g, b, a) → widget#A coloured rectangle holding one child.
UI:CreateBox(parent, horizontal) → widget#An invisible row (true) or column (false).
UI:CreateGrid(parent, columns) → widget#A grid of equal cells; place children with SetGridSlot.
UI:CreateList(parent) → widget#A vertical list; add rows with CreateListItem.
UI:CreateOverlay(parent) → widget#Children stacked on top of each other.
UI:CreatePanel(parent, horizontal, fill?, border?) → widget#A themed glass card; returns its inner box. fill/border override the opacities.
UI:CreateScrollBox(parent) → widget#A scrolling column.
UI:CreateSizeBox(parent, width, height) → widget#A fixed-size frame around one child; 0 or nil leaves an axis free.
UI:CreateWrapBox(parent) → widget#A row that wraps onto new lines.
Content
UI:CreateIcon(parent, assetPath, tint) → widget#A built-in game icon by engine path, tinted primary/secondary/accent/disabled.
UI:CreateImage(parent, path) → widget#A picture from a mod's Images/ folder (later mods win on the same path).
UI:CreateImage(row, "Nightlife/cocktail.png")UI:CreateProgressBar(parent, value) → widget#A fill bar, 0–1.
UI:CreateSeparator(parent, horizontal) → widget#A thin divider.
UI:CreateSpacer(parent, width, height) → widget#Empty space.
UI:CreateText(parent, text) → widget#A text block.
local t = UI:CreateText(Root, "Hello")UI:CreateThrobber(parent) → widget#A busy spinner.
Controls
UI:CreateButton(parent, text) → widget#A themed button; react with OnClick.
UI:CreateDropdown(parent, { options }, index) → widget#A combo box; index is 0-based. React with OnSelectionChanged.
UI:CreateInput(parent, text, hint) → widget#A single-line text field; OnTextCommitted on Enter or focus loss.
UI:CreateListItem(list, text) → widget#A clickable row in a list.
UI:CreateSlider(parent, min, max, value) → widget#A slider; OnValueChanged fires on release.
UI:CreateSpinBox(parent, min, max, value) → widget#A number you can drag or type.
UI:CreateToggle(parent, on) → widget#A checkbox; react with OnToggleChanged.
Layout
UI:SetAlign(widget, horizontal, vertical)#Placement in its slot: left|center|right|fill, top|center|bottom|fill.
UI:SetCanvasSlot(widget, x, y, width, height)#Absolute placement inside a canvas parent.
UI:SetFill(widget, weight)#Share of the free space in a row or column (0 = only what it needs).
UI:SetGridSlot(widget, row, column)#Places a child in a grid cell.
UI:SetPadding(widget, left, top, right, bottom)#Space around a widget in its row or column.
UI:SetParent(widget, parent)#Moves a widget under another parent (nil = the root).
UI:SetSize(widget, width, height)#Draw size of an image.
Appearance
UI:SetEnabled(widget, on)#Enables or greys out a control.
UI:SetFontSize(widget, points)#Text size (map pages use 11–13).
UI:SetImage(widget, path)#Swaps an image's picture.
UI:SetOpacity(widget, opacity)#0–1.
UI:SetSelected(widget, on)#The theme's selected look on a button (a current tab).
UI:SetText(widget, text)#Text of a text block, button or input.
UI:SetTextStyle(widget, style)#primary, secondary, disabled, bold or heading.
UI:SetTint(widget, r, g, b, a?)#Colour-multiplies an image, text or bar (0–1 per channel).
UI:SetTooltip(widget, text)#Hover text.
UI:SetVisible(widget, on)#Shows or hides.
UI:SetWrap(widget, on)#Wraps text at the container's width.
Values
UI:GetText(widget) → text#Text of a text block, button or input.
UI:GetValue(widget) → value#Current value of a slider, spin box, progress bar or toggle.
UI:SetStep(widget, step)#Snap step of a slider or spin box.
UI:SetValue(widget, value)#Value of a slider, spin box, progress bar or toggle.
Events
UI:OnClick(widget, function)#Runs the function when a button or list row is clicked.
UI:OnClick(btn, function() Game:ShowMessage("Hi", 2) end)UI:OnSelectionChanged(widget, function(option))#Dropdown selection changed (the option's text).
UI:OnTextCommitted(widget, function(text))#Input committed.
UI:OnToggleChanged(widget, function(on))#Checkbox switched.
UI:OnValueChanged(widget, function(value))#Slider (on release) or spin box (on commit) value.
Navigation
UI:actionAvailability(actionId)#Whether an action can be taken now: { ok = bool, reason = string }, the same check and reason the action lists show.
local a = UI:actionAvailability("ynl_book")UI:closePage()#Closes the open Mods page on the next frame.
UI:closePage()UI:openAgenda()#Opens the agenda panel on the next frame.
UI:openAgenda()UI:openPage(mod [, pageId])#Opens a Mods page on the next frame. pageId is the page's MENU.id or file name; omit it for the mod's first page. false when there is no such page.
UI:openPage("ynl_Nightlife", "bookings")UI:openPerson(personOrId)#Opens a person's sheet on the next frame, by id; never spawns them. false for someone deleted or blocked.
UI:openPerson(People:byTag("ynl_host"))UI:openPlace(buildingId)#Opens a building's card on the map, framed, on the next frame.
UI:openPlace(Programmes:where(M, "quiz_night")[1].id)UI:runAction(actionId)#Starts an action on the next frame, as if picked in the Actions panel (checked now and again when it starts). false when it cannot be taken now.
UI:runAction("ynl_book")UI:runScene(sceneName)#Closes the page and runs a scene on the next frame, outside your button callback. false while another scene or an action is running.
UI:runScene("ynl_meet_host")