# Dialog

> Dialog menus and text boxes, and how scripts handle the answers.

[`llDialog`](/functions/llDialog/) shows a blue menu with a message and up to 12 buttons. [`llTextBox`](/functions/llTextBox/) asks for a line of text. In both cases the viewer makes the avatar say the answer on a channel the script chose, so a dialog is really a [listener](/functions/llListen/) plus a prompt.

A dialog is not a window the script controls: once shown, the script cannot close or update it, and the answer is just chat, heard like any other message. Simple menus are easy; multi-page menus, several users at once and timeouts take more design.

For complex interfaces, a HUD built from prims can be a better fit: buttons are prims [touched](/events/touch_start/) by the wearer, read with [`llDetectedLinkNumber`](/functions/llDetectedLinkNumber/).

## Concepts

- Showing a menu
  - Buttons are a list of short labels; [clicking a button chats its label](/functions/llDialog/) on the channel
  - A [text box](/functions/llTextBox/) chats whatever the avatar typed instead
  - Use a large negative [random](/functions/llFrand/) channel so other scripts and people are unlikely to collide with it
- Handling the answer
  - [Open a listener](/functions/llListen/) on the dialog channel, filtered to the avatar's key, before showing the dialog
  - The reply arrives in the [`listen`](/events/listen/) event
  - [Remove the listener](/functions/llListenRemove/) after the answer, or after a timeout set with a [timer](/functions/llSetTimerEvent/); a listener can also be [paused and resumed](/functions/llListenControl/)
- Opening menus
  - Menus are usually opened by [touch](/events/touch_start/), using [who touched](/functions/llDetectedKey/) as the dialog target
  - The [touch text](/functions/llSetTouchText/) and [click action](/functions/llSetClickAction/) change what the viewer shows on hover and click
- Other viewer prompts
  - Scripts can also [open a web page](/functions/llLoadURL/), [a map location](/functions/llMapDestination/) or [a floater](/functions/llOpenFloater/), and [give items](/functions/llGiveInventory/) with an accept prompt

## Functions and events

- `void` [`llDialog`](/functions/llDialog/) `(key agent, string msg, list buttons, integer channel)`
- `void` [`llTextBox`](/functions/llTextBox/) `(key agent, string msg, integer channel)`
- `integer` [`llListen`](/functions/llListen/) `(integer channel, string name, key id, string msg)`
- `event` [`listen`](/events/listen/) `(integer channel, string name, key id, string msg)`
- `void` [`llListenRemove`](/functions/llListenRemove/) `(integer handle)`
- `void` [`llSetTimerEvent`](/functions/llSetTimerEvent/) `(float sec)`
- `event` [`timer`](/events/timer/) `()`

## [Dialog Menus](https://wiki.secondlife.com/wiki/Dialog_Menus)

Multi-page menus, menu state machines and prim HUDs are covered in the archived wiki articles.

## [Prim HUDs](https://wiki.secondlife.com/wiki/CatHUD)

A HUD is an attachment on the screen; its buttons are prims that the wearer touches, so it is not limited to 12 buttons.

## Scripting Details

