Difference between revisions of "User:Lynnore Vaher"

From Second Life Wiki
Jump to navigation Jump to search
(New page: A little dump of what i made, started scripting a few months ago. Things can be better i know, but this works so i'm good with it. <b>Menu Pagination Script</b> <lsl> ////////////////////...)
 
Line 193: Line 193:
     timer(){
     timer(){
         llCloseAll();
         llCloseAll();
    }
}
</lsl>
<b>Open Mouth Script (For gag or whatever.)</b>
<lsl>
default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llSetTimerEvent(1.0);
        }
    }
    timer()
    {
        llSetTimerEvent(1.0);
        llStopAnimation("express_open_mouth");
        llStartAnimation("express_open_mouth");
     }
     }
}
}
</lsl>
</lsl>

Revision as of 06:04, 16 February 2009

A little dump of what i made, started scripting a few months ago. Things can be better i know, but this works so i'm good with it.

Menu Pagination Script <lsl> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // PageScript by Lynnore Vaher // Version number 1.00 // // !Important: // - Give me credit if you use parts or fully use this script, eg: mention as special thanks or something. // - If you like this script, please consider a small(or big) donation. // - This script can NOT be resold as full perm since i offer this for free. // - This script CAN be given away/copied but the top text has to stay. // - You can not ask me for help, if you have this script i assume you have scripting experience. // // Notes: // - Can handle only 1 person at a time. // - Don't feel like explaining the whole thing. // // BugFixes: // - Fixed a bug where a back button got added with lists just above 12 items. // - Fixed llPagesFunc start wich gave an error with lists with less then 12 items. // - Deleted a line of code wich wasn't suppose to be there, this cause a wrong display of the menu. // // Usage: // - Put all the functions and variables in your script. // - Call the menu with llPagesFunc(LISTNAME, USERKEY), where LISTNAME is the list of buttons you want and // USERKEY is the key of the person to send the dialog to. This is NEEDED before calling the next and back functions // - Call the next pages with llPagesNext(LISTNAME, USERKEY). // - Call the previous pages with llPagesBack(LISTNAME, USERKEY). // - This is a fully working example and requires some experience with scripting. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Start Global Variables // ----------------------- integer curPage = 0; // Current page, Do not change this. integer curStart = 0; // The start of the buttonlist, don't change. integer curEnd = 9; // The end of the buttonlist, do not change this. integer curLength = 0; // Length of the list, will be changed by the script. integer curChan = 0; // Random channel, script will change this. integer curListen = 0; // Listen number, again script will change this. integer maxPerDia = 9; // Max items per dialog, don't change this. integer itemBusy = FALSE; // Check if dialog is in use FALSE = no, TRUE = yes. integer totalPages = 0; // Total of pages, script will calculate this.

float curDelay = 60.0; // Time before the listen will time out.

string curMsg = "Select wich notecard you want to load."; // Dialog message

list FirstAdd = [" ", "Exit", "Next >"]; // Added on the first page list MidAdd = ["< Back", "Exit", "Next >"]; // Added on middle pages list BackAdd = ["< Back", "Exit", " "]; // Added on last page list notes = ["1", "2"]; // This is the actual list that will be split in pages // -------------------- // End Global Variables

// Start Functions // ---------------- llReset(){ // Reset the global variables

   curStart = 0;
   curEnd = 0;
   maxPerDia = 9;
   itemBusy = TRUE;

} llPagesFunc(list notes, key user){ // Create the start dialog

   list curButtons = [];
   llReset();
   curLength = llGetListLength(notes); 
   totalPages = llCeil((float)curLength / 9.0);
   if(curLength <= 12){
       totalPages = 1;
       for(curStart=0;curStart<curLength;curStart++){
           curButtons += llList2String(notes, curStart);
       }
       curButtons = FillMenu(curButtons);
   }else if(curLength > 12){
       totalPages = llCeil((float)curLength / 9.0);
       for(curStart=0;curStart<maxPerDia;curStart++){
           curButtons += llList2String(notes, curStart);
       }
       curEnd = 9;
       curButtons = FillMenu(curButtons) + FirstAdd;
   }
   curPage = 1;
   llGiveDialog(user, RestackMenu(curButtons));

}

