Skip to content
lsl.devlsl.devLSL Dev

Dialog

llDialog shows a blue menu with a message and up to 12 buttons. 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 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 by the wearer, read with llDetectedLinkNumber.

Concepts

Functions and events

voidllDialog(key agent, string msg, list buttons, integer channel)
voidllTextBox(key agent, string msg, integer channel)
integerllListen(integer channel, string name, key id, string msg)
eventlisten(integer channel, string name, key id, string msg)
voidllListenRemove(integer handle)
voidllSetTimerEvent(float sec)
eventtimer()

Dialog Menus

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

Prim HUDs

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

voidllDialog(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.
voidllTextBox(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.
floatllFrand(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.
integerllListen(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.
eventlisten(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.
voidllListenRemove(integer handle)
Completely removes the listener specified by the integer handle.
voidllListenControl(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.
voidllSetTimerEvent(float sec)
Sets a timer to trigger a timer event periodically every sec seconds. Passing 0.0 stops further timer events.
eventtimer()
Triggered at regular periodic intervals configured by llSetTimerEvent.
eventtouch_start(integer num_detected)
Triggered when an avatar first touches the object. Passes num_detected, representing the number of touching agents.
keyllDetectedKey(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.
voidllSetTouchText(string text)
Displays the string text instead of 'Touch' in the right-click context menu.
voidllSetClickAction(integer action)
Sets the action (a CLICK_ACTION_* flag) performed when an avatar left-clicks the prim.

Additional

Constant groups ChannelNonPublic 2ClickAction 11MapBeaconParam 1

See also Feature InputCategory User Interface

See also SL Wiki Dialog MenusSL Wiki LSL DialogSL Wiki DialogPlusFeature CommunicationsFeature AvatarsSL Wiki Script library: dialogsSL Wiki Script library: HUDsPlanned Recipe: multi-page dialog menuPlanned Guide: building a prim HUD