DirkScripts
Docs
Context
#Context Menus
#lib.registerContext
Register a context menu that can be opened by ID
lualib.registerContext('my_menu', { title = 'Main Menu', icon = 'fa-bars', options = { { title = 'Option 1', description = 'Does something', icon = 'fa-cog', onSelect = function() print('selected!') end, }, { title = 'Sub Menu', icon = 'fa-arrow-right', arrow = true, menu = 'my_sub_menu', -- opens another registered context }, }, })
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | yes | Unique menu identifier |
| data | table | yes | Menu definition (see below) |
#Menu Data
| Field | Type | Description |
|---|---|---|
title | string | Menu header title |
icon | string | FontAwesome icon class |
options | table[] | Array of menu options |
#Option Fields
| Field | Type | Description |
|---|---|---|
title | string | Option label |
description | string | Subtitle text |
icon | string | FontAwesome icon |
onSelect | function | Callback when selected |
menu | string | ID of a sub-menu to open |
dialog | string | ID of a dialog to open |
args | any | Arguments passed to clientEvent / serverEvent |
clientEvent | string | Trigger a client event when selected |
serverEvent | string | Trigger a server event when selected |
metadata | table | Key-value pairs displayed as badges |
disabled | boolean | Grey out the option |
arrow | boolean | Show a right arrow |
willClose | boolean | Force option to close (or keep open) before callbacks |
#lib.openContext
Open a registered context menu
lualib.openContext('my_menu')
#lib.closeContext
Close the currently open context menu
lualib.closeContext()
#lib.getOpenContextMenu
Get the ID of the currently open context menu
lualocal id = lib.getOpenContextMenu()
#lib.showContext / lib.hideContext
Show or hide the context menu without destroying it
lualib.showContext() lib.hideContext()