llPagesNext(list notes, key user){ // Create the next page

   list curButtons = [];
   curEnd = curEnd + 9;
   if(curEnd >= curLength){
       curEnd = curLength;
       for(curStart;curStart<curEnd;curStart++){
           curButtons += llList2String(notes, curStart);
       }
       curButtons = FillMenu(curButtons) + BackAdd;
   }else if (curEnd < curLength){
       for(curStart;curStart<curEnd;curStart++){
           curButtons += llList2String(notes, curStart);
       }
       curButtons = FillMenu(curButtons) + MidAdd;
   }
   curPage++;
   llGiveDialog(user, RestackMenu(curButtons));

}

llPagesBack(list notes, key user){ // Recreate the previous page

   curPage--;
   list curButtons = [];
   curStart = curStart - 9;
   integer tempEnd = curEnd - 9;
   integer tempStart = curStart - 9;
   if(curEnd == curLength){
       if(curPage == 1){
           curStart = curStart - (curLength % 9);
           curEnd = curStart + 9;
           for(curStart;curStart<curEnd;curStart++){
               curButtons += llList2String(notes, curStart);
           }
           curButtons = FillMenu(curButtons) + FirstAdd;
       }else{
           curStart = curStart - (curLength % 9);
           curEnd = curStart + 9;
           for(curStart;curStart<curEnd;curStart++){
               curButtons += llList2String(notes, curStart);
           }
           curButtons = FillMenu(curButtons) + MidAdd;
       }
   }else if((tempEnd != 9) && (tempStart != 0) && (curEnd < curLength)){
       curStart = curStart - 9;
       curEnd = curEnd - 9;
       for(curStart;curStart < curEnd;curStart++){
           curButtons += llList2String(notes, curStart);
       }
       curButtons = FillMenu(curButtons) + MidAdd;
   }else if(tempStart == 0){ 
       llPagesFunc(notes,user);
       return;
   }
   llGiveDialog(user, RestackMenu(curButtons));

} llGiveDialog(key user, list buttons){ // This will give the dialog

   curListen = llListen(curChan, "", user, "");
   llDialog(user, curMsg + "\n\n\n\nPage: " + (string)curPage + "/" + (string)totalPages, buttons, curChan);
   llSetTimerEvent(curDelay);

} list FillMenu(list in){ // Fill the menu

   while (llGetListLength(in) != 3 
       && llGetListLength(in) != 6 
       && llGetListLength(in) != 9 
       && llGetListLength(in) < 12){
           in += [" "];
   }
   return in;

}

list RestackMenu(list in){ // Restack the manu so the order is correct

   list out = llList2List(in, 9, 11);
   out += llList2List(in, 6, 8);
   out += llList2List(in, 3, 5);    
   out += llList2List(in, 0, 2);    
   return out;

}

llShowError(key user, integer errorNum){ // Show an error, errorNum is used to add errors without changing much

   string errorMsg = "";
   if(errorNum == 1) errorMsg = "\n\nDialog currently in use, try again in 60 seconds.";
   llDialog(user, errorMsg, ["Ok"], 465465);

} llCloseAll(){ // Close listen, tell the menu can be used again.

   itemBusy = FALSE;
   llListenRemove(curListen);

} // ------------- // End Functions

default {

   state_entry()
   {
       curChan =  ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
   }
   touch_start(integer num){
       if(itemBusy) llShowError(llDetectedKey(0),1);
       else llPagesFunc(notes,llDetectedKey(0));
   }
   listen(integer _c, string _n, key _id, string _m){
       if(_m == "Next >") llPagesNext(notes,_id);
       else if(_m == "< Back") llPagesBack(notes,_id);
       else if(_m == "Exit") llCloseAll();
   }
   timer(){
       llCloseAll();
   }

} </lsl>

Open Mouth Script (For gag or whatever.)

<lsl> default {

   state_entry()
   {
       llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
   }
   run_time_permissions(integer perm)
   {
       if (perm & PERMISSION_TRIGGER_ANIMATION)
       {
           llSetTimerEvent(1.0);
       }
   }
   timer()
   {
       llSetTimerEvent(1.0);
       llStopAnimation("express_open_mouth");
       llStartAnimation("express_open_mouth");
   }

} </lsl>