tw.menu
Side: Client
NUI interactive menu system. Cross-framework replacement for vorp_menu.
Functions
tw.menu.open(data, on_click, on_close)
Opens a menu with the given configuration.
| Parameter | Type | Description |
|---|---|---|
data | table | Menu configuration (see below) |
on_click | function(data, menu) | Called when the player clicks an item |
on_close | function(nil, menu) | Called when the player closes the menu |
data structure:
| Field | Type | Description |
|---|---|---|
title | string | Menu title |
subtitle | string? | Subtitle displayed below the title |
items | table | Array of menu items |
Item structure:
| Field | Type | Description |
|---|---|---|
label | string | Display text |
value | any | Value passed to the click callback |
desc | string? | Description text |
rightLabel | string? | Right-aligned label (e.g., price) |
disabled | boolean? | If true, the item is greyed out and not clickable |
child | table? | Nested menu data (same structure as data) |
Callback on_click:
The data parameter contains:
| Field | Type | Description |
|---|---|---|
data.current | table | { value, label, desc } of the clicked item |
The menu parameter is a handle with a :close() method.
Callback on_close:
Called when the menu is closed by the player (Escape). The first parameter is nil, the second is the menu handle.
tw.menu.close()
Closes the currently open menu.
tw.menu.isOpen()
Checks if a menu is currently open.
Returns: boolean
Examples
Basic menu with click handling
lua
tw.menu.open({
title = "General Store",
subtitle = "Valentine",
items = {
{ label = "Bread", value = "bread", desc = "Fresh baked bread", rightLabel = "$1.50" },
{ label = "Coffee", value = "coffee", desc = "Hot black coffee", rightLabel = "$0.75" },
{ label = "Ammo", value = "ammo", rightLabel = "$5.00", disabled = true },
}
}, function(data, menu)
local item = data.current
print("Selected: " .. item.label .. " (value: " .. tostring(item.value) .. ")")
menu:close()
end, function(_, menu)
print("Menu closed by player")
end)Nested menus (child)
lua
tw.menu.open({
title = "Crafting",
items = {
{ label = "Weapons", value = "weapons", child = {
title = "Weapons",
items = {
{ label = "Knife", value = "knife", rightLabel = "2x Iron" },
{ label = "Bow", value = "bow", rightLabel = "3x Wood" },
}
}},
{ label = "Food", value = "food", child = {
title = "Food",
items = {
{ label = "Cooked Meat", value = "meat", rightLabel = "1x Raw Meat" },
}
}},
}
}, function(data, menu)
print("Craft: " .. data.current.value)
menu:close()
end, function(_, menu)
print("Closed")
end)Notes
- Only one menu can be open at a time. Opening a new menu replaces the current one.
- The menu is a NUI overlay rendered in the browser layer.
- Use
menu:close()inside callbacks to close the menu after an action.

