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
- Showing a menu
- Buttons are a list of short labels; clicking a button chats its label on the channel
- A text box chats whatever the avatar typed instead
- Use a large negative
randomchannel so other scripts and people are unlikely to collide with it
- Handling the answer
- Open a listener on the dialog channel, filtered to the avatar’s key, before showing the dialog
- The reply arrives in the
listenevent - Remove the listener after the answer, or after a timeout set with a
timer; a listener can also be paused and resumed
- Opening menus
- Menus are usually opened by
touch, using who touched as the dialog target - The touch text and click action change what the viewer shows on hover and click
- Menus are usually opened by
- Other viewer prompts
- Scripts can also open a web page, a map location or a floater, and give items with an accept prompt
Functions and events
void | llDialog(key agent, string msg, list buttons, integer channel) |
void | llTextBox(key agent, string msg, integer channel) |
integer | llListen(integer channel, string name, key id, string msg) |
event | listen(integer channel, string name, key id, string msg) |
void | llListenRemove(integer handle) |
void | llSetTimerEvent(float sec) |
event | timer() |
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
void | 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(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(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(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(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(integer handle)Completely removes the listener specified by the integer handle. |
void | 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(float sec)Sets a timer to trigger a timer event periodically every sec seconds. Passing 0.0 stops further timer events. |
event | timer()Triggered at regular periodic intervals configured by llSetTimerEvent. |
event | touch_start(integer num_detected)Triggered when an avatar first touches the object. Passes num_detected, representing the number of touching agents. |
key | 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(string text)Displays the string text instead of 'Touch' in the right-click context menu. |
void | llSetClickAction(integer action)Sets the action (a CLICK_ACTION_* flag) performed when an avatar left-clicks the prim. |
Additional
llListen— channels that are not for menusDEBUG_CHANNEL— reserved for script debugging and error messagesCOMBAT_CHANNEL— reserved for the combat log
llSetClickAction— what a left-click does (all click actions)CLICK_ACTION_TOUCH— triggers touch events, the usual way to open a menuCLICK_ACTION_SIT— sits the avatar on the primCLICK_ACTION_PAY— opens the pay dialog
llMapBeacon— displays an in-world beacon for the avatar touching or wearing the objectBEACON_MAP— also display and focus the world map
llMapDestination— opens the world map; only works for attached scripts or during touch eventsllLoadURL— offers to open a URL in the avatar’s web browserllOpenFloater— opens a viewer floater loaded with a URLllGiveInventory— gives an item, as permitted by the permissions system
Constant groups
Section titled “Constant groups”Constant groups ChannelNonPublic 2ClickAction 11MapBeaconParam 1
Related
Section titled “Related”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