Dialog Control
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
This is example of usage and function library needed in each scripts to use this dialog module.
Functions List
- Standard dialog with buttons. If there are more than 12 buttons, BACK/NEXT button will be added automatically! In that case, the last button on the list will be used as Close/Cancel button.
- dialog(key id, string message, list buttons, list returns);
- Normal notification dialog, ie: dialog which requires no response from user.
- dialogNotify(key id, string message);
- To display current dialog again:
- dialogReshow();
- To cancel current dialog; Currently displayed dialog will give no response when clicked.
- dialogCancel();
Sample Scripts
- OnTouchSelectTexture (Tiyuk Quellmalz)
If anyone uses this module, please IM Nargus Asturias, I'd love to hear what you think.
Scripts
- Dialog Control v1.8 (with built-in Dialog Menus Control)
- Dialog Control (legacy) (Legacy version; do not have built-in menus control)
Basic Usage Example
<lsl> // READ ME: // To see this sample in action; // Put "Nargus Dialog Control" along with this script in a prim and touch.
// ********** DIALOG FUNCTIONS ********** // Dialog constants integer lnkDialog = 14001; integer lnkDialogNotify = 14004; integer lnkDialogResponse = 14002; integer lnkDialogTimeOut = 14003;
integer lnkDialogReshow = 14011; integer lnkDialogCancel = 14012;
string seperator = "||"; integer dialogTimeOut = 0;
string packDialogMessage(string message, list buttons, list returns){
string packed_message = message + seperator + (string)dialogTimeOut; integer i; integer count = llGetListLength(buttons); for(i=0; i<count; i++){ string button = llList2String(buttons, i); if(llStringLength(button) > 24) button = llGetSubString(button, 0, 23); packed_message += seperator + button + seperator + llList2String(returns, i); }
return packed_message;
}
dialogReshow(){llMessageLinked(LINK_THIS, lnkDialogReshow, "", NULL_KEY);} dialogCancel(){
llMessageLinked(LINK_THIS, lnkDialogCancel, "", NULL_KEY); llSleep(1);
}
dialog(key id, string message, list buttons, list returns){
llMessageLinked(LINK_THIS, lnkDialog, packDialogMessage(message, buttons, returns), id);
}
dialogNotify(key id, string message){
list rows; llMessageLinked(LINK_THIS, lnkDialogNotify, message + seperator + (string)dialogTimeOut + seperator, id);
} // ********** END DIALOG FUNCTIONS **********
default{
state_entry(){ llSetText("Touch me to show dialog", <1,1,1>, 1); }
link_message(integer sender_num, integer num, string str, key id){ if(num == lnkDialogTimeOut){ dialogNotify(llGetOwner(), "Menu time-out. Please try again."); state default; }else if(num == lnkDialogResponse){ llWhisper(0, str); } } touch_start(integer num_detected){ dialog(llDetectedKey(0), // Dialog message here "Messages go here", // List of dialog buttons [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, "Close" ],
// List of return value from the buttons, in same order // Note that this value do not need to be the same as button texts [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, "X" ] ); }
} </lsl>