Menu
Context menus provide navigation and action selection with hierarchical support
Registration Options
Option | Type | Required | Default | Description |
---|---|---|---|---|
id | string | Yes | nil | Unique menu identifier |
title | string | No | nil | Menu title (supports markdown) |
subtitle | string | No | nil | Menu subtitle (supports markdown) |
menu | string | No | nil | Parent menu ID (for back navigation) |
canClose | boolean | No | true | Whether menu can be closed with ESC |
options | table | Yes | {} | Array of menu options |
Option Properties
Option | Type | Required | Default | Description |
---|---|---|---|---|
title | string | Yes | nil | Option display text (supports markdown) |
icon | string | No | nil | FontAwesome icon class or image URL (supports .png , .webp , .jpg , .jpeg , .gif , .svg ) |
iconColor | string | No | '#71717A' | Icon color (hex) |
iconAnimation | string | No | nil | Icon animation: 'spin' , 'spinPulse' , 'spinReverse' , 'pulse' , 'beat' , 'fade' , 'beatFade' , 'bounce' , 'shake' , |
description | string | No | nil | Option description (supports markdown) |
keybind | string | No | nil | Keybind display text |
disabled | boolean | No | false | Whether option is disabled |
readOnly | boolean | No | false | Whether option is read-only (no click) |
menu | string | No | nil | Submenu ID to open |
arrow | boolean | No | false | Show arrow indicator (auto-set for submenus) |
progress | number | No | nil | Progress bar value (0-100) |
progressColor or colorScheme | string | No | '#3B82F6' | Progress bar color (hex) |
image | string | No | nil | URL to an image displayed in the hover metadata |
metadata | table | No | nil | Additional information displayed on hover (see Metadata) |
onSelect | function | No | nil | Callback function |
event | string | No | nil | Client event to trigger |
serverEvent | string | No | nil | Server event to trigger |
args | any | No | nil | Arguments for events |
Metadata
The metadata
property displays additional information in a hover card. It supports three formats:
String Array
metadata = {
"Additional info line 1",
"Additional info line 2",
"Additional info line 3"
}
Key-Value Object
metadata = {
["Property 1"] = "Value 1",
["Property 2"] = "Value 2",
["Status"] = "Active"
}
Structured Array (Recommended)
metadata = {
{ label = "Health", value = "85%" },
{ label = "Armor", value = "100%" },
{ label = "Experience", value = "1,250 XP", progress = 75, progressColor = "#3B82F6" },
{ label = "Level Progress", value = "3/4", progress = 75, progressColor = "#10B981" }
}
Metadata Item Properties
Property | Type | Required | Description |
---|---|---|---|
label | string | Yes | The label text |
value | any | Yes | The value to display |
progress | number | No | Progress bar value |
progressColor or colorScheme | string | No | Progress bar color (hex) |
Functions
-- Register a menu
exports.lation_ui:registerMenu(menuData)
-- Show a registered menu
exports.lation_ui:showMenu(menuId)
-- Hide the current menu
exports.lation_ui:hideMenu()
-- Get the currently open menu ID
local menuId = exports.lation_ui:getOpenMenu()
Example
-- Register main menu
exports.lation_ui:registerMenu({
id = 'test_menu',
title = 'Test Menu',
subtitle = 'Select an option below',
options = {
{
title = 'Simple',
description = 'This is a simple menu option',
icon = 'fas fa-bars',
},
{
title = 'Disabled',
description = 'This option is disabled',
icon = 'fas fa-ban',
iconColor = '#EF4444',
disabled = true
},
{
title = 'Read-Only',
description = 'This option is read-only',
icon = 'fas fa-circle-info',
iconColor = '#44aae8',
readOnly = true
},
{
title = 'Progress Bar',
description = 'This option shows a progress bar',
icon = 'fas fa-bars-progress',
progress = 45,
},
{
title = 'Image',
description = 'This option shows an image',
icon = 'fas fa-image',
image = 'https://img.lationscripts.com/lation-scripts-primary.png',
},
{
title = 'Sub Menu',
description = 'This option opens a sub menu',
icon = 'fas fa-list',
menu = 'sub_menu'
}
}
})
-- Register submenu
exports.lation_ui:registerMenu({
id = 'sub_menu',
title = 'Sub Menu',
subtitle = 'Select an option below',
menu = 'test_menu', -- Back button to test_menu
options = {
{
title = 'Metadata',
description = 'This option has metadata',
icon = 'fas fa-database',
metadata = {
{ label = 'Label 1', value = 'Value' },
{ label = 'Label 2', value = 69 }
}
},
{
title = 'onSelect',
description = 'This option triggers a function',
icon = 'fas fa-play',
onSelect = function()
print('onSelect function triggered')
end
},
{
title = 'Events',
description = 'This option triggers a client event',
icon = 'fas fa-broadcast-tower',
event = 'resourceName:eventName',
args = {
message = 'Hello from sub_menu',
}
},
{
title = 'Keybind',
description = 'This can be triggered with a keybind',
icon = 'fas fa-keyboard',
keybind = 'F2',
}
}
})
-- Show menu
exports.lation_ui:showMenu('test_menu')