Search:


Follow Us On:

Script Insert Custom Textures Riding Horse

This script is put into a pretty box, which is then sold. Users will rez and click the box to have it feed custom textures to the HUD.

 // ----------------------------------------
 // Warning: Set this script notrans/nomodify,
 //  or you might as well give out fullperm textures.
 // ----------------------------------------

 // ----------------------------------------
 // Intended use:
 // Put your brand logo texture UUID into the
 //  gsBrand variable.
 // Fill out the glTexture list below, then put
 //  this script in a pretty looking box.
 // Sell the box, and when people rez and then
 //  click it, it will send texture data to the HUD.
 // ----------------------------------------

 // ----------------------------------------
 // Format:
 //  1: Bodypart Name
 //  2: Texture group count.
 //  2: HUD Display texture UUID
 //  3: Diffuse/base texture UUID
 //  4: Normalmap texture UUID
 //  5: Specular texture UUID
 //  For additional textures, omit the bodypart and
 //   add simply add more textures.
 //
 //   "head", 2, "Display-UUID", "Diffuse-UUID", "Normalmap-UUID", "Specular-UUID",
 //              "Display-UUID", "Diffuse-UUID", "Normalmap-UUID", "Specular-UUID",
 //   "mane", 1, "Display-UUID", "Diffuse-UUID", "Normalmap-UUID", "Specular-UUID",
 //   "tail", 1, "Display-UUID", "Diffuse-UUID", "Normalmap-UUID", "Specular-UUID"
 //
 // The first item is the bodypart as appears in
 //  the avatar prim's description field.
 //
 // With the Materials update, Second Life now has support
 //  for multiple kinds of textures.
 // The Diffuse texture is what's commonly refered to as
 //  "the texture." It's the colors -- the actual texture.
 // The Normal texture is how light interacts with the texture.
 //  It gives the model extra details beyond the geometry.
 // The specular texture is how light reflects off the model.
 // 
 // The Display texture is unrelated. It's a diffuse texture
 //  the HUD texture button will display.
 // The brand texture will show in the corner of the HUD texture
 //  button and let people know that texture was created by you.
 //
 // For a texture that applies to multiple bodyparts,
 //  add multiple entries for it.
 // ----------------------------------------
 string gsBrand = NULL_KEY;

 list glTexture = [
   "head", 2, "Display-UUID", "Diffuse-UUID", "Normalmap-UUID", "Specular-UUID",
              "Display-UUID", "Diffuse-UUID", "Normalmap-UUID", "Specular-UUID",
   "mane", 1, "Display-UUID", "Diffuse-UUID", "Normalmap-UUID", "Specular-UUID",
   "tail", 1, "Display-UUID", "Diffuse-UUID", "Normalmap-UUID", "Specular-UUID"
 ];

 // This is the message sent after the textures are inserted.
 // You may want to change this to a custom thank you message,
 //  including your brand name, and the texture pack name.
 string gsSuccessMessage = "Custom textures have been sent to the HUD.";


 // --------------------------------------------------
 // Please do not edit below this line.
 // (unless you know what you're doing.)
 // --------------------------------------------------

 integer giListenHandle;
 integer CHANNEL_OUTPUT = 46773;
 string REQUEST_BRAND_ID = "brand_id";
 string BRAND_ID_DUPE = "brand_dupe";
 string PREFIX_INSERT = "pennon_new";
 string SEP = ";";
 string SEP_ID = ",";

 validationCheck() {
   // Only run the validation check if the owner/creator are the same person.
   if (llGetCreator() == llGetOwner()) {
     integer iPermMask = llGetInventoryPermMask(llGetScriptName(),MASK_NEXT);
     integer iPermMaskObj = llGetObjectPermMask(MASK_NEXT);
     if (iPermMask & PERM_MODIFY) {
       llOwnerSay("PERMISSIONS WARNING: Modify permission is allowed on the script. This exposes your texture UUIDs to all users, and having it set is not recommended."); 
     }
     if (iPermMask & PERM_COPY & PERM_TRANSFER == PERM_COPY & PERM_TRANSFER) {
       llOwnerSay("PERMISSIONS WARNING: Copy and Transfer permissions are both allowed on the script. This allows people to make copies of this object and transfer them to other users, effectively making it free.");
     }
     if (iPermMaskObj & PERM_COPY & PERM_TRANSFER == PERM_COPY & PERM_TRANSFER) {
       llOwnerSay("PERMISSIONS WARNING: Copy and Transfer permissions are both allowed on the object. This allows people to make copies of this object and transfer them to other users, effectively making it free.");
     }
     if (gsBrand == NULL_KEY) {
       llOwnerSay("The brand identifier key is not a valid key. If you don't want it blank, please verify.");
     }
    }
 }

 default {
   state_entry() {
     validationCheck();
     llListen(CHANNEL_OUTPUT, "", "", "");
   }

   touch_start(integer num) {
     if (llDetectedKey(0) == llGetOwner()) {
       llOwnerSay("Sending textures to your HUD, please wait!");
       llRegionSay(CHANNEL_OUTPUT, REQUEST_BRAND_ID+SEP+gsBrand);
     }
   }

   listen(integer chan, string name, key id, string msg) {
     if (llGetOwnerKey(id) == llGetOwner()) {
       list l = llParseString2List(msg,[SEP],[]);
       if (llList2String(l,0) == REQUEST_BRAND_ID) {
         // We're given an ID to use when sending display textures.
         string a = llList2String(l,1);
         string sBrand = llList2String(l,2);
         if (sBrand == "") {
           sBrand += gsBrand;
         }

         // Sending one bodypart at a time.
         integer x;
         while (x < llGetListLength(glTexture)) {
           integer iCount = llList2Integer(glTexture,x+1);
           l = llList2List(glTexture,x,x+iCount*4+1);
           integer y;
           // Replace the display textures with id;display
           while (iCount--) {
             l = llListReplaceList(l,[a+SEP_ID+llList2String(l,2+iCount*4)],2+iCount*4,2+iCount*4);
           }
           // Pack and send.
           // TODO: Figure out a maximum count (length of msg) and break it up.
           llRegionSayTo(id,CHANNEL_OUTPUT,PREFIX_INSERT+SEP+sBrand+SEP+llDumpList2String(l,SEP));
           // Update index to next bodypart in the list (or past the list)
           x += llList2Integer(glTexture,x+1) * 4 + 2;
         }

         llSleep(2.0);
         llRegionSayTo(id, CHANNEL_OUTPUT, "done");
         llOwnerSay(gsSuccessMessage);
       }
     }
   }
 }
Edit - Upload - Edit Sidebar
Page last modified on March 03, 2017, at 07:30 AM