Interface API
Documentation to get started using our interface API.
#Forms
The form system provides a way to open modal dialogs with dynamic input fields from Lua. Forms are blocking, the calling thread yields until the player submits or cancels. The return value is a table of input values keyed by name, or nil if cancelled.
#Usage
title(string, required) -- text displayed in the modal header.inputs(table[], required) -- array of input definitions.options(table, optional) -- modal-level configuration.
Returns a table of values keyed by each input's name, or nil if cancelled.
#Helpers
#Options
The third parameter controls the modal itself. All fields are optional.
icon(string) -- icon shown in the header next to the title.width(string, default"30rem") -- CSS width of the modal.showCancel(boolean, defaulttrue) -- whether to show a cancel button.disableClickOutside(boolean, defaultfalse) -- prevent closing by clicking the backdrop.buttons(table[]) -- array of submit buttons to render in the footer (see Buttons).
Pressing Enter submits the form with the first button's action. Pressing Escape cancels it.
#Buttons
The buttons array defines one or more submit buttons rendered in the form footer. Each entry is a table:
text(string, required) -- button label.icon(string) -- icon rendered before the label.color(string, default"var(--blue1)") -- CSS color for the button.action(string) -- identifier forwarded to the caller viaresult._action.
When a button is clicked, the returned table will contain _action matching that button's action field. This lets you branch on which button the player chose:
Legacy submit fields
Deprecated -- prefer
buttons[]for new code.
The following fields are kept for backward compatibility. If buttons is not provided, a single submit button is generated from these:
submitText(string, default"Confirm") -- label on the submit button.submitIcon(string) -- icon on the submit button.submitColor(string, default"var(--blue1)") -- CSS color for the submit button.
These are ignored when buttons is present.
#Input Types
Each entry in the inputs array is a table with a type field and additional properties depending on the type.
#Common Properties
These apply to all input types.
type(string, required) -- one of:text,number,select,select-player,checkbox,slider,textarea.name(string, required) -- key used in the returned values table.label(string) -- label shown above the input.description(string) -- secondary text below the label.icon(string) -- icon displayed in the input (select and text types).disabled(boolean) -- prevent interaction.defaultValue(any) -- initial value.
#text
Standard single-line text input.
placeholder(string) -- placeholder text when empty.
Returns string.
#number
Numeric input.
placeholder(string) -- placeholder text.min(number) -- minimum allowed value.max(number) -- maximum allowed value.
Returns number.
#select
Dropdown selection with optional search filtering.
content(table[]) -- array of{ label = "...", value = "..." }options.searchable(boolean) -- enable search filtering.multiselect(boolean) -- allow multiple selections.placeholder(string) -- placeholder text.
Returns string (selected value) or table (array of values if multiselect).
#select-player
A select dropdown automatically populated with all connected players. Each entry renders as (id) Firstname Lastname with the player's identifier as the value. Searchable by default. Defaults to the person icon if none is specified.
All standard select properties (searchable, multiselect, placeholder, defaultValue) are supported.
Returns string (player identifier).
#checkbox
Boolean toggle with a label.
Returns boolean.
#slider
Range slider with optional step marks.
min(number) -- minimum value.max(number) -- maximum value.step(number) -- step increment.marks(table[]) -- array of{ value = n, label = "..." }tick marks.
Returns number.
#textarea
Multi-line text input with auto-resize.
placeholder(string) -- placeholder text.minRows(number, default3) -- minimum visible rows.maxRows(number, default6) -- maximum visible rows.maxLength(number) -- character limit.
Returns string.
#Icons
Icons can be specified by name as a string on any icon field (inputs and options). Resolution works in two layers:
- Icon Registry -- SVG icons from MUI and react-icons. These are the same icons used throughout zyke_garages and render as crisp vector graphics.
- Material Icons (fallback) -- if the name is not found in the registry, it is treated as a Material Icons font name.
#Registry Icons
#Material Icons Fallback
Any string not found in the registry is treated as a Material Icons font name. Browse the available icons at fonts.google.com/icons.
#Full Example
