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.

RELEASED AS-IS; USE AT YOUR OWN RISK; ETC
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...!

doRead()
{
    string name = llGetObjectName();
    llSetObjectName("//");
    
    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;
    
    doHeader(name);
    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
        {
            llOwnerSay("Texture="+txname); 
          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;
         }
         else
         {
             //llOwnerSay("^^^^^ DELETE ABOVE ENTRY ^^^^^");
             output = llGetSubString(output, 0, -3); //chop off ; and ]
             output += ", ";
         }
          output += "PRIM_TEXTURE, "+(string)t+", ";
          output += llDumpList2String(l, ",");
          output += "];";
        }
        
        @out;
      }//--end Face loop
      
      if(TEST)
      { 
        llOwnerSay(output);
        ListOfNumbers += i;
        llOwnerSay("Adding "+(string)i+" to list.");
      }
    }//--end Link loop
    
    doBody();
    
    llSetObjectName(name);
    
}



//-- 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-----");
   llOwnerSay("-----"+x+"-----");
}


//--this part does the whole script default state and state_entry
doBody()
{
    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(output);
    }
    
    llOwnerSay("-- Uncomment next line to make it self destruct.  WARNING: SAVE A COPY TO YOUR INVENTORY!");
    llOwnerSay("llRemoveInventory(llGetScriptName());");
    
    //--end the state entry and the script
    llOwnerSay("\n}\n}");
    llOwnerSay("===================END SCRIPT==================="); 
}


default
{
    state_entry()
    {
        doRead();
    }

    touch_start(integer total_number)
    {
        doRead();
    }
}
/*=============================================
FULL INSTRUCTIONS:

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.


THEN

   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.


NOTE

   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.

GOOD LUCK!
====================================================================*/

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×