OnTouchSelectTexture

From Second Life Wiki
Jump to navigation Jump to search

IMPORTANT NOTE: This menus control REQUIRED Nargus Dialog Control script. You MUST have all both the script and this one in the same prim for it to work.

Scripts

OnTouchSelectTexture.lsl <lsl> // ********** DIALOG FUNCTIONS ********** // Dialog constants integer lnkDialog = 14001; integer lnkDialogNotify = 14004; integer lnkDialogResponse = 14002; integer lnkDialogTimeOut = 14003;

integer lnkDialogReshow = 14011; integer lnkDialogCancel = 14012;

integer lnkMenuClear = 15001; integer lnkMenuAdd = 15002; integer lnkMenuShow = 15003;

string seperator = "||"; integer dialogTimeOut = 0; // ********** END DIALOG FUNCTIONS **********

string texturesDialog;

initTextures(){ // Please me reminded that Nargus Dialog script autometicly add Back/Next buttons for you. // Optimised dialog generator script. Much more memory efficient than usage of Dialog+Menus control function

   llOwnerSay("Inventory change detected; re-initializing...");
   
   texturesDialog = "Click BACK/NEXT to change page.\n" +
       "Click a texture button to choose." +
       seperator + (string)dialogTimeOut;
   
   integer count = llGetInventoryNumber(INVENTORY_TEXTURE);
   integer i;
   for(; i<count; ++i){
       string name = llGetInventoryName(INVENTORY_TEXTURE, i);
       texturesDialog += seperator + name + seperator + llGetSubString(name, 0, 15);
   }
   texturesDialog += seperator + "CLOSE" + seperator;
   llOwnerSay("Initializing completed.");

}

default{

   state_entry(){
       initTextures();
   }
   
   changed(integer changes){
       if(changes & CHANGED_INVENTORY) initTextures();
   }

   link_message(integer sender_num, integer num, string str, key id){
       if(num == lnkDialogResponse){
           if(llGetInventoryType(str) == INVENTORY_TEXTURE) llSetTexture(str, ALL_SIDES);
       }
   }

   touch_start(integer num_detected){
       llMessageLinked(LINK_THIS, lnkDialog, texturesDialog, llDetectedOwner(0));
   }

} </lsl>