Jump to content
Sign in to follow this  
Bloodsong Termagant

13T Texture Applier SETUP

Recommended Posts

This script will help texture creators create texture applier scripts for any object.  It is NOT foolproof.  It will screw up if the end user has somehow changed the link order of their object.  It may also choke if any link in a linkset has settings for more than 3 or 4 faces.

Open Source; please share any improvements you make to it.

Thanks and Enjoy!

//-- Texture Applier SETUP v 1.0
//-- by bloodsong termagant
//  WARNING: make croak if one link has many faces/materials set up.
//  The script only writes textures and colours & transparency.
//  It does not do shine or bump or glow or anything else.
//  WARNING:  this is a free script, distributed as-is
//  use at your own risk.  TEST.
//  If you improve it, please share on the SL forum topic -- thanks!
//  This script will create a script (chat output)
//  to apply textures, via UUID, to various links/faces in a set.
//  Throw it in an object you have textured.
//  If you make changes afterwards, click the object.
//  Copy and paste the output to a New Script.
//  See bottom for complete instructions.

string s = "\n";
list ListOfLists = [];//--our list variable names
list ListOfNumbers = []; //--which links have lists...!

    string name = llGetObjectName();
    string output = "";  //--this will write our lines
    list l; //--temp holding list
    string txname = ""; //--texture name check
    key id; //--key check
    integer n = llGetNumberOfPrims();
    integer i = 1;  //--counting prims
    if(n == 1) i = 0;  //-- solo = 0; root = 1
    integer nt;  //-- how many texture sides
    integer t = 0; //-- texture face # 0-7
    integer TEST = FALSE;
    llOwnerSay(s+"integer nLinks = "+(string)n+";"); //--line to load nLinks variable
    for(i; i<=n; i++)
    {//llOwnerSay("Checking Link#"+(string)i);
       TEST = FALSE;
       output = "";
       nt = llGetLinkNumberOfSides(i);
      for(t=0; t<nt; t++)
      {//llOwnerSay("Checking Face#"+(string)t);  
        l = llGetLinkPrimitiveParams(i, [PRIM_TEXTURE, t, PRIM_COLOR, t]);
        txname = llList2String(l, 0);

        //--dont do anything if its not our texture
        if(txname ==  "00000000-0000-0000-0000-000000000000")  jump out;
        else //--YTF do i need this???  i dont, if i do ^^ right
          TEST = TRUE;
         //--now surgically alter the list, because ANNOYANCES
         txname = "\""+(string)llGetInventoryKey(txname)+"\"";
         l = llListReplaceList(l, [txname], 0,0);
         l = llListInsertList(l, ["PRIM_COLOR", t], -2);
         if(output == "")
         {//--first face in list 
          output += s;  //--skip a line
          output += "list Link"+(string)i+" = ["; //--variable list
          //--add to our ListOfLists
          ListOfLists += "Link"+(string)i;
             //llOwnerSay("^^^^^ DELETE ABOVE ENTRY ^^^^^");
             output = llGetSubString(output, 0, -3); //chop off ; and ]
             output += ", ";
          output += "PRIM_TEXTURE, "+(string)t+", ";
          output += llDumpList2String(l, ",");
          output += "];";
      }//--end Face loop
        ListOfNumbers += i;
        llOwnerSay("Adding "+(string)i+" to list.");
    }//--end Link loop

//-- Start our chat output for the script with a header
//-- x is the name of the object
doHeader(string x)
   llOwnerSay("===================START SCRIPT==================="); 
   llOwnerSay("----TEXTURE APPLIER SCRIPT-----");

//--this part does the whole script default state and state_entry
    llOwnerSay(s+"default\n{\nstate_entry()\n{"); //--start
    //--state entry; run through and apply per Link per Face

    string output = "";  //--this will write our lines
    integer n = llGetListLength(ListOfLists);
    integer i = 0;  

    for(i; i<n; i++)
    {//llOwnerSay("Writing Link#"+(string)i);
          output = "";
          output += s;  //--skip a line to avoid commenting it out
          output += "llSetLinkPrimitiveParamsFast("+llList2String(ListOfNumbers, i)+", "; //--command
          output += llList2String(ListOfLists, i); //--which list params
          output += ");";
    llOwnerSay("-- Uncomment next line to make it self destruct.  WARNING: SAVE A COPY TO YOUR INVENTORY!");
    //--end the state entry and the script
    llOwnerSay("===================END SCRIPT==================="); 


    touch_start(integer total_number)

If You Created The Object:-----------------------------

   1: (Re)texture it how you wish.   
   2: Throw the textures you used into
    the object's inventory.  
   3: Throw in this script.
If it doesn't work, see below.

   4: Open chat history and copy the script.
   5: (In Inventory) Create a New Script.  Select all, Paste.  Save.
      (Make sure you name it so you know what it is, and what it goes to!)
      (Also, uncomment the Self Destruct line at the end.)
      (And set the script perms as you wish.)
If You Are Not The Creator:----------------------------

   1: Retexture the object.
   2: Throw the textures you used into the object, AND 
      throw whatever texture you used in child objects 
      into those child objects.
   3: Throw in this script (to the Root Prim).

   4: Open chat history and copy the script.
   5: (In Inventory) Create a New Script.  Select all, Paste.  Save.
      (Make sure you name it so you know what it is, and what it goes to!)
      (Also, uncomment the Self Destruct line at the end.)
      (And set the script perms as you wish.)

   It works like this:
   "With texture as with llGetTexture, NULL_KEY is returned 
   when the owner does not have full permissions to the object
   and the texture is not in the prim's inventory."
   So, if you did not create the object (not full perms), 
&AND& the texture is not IN the object, it will not tell 
you the texture name or UUID.
   Therefore, if you don't have full perms on the object,
you need to put your texture in the object for
it to return the texture name.

    To get the script to get the texture KEY... it needs to
find the texture name in its inventory and get the key from that.
   Therefore, if you DO have full perms on the object,
you still need to throw the textures in it.


   The script it generates is pretty basic.
   It has one list variable for each link in the object.  It goes through
each list, applying it to the link it goes to.


   If you don't want to dick with throwing this script (and a buncha textures) into each variant of an object you textured, but prefer to dick with copying and pasting UUIDs from your inventory, you can do that, too.

   The output will look something like this:
//: Texture=13T-TM-AlbinoBase
list Link0 = [PRIM_TEXTURE, 0, "5452154c-f1fd-c5e8-32zz-8e45c9439689",<0.600000, 1.000000, 0.000000>,<-0.499985, 0.000000, 0.000000>,0.000000,PRIM_COLOR,0,<1.000000, 1.000000, 1.000000>,1.000000];

   The texture name is in the comment above.  So, for example, to change the AlbinoBase texture to a PiebaldBase texture, you'd just copy the UUID of PiebaldBase from your inventory and paste it into that long text line of 
secret code, there.




Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...