- `void` [`llDialog`](/functions/llDialog/) `(key agent, string msg, list buttons, integer channel)`: Shows a dialog box on the screen of the specified agent, displaying msg along with up to 12 choice buttons. Clicking a button chats its label on channel. The chat originates at the object's position, but uses the agent's name and UUID, so it can be heard as long as the agent is still in the region.
- `void` [`llTextBox`](/functions/llTextBox/) `(key agent, string msg, integer channel)`: Opens an input text box dialog displaying msg to the agent. Submitting text chats the input string on channel as if said by the agent. The chat originates at the object's position, but uses the agent's name and UUID, so it can be heard as long as the agent is still in the region.
- `float` [`llFrand`](/functions/llFrand/) `(float mag)`: Returns a pseudo-random float in the range [0.0, mag) or (mag, 0.0] depending on the sign of mag. The value is inclusive of 0.0 but exclusive of mag.
- `integer` [`llListen`](/functions/llListen/) `(integer channel, string name, key id, string msg)`: Creates a listener on channel from name and id for msg. Returns an integer listener handle used to control or remove the listener. Empty strings or NULL_KEY filters do not filter on those parameters.
- `event` [`listen`](/events/listen/) `(integer channel, string name, key id, string msg)`: Triggered when a chat message matching active llListen filters is received on channel. Passes the sender's name and UUID key id, along with the spoken string msg.
- `void` [`llListenRemove`](/functions/llListenRemove/) `(integer handle)`: Completely removes the listener specified by the integer handle.
- `void` [`llListenControl`](/functions/llListenControl/) `(integer handle, integer active)`: Enables or disables the listener specified by the integer handle. If active is TRUE, the listener is activated; if FALSE, it is deactivated.
- `void` [`llSetTimerEvent`](/functions/llSetTimerEvent/) `(float sec)`: Sets a timer to trigger a timer event periodically every sec seconds. Passing 0.0 stops further timer events.
- `event` [`timer`](/events/timer/) `()`: Triggered at regular periodic intervals configured by llSetTimerEvent.
- `event` [`touch_start`](/events/touch_start/) `(integer num_detected)`: Triggered when an avatar first touches the object. Passes num_detected, representing the number of touching agents.
- `key` [`llDetectedKey`](/functions/llDetectedKey/) `(integer number)`: Returns the key (UUID) of the detected object or avatar specified by number, or NULL_KEY if number is not a valid index.
- `void` [`llSetTouchText`](/functions/llSetTouchText/) `(string text)`: Displays the string text instead of 'Touch' in the right-click context menu.
- `void` [`llSetClickAction`](/functions/llSetClickAction/) `(integer action)`: Sets the action (a CLICK_ACTION_* flag) performed when an avatar left-clicks the prim.

## Additional

- [`llListen`](/functions/llListen/) — channels that are not for menus
  - [`DEBUG_CHANNEL`](/constants/DEBUG_CHANNEL/) — reserved for script debugging and error messages
  - [`COMBAT_CHANNEL`](/constants/COMBAT_CHANNEL/) — reserved for the [combat](/features/combat/) log
- [`llSetClickAction`](/functions/llSetClickAction/) — what a left-click does ([all click actions](/constants/groups/ClickAction/))
  - [`CLICK_ACTION_TOUCH`](/constants/CLICK_ACTION_TOUCH/) — triggers touch events, the usual way to open a menu
  - [`CLICK_ACTION_SIT`](/constants/CLICK_ACTION_SIT/) — sits the avatar on the prim
  - [`CLICK_ACTION_PAY`](/constants/CLICK_ACTION_PAY/) — opens the pay dialog
- [`llMapBeacon`](/functions/llMapBeacon/) — displays an in-world beacon for the avatar touching or wearing the object
  - [`BEACON_MAP`](/constants/BEACON_MAP/) — also display and focus the world map
- [`llMapDestination`](/functions/llMapDestination/) — opens the world map; only works for attached scripts or during touch events
- [`llLoadURL`](/functions/llLoadURL/) — offers to open a URL in the avatar's web browser
- [`llOpenFloater`](/functions/llOpenFloater/) — opens a viewer floater loaded with a URL
- [`llGiveInventory`](/functions/llGiveInventory/) — gives an item, as permitted by the permissions system

## Constant groups

Constant groups: [ChannelNonPublic](/constants/groups/ChannelNonPublic/) (2), [ClickAction](/constants/groups/ClickAction/) (11), [MapBeaconParam](/constants/groups/MapBeaconParam/) (1)

## Related

See also: [Input](/features/input/), [User Interface](/categories/user_interface/)

See also: [Dialog Menus (Second Life Wiki)](https://wiki.secondlife.com/wiki/Dialog_Menus), [LSL Dialog (Second Life Wiki)](https://wiki.secondlife.com/wiki/Category:LSL_Dialog), [DialogPlus (Second Life Wiki)](https://wiki.secondlife.com/wiki/DialogPlus), [Communications](/features/communications/), [Avatars](/features/avatar/), [Script library: dialogs (Second Life Wiki)](https://wiki.secondlife.com/wiki/CatDialogs), [Script library: HUDs (Second Life Wiki)](https://wiki.secondlife.com/wiki/CatHUD)
   (planned: Recipe: multi-page dialog menu)
   (planned: Guide: building a prim HUD)

## Related features

- [Communications](/features/communications/)
- [Input](/features/input/)

## Categories

- [User Interface](/categories/user_interface/)

---

From lsl.dev: https://lsl.dev/features/dialog/
