Jump to content
You are about to reply to a thread that has been inactive for 97 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted

I have a basic script that will make a prim into a texture display showing random textures in the prims inventory.  

What I am hoping to do is to be able to choose a theme that is will choose within that theme randomly.

Example would be I have 15 total textures.  5 are Cats, 5 are Dogs and 5 are Birds.  I want to be able to set it to show only random textures of cats.  And later I might choose birds.

Additionally I would like to be able to add to it later so having it show only pics 1-5 or 6-10 is not the best option.  

Is there a way to basically tell it that all the textures that have a C- are cats and D- are Dogs?  like using a wildcard or something?

I am thinking like a long click to bring up a menu with the 3 categories and then selecting one.  I can do that part. But I have no idea how to keep the random texture within the selected category.

Here is what I have for the basic script:

RandomTexture ()
{
    llSetTexture (llGetInventoryName (INVENTORY_TEXTURE, (integer) llFrand (llGetInventoryNumber (INVENTORY_TEXTURE))), ALL_SIDES);
}
default
{
    state_entry ()
    {
        llAllowInventoryDrop (TRUE);
        llSetTimerEvent (60.0);
        RandomTexture ();
    }
    timer ()
    {
        RandomTexture ();
    }
    touch_start (integer touches)
    {
        RandomTexture ();
    }
    changed (integer Change)
    {
        if (Change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
            RandomTexture ();
    }
}

Posted (edited)

No matter what you do, You're going to have to parse your objects inventory to somehow sort it into different categories, and come up with some standard format.

If you only have a fixed set of categories (cats dogs and birds) that might not be too hard with a couple of global lists, but of you want to be able to add more categories without changing the script, you'll probably want to make use of linksetData.

For sake of simplicity, lets say you name all of your textures ###_<category>.  so, 000_dog, 001_dog, 000_cat. . .

changed(integer c)
{	if(c&CHANGED_INVENTORY)
	{	// assume this is the only script in the object that uses linksetData:
  		llLinksetDataClear();
  		integer n = llGetInventoryNumber(INVENTORY_TEXTURE);
		while(~--n)
		{	string inv = llGetInventoryName(INVENTORY_TEXTURE,n);
			list l_inv = llParseString2List(inv,["_"],[]); // I'm forgetting which list is which, assume I guessed right.
			llLinksetDataWrite(llList2String(l_inv,1)+":isCategory", "Y"); // record that the category of this item is a category.
			llLinksetDataWrite(inv); 
		}
	}
}
// these functions should be at the top ofnthe script, but placing below for clarity:
string select_category_at_random()
{	list categories = llLinksetDataFindKeys("isCategory$",0,0);
 	return llDeleteSubString(llList2String(categories,(integer)llFrand(llGetListLength(categories))),-10,-1); // check correct parentheses.
}

string select_texture_from_category_at_random(string category)
{	list textures = llLinksetDataFindKeys(category+"$");
 	return llList2String(textures,(integer)llFrand(llGetListLength(textures)));
}

(Rough unchecked example)

Edited by Quistess Alpha
Posted

It would be just a fixed set of 3 or 4 categories. I would just add new pictures as I found them. 
And I would name them with a standard format of some kind. 

Unfortunately I am completely unfamiliar with parsing and link data sets so this might end up being beyond my current abilities to do. 

I’ll see if I can break down your example and figure it out. Thank you. 

Posted (edited)

@Kitiara Galicia

here is a simple list thang...

( assuming your textures have "dog" or "cat" in their name...)

list dogs;
list cats;
default
{
    state_entry()
    {
        integer total_Items = llGetInventoryNumber(INVENTORY_ALL);
        integer index;
        while (index < total_Items)
        {
            string  itemName = llGetInventoryName(INVENTORY_ALL, index);
            integer type     = llGetInventoryType(itemName);
               
            if (type == INVENTORY_TEXTURE)
            { 
              integer d = llSubStringIndex( llToLower(itemName), "dog");
              if( d != -1)
              { dogs += itemName;
              }
              integer c = llSubStringIndex( llToLower(itemName), "cat");
              if( c != -1)
              { cats += itemName;
              }            
            }
            ++index;
        }
        
    }
    touch_start(integer total_number)
    {   string pups = llDumpList2String( dogs, "\n");
        string kits = llDumpList2String( cats, "\n");
        llOwnerSay("\nDogs: \n" + pups + "\nCats: \n" + kits);       
    }
}

 

Edited by Xiija
  • Thanks 1
You are about to reply to a thread that has been inactive for 97 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...