DirkScripts
Docs
Dialog
The dialog system provides interactive NPC-style dialog with camera focus, branching responses, and metadata display.
#lib.registerDialog
Register a dialog tree.
lualib.registerDialog('shop_npc', { entity = pedEntity, title = 'Shop Keeper', dialog = 'Welcome! What can I help you with?', responses = { { label = 'Show me your wares', action = function() TriggerEvent('shop:open') end }, { label = 'Nevermind', action = function() end }, }, })
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | yes | Unique dialog identifier |
| data | table | yes | Dialog definition |
#Dialog Data
| Field | Type | Description |
|---|---|---|
title | string | Dialog title |
dialog | string | Main dialog text |
icon | string | Optional icon |
entity | number | Optional ped/entity for camera focus |
responses | table | function | Dialog responses array or callback returning responses |
metadata | table | function | Optional metadata badges |
prevDialog | string | Previous dialog ID for back-navigation |
prevContext | string | Previous context menu ID for back-navigation |
clickSounds | boolean | Override click sounds |
hoverSounds | boolean | Override hover sounds |
disableFocus | boolean | Disable scripted camera focus |
#Response Fields
| Field | Type | Description |
|---|---|---|
label | string | Button label |
action | function | Callback when selected |
dialog | string | Open another dialog |
context | string | Open a context menu |
dontClose | boolean | Keep dialog open after action |
#lib.openDialog
Open a registered dialog.
lualib.openDialog(pedEntity, 'shop_npc')
| Parameter | Type | Required | Description |
|---|---|---|---|
| entity | number | no | Entity used for camera focus |
| id | string | yes | Registered dialog ID |
#lib.closeDialog
Close one dialog by ID, or all open dialogs if no ID is provided.
lualib.closeDialog('shop_npc') lib.closeDialog() -- close all
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | no | Dialog ID to close |
| keep_cam | boolean | no | Keep current dialog camera active |
