Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer iMax;
- integer iHandle;
- integer iChannel;
- key kToucher;
- key kChosenUUID;
- list lNames;
- list lUUIDs;
- list lTemp;
- list lDialogLabels;
- list lMenuChoices;
- list lMenuButtons( integer vIntPag )
- {
- integer vIdxBeg = 10 * (~-vIntPag); //-- 10 * (vIntPag - 1), enclose "~-X" in parens to avoid LSL bug
- integer vIdxMax = -~(~([] != lMenuChoices) / 10); //-- (llGetListLength( lMenuChoices ) - 1) / 10 + 1
- list vLstRtn =
- llListInsertList(
- llList2List( lMenuChoices, vIdxBeg, vIdxBeg + 9 ), //-- grab 10 dialog buttons
- (list)(" <<---(" + (string)(vIntPag + (-(vIntPag > 1) | vIdxMax - vIntPag)) + ")"), //-- back button
- -1 ) + //-- inserts back button at index 9, pushing the last menu item to index 10
- (list)(" (" + (string)(-~((vIntPag < vIdxMax) * vIntPag)) + ")--->>"); //-- add fwd button at index 11
- return //-- fix the order to L2R/T2B
- llList2List( vLstRtn, -3, -1 ) + llList2List( vLstRtn, -6, -4 ) +
- llList2List( vLstRtn, -9, -7 ) + llList2List( vLstRtn, -12, -10 );
- }
- string strCaption = "Please choose someone:";
- string strChoice;
- default {
- state_entry() {
- iChannel = -((integer)(10000 + llFrand(9999999)));
- }
- attach(key id) {
- if(id){
- llRequestPermissions(id, PERMISSION_TAKE_CONTROLS);//needed to run in no script areas
- }
- }
- run_time_permissions(integer perm) {
- if(perm & PERMISSION_TAKE_CONTROLS){
- llTakeControls(CONTROL_ML_LBUTTON, FALSE, TRUE);
- }
- }
- touch_end(integer num_detected) {
- kToucher = llDetectedKey(0);
- lTemp = llGetAgentList(AGENT_LIST_REGION, []);//build list of avatars on the region
- lNames =[];//clear the lists of existing contents
- lUUIDs= [];
- lDialogLabels=[];
- lMenuChoices=[];
- iMax = -llGetListLength(lTemp);
- do{ //loop through lTemp and populate the lists
- key k = llList2Key(lTemp,iMax);
- lNames +=[llGetDisplayName(k)];
- lUUIDs +=[k];
- }
- while(++iMax);
- integer counter = 0 ;
- iMax = llGetListLength(lNames);
- do{
- lDialogLabels += [(string)(counter + 1)+": "+llList2String(lNames, counter)+"\n"];
- lMenuChoices +=[(string)(counter + 1)];
- }
- while(++counter < iMax);
- llOwnerSay("lMenuChoices is "+llList2CSV(lMenuChoices));
- llListenRemove(iHandle); // close
- iHandle = llListen(iChannel, "", "", "");
- string str = "";
- integer i;
- //Display the first 10 sites in dialog
- for (i=0;i<10;++i)
- {
- str += llList2String(lDialogLabels,i);
- }
- llDialog(kToucher, strCaption+"\n"+str, lMenuButtons(1), iChannel);
- }
- listen(integer channel, string name, key id, string message) {
- if(!llSubStringIndex(message, " ")){//if the first two characters of the message are leading spaces, then it's the forward or back button
- string str = "";
- integer menu = (integer)llGetSubString( message, -~llSubStringIndex( message, "(" ), -1 );
- integer i;
- for (i=(10*(menu - 1));i<(10*menu);++i){
- str += llList2String(lDialogLabels,i);
- }
- llDialog(kToucher, strCaption+"\n"+str, lMenuButtons(menu), iChannel);
- }
- else{
- integer n = (integer)message -1;
- llRegionSayTo(kToucher, 0, "You chose: " + strChoice = llList2String(lNames,n)+", uuid "+(string)(kChosenUUID = llList2Key(lUUIDs, n)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement