Neverworld Grid

You are not logged in. Would you like to login or register?



6/10/2019 5:59 pm  #1


Display Box's content

Displays the content of a box and updates in real time as contents change

/*
    Logan's Content Counter V3.0
    Copylefted Jun/08/2019 - Logan "Smexypants" Stargazer

    Just drop this into a prim and it will show you the contents.
    The total will update as you add/remove items

    V3 is a total rewrite. I *knew* there had to be a more elequent way of doing it!
*/

list TYPES = [
    INVENTORY_ALL,INVENTORY_ANIMATION,INVENTORY_BODYPART,INVENTORY_CLOTHING,
    INVENTORY_GESTURE,INVENTORY_LANDMARK,INVENTORY_NOTECARD,INVENTORY_OBJECT,
    INVENTORY_SCRIPT,INVENTORY_SOUND,INVENTORY_TEXTURE];
    
list DESCRIPTIONS = [
    "items in Total","Animations","Bodyparts","Clothings","Gesturea",
    "Landmarks","Notecards","Objects","Scripts","Sounds","Textures"];

  string DataString;
  integer Count; integer i;

DoStuff()
{
  llSetText("", <0,0,0>,1.0);
  DataString = llGetObjectName() + "\n \nThis box contains:\n \n";

for (i=0; i<10; i++)
{
  Count = llGetInventoryNumber(llList2Integer(TYPES,i));
 if (Count >0) {DataString += "\n" + (string) Count + " " + llList2String(DESCRIPTIONS,i);}
}

DataString += "\n \n";
llSetText(DataString,<1,1,0>,1.0);
}
 
 default
{
    state_entry() {DoStuff();}
    changed(integer change) {if (change & CHANGED_INVENTORY) {DoStuff();}}
}

 

6/25/2019 6:17 pm  #2


Re: Display Box's content

This is a slightly improved version call with:
DisplayContentsHoverText("TextOn"); 
DisplayContentsHoverText("TextOff"); 

DisplayContentsHoverText(string instruction)
{   //sets the hover text info or removes it
    if  (instruction == "TextOff") llSetText("", ZERO_VECTOR, 0); //turns off hover text
    else if (instruction == "TextOn") 
    {   //generate display text and display it
        string displayText = "This box contains: " + "\n \n "; 
        list inventoryTypes = [ INVENTORY_ALL, "Inventory Total: ", 
                                INVENTORY_TEXTURE, "Textures: ", 
                                INVENTORY_SOUND, "Sounds: ", 
                                INVENTORY_LANDMARK, "Landmarks: ", 
                                INVENTORY_CLOTHING, "Clothing Items: ",
                                INVENTORY_OBJECT, "Objects: ",
                                INVENTORY_NOTECARD, "Notecards: ", 
                                INVENTORY_SCRIPT, "Scripts: ",
                                INVENTORY_BODYPART, "Body Parts: ", 
                                INVENTORY_ANIMATION, "Animations: ",
                                INVENTORY_GESTURE, "Guestures: "
                               ];
        integer i;
        for (i = 0; i < llGetListLength(inventoryTypes); i = i+2)
        {   //loops through the types string adding found items to the display text
            integer itemTypeCount = llGetInventoryNumber(llList2Integer(inventoryTypes,i));
            if (itemTypeCount > 0)
            {   //if there are items if this kind found, add the information to the display info
                string dataToAdd = llList2String(inventoryTypes, (i+1)) + (string)itemTypeCount + "\n ";
                displayText += dataToAdd;   
            }//close if items of this type found
        }//close loop through types
        llSetText(displayText, <1,1,0>, 1.0);
    }//close if display text is on
} //close hover text info

Last edited by sara (6/25/2019 6:22 pm)

 

Board footera

 

Powered by Boardhost. Create a Free Forum