cobalt_interfaces
Draws notifications, progress bars, prompts and menus; other resources reach it through cobalt_core's interface exports.
| Export | Side | What it does |
|---|---|---|
notify | Client, Server | Shows a notification. |
progressBar | Client | Yields until the bar fills (true) or is cancelled or interrupted (false). |
progressActive | Client | |
cancelProgress | Client | Errors when no bar is running. |
showTextUI | Client | Hides when the owner stops or the character unloads. |
hideTextUI | Client | Hides the prompt only when owner showed it. |
isTextUIOpen | Client | |
skillCheck | Client | Yields. |
skillCheckActive | Client | |
cancelSkillCheck | Client | Errors when no check is running. |
registerContext | Client | The menus are dropped, and closed if open, when the owner stops. |
showContext | Client | Errors on an unknown id, a non-string id or a menu without an options table. |
hideContext | Client | |
getOpenContextMenu | Client | |
inputDialog | Client | Yields; one value per row. |
closeInputDialog | Client | |
alertDialog | Client | Yields. |
closeAlertDialog | Client | |
addRadialItem | Client | Adds or replaces top-level radial items by id. |
removeRadialItem | Client | |
clearRadialItems | Client | Removes the top-level items the calling resource added. |
registerRadial | Client | |
hideRadial | Client | |
disableRadial | Client | |
getCurrentRadialId | Client | The open menu's id, 'root' for the top level, nil when closed. |
notify
ClientShows a notification.
exports.cobalt_interfaces:notify(data)| Parameter | Type | Optional | Description |
|---|---|---|---|
data | InterfaceNotifyProps | No |
exports.cobalt_interfaces:notify(
{ title = 'Garage', description = 'Vehicle stored', type = 'success', duration = 5000, icon = 'car' }
)Server
Shows a notification to one player.
exports.cobalt_interfaces:notify(source, data)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | server id, or -1 for everyone |
data | InterfaceNotifyProps | No |
exports.cobalt_interfaces:notify(
source,
{ title = 'Garage', description = 'Vehicle stored', type = 'success', duration = 5000, icon = 'car' }
)progressBar
ClientYields until the bar fills (true) or is cancelled or interrupted (false).
exports.cobalt_interfaces:progressBar(data)| Parameter | Type | Optional | Description |
|---|---|---|---|
data | InterfaceProgressProps | No |
| Returns | Description |
|---|---|
boolean | completed |
local completed = exports.cobalt_interfaces:progressBar(
{ label = 'Repairing engine', duration = 10000, icon = 'wrench', canCancel = true, disable = { move = true, combat = true } }
)progressActive
Clientexports.cobalt_interfaces:progressActive()| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_interfaces:progressActive()cancelProgress
ClientErrors when no bar is running.
exports.cobalt_interfaces:cancelProgress()exports.cobalt_interfaces:cancelProgress()showTextUI
ClientHides when the owner stops or the character unloads.
exports.cobalt_interfaces:showTextUI(text, options, owner)| Parameter | Type | Optional | Description |
|---|---|---|---|
text | string | No | |
options | InterfaceTextUIOptions | Yes | |
owner | string | Yes | resource the prompt belongs to, the invoking resource by default |
exports.cobalt_interfaces:showTextUI(
'Press [E] to open the garage',
{ key = 'E', position = 'right-center' },
'ABC12345'
)hideTextUI
ClientHides the prompt only when owner showed it.
exports.cobalt_interfaces:hideTextUI(owner)| Parameter | Type | Optional | Description |
|---|---|---|---|
owner | string | Yes | the invoking resource by default |
exports.cobalt_interfaces:hideTextUI('ABC12345')isTextUIOpen
Clientexports.cobalt_interfaces:isTextUIOpen()| Returns | Description |
|---|---|
boolean | open |
string? | text |
local open, text = exports.cobalt_interfaces:isTextUIOpen()skillCheck
ClientYields. False when failed, when the owner stops, the character unloads or the player dies, and at once with a busy notification when a check is already running.
exports.cobalt_interfaces:skillCheck(difficulty, inputs, owner)| Parameter | Type | Optional | Description |
|---|---|---|---|
difficulty | SkillCheckDifficulty | SkillCheckDifficulty[] | No | |
inputs | string[] | Yes | keys picked from each round, { 'e' } by default |
owner | string | Yes | resource the check belongs to, the invoking resource by default |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_interfaces:skillCheck(
{ 'easy', 'easy', 'medium' },
{ 'w', 'a', 's', 'd' },
'ABC12345'
)skillCheckActive
Clientexports.cobalt_interfaces:skillCheckActive()| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_interfaces:skillCheckActive()cancelSkillCheck
ClientErrors when no check is running.
exports.cobalt_interfaces:cancelSkillCheck()exports.cobalt_interfaces:cancelSkillCheck()registerContext
ClientThe menus are dropped, and closed if open, when the owner stops.
exports.cobalt_interfaces:registerContext(context, owner)| Parameter | Type | Optional | Description |
|---|---|---|---|
context | ContextMenu | ContextMenu[] | No | |
owner | string | Yes | resource the menus belong to, the invoking resource by default |
exports.cobalt_interfaces:registerContext(
{ id = 'garage_menu', title = 'Legion Square garage', options = { { title = 'Take out Sultan', icon = 'car', serverEvent = 'cobalt_garages:server:takeOut', args = { plate = 'COBALT01' } } } },
'ABC12345'
)showContext
ClientErrors on an unknown id, a non-string id or a menu without an options table.
exports.cobalt_interfaces:showContext(id)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | string | No |
exports.cobalt_interfaces:showContext('garage_menu')hideContext
Clientexports.cobalt_interfaces:hideContext(onExit)| Parameter | Type | Optional | Description |
|---|---|---|---|
onExit | boolean | Yes | run the menu's onExit |
exports.cobalt_interfaces:hideContext(true)getOpenContextMenu
Clientexports.cobalt_interfaces:getOpenContextMenu()| Returns | Description |
|---|---|
string? |
local result = exports.cobalt_interfaces:getOpenContextMenu()inputDialog
ClientYields; one value per row. Nil when cancelled, when the owner stops, the character unloads or the player dies, and at once with a busy notification when another input dialog is open. Errors when rows is not a list.
exports.cobalt_interfaces:inputDialog(heading, rows, options, owner)| Parameter | Type | Optional | Description |
|---|---|---|---|
heading | string | No | |
rows | (string | InputRow)[] | No | |
options | InputOptions | Yes | |
owner | string | Yes | resource the dialog belongs to, the invoking resource by default |
| Returns | Description |
|---|---|
any[]? |
local result = exports.cobalt_interfaces:inputDialog(
'Rename vehicle',
{ { type = 'input', label = 'Plate', required = true }, { type = 'number', label = 'Price', min = 1 } },
{ allowCancel = true, submitText = 'Save' },
'ABC12345'
)closeInputDialog
Clientexports.cobalt_interfaces:closeInputDialog()exports.cobalt_interfaces:closeInputDialog()alertDialog
ClientYields. 'cancel' when dismissed, timed out, when the owner stops, the character unloads or the player dies, and at once with a busy notification when another alert is open.
exports.cobalt_interfaces:alertDialog(data, timeout, owner)| Parameter | Type | Optional | Description |
|---|---|---|---|
data | AlertProps | No | |
timeout | number | Yes | milliseconds before it closes as 'cancel' |
owner | string | Yes | resource the alert belongs to, the invoking resource by default |
| Returns | Description |
|---|---|
'confirm' | 'cancel' |
local result = exports.cobalt_interfaces:alertDialog(
{ header = 'Sell vehicle', content = 'Sell your Sultan for $12,000?', type = 'confirm', labels = { confirm = 'Sell', cancel = 'Keep' } },
10000,
'ABC12345'
)closeAlertDialog
Clientexports.cobalt_interfaces:closeAlertDialog(reason)| Parameter | Type | Optional | Description |
|---|---|---|---|
reason | 'confirm' | 'cancel' | Yes |
exports.cobalt_interfaces:closeAlertDialog('confirm')addRadialItem
ClientAdds or replaces top-level radial items by id.
exports.cobalt_interfaces:addRadialItem(items)| Parameter | Type | Optional | Description |
|---|---|---|---|
items | InterfaceRadialItem | InterfaceRadialItem[] | No |
exports.cobalt_interfaces:addRadialItem(
{ id = 'toggle_seatbelt', label = 'Seatbelt', icon = 'seatbelt', onSelect = function() ExecuteCommand('seatbelt') end }
)removeRadialItem
Clientexports.cobalt_interfaces:removeRadialItem(id)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | string | No |
exports.cobalt_interfaces:removeRadialItem('toggle_seatbelt')clearRadialItems
ClientRemoves the top-level items the calling resource added.
exports.cobalt_interfaces:clearRadialItems()exports.cobalt_interfaces:clearRadialItems()registerRadial
Clientexports.cobalt_interfaces:registerRadial(menu)| Parameter | Type | Optional | Description |
|---|---|---|---|
menu | RadialMenu | No |
exports.cobalt_interfaces:registerRadial(
{ id = 'vehicle_doors', label = 'Doors', items = { { id = 'door_driver', label = 'Driver door', icon = 'car-door' } } }
)hideRadial
Clientexports.cobalt_interfaces:hideRadial()exports.cobalt_interfaces:hideRadial()disableRadial
Clientexports.cobalt_interfaces:disableRadial(state)| Parameter | Type | Optional | Description |
|---|---|---|---|
state | boolean | No |
exports.cobalt_interfaces:disableRadial(true)getCurrentRadialId
ClientThe open menu's id, 'root' for the top level, nil when closed.
exports.cobalt_interfaces:getCurrentRadialId()| Returns | Description |
|---|---|
string? |
local result = exports.cobalt_interfaces:getCurrentRadialId()