Context Menu
Structured menus with options, descriptions, and nested submenus.
Exports
| Export | Parameters | Returns |
|---|---|---|
RegisterContext | (context) | — |
ShowContext | (id) | — |
HideContext | (onExit) | — |
GetOpenContextMenu | () | string or nil |
RegisterContext Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Unique menu identifier |
title | string | Yes | Menu title |
menu | string | No | Parent menu ID (enables back button) |
canClose | boolean | No | Whether the menu can be closed with ESC |
options | table | Yes | Array of menu options |
Option Fields
| Field | Type | Description |
|---|---|---|
title | string | Option label |
description | string | Description text below the title |
icon | string | FontAwesome icon name or image URL |
iconColor | string | Custom icon color |
iconAnimation | string | Icon animation: 'spin', 'beat', 'fade', 'bounce', 'shake' |
arrow | boolean | Show arrow indicator |
progress | number | Show a progress bar (0–100) |
colorScheme | string | Color for the progress bar |
image | string | Image URL shown on hover |
metadata | table | Key-value data shown on hover |
disabled | boolean | Grey out and disable the option |
readOnly | boolean | Show but prevent interaction |
onSelect | function | Callback when selected |
menu | string | ID of a submenu to open |
event | string | Client event to trigger |
serverEvent | string | Server event to trigger |
command | string | Console command to execute |
args | any | Arguments passed to event/callback |
Usage
Register and Show
exports['flux-ui-pack']:RegisterContext({
id = 'my_menu',
title = 'My Menu',
options = {
{
title = 'Option 1',
icon = 'check',
onSelect = function()
print('Selected option 1!')
end
},
{
title = 'Option 2',
description = 'This has a description',
icon = 'gear'
}
}
})
exports['flux-ui-pack']:ShowContext('my_menu')With Events and Commands
exports['flux-ui-pack']:RegisterContext({
id = 'action_menu',
title = 'Actions',
options = {
{
title = 'Trigger Event',
icon = 'bolt',
event = 'myScript:doSomething',
args = { id = 1 }
},
{
title = 'Server Action',
icon = 'server',
serverEvent = 'myScript:serverAction',
args = { id = 1 }
},
{
title = 'Run Command',
icon = 'terminal',
command = 'status'
}
}
})With Metadata and Progress
exports['flux-ui-pack']:RegisterContext({
id = 'item_info',
title = 'Item Details',
options = {
{
title = 'Armor Vest',
icon = 'shield',
metadata = {
{ label = 'Durability', value = '75%', progress = 75 },
{ label = 'Weight', value = '2.5kg' }
},
progress = 75,
colorScheme = 'green'
}
}
})With Submenus
exports['flux-ui-pack']:RegisterContext({
id = 'main_menu',
title = 'Main Menu',
options = {
{
title = 'Vehicle Options',
menu = 'vehicle_menu'
}
}
})
exports['flux-ui-pack']:RegisterContext({
id = 'vehicle_menu',
title = 'Vehicle Options',
menu = 'main_menu', -- Back button returns here
options = {
{ title = 'Lock Vehicle', onSelect = function() end },
{ title = 'Toggle Engine', onSelect = function() end },
}
})
exports['flux-ui-pack']:ShowContext('main_menu')Hide Context Menu
exports['flux-ui-pack']:HideContext()Get Open Menu
local openMenu = exports['flux-ui-pack']:GetOpenContextMenu()
if openMenu then
print('Currently open: ' .. openMenu)
endLast updated